Romain Rigaux 4 жил өмнө
parent
commit
b7d395af69

+ 5 - 5
desktop/libs/azure/src/azure/abfs/abfs.py

@@ -52,7 +52,7 @@ else:
 
 LOG = logging.getLogger(__name__)
 
-#Azure has a 30MB block limit on upload.
+# Azure has a 30MB block limit on upload.
 UPLOAD_CHUCK_SIZE = 30 * 1000 * 1000
 
 class ABFSFileSystemException(IOError):
@@ -131,7 +131,7 @@ class ABFS(object):
   def _getheaders(self):
     return {
       "Authorization": self._token_type + " " + self._access_token,
-      "x-ms-version" : "2019-02-02" #note this is required for setaccesscontrols
+      "x-ms-version" : "2019-02-02" # Note: this is required for setaccesscontrols
     }
 
   @property
@@ -149,7 +149,6 @@ class ABFS(object):
     Checks if the path is a directory (note diabled because filebrowser/views is bugged)
     """
     resp = self.stats(path)
-    #LOG.debug("checking directoty or not")
     return resp.isDir
 
   def isfile(self, path):
@@ -224,7 +223,7 @@ class ABFS(object):
     if params is None:
       params = {}
     params["resource"] = "account"
-    res = self._root._invoke("GET", params=params, headers=self._getheaders() )
+    res = self._root._invoke("GET", params=params, headers=self._getheaders())
     resp = self._root._format_response(res)
     for x in resp['filesystems']:
       stats.append(ABFSStat.for_filesystems(res.headers, x, root))
@@ -275,6 +274,7 @@ class ABFS(object):
     Attempts to go to the directory set by the user in the configuration file. If not defaults to abfs://
     """
     return Init_ABFS.get_home_dir_for_ABFS()
+
   # Find or alter information about the URI path
   # --------------------------------
   @staticmethod
@@ -652,7 +652,7 @@ class ABFS(object):
   def filebrowser_action(self):
     return self._filebrowser_action
 
-  #Other Methods to condense stuff
+  # Other Methods to condense stuff
   #----------------------------
   # Write Files on creation
   #----------------------------

+ 5 - 3
desktop/libs/azure/src/azure/abfs/abfsfile.py

@@ -13,16 +13,18 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+import errno
 import os
 import logging
 
 from hadoop.fs.hadoopfs import require_open
 from azure.abfs.__init__ import normpath
 
-LOG = logging.getLogger(__name__)
 
+LOG = logging.getLogger(__name__)
 SEEK_SET, SEEK_CUR, SEEK_END = os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
 
+
 class ABFSFile(object):
   """ Represents an open file on ABFS. """
 
@@ -83,11 +85,11 @@ class ABFSFile(object):
     except:
       resp =''
     return resp
-    
+
   def close(self):
     self.closed = True
 
   def _stat(self):
     if not hasattr(self, "_stat_cache"):
       self._stat_cache = self.fs.stats(self.path)
-    return self._stat_cache
+    return self._stat_cache

+ 8 - 8
desktop/libs/azure/src/azure/abfs/abfsstats.py

@@ -24,6 +24,7 @@ from django.utils.encoding import smart_str
 LOG = logging.getLogger(__name__)
 CHAR_TO_OCT = {"---": 0, "--x" : 1, "-w-": 2, "-wx": 3, "r--" : 4, "r-x" : 5, "rw-" : 6,"rwx": 7}
 
+
 class ABFSStat(object):
 
   def __init__(self, isDir, atime, mtime, size, path, owner = '', group = '', mode = None):
@@ -45,28 +46,28 @@ class ABFSStat(object):
       self.mode |= stat.S_IFDIR
     else:
       self.mode |= stat.S_IFREG
-    
+
   def __getitem__(self, key):
     try:
       return getattr(self, key)
     except AttributeError:
       raise KeyError(key)
-  
+
   def __setitem__(self, key, value):
     # What about derivable values?
     setattr(self, key, value)
-    
+
   def __repr__(self):
     return smart_str("<abfsStat %s>" % (self.path,))
-  
+
   @property
   def aclBit(self):
     return False
-  
+
   @classmethod
   def for_root(cls,path):
     return cls(True, 0, 0, 0, path)
-  
+
   @classmethod
   def for_filesystems(cls,headers,resp, scheme):
     return cls(True, headers['date'], resp['lastModified'], 0, scheme + resp['name'])
@@ -108,7 +109,7 @@ class ABFSStat(object):
     except:
       return None
     return octal_permissions
-    
+
   def to_json_dict(self):
     """
     Returns a dictionary for easy serialization
@@ -118,4 +119,3 @@ class ABFSStat(object):
     for k in keys:
       res[k] = self[k]
     return res
-    

+ 5 - 3
desktop/libs/azure/src/azure/client.py

@@ -25,8 +25,10 @@ from azure.active_directory import ActiveDirectory
 from desktop.lib.idbroker import conf as conf_idbroker
 from desktop.lib.idbroker.client import IDBroker
 
+
 LOG = logging.getLogger(__name__)
 
+
 def _make_adls_client(identifier, user):
   client_conf = conf.ADLS_CLUSTERS[identifier]
   return WebHdfs.from_config(client_conf, get_credential_provider(identifier, user))
@@ -41,14 +43,14 @@ def get_credential_provider(identifier, user, version=None):
 
 class CredentialProviderAD(object):
   def __init__(self, ad):
-    self.ad=ad
+    self.ad = ad
 
   def get_credentials(self):
     return self.ad.get_token()
 
 class CredentialProviderIDBroker(object):
   def __init__(self, idbroker):
-    self.idbroker=idbroker
+    self.idbroker = idbroker
 
   def get_credentials(self):
-    return self.idbroker.get_cab()
+    return self.idbroker.get_cab()