def __init__(self, repo, databases): Backend.__init__(self, repo, "checker", databases) self.checks = {} self.checks["unsupportedlicense"] = UnsupportedLicenseTable() self.checks["unknownfile"] = UnknownFileTable() self.checks[ "nonconformingparametername"] = NonconformingParameternameTable() self.checks["nonconformingclassids"] = NonconformingClassIdTable() self.checks["missingbaseconnection"] = MissingBaseConnectionTable() self.checks[ "missingparameterdescription"] = MissingParameterDescriptionTable( ) self.checks["unknownconnectors"] = UnknownConnectorLocationTable() self.checks["pointlessgroup"] = PointlessGroupTable() self.checks["lowercasedescription"] = LowercaseDescriptionTable() self.checks["invalidlabeling"] = InvalidLabelingTable() self.tasks = {} self.tasks["missingcommonparameters"] = MissingCommonParametersTable() self.tasks["missingconnectors"] = MissingConnectorTable() self.tasks["missingbase"] = MissingBaseTable() self.tasks["missingdrawing"] = MissingDrawingTable() self.tasks["missingsvgsource"] = MissingSVGSourceTable() for check in self.checks.values(): check.populate(repo, databases) for task in self.tasks.values(): task.populate(repo, databases)
def manual_backup(): backend = Backend() # keyfile is in vault directories_to_backup = action_get('directory-list') timestamp = "{:%Y-%m-%d-%H-%M-%S}".format(datetime.datetime.now()) try: log("Running a manual backup on {}".format(directories_to_backup), level=DEBUG) for directory in directories_to_backup: check_output( ["/snap/bin/preserve", "--configdir", os.path.join(os.path.expanduser("~"), ".config"), "--loglevel", "error", "create", "{name}-{timestamp}".format(name=directory, timestamp=timestamp), str(directory), "--backend", backend.get_backend(), "--vault" ]) except OSError as err: log("Create backup failed with error: {}".format(err.message), level=ERROR) action_fail("List backup failed with error: {}".format(err.message))
def list_backups(): backend = Backend() try: log("Listing backups", level=DEBUG) preserve_list = check_output( ["/snap/bin/preserve", "--configdir", os.path.join(os.path.expanduser("~"), ".config"), "--loglevel", "error", "list", "--vault", "--backend", backend.get_backend(), "--json"]) try: backup_list = json.loads(preserve_list) action_set({"message": backup_list}) except ValueError as verr: log("Unable to load preserve output as json. Error {}".format( verr), level=ERROR) action_fail( "Json loading of preserve output failed: {}".format(verr)) except OSError as err: log("List backup failed with error: {}".format(err.message), level=ERROR) action_fail("List backup failed with error: {}".format(err.message))
def setup_cron_job(cron_spec, directories_list): cron_path = os.path.join(os.sep, "etc", "cron.d", "backup") context = {'directories': directories_list} backend = Backend() # Overwrite the file if needed try: context['cron_spec'] = cron_spec context['backend'] = backend.get_backend() context['configdir'] = CONFIG_DIR # Add --vault flag if vault is related if relation_ids('vault'): context['vault'] = True else: context['vault'] = False render('backup_cron', cron_path, context, perms=0o644) except IOError as err: log("Error creating cron file: {}".format(err.message), level='error')
def restore_backup(): backend = Backend() backup_name = action_get("backup-name") restore_path = action_get("restore-path") if not os.path.exists(restore_path): log("Creating restore path: {}".format(restore_path)) os.mkdir(restore_path) try: log("Restoring backup {} to {}".format(backup_name, restore_path), level=DEBUG) check_output( ["/snap/bin/preserve", "--configdir", os.path.join(os.path.expanduser("~"), ".config"), "--loglevel", "error", "restore", "--backend", backend.get_backend(), "--vault", backup_name, restore_path]) except OSError as err: log("Restore backup failed with error: {}".format(err.message), level=ERROR) action_fail("Restore backup failed with error: {}".format(err.message))
def __init__(self,repo,databases): Backend.__init__(self,repo,"checker",databases) self.checks = {} self.checks["unsupportedlicense"] = UnsupportedLicenseTable() self.checks["unknownfile"] = UnknownFileTable() self.checks["nonconformingparametername"] = NonconformingParameternameTable() self.checks["nonconformingclassids"] = NonconformingClassIdTable() self.checks["missingbaseconnection"] = MissingBaseConnectionTable() self.checks["missingparameterdescription"] = MissingParameterDescriptionTable() self.checks["defaultsmismatch"] = DefaultsMismatchTable() self.checks["unknownconnectors"] = UnknownConnectorLocationTable() self.checks["pointlessgroup"] = PointlessGroupTable() self.checks["lowercasedescription"] = LowercaseDescriptionTable() self.checks["invalidlabeling"] = InvalidLabelingTable() self.tasks = {} self.tasks["missingcommonparameters"] = MissingCommonParametersTable() self.tasks["missingconnectors"] = MissingConnectorTable() self.tasks["missingbase"] = MissingBaseTable() self.tasks["missingdrawing"] = MissingDrawingTable() self.tasks["missingsvgsource"] = MissingSVGSourceTable() for check in self.checks.values(): check.populate(repo,databases) for task in self.tasks.values(): task.populate(repo,databases)
def __init__(self,repo,databases): Backend.__init__(self,repo,"freecad",databases,["freecad"])
def __init__(self, repo, databases): Backend.__init__(self, repo, "connectordrawings", databases, ["openscad", "drawings"])
def __init__(self,repo,databases): Backend.__init__(self,repo,'translations',databases,[])
def __init__(self, repo, databases): Backend.__init__(self, repo, "iges", databases, ["freecad"])
def __init__(self, repo, databases): Backend.__init__(self, repo, "openscad", databases, ["openscad"]) # check for module name clashes modules = [] # common.scad for mod in [ "BOLTS_error", "BOLTS_warning", "BOLTS_check_dimension", "BOLTS_convert_to_default_unit", "get_dim", "type", "BOLTS_check_parameter_type", "BOLTS_thread_external", "BOLTS_hex_head", "BOLTS_hex_socket_neg", ]: modules.append(mod) # conf.scad for mod in ["BOLTS_MODE", "BOLTS_DEFAULT_UNIT", "BOLTS_THREAD_COLOR"]: modules.append(mod) # local.scad for mod in [ "norm", "unit_vector", "clamp", "cross_product", "almost_equal", "_rotation_angle", "calculate_rotation_axis", "calculate_axis", "new_cs", "is_orthonromal", "unit_matrix", "tensor_product_matrix3", "cross_product_matrix3", "rotation_matrix3", "show_cs", "translate_local", "in_cs", "align", ]: modules.append(mod) # version.scad for mod in ["BOLTS_version", "BOLTS_date", "BOLTS_license"]: modules.append(mod) # base modules for (module,) in self.dbs["openscad"].itermodules(): if module.name in modules: raise ModuleNameCollisionError(module.name) modules.append(module.name) # names for (name,) in self.dbs["openscad"].iternames(): if name.get_id() in modules: raise ModuleNameCollisionError(name.get_id()) modules.append(name.get_id()) # standards for (std,) in self.dbs["openscad"].iterstandards(): if std.get_id() in modules: raise ModuleNameCollisionError(std.get_id()) modules.append(std.get_id()) # classes for cl, module in self.dbs["openscad"].iterclasses(["class", "module"]): params = cl.parameters.union(module.parameters) # tables for table, i in zip(params.tables, range(len(params.tables))): tablename = "%s_table_%s" % (cl.id, i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # 2d tables for table, i in zip(params.tables2d, range(len(params.tables))): tablename = "%s_table2d_%s" % (cl.id, i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # stub module modulename = "%s_geo" % cl.id if modulename in modules: raise ModuleNameCollisionError(modulename) modules.append(modulename) # dim accessors accessorname = "%s_dims" % cl.id if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) # conn accessors accessorname = "%s_conn" % cl.id if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) # names for name, cl, module in self.dbs["openscad"].iternames(["name", "class", "module"]): params = cl.parameters.union(module.parameters) # tables for table, i in zip(params.tables, range(len(params.tables))): tablename = "%s_table_%s" % (name.get_id(), i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # 2d tables for table, i in zip(params.tables2d, range(len(params.tables))): tablename = "%s_table2d_%s" % (name.get_id(), i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # dim accessors accessorname = "%s_dims" % name.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) # conn accessors accessorname = "%s_conn" % name.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) # standards for std, cl, module in self.dbs["openscad"].iterstandards(["standard", "class", "module"]): params = cl.parameters.union(module.parameters) # tables for table, i in zip(params.tables, range(len(params.tables))): tablename = "%s_table_%s" % (std.get_id(), i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # 2d tables for table, i in zip(params.tables2d, range(len(params.tables))): tablename = "%s_table2d_%s" % (std.get_id(), i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) # dim accessors accessorname = "%s_dims" % std.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) # conn accessors accessorname = "%s_conn" % std.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname)
def __init__(self,repo,databases): Backend.__init__(self,repo,"openscad",databases,["openscad"]) #check for module name clashes modules = [] #common.scad for mod in ["BOLTS_error", "BOLTS_warning", "BOLTS_check_dimension", "BOLTS_convert_to_default_unit", "get_dim", "type", "BOLTS_check_parameter_type", "BOLTS_thread_external", "BOLTS_hex_head", "BOLTS_hex_socket_neg"]: modules.append(mod) #conf.scad for mod in ["BOLTS_MODE", "BOLTS_DEFAULT_UNIT", "BOLTS_THREAD_COLOR"]: modules.append(mod) #local.scad for mod in ["norm", "unit_vector", "clamp", "cross_product", "almost_equal", "_rotation_angle", "calculate_rotation_axis", "calculate_axis", "new_cs", "is_orthonromal", "unit_matrix", "tensor_product_matrix3", "cross_product_matrix3", "rotation_matrix3", "show_cs", "translate_local", "in_cs", "align"]: modules.append(mod) #version.scad for mod in ["BOLTS_version", "BOLTS_date", "BOLTS_license"]: modules.append(mod) #base modules for module, in self.dbs["openscad"].itermodules(): if module.name in modules: raise ModuleNameCollisionError(module.name) modules.append(module.name) #names for name, in self.dbs["openscad"].iternames(): if name.get_id() in modules: raise ModuleNameCollisionError(name.get_id()) modules.append(name.get_id()) #standards for std, in self.dbs["openscad"].iterstandards(): if std.get_id() in modules: raise ModuleNameCollisionError(std.get_id()) modules.append(std.get_id()) #classes for cl,module in self.dbs["openscad"].iterclasses(["class","module"]): params = cl.parameters.union(module.parameters) #tables for table,i in zip(params.tables,range(len(params.tables))): tablename = "%s_table_%s" % (cl.id,i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #2d tables for table,i in zip(params.tables2d,range(len(params.tables))): tablename = "%s_table2d_%s" % (cl.id,i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #stub module modulename = "%s_geo" % cl.id if modulename in modules: raise ModuleNameCollisionError(modulename) modules.append(modulename) #dim accessors accessorname = "%s_dims" % cl.id if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) #conn accessors accessorname = "%s_conn" % cl.id if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) #names for name,cl,module in self.dbs["openscad"].iternames(["name","class","module"]): params = cl.parameters.union(module.parameters) #tables for table,i in zip(params.tables,range(len(params.tables))): tablename = "%s_table_%s" % (name.get_id(),i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #2d tables for table,i in zip(params.tables2d,range(len(params.tables))): tablename = "%s_table2d_%s" % (name.get_id(),i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #dim accessors accessorname = "%s_dims" % name.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) #conn accessors accessorname = "%s_conn" % name.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) #standards for std,cl,module in self.dbs["openscad"].iterstandards(["standard","class","module"]): params = cl.parameters.union(module.parameters) #tables for table,i in zip(params.tables,range(len(params.tables))): tablename = "%s_table_%s" % (std.get_id(),i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #2d tables for table,i in zip(params.tables2d,range(len(params.tables))): tablename = "%s_table2d_%s" % (std.get_id(),i) if tablename in modules: raise ModuleNameCollisionError(tablename) modules.append(tablename) #dim accessors accessorname = "%s_dims" % std.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname) #conn accessors accessorname = "%s_conn" % std.get_id() if accessorname in modules: raise ModuleNameCollisionError(accessorname) modules.append(accessorname)
def __init__(self,repo,databases): Backend.__init__(self,repo,"connectordrawings",databases,["openscad","drawings"])