def cleanTempPki(): pkies = glob.glob( os.path.join(tempfile.gettempdir(), 'tmp*_{*}.pem')) for fn in pkies: f = QFile(fn) f.setPermissions(QFile.WriteOwner) f.remove()
def _prepare_code(self, specification): """Prepare the code turning templates into python. :param specification: Specification instance containing template replacement keys/values. :type specification: PluginSpecification """ # process the user entries if specification.gen_makefile: self.populate_template(specification, self.shared_dir, 'Makefile.tmpl', 'Makefile') if specification.gen_pb_tool: self.populate_template(specification, self.shared_dir, 'pb_tool.tmpl', 'pb_tool.cfg') self.populate_template(specification, self.template_dir, '__init__.tmpl', '__init__.py') self.populate_template(specification, self.template_dir, 'module_name.tmpl', '%s.py' % specification.module_name) if specification.gen_scripts: release_script = QFile(os.path.join(self.shared_dir, 'release.sh')) release_script.copy(os.path.join(self.plugin_path, 'release.sh')) plugin_upload = QFile( os.path.join(self.shared_dir, 'plugin_upload.py')) plugin_upload.copy( os.path.join(self.plugin_path, 'plugin_upload.py')) # noinspection PyCallByClass,PyTypeChecker QFile.setPermissions( os.path.join(self.plugin_path, 'plugin_upload.py'), QFile.ReadOwner | QFile.WriteOwner | QFile.ExeOwner | QFile.ReadUser | QFile.WriteUser | QFile.ExeUser | QFile.ReadGroup | QFile.ExeGroup | QFile.ReadOther | QFile.ExeOther)
def removeCert(certFile): certFile = certFile.replace("'", "") file = QFile(certFile) # set permission to allow removing on Win. # On linux and Mac if file is set with QFile::>ReadUser # does not create problem removing certs if not file.setPermissions(QFile.WriteOwner): raise Exception('Cannot change permissions on {}: error code: {}'.format(file.fileName(), file.error())) if not file.remove(): raise Exception('Cannot remove {}: error code: {}'.format(file.fileName(), file.error()))
def cleanTempPki(): pkies = glob.glob(os.path.join(tempfile.gettempdir(), 'tmp*_{*}.pem')) for fn in pkies: f = QFile(fn) f.setPermissions(QFile.WriteOwner) f.remove()