diff --git a/qcloudcli/configure.py b/qcloudcli/configure.py index 7d784cd..a9a31b5 100644 --- a/qcloudcli/configure.py +++ b/qcloudcli/configure.py @@ -27,10 +27,25 @@ def __init__(self, configWriter=None): self.home = ".qcloudcli" self.configure = "configure" self.credentials = "credentials" - self.qcloudConfigurePath = os.path.join(self.findConfigureFilePath(), - self.home) self.parser = handleParameter.handleParameter() + def showQcloudConfigurePath(self): + configurePathName = ".qcloudcli" + sysHomePath = '' + if 'Windows' in platform.system(): + sysHomePath = os.environ['HOMEPATH'] + else: + sysHomePath = os.environ['HOME'] + pass + qcloudConfigurePath = os.path.join(sysHomePath, configurePathName) + if os.path.isdir(qcloudConfigurePath): + return qcloudConfigurePath + if 'Windows' not in platform.system(): + systemWideConfigurePath = '/etc/qcloudcli' + if os.path.isdir(systemWideConfigurePath): + return systemWideConfigurePath + return qcloudConfigurePath + def getConfig(self, profilename=None): if profilename is None: profilename = 'default' @@ -63,10 +78,10 @@ def _getConfigFromFile(self, config, profile, filename): j = j+1 def getConfigFileName(self): - return os.path.join(self.qcloudConfigurePath, self.configure) + return os.path.join(self.showQcloudConfigurePath(), self.configure) def getCredsFileName(self): - return os.path.join(self.qcloudConfigurePath, self.credentials) + return os.path.join(self.showQcloudConfigurePath(), self.credentials) def findConfigureFilePath(self): homePath = "" diff --git a/qcloudcli/handleCmd.py b/qcloudcli/handleCmd.py index 22c6164..95b1ab8 100644 --- a/qcloudcli/handleCmd.py +++ b/qcloudcli/handleCmd.py @@ -74,15 +74,7 @@ def showQcloudCliHelp(self): "know the module corresponding actions." % (self.red, self.end)) def showQcloudConfigurePath(self): - configurePathName = ".qcloudcli" - sysHomePath = '' - if 'Windows' in platform.system(): - sysHomePath = os.environ['HOMEPATH'] - else: - sysHomePath = os.environ['HOME'] - pass - qcloudConfigurePath = os.path.join(sysHomePath, configurePathName) - return qcloudConfigurePath + return self.globalConfigure.showQcloudConfigurePath() def getAllmodules(self): site_packages_path = get_python_lib()