def jsonrpc_register(self, plugin_ip): result = [] print plugin_ip self.rpclogger.debug('In %s' % sys._getframe().f_code.co_name) # DEBUG mode da hangi fieldlarin hatali geldigini yazdirabiliriz tabiki sadece query server ' a. self.store = db.get_store() plugin = self.store.find(Plugin, Plugin.plugin_ip == plugin_ip).one() #TODO Anywhere plugins registered flags not set. Flags must be define. if plugin is None: result.append(0) print result return result else: if plugin.registered == 1: result.append(1) print result return result if plugin.registered == 2: result.append(2) print result return result if plugin.registered == 3: result.append(3) print result return result print result return result
def display_items_by_store(): store_id = int(input("Store ID: ")) store = db.get_store(store_id) if store == None: print("There is no store with that ID.\n") else: print() items = db.get_items_by_store(store_id) display_items(items, store.name.upper())
def __init__(self, sources): self.qglogger = logger.createLogger('querygenerator') self.qglogger.debug('In %s' % sys._getframe().f_code.co_name) self.qglogger.info('Starting Query Generator') self.nfsen_filters = [ 'src_ip', 'src_port', 'dst_ip', 'dst_port', 'proto', 'protocol_version', 'packets', 'bytes', 'duration', 'flags', 'tos', 'pps', 'bps', 'bpp', 'AS', 'scale' ] self.store = db.get_store() self.sources = sources
def add_item(): name = input("Name: ") types = input("Type: ") cost = int(input("Cost (cost cannot include cents): ")) store_id = int(input("Store ID: ")) store = db.get_store(store_id) if store == None: print("There is no category with that ID. Movie NOT added.\n") else: item = Item(name=name, types=types, cost=cost, store=store) db.add_item(item) print(name + " was added to database.\n")
def do_POST(self): global store print "POST %s" % self.path bits = urllib.unquote(self.path).split('/') x = None if bits[1] == "people": clen, pdict = cgi.parse_header(self.headers.getheader('content-length')) c = self.rfile.read(int(clen)) j = simplejson.loads(unicode(c)) print "POST people: %s" % j x = Person.of_dict(j) elif bits[1] == 'service': clen, pdict = cgi.parse_header(self.headers.getheader('content-length')) c = self.rfile.read(int(clen)) j = simplejson.loads(unicode(c)) print "POST service: %s" % j x = Service.of_dict(j) elif bits[1] == 'att': clen, pdict = cgi.parse_header(self.headers.getheader('content-length')) mime, pdict = cgi.parse_header(self.headers.getheader('content-type')) c = self.rfile.read(int(clen)) print "POST att: %s" % bits[1] x = Att.insert(unicode(bits[2]), c, unicode(mime)) elif bits[1] == 'thing': clen, pdict = cgi.parse_header(self.headers.getheader('content-length')) c = self.rfile.read(int(clen)) j = simplejson.loads(unicode(c)) print "POST thing: %s" % j x = Thing.of_dict(j) elif bits[1] == 'credential': clen, pdict = cgi.parse_header(self.headers.getheader('content-length')) c = self.rfile.read(int(clen)) j = simplejson.loads(unicode(c)) print "POST credential: %s" % j x = Credential.of_dict(j) try: store.commit() except: store = get_store() store.commit() if x: self.send_response(200) else: self.send_response(500) self.end_headers()