def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('connection', sa.Column('id', GUID(), nullable=False), sa.Column('user_id', GUID(), nullable=False), sa.Column('discord_id', sa.String(length=80), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa.Column('kind', sa.String(length=80), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('discord_id') )
def sendImageAsync(self, *img): encoded_string = base64.b64encode(img[0]).decode("utf-8") imgSize = sys.getsizeof(encoded_string) guid = GUID() msg = { "guid": guid.uuid, "image": encoded_string, "channel": "Kasif", "key": socket.gethostname() } # print(encoded_string) # sendMsg = json.dumps(msg) try: self.sio.emit('frreq', msg) time.sleep(0.1) print( str(imgSize) + ' - ' + str(self.queueFrame.qsize()) + ' memory % used:', psutil.virtual_memory()[2]) except Exception as ex: self.IsConnected = False print(ex)
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'user', sa.Column('id', GUID(), nullable=False), sa.Column('discord_id', sa.String(length=80), nullable=False), sa.Column('username', sa.String(length=80), nullable=False), sa.Column('discriminator', sa.String(length=4), nullable=False), sa.Column('avatar_hash', sa.String(length=120), nullable=True), sa.Column('oauth_token', JSONEncodedDict(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('discord_id'))
def __init__(self, pos, color, radius): ''' Any visible object has a guid attached for eq operations. ''' self.guid = GUID.next_guid() self.pos = pos self.color = color self.radius = radius WorldObject.objects.add(self)
def sendImageAsync(self,*img): encoded_string = base64.b64encode(img[0]).decode("utf-8") imgSize = sys.getsizeof(encoded_string) guid = GUID() msg = { "guid": guid.uuid, "image": encoded_string, "key" : "Kasif" } # print(encoded_string) sendMsg = json.dumps(msg) try: self.sock.send(sendMsg.encode()) print(str(imgSize) + ' - ' + str(self.queueFrame.qsize()) + ' memory % used:', psutil.virtual_memory()[2]) except Exception as ex: self.IsConnected=False print(ex)
async def post(self, request): log.info('create new api key for user %s' % user_id) return UJSONResponse({'apikey': GUID().slug})
class OrganizationSchema(BaseSchema): _model = OrganizationModel name = fields.Str(required=True) id = fields.Str(missing=str(GUID()))
def test_1(self): g1 = GUID() u = guid_to_uuid(g1) g2 = uuid_to_guid(u) self.assertEqual(g1, g2)
def start(self): p = [] try: self.connect() print('start') p.append(threading.Thread(target=self.capture, args=(1,))) p[0].daemon=True p[0].start() # with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: # s.connect((serverIP,tcpPort)) while True: if self.queueFrame.empty(): time.sleep(0.05) while not self.IsConnected: time.sleep(3) print('retry connect') self.connect() frame=self.queueFrame.get() try: (boxes, scores, classes, num_detections) = self.t1.run(frame) except Exception as e: print(e) encoded_string = base64.b64encode(frame).decode("utf-8") guid = GUID() msg = { "guid": guid.uuid, "image": encoded_string, "key" : "Kasif" } # print(encoded_string) sendMsg = json.dumps(msg) try: self.sock.send(sendMsg.encode()) time.sleep(0.05) except Exception as ex: self.IsConnected=False print(ex) imgSize = sys.getsizeof(frame) # print(imgSize) # print(queueFrame.qsize()) # print(psutil.virtual_memory()) # physical memory usage print(str(imgSize) + ' - ' + str(self.queueFrame.qsize()) + ' memory % used:', psutil.virtual_memory()[2]) except Exception as e: print(e) # is_exit=True p[0].join()