Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from lemoney/support/catch-permission-denied-i…
Browse files Browse the repository at this point in the history
…n-config

Fixed rtd Bug
  • Loading branch information
James Bell authored Dec 31, 2017
2 parents 4a33fcd + 4f1b71e commit 41ce0f8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
# built documents.
#
# The short X.Y version.
version = u'2.0.0'
version = u'2.0'
# The full version, including alpha/beta/rc tags.
release = u'2.0.0'
release = u'2.0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='tgt_grease',
version='2.0.0',
version='2.0.1',
license="MIT",
description='GRE Application Service Engine',
long_description="""
Expand Down
37 changes: 24 additions & 13 deletions tgt_grease/core/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ class Configuration(object):
greaseConfigFile = greaseDir + "grease.conf.json"

if os.path.isfile(greaseDir + 'grease.identity'):
fil = open(greaseDir + 'grease.identity')
NodeIdentity = fil.read().rstrip()
fil.close()
del fil
with open(greaseDir + 'grease.identity', 'r') as fil:
NodeIdentity = fil.read().rstrip()
else:
NodeIdentity = "Unknown"

Expand Down Expand Up @@ -74,9 +72,19 @@ def ReloadConfig(ConfigFile=None):
# load defaults
GREASE_CONFIG = Configuration.DefaultConfig()
# write config to disk
fil = open(Configuration.greaseConfigFile, 'w')
fil.write(json.dumps(GREASE_CONFIG, indent=4, sort_keys=True))
fil.close()
try:
with open(Configuration.greaseConfigFile, 'w') as fil:
fil.write(json.dumps(GREASE_CONFIG, indent=4, sort_keys=True))
except:
print("""
!!!!!!!!!!!!!!!!!!FAILED TO WRITE CONFIGURATION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
THIS IS CRITICAL! EITHER [{0}] is unavailable or does not exist! log files will not be written and only the
default configuration is accessible!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
""".format(Configuration.greaseDir))
return

@staticmethod
def get(section, key=None, default=None):
Expand Down Expand Up @@ -139,12 +147,15 @@ def EnsureGreaseFS(self):
bool: If the FS is in place then True
"""
if not os.path.isdir(self.greaseDir):
os.mkdir(self.greaseDir)
for elem in self.FileSystem:
if not os.path.isdir(self.greaseDir + elem):
os.mkdir(self.greaseDir + elem)
return True
try:
if not os.path.isdir(self.greaseDir):
os.mkdir(self.greaseDir)
for elem in self.FileSystem:
if not os.path.isdir(self.greaseDir + elem):
os.mkdir(self.greaseDir + elem)
return True
except:
return False

@staticmethod
def DefaultConfig():
Expand Down
15 changes: 10 additions & 5 deletions tgt_grease/core/Logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ def DefaultLogger(self):
"""
global GREASE_LOG_HANDLER
logFilename = self._conf.get('Logging', 'file')
self._logger = logging.getLogger('GREASE')
self._logger.setLevel(logging.DEBUG)
self._formatter = logging.Formatter(
Expand All @@ -299,7 +298,13 @@ def DefaultLogger(self):
)
self._formatter.converter = time.gmtime
if not GREASE_LOG_HANDLER:
GREASE_LOG_HANDLER = logging.FileHandler(logFilename)
GREASE_LOG_HANDLER.setLevel(logging.DEBUG)
GREASE_LOG_HANDLER.setFormatter(self._formatter)
self._logger.addHandler(GREASE_LOG_HANDLER)
if os.path.isdir(self._conf.greaseDir):
GREASE_LOG_HANDLER = logging.FileHandler(self._conf.get('Logging', 'file'))
GREASE_LOG_HANDLER.setLevel(logging.DEBUG)
GREASE_LOG_HANDLER.setFormatter(self._formatter)
self._logger.addHandler(GREASE_LOG_HANDLER)
else:
GREASE_LOG_HANDLER = logging.StreamHandler()
GREASE_LOG_HANDLER.setLevel(logging.DEBUG)
GREASE_LOG_HANDLER.setFormatter(self._formatter)
self._logger.addHandler(GREASE_LOG_HANDLER)

0 comments on commit 41ce0f8

Please sign in to comment.