def install_gist(self):
logger.info("Trying to get Gist")
gist = json.load(urllib2.urlopen(
'https://api.github.com/gists/{}'.format(self.__gist_id)))
try:
# first json file for config
config_file = self.get_gist_files_path(gist, '.json')[0]
bash_files = self.get_gist_files_path(gist, '.sh')
except Exception as e:
logger.critical(
"This is invalid gist_id or something else went wrong")
raise e
logger.info("Trying to save recipe files")
try:
bash_dir = os.path.join(self.__recipes_path, os.path.splitext(
os.path.basename(config_file))[0])
if not os.path.exists(bash_dir):
os.makedirs(bash_dir)
config_file_path = os.path.join(
self.__recipes_path, os.path.basename(config_file))
silent_remove(config_file_path)
with open(config_file_path, "wb") as local_file:
local_file.write(urllib2.urlopen(config_file).read())
for bash_file in bash_files:
bash_file_path = os.path.join(
bash_dir, os.path.basename(bash_file))
silent_remove(bash_file_path)
with open(bash_file_path, "wb") as local_file:
local_file.write(urllib2.urlopen(bash_file).read())
logger.info("Recipe files was saved successfully")
except Exception as e:
logger.critical("Something went wrong with the internet. "
"Internet dies[SCREAMING]. Run, quickly run away")
raise e
评论列表
文章目录