def config_file():
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.mycroft')
filename = os.path.join(credential_dir,'mycroft.conf')
if os.path.isfile(filename):
try:
with open(filename, "r") as jsonFile:
data = json.load(jsonFile, object_pairs_hook=OrderedDict)
resultado = list(v for k,v in data.items() if "GoogleGmailSkill" in k.lower())
if len(resultado) == 0:
print "Updating configuration file"
data["GoogleGmailSkill"]={"loginEnabled":False,"loginLevel":3,"maxResults":5,"time_format":12}
try:
with open(filename, "w") as jsonFile:
jsonFile.write(json.dumps(OrderedDict(data), indent=4, sort_keys=False))
except IOError as error:
print "Saving configuration file failed"
return False
time.sleep(10)
else:
return data
except IOError as error:
print "Reading config file failed"
return False
else:
print "Creating new Config file"
data = {"GoogleGmailSkill":{"loginEnabled":False,"loginLevel":3,"maxResults":5,"time_format":12}}
try:
with open(filename, "w") as jsonFile:
jsonFile.write(json.dumps(OrderedDict(data), indent=4, sort_keys=False))
except IOError as error:
print "Saving configuration file failed: "
return False
time.sleep(10)
评论列表
文章目录