Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add system wide condig path #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions qcloudcli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = ""
Expand Down
10 changes: 1 addition & 9 deletions qcloudcli/handleCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down