Ejemplo n.º 1
0
 def setAccessControl(self, path, headers, **kwargs):
     """
 Set Access Controls (Can do both chmod and chown) (not implemented)
 """
     path = Init_ABFS.strip_scheme(path)
     params = {'action': 'setAccessControl'}
     if headers is None:
         headers = {}
     self._patching_sl(path, params, header=headers, **kwargs)
Ejemplo n.º 2
0
 def read(self, path, offset='0', length=0, *args, **kwargs):
   """
   Read data from a file
   """
   path = Init_ABFS.strip_scheme(path)
   headers = self._getheaders()
   if length != 0 and length != '0':
     headers['range']= 'bytes=%s-%s' % (str(offset), str(int(offset) + int(length)))
   return self._root.get(path, headers = headers)
Ejemplo n.º 3
0
 def rename(self, old, new): 
   """
   Renames a file
   """ 
   LOG.debug("%s\n%s" % (old, new))
   headers = {'x-ms-rename-source' : '/' + Init_ABFS.strip_scheme(old) }
   try:
     self._create_path(new, headers=headers, overwrite=True)
   except WebHdfsException as e:
     if e.code == 409:
       self.copy(old, new)
       self.rmtree(old)
     else:
       raise e
Ejemplo n.º 4
0
 def flush(self, path, params=None, headers=None, **kwargs):
     """
 Flushes the data(i.e. writes appended data to File)
 """
     path = Init_ABFS.strip_scheme(path)
     if params is None:
         LOG.warning("Params not specified")
         params = {'position': 0}
     if 'position' not in params:
         LOG.warning("Position is not specified")
         params['position'] = 0
     params['action'] = 'flush'
     if headers is None:
         headers = {}
     headers['Content-Length'] = '0'
     self._patching_sl(path, params, header=headers, **kwargs)
Ejemplo n.º 5
0
 def _append(self, path, data, size=0, offset=0 ,params=None, **kwargs):
   """
   Appends the data to a file
   """
   path = Init_ABFS.strip_scheme(path)
   if params is None:
     LOG.warn("Params not specified, Append will take longer")
     resp = self._stats(path)
     params = {'position' : int(resp['Content-Length']) + offset, 'action' : 'append'}
     LOG.debug("%s" % params)
   else:
     params['action'] = 'append'
   headers = {}
   if size == 0 or size == '0':
     headers['Content-Length'] = str(len(data))
     if headers['Content-Length'] == '0':
       return
   else:
     headers['Content-Length'] = str(size)
   LOG.debug("%s" % headers)
   return self._patching_sl( path, params, data, headers, **kwargs)