Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _load_json(self, filename):
if not os.path.exists(filename):
mys.log("Failed to find Miragefile!", withError = True)
raise FileNotFoundError
with open(filename, "r") as jsonfile:
try:
return json.load(jsonfile)
except:
mys.log("Failed to load Miragefile!", withError = True, errorDetail = mys.raise_error_message(self._load_json))
raise FileNotFoundError
with open(str(self._fname), "w") as f:
# When copyrights is list, copyright_source raises TypeError: unhashable type: 'list'
if [ext for ext in [".py", ".rb", ".sh"] if ext in self._fname]:
f.write(
copyright_source.copyright_script_style_doc(proj_name, self._fname, your_name,
start_year, tuple(copyrights), licensename, license_url)
)
elif [ext for ext in [".scss", ".js", ".ts", ".swift", ".c"] if ext in self._fname]:
f.write(
copyright_source.copyright_c_style_doc(proj_name, self._fname, your_name,
start_year, tuple(copyrights), licensename, license_url)
)
except:
mys.log("Failed to touch new python script \"" + self._fname + "\"!", withError = True, errorDetail = mys.raise_error_message(self.main, traceback.format_exc()))
return True
def query_execute(connection, cur, query):
try:
cur.execute(query)
except sqlite3.Error as e:
mys.log("SQLite3 error has occured!", withError = True, errorDetail = e.args[0])
except:
mys.log("Unknown error has occured!", withError = True,
errorDetail = mys.raise_error_message(MirageWorkspace.__write_persistence_file_meta))
# In advance checking.
try:
self._check(logger)
except:
return
logger.write("Searching application %s..." % self._app, withLazy = True)
if Path(self._app).is_dir():
mys.log(os.getcwd())
shutil.copytree(self._app, os.path.join(self._to, self._app))
logger.update("Completed!")
else:
logger.update("Can not detect application %s!" % self._app)
mys.log("Failed to transfer app %s!" % self._app, withError = True,
errorDetail = mys.raise_error_message(
"The application diresctory does not exists!"
))
return
def _load_json(self, filename):
if not os.path.exists(filename):
mys.log("Failed to find Miragefile!", withError = True)
raise FileNotFoundError
with open(filename, "r") as jsonfile:
try:
return json.load(jsonfile)
except:
mys.log("Failed to load Miragefile!", withError = True, errorDetail = mys.raise_error_message(self._load_json))
raise FileNotFoundError
# ModelClass name:string+maxlen=40 no:integer+as_primary=True
model_contents = ""
for data in self._data:
model_contents += "{0}\n".format(self._parse_data(data))
# Write model file
sys.log("Writing model...")
try:
with open("models.py", "a") as writing:
writing.write(create_model_class(self._model_name, model_contents))
except:
sys.log("Failed to create / overwrite models.py!", withError = True,
errorDetail = sys.raise_error_message(self.main))
def main(self) -> Void:
mys.log("Checking mirage update...")
with tempfile.TemporaryDirectory() as td:
with InDir(td):
sys.path.append(td)
request.urlretrieve(self._url, "mg_version_check.py")
try:
import mg_version_check
except ImportError:
mys.log("Failed to get version information!", withError=True,
errorDetail=mys.raise_error_message(self.main, traceback.format_exc()))
return
if ver == mg_version_check.__version__:
if ver == "0.1.7":
mys.log("New mirage framework tools available!")
mys.log("See, https://github.com/shotastage/mirageframework for detail.")
else:
mys.log("Update available!", withError=True)
print("This version: {0}".format(ver))
print("Available version: {0}".format(mg_version_check.__version__))