def export_subtitles(video_id, subtitles, database: dal.DataAccessLayer): for sub in subtitles['subtitles']: if isinstance(sub['ts_start'], datetime.time): start = get_ms(sub['ts_start']) else: start = sub['ts_start'] if isinstance(sub['ts_end'], datetime.time): end = get_ms(sub['ts_end']) else: end = sub['ts_end'] database.add_subtitle(video_id, sub['original_phrase'].lower(), start, end)
def syncRecords(): """ Envio producción de pieza a la API """ counter = 0 db = DataAccessLayer() rows = db.getPendingRecords() for row in rows: rowid = row[0] sensor = row[1] qty = row[2] sync_ok = sendApiRequest(sensor, qty) if sync_ok: db.markRecordAsSynched(rowid) counter = counter + 1 else: logError('api-error') return counter
def mark_subtitles_invalid(video_id, video_file, database: dal.DataAccessLayer): database.set_video_status(video_id, database.STATUS_INVALID_SUBS) os.remove(video_file)
def mark_subtitles_missing(video_id, video_file, database: dal.DataAccessLayer): database.set_video_status(video_id, database.STATUS_SUBS_MISSING) os.remove(video_file)
return True except RequestException as e: logInfo('could not update ' + sensor + ' qty ' + str(production)) return False ####################### ######## MAIN ######### ####################### try: if __name__ == '__main__': os.system('clear') # clear screen START_MESSAGE = "Starting API service for Wiidem Sensor Gadget #" + str( settings.GADGET_CODE) logInfo(START_MESSAGE) db = DataAccessLayer() db.initDb() # flags is_first_time = True is_client_online = False is_server_online = False has_unsync_data = False while True: # Online Wiidem Server Check is_server_online = checkWiidemServerConnection() if is_server_online: if is_first_time: is_first_time = False msg_success = settings.MESSAGES['SERVER_ONLINE']
def handle_get_request(self, args): try: return DataAccessLayer(self.collection).list() except Exception as e: print("Exception e {}".format(e)) return False, None
def process_document(self, document): return DataAccessLayer(self.collection).add_or_update( document, str(document['app_id']))
""" Create database object Database schema: <chat_id>_adm -> user id of the user who invited the bot <chat_id>_spb -> user id of the user who is target of mocking spongebob chats -> list of chat ids where the bot has received messages in. """ # Create database object db = pickledb.load("bot.db", True) if not db.get("chats"): db.set("chats", []) dal = DataAccessLayer() TOKEN = "726693597:AAGuNw5J2QiDc-C7DKr2Sa4gaQFJy51E4Bc" BOT_USERNAME = "******" HELP_TEXT = """ერთაოზი ძუყნურიდან! დახმარება: /help {ბრძანება} - დახმარება ბრძანებები: /minify - URL-ის შემცირება /cat - კატის ფოტოს გამოგზავნა /order - ჩატში წესრიგის დამყარება /weather - მიმდინარე ამინდი /weather_forecast - ამინდის პროგნოზი