Beispiel #1
0
    def executer(self, *args):
        """Execute remotely"""

        options = self.options

        try:
            # from dbnav import daemon
            # if not daemon.is_running(options):
            #     daemon.start_server(options)

            url = 'http://{host}:{port}/{path}'.format(
                host=options.host,
                port=options.port,
                path=COMMANDS[options.prog])
            request = json.dumps(args[1:])

            log.logger.debug('Request to %s:\n%s', url, request)

            response = urllib2.urlopen(url, request)

            for i in ijson.items(response, 'item'):
                yield from_json(i)
        except urllib2.HTTPError as e:
            raise from_json(json.load(e))
        except urllib2.URLError as e:
            log.logger.error('Daemon not available: %s', e)
        except BaseException as e:
            log.logger.exception(e)
Beispiel #2
0
 def from_json(d):
     return Item(
         title=from_json(d["title"]),
         subtitle=from_json(d["subtitle"]),
         autocomplete=from_json(d["autocomplete"]),
         uid=from_json(d["uid"]),
         icon=from_json(d["icon"]),
         value=from_json(d["value"]),
         validity=from_json(d["validity"]),
         format_=from_json(d["format_"]),
     )
Beispiel #3
0
 def from_json(d):
     return Column(
         **from_json(
             filter_keys(
                 d,
                 'name', 'tablename', 'type', 'nullable', 'default',
                 'autoincrement', 'primary_key', 'autocomplete'
             )
         )
     )
Beispiel #4
0
 def from_json(d):
     return Table(
         **from_json(
             filter_keys(
                 d,
                 'name', 'uri', 'owner', 'size', 'primary_key', 'columns',
                 'foreign_keys', 'autocomplete'
             )
         )
     )
Beispiel #5
0
 def from_json(d):
     return ForeignKeyNode(from_json(d["fk"]), from_json(d["parent"]), from_json(d["indent"]))
Beispiel #6
0
 def from_json(d):
     return ColumnNode(from_json(d["column"]), from_json(d["indent"]))
Beispiel #7
0
 def from_json(d):
     return NameNode(from_json(d["name"]), from_json(d["indent"]))
Beispiel #8
0
 def from_json(d):
     return TableNode(from_json(d["table"]), from_json(d["indent"]))
Beispiel #9
0
 def from_json(d):
     return RowItem(
         from_json(d['row'])
     )
Beispiel #10
0
 def from_json(d):
     return RowItem(
         from_json(d["row"]), from_json(d["include"]), from_json(d["exclude"]), from_json(d["substitutes"])
     )
Beispiel #11
0
 def from_json(d):
     return Row(
         **from_json(filter_keys(d, 'table', 'row', 'autocomplete'))
     )
Beispiel #12
0
 def from_json(d):
     return ForeignKey(
         a=from_json(d.get('a')),
         b=from_json(d.get('b'))
     )