Exemplo n.º 1
0
  def __init__(self, ui, data):
    self.settings = Settings(ui)
    xml = xmlfromstring(data)
    bug = xml.find("bug")
    self.num = int(bug.find('bug_id').text)
    self.title = bug.find('short_desc').text
    self.comments = [Comment(n) for n in xml.findall("bug/long_desc")]
    self.desc = self.comments[0].text if len(self.comments)>0 else ""
    self.attachments = [Attachment.parse(self, a) for a in xml.findall("bug/attachment")]
    if bug.get("error") == "NotPermitted":
      raise PermissionError("Not allowed to access bug.  (Perhaps it is marked with a security group?)")

    # Add to cache so we can avoid network lookup later in this process
    cache[self.num] = self
Exemplo n.º 2
0
    def visible_networks(self):
        """
        Retrieves list of wireless networks visible to Mebo.

        :returns: A dictionary of name to `WirelessNetwork`

        >>> m = Mebo(auto_connect=True)
        >>> print(m.visible_networks())
        """
        resp = self._request(req='get_rt_list', need_response=True)
        et = xmlfromstring(f'{resp.text}')
        visible = {}
        for nw in et.findall('w'):
            visible[nw.find('s').text.strip('"')] = WirelessNetwork(*(i.text.strip('"') for i in nw.getchildren()))
        return visible
Exemplo n.º 3
0
def _validate_jshint(fd, options=None):
    cfgfile = os.path.join(BASE_DIR, 'config/jshint.json')
    po = subprocess.Popen([
        'jshint',
        '--reporter=jslint',
        '--config',
        cfgfile,
        '-',
    ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, stderr = po.communicate(input=fd.read())
    tree = xmlfromstring(output)
    has_errors = False
    for elem in tree.findall('.//issue'):
        _detail(elem.attrib['reason'], line=elem.attrib['line'], column=elem.attrib['char'])
        has_errors = True
    return not has_errors
Exemplo n.º 4
0
def _validate_jshint(fd, options=None):
    cfgfile = os.path.join(BASE_DIR, 'config/jshint.json')
    po = subprocess.Popen([
        'jshint',
        '--reporter=jslint',
        '--config',
        cfgfile,
        '-',
    ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, stderr = po.communicate(input=fd.read())
    tree = xmlfromstring(output)
    has_errors = False
    for elem in tree.findall('.//issue'):
        _detail(elem.attrib['reason'], line=elem.attrib['line'], column=elem.attrib['char'])
        has_errors = True
    return not has_errors
Exemplo n.º 5
0
    def load_xml(self):
        FILE = open(self.path_modules_and_xml + "/setup.xml", 'r')
        modules = xmlfromstring(FILE.read())

        dic_return = {}

        for module in modules._children:
            module_name = module.attrib['name']
            module_dict = {}
            for functions in module._children:
                function_name = functions.attrib['name']
                args_name = []
                for args in functions._children:
                    args_name.append(args.attrib['name'])
                module_dict[function_name] = args_name
            dic_return[module_name] = module_dict

        return dic_return
Exemplo n.º 6
0
Arquivo: obo.py Projeto: diluga/obo
    def search(self):
        q = self.query or ''
        query_args = append_query_arg(self.query_args, 'query',
                                      urllib.quote_plus(q))

        headers = {}

        result = self.obo.conn.make_request("GET",
                                            bucket=self.bucket_name,
                                            key='',
                                            query_args=query_args,
                                            headers=headers)
        if result.status == 200:
            s = result.read()
            print dump_json(xj.data(xmlfromstring(s)))
            # print dump_json([dict(next_xml_entry(attr) for attr in el) for el in et.fromstring(s)])

        else:
            print 'ERROR: http status: ' + str(result.status)
            print result.read()