Skip to content

Commit

Permalink
[abfs] Small typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
romainr committed Jun 29, 2021
1 parent 53439a2 commit b7d395a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
10 changes: 5 additions & 5 deletions desktop/libs/azure/src/azure/abfs/abfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

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):
Expand Down Expand Up @@ -131,7 +131,7 @@ def get_client(self, url):
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
Expand All @@ -149,7 +149,6 @@ def isdir(self, path):
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):
Expand Down Expand Up @@ -224,7 +223,7 @@ def listfilesystems_stats(self, root = Init_ABFS.ABFS_ROOT, params=None, **kwarg
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))
Expand Down Expand Up @@ -275,6 +274,7 @@ def get_home_dir():
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
Expand Down Expand Up @@ -652,7 +652,7 @@ def get_upload_chuck_size(self):
def filebrowser_action(self):
return self._filebrowser_action

#Other Methods to condense stuff
# Other Methods to condense stuff
#----------------------------
# Write Files on creation
#----------------------------
Expand Down
8 changes: 5 additions & 3 deletions desktop/libs/azure/src/azure/abfs/abfsfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """

Expand Down Expand Up @@ -83,11 +85,11 @@ def read(self, length=0):
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
16 changes: 8 additions & 8 deletions desktop/libs/azure/src/azure/abfs/abfsstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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):
Expand All @@ -45,28 +46,28 @@ def __init__(self, isDir, atime, mtime, size, path, owner = '', group = '', mode
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'])
Expand Down Expand Up @@ -108,7 +109,7 @@ def char_permissions_to_oct_permissions(permissions):
except:
return None
return octal_permissions

def to_json_dict(self):
"""
Returns a dictionary for easy serialization
Expand All @@ -118,4 +119,3 @@ def to_json_dict(self):
for k in keys:
res[k] = self[k]
return res

8 changes: 5 additions & 3 deletions desktop/libs/azure/src/azure/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
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))
Expand All @@ -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()

0 comments on commit b7d395a

Please sign in to comment.