コード例 #1
0
ファイル: import_subs.py プロジェクト: atsunaakiya/octobot3
def main():
    connect_db()
    service, func, channel = sys.argv[1:]
    service = ServiceType(service)
    line = next_line()
    while line:
        SubscribeSource.add_subs(service, func, line, channel)
        line = next_line()
コード例 #2
0
def run_schedule(task):
    minutes, func = task_conf[task]
    func = partial(try_to_run, func)
    connect_db()
    ItemInfo.clean_pending_items()
    while True:
        try:
            func()
        except KeyboardInterrupt:
            break
        time.sleep(minutes * 60)
コード例 #3
0
ファイル: main.py プロジェクト: atsunaakiya/octobot3
def main():
    cmd = sys.argv[1]
    if cmd == 'server':
        launch()
    elif cmd == 'cron':
        task = sys.argv[2]
        run_schedule(task)
    elif cmd == 'update_subs':
        connect_db()
        update_subs()
    elif cmd == 'update_index':
        connect_db()
        update_index()
    elif cmd == 'download_images':
        connect_db()
        download_images()
    elif cmd == 'post_images':
        connect_db()
        post_images()
    elif cmd == 'clean_cache':
        connect_db()
        clean_cache()
    else:
        print("WTF??")
コード例 #4
0
def launch():
    conf = load_config().server
    connect_db()
    app.run(host=conf.host, port=conf.port)
コード例 #5
0
def main():
    connect_db()
    service, func, channel = sys.argv[1:]
    service = ServiceType(service)
    for name in SubscribeSource.export_subs_by_channel(service, func, channel):
        print(name)
コード例 #6
0
                    BytesIO(i.read()) for i in ItemInfo.get_attachment_images(item)
                ]
                images.extend(attachment_images)
            converted_username = pull_services[item.service].convert_username(item.source_id)
            try:
                client.push_item(item, images, ch, converted_username)
            except Exception as err:
                traceback.print_exc()
                SecondaryTask.release_task(stype, item_id, ptype, conf, ch)
            else:
                SecondaryTask.close_task(stype, item_id, ptype, conf, ch)
        if SecondaryTask.task_done(stype, item_id):
            print("Post Done", (item.service, item.item_id))
            ItemInfo.set_status(item.service, item.item_id, TaskStage.Cleaning, TaskStatus.Queued)

def service_exists(stype: ServiceType, conf: str):
    s = config.api.get(stype)
    if s is None:
        return False
    c = s.get(conf)
    return c is not None

@lru_cache()
def get_service(stype: ServiceType, conf: str):
    service_type = push_services[stype]
    api_conf = config.api[stype][conf]
    return service_type(api_conf)

if __name__ == '__main__':
    connect_db()
    post_images()
コード例 #7
0
 def test_create_dir(self):
     config = load_config()
     connect_db()
     d = WebDavServiceBase(config.api[ServiceType.WebDav]['cos'])
     d.ensure_dir('cos', 'twitter/fffff')
コード例 #8
0
ファイル: twitter_tests.py プロジェクト: atsunaakiya/octobot3
 def test_crawler(self):
     connect_db()
     config = load_config()
     conf = config.api[ServiceType.Twitter]['default']
     res = TwitterService(conf).pull_item(IndexItem(item_id='1390984246781644802', service=ServiceType.Twitter))
     print(res)
コード例 #9
0
ファイル: twitter_tests.py プロジェクト: atsunaakiya/octobot3
 def test_timeline(self):
     connect_db()
     config = load_config()
     conf = config.api[ServiceType.Twitter]['default']
     service = TwitterUsernameSubs(conf)
     print(list(service.subscribe_full('Strangestone')))