コード例 #1
0
ファイル: process.py プロジェクト: torshie/speech-crawler
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)
コード例 #2
0
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
コード例 #3
0
ファイル: process.py プロジェクト: torshie/speech-crawler
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)
コード例 #4
0
ファイル: process.py プロジェクト: torshie/speech-crawler
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)
コード例 #5
0
        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']
コード例 #6
0
 def handle_get_request(self, args):
     try:
         return DataAccessLayer(self.collection).list()
     except Exception as e:
         print("Exception e {}".format(e))
         return False, None
コード例 #7
0
 def process_document(self, document):
     return DataAccessLayer(self.collection).add_or_update(
         document, str(document['app_id']))
コード例 #8
0
ファイル: ertaoz_bot.py プロジェクト: MadViper/ertaoz-bot
"""
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 - ამინდის პროგნოზი