def xmlrpc_putPackageDetail(self, package, need_assign = True): self.logger.debug("xmlrpc_putPackageDetail") pa = Package() pa.fromH(package) if Common().dontgivepkgs.has_key(pa.id) and len(Common().dontgivepkgs[pa.id]) > 0: return (False, "This package is curently locked") ret = Common().editPackage(package['id'], pa, need_assign) if not ret: return False # Create conf.xml file in package ret = Common().writePackageTo(package['id'], self.mp) ret, confdir = ret if not ret: return False ret = Common().associatePackage2mp(package['id'], self.mp) if not ret: return False if not P2PServerCP().package_detect_activate: del Common().inEdition[package['id']] # Force packavge detection Common().detectNewPackages() # Reload all package info desc = Common().desc Common().init(Common().config) Common().desc = desc return (True, package['id'], confdir, pa.toH())
def xmlrpc_putPackageDetail(self, package, need_assign=True): self.logger.debug("xmlrpc_putPackageDetail") pa = Package() pa.fromH(package) if pa.id in Common().dontgivepkgs and len( Common().dontgivepkgs[pa.id]) > 0: return (False, "This package is curently locked") ret = Common().editPackage(package['id'], pa, need_assign, self.mp) if not ret: return False # Create conf file in package ret = Common().writePackageTo(package['id'], self.mp) ret, confdir = ret if not ret: return False ret = Common().associatePackage2mp(package['id'], self.mp) if not ret: return False if not P2PServerCP().package_detect_activate: del Common().inEdition[package['id']] # Force packavge detection Common().detectNewPackages() Common()._createMD5File(pa.root, force_compute=True) # Reload all package info #desc = Common().desc #Common().init(Common().config) #Common().desc = desc return (True, package['id'], confdir, pa.toH())
def parse_str(self, file): try: # Nonesense: we don't know if file is a path or content ??!! wtf if os.path.exists(file): try: data = json.loads(open(file).read()) except IOError: pass except: pass else: data = json.loads(file) # parsing routines self.logger = logging.getLogger() try: pid = data['id'] if 'appstream_family' in data: appstream_family = data['appstream_family'] else: appstream_family = '' name = data['name'].strip() v_txt = data['version'] or '0' desc = data['description'] cmds = data['commands'] reboot = data['reboot'] or 0 try: sub_packages = data['sub_packages'] except KeyError: sub_packages = [] # Inventory section licenses = data['inventory']['licenses'] associateinventory = data['inventory']['associateinventory'] queries = data['inventory']['queries'] except KeyError: raise Exception('CANTPARSE') p = Package() p.init(pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot, appstream_family, queries['Qvendor'], queries['Qsoftware'], queries['Qversion'], queries['boolcnd'], licenses, sub_packages, associateinventory) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def xmlrpc_putPackageDetail(self, package, need_assign = True): self.logger.debug("xmlrpc_putPackageDetail") pa = Package() pa.fromH(package) if Common().dontgivepkgs.has_key(pa.id) and len(Common().dontgivepkgs[pa.id]) > 0: return (False, "This package is curently locked") ret = Common().editPackage(package['id'], pa, need_assign) if not ret: return False # Create conf.xml file in package ret = Common().writePackageTo(package['id'], self.mp) ret, confdir = ret if not ret: return False ret = Common().associatePackage2mp(package['id'], self.mp) if not ret: return False if not P2PServerCP().package_detect_activate: del Common().inEdition[package['id']] return (True, package['id'], confdir, pa.toH())
def parse_str(self, file): xml = None try: if os.path.exists(file): xml = minidom.parse(file) else: xml = minidom.parseString(file) # parsing routines self.logger = logging.getLogger() root = xml.getElementsByTagName('package') if len(root) != 1: raise Exception('CANTPARSE') root = root[0] pid = root.getAttribute('id') appstream_family = '' if root.hasAttribute('appstream_family'): appstream_family = root.getAttribute('appstream_family') tmp = root.getElementsByTagName('name')[0] name = tmp.firstChild.wholeText.strip() version = root.getElementsByTagName('version')[0] tmp = version.getElementsByTagName('numeric')[0] tmp = version.getElementsByTagName('label')[0] if tmp.firstChild is not None: v_txt = tmp.firstChild.wholeText.strip() else: v_txt = "0" tmp = root.getElementsByTagName('description') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] desc = tmp.firstChild.wholeText.strip() else: desc = "" licenses = '' tmp = root.getElementsByTagName('licenses') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] licenses = tmp.firstChild.wholeText.strip() cmd = root.getElementsByTagName('commands')[0] reboot = 0 if cmd.hasAttribute('reboot'): reboot = cmd.getAttribute('reboot') cmds = {} for c in ['installInit', 'preCommand', 'command', 'postCommandSuccess', 'postCommandFailure']: tmp = cmd.getElementsByTagName(c) if len(tmp) == 1 and tmp[0].firstChild is not None: command = tmp[0].firstChild.wholeText.strip() if tmp[0].hasAttribute('name'): ncmd = tmp[0].getAttribute('name') else: ncmd = '' cmds[c] = {'command': command, 'name': ncmd} else: cmds[c] = '' associateinventory = 0 tmp = root.getElementsByTagName('associateinventory') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] associateinventory = tmp.firstChild.wholeText.strip() query = root.getElementsByTagName('query') queries = {'Qvendor': '', 'Qsoftware': '', 'Qversion': '', 'boolcnd': ''} if query.length >= 1 and query[0].firstChild: for k in queries: tmp = query[0].getElementsByTagName(k) if tmp.length >= 1 and tmp[0].firstChild: queries[k] = tmp[0].firstChild.wholeText.strip() p = Package() p.init( pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot, appstream_family, queries['Qvendor'], queries['Qsoftware'], queries['Qversion'], queries['boolcnd'], licenses, associateinventory ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def parse_str(self, file): try: # Nonesense: we don't know if file is a path or content ??!! wtf if os.path.exists(file): try: data = json.loads(open(file).read()) except IOError: pass except: pass else: data = json.loads(file) # parsing routines self.logger = logging.getLogger() try: pid = data['id'] if 'appstream_family' in data: appstream_family = data['appstream_family'] else: appstream_family = '' name = data['name'].strip() v_txt = data['version'] or '0' desc = data['description'] cmds = data['commands'] reboot = data['reboot'] or 0 try: sub_packages = data['sub_packages'] except KeyError: sub_packages = [] # Inventory section licenses = data['inventory']['licenses'] associateinventory = data['inventory']['associateinventory'] queries = data['inventory']['queries'] except KeyError: raise Exception('CANTPARSE') p = Package() p.init( pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot, appstream_family, queries['Qvendor'], queries['Qsoftware'], queries['Qversion'], queries['boolcnd'], licenses, sub_packages, associateinventory ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def parse_str(self, file): xml = None try: if os.path.exists(file): xml = minidom.parse(file) else: xml = minidom.parseString(file) # parsing routines self.logger = logging.getLogger() root = xml.getElementsByTagName("package") if len(root) != 1: raise Exception("CANTPARSE") root = root[0] pid = root.getAttribute("id") tmp = root.getElementsByTagName("name")[0] name = tmp.firstChild.wholeText.strip() version = root.getElementsByTagName("version")[0] tmp = version.getElementsByTagName("numeric")[0] tmp = version.getElementsByTagName("label")[0] if tmp.firstChild != None: v_txt = tmp.firstChild.wholeText.strip() else: v_txt = "0" tmp = root.getElementsByTagName("description") if len(tmp) == 1 and tmp[0].firstChild != None: tmp = tmp[0] desc = tmp.firstChild.wholeText.strip() else: desc = "" cmd = root.getElementsByTagName("commands")[0] reboot = 0 if cmd.hasAttribute("reboot"): reboot = cmd.getAttribute("reboot") cmds = {} for c in ["installInit", "preCommand", "command", "postCommandSuccess", "postCommandFailure"]: tmp = cmd.getElementsByTagName(c) if len(tmp) == 1 and tmp[0].firstChild != None: command = tmp[0].firstChild.wholeText.strip() if tmp[0].hasAttribute("name"): ncmd = tmp[0].getAttribute("name") else: ncmd = "" cmds[c] = {"command": command, "name": ncmd} else: cmds[c] = "" p = Package() p.init( pid, name, v_txt, 0, desc, cmds["command"], cmds["installInit"], cmds["preCommand"], cmds["postCommandSuccess"], cmds["postCommandFailure"], reboot, ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def parse_str(self, file): xml = None try: if os.path.exists(file): xml = minidom.parse(file) else: xml = minidom.parseString(file) # parsing routines self.logger = logging.getLogger() root = xml.getElementsByTagName('package') if len(root) != 1: raise Exception('CANTPARSE') root = root[0] pid = root.getAttribute('id') tmp = root.getElementsByTagName('name')[0] name = tmp.firstChild.wholeText.strip() version = root.getElementsByTagName('version')[0] tmp = version.getElementsByTagName('numeric')[0] tmp = version.getElementsByTagName('label')[0] if tmp.firstChild is not None: v_txt = tmp.firstChild.wholeText.strip() else: v_txt = "0" tmp = root.getElementsByTagName('description') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] desc = tmp.firstChild.wholeText.strip() else: desc = "" licenses = '' tmp = root.getElementsByTagName('licenses') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] licenses = tmp.firstChild.wholeText.strip() cmd = root.getElementsByTagName('commands')[0] reboot = 0 if cmd.hasAttribute('reboot'): reboot = cmd.getAttribute('reboot') cmds = {} for c in ['installInit', 'preCommand', 'command', 'postCommandSuccess', 'postCommandFailure']: tmp = cmd.getElementsByTagName(c) if len(tmp) == 1 and tmp[0].firstChild is not None: command = tmp[0].firstChild.wholeText.strip() if tmp[0].hasAttribute('name'): ncmd = tmp[0].getAttribute('name') else: ncmd = '' cmds[c] = {'command': command, 'name': ncmd} else: cmds[c] = '' associateinventory = 0 tmp = root.getElementsByTagName('associateinventory') if len(tmp) == 1 and tmp[0].firstChild is not None: tmp = tmp[0] associateinventory = tmp.firstChild.wholeText.strip() query = root.getElementsByTagName('query') queries = {'Qvendor': '', 'Qsoftware': '', 'Qversion': '', 'boolcnd': ''} if query.length >= 1 and query[0].firstChild: for k in queries: tmp = query[0].getElementsByTagName(k) if tmp.length >= 1 and tmp[0].firstChild: queries[k] = tmp[0].firstChild.wholeText.strip() p = Package() p.init( pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot, 0, queries['Qvendor'], queries['Qsoftware'], queries['Qversion'], queries['boolcnd'], licenses, [], associateinventory ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def parse_str(self, file): xml = None try: if os.path.exists(file): xml = minidom.parse(file) else: xml = minidom.parseString(file) # parsing routines self.logger = logging.getLogger() root = xml.getElementsByTagName('package') if len(root) != 1: raise Exception('CANTPARSE') root = root[0] pid = root.getAttribute('id') tmp = root.getElementsByTagName('name')[0] name = tmp.firstChild.wholeText.strip() version = root.getElementsByTagName('version')[0] tmp = version.getElementsByTagName('numeric')[0] tmp = version.getElementsByTagName('label')[0] if tmp.firstChild != None: v_txt = tmp.firstChild.wholeText.strip() else: v_txt = "0" tmp = root.getElementsByTagName('description') if len(tmp) == 1 and tmp[0].firstChild != None: tmp = tmp[0] desc = tmp.firstChild.wholeText.strip() else: desc = "" cmd = root.getElementsByTagName('commands')[0] reboot = 0 if cmd.hasAttribute('reboot'): reboot = cmd.getAttribute('reboot') cmds = {} for c in ['installInit', 'preCommand', 'command', 'postCommandSuccess', 'postCommandFailure']: tmp = cmd.getElementsByTagName(c) if len(tmp) == 1 and tmp[0].firstChild != None: command = tmp[0].firstChild.wholeText.strip() if tmp[0].hasAttribute('name'): ncmd = tmp[0].getAttribute('name') else: ncmd = '' cmds[c] = {'command':command, 'name':ncmd} else: cmds[c] = '' p = Package() p.init( pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None
def parse_str(self, file): xml = None try: if os.path.exists(file): xml = minidom.parse(file) else: xml = minidom.parseString(file) # parsing routines self.logger = logging.getLogger() root = xml.getElementsByTagName('package') if len(root) != 1: raise Exception('CANTPARSE') root = root[0] pid = root.getAttribute('id') tmp = root.getElementsByTagName('name')[0] name = tmp.firstChild.wholeText.strip() version = root.getElementsByTagName('version')[0] tmp = version.getElementsByTagName('numeric')[0] if tmp.firstChild != None: v_num = tmp.firstChild.wholeText else: v_num = 0 tmp = version.getElementsByTagName('label')[0] if tmp.firstChild != None: v_txt = tmp.firstChild.wholeText.strip() else: v_txt = "0" tmp = root.getElementsByTagName('description') if len(tmp) == 1 and tmp[0].firstChild != None: tmp = tmp[0] desc = tmp.firstChild.wholeText.strip() else: desc = "" cmd = root.getElementsByTagName('commands')[0] reboot = 0 if cmd.hasAttribute('reboot'): reboot = cmd.getAttribute('reboot') cmds = {} for c in ['installInit', 'preCommand', 'command', 'postCommandSuccess', 'postCommandFailure']: tmp = cmd.getElementsByTagName(c) if len(tmp) == 1 and tmp[0].firstChild != None: command = tmp[0].firstChild.wholeText.strip() if tmp[0].hasAttribute('name'): ncmd = tmp[0].getAttribute('name') else: ncmd = '' cmds[c] = {'command':command, 'name':ncmd} else: cmds[c] = '' p = Package() p.init( pid, name, v_txt, 0, desc, cmds['command'], cmds['installInit'], cmds['preCommand'], cmds['postCommandSuccess'], cmds['postCommandFailure'], reboot ) except Exception, e: logging.getLogger().error("parse_str failed") logging.getLogger().error(e) p = None