Exemplo n.º 1
0
# -*- coding: utf-8 -*-

from cronjob.datacenter.cache.cache_controller import CacheController
from cronjob.datacenter.file.file import sort_hotkey_order_by_amount
from util.base.time import TimeTranslator

if __name__ == "__main__":
    cache_controller = CacheController(0)
    cache = cache_controller.get_today_cache()
    ordered_cache = sort_hotkey_order_by_amount(cache)

    for data in ordered_cache:

        datetime = TimeTranslator.timestamp2datetime(data['time'])

        print("{}|{}|{}|{}|{}".format(
            datetime.time(), data['hotkey'], data['amount'],
            '' if len(data['flag']) == 0 else data['flag'][0],
            '' if len(data['emoji']) == 0 else data['emoji'][0]))
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
# Update Weibo's hotkey list daily.

# 1. Get cache data where key is '0'
# 2. Clean cache where key is '0'
# 3. Update the data to this repo.

import time

from cronjob.datacenter.file.file import FileController
from cronjob.datacenter.cache.cache_controller import CacheController
from cronjob.tool.git_tool import GitTool

if __name__ == '__main__':
    cache_controller = CacheController(0)
    today_cache = cache_controller.get_today_cache()

    # save cache.
    file_controller = FileController()
    file_controller.write_data_md(today_cache)

    # update data.
    git_tool = GitTool()
    git_tool.push_data()

    # clear cache.
    time.sleep(2)
    cache_controller.clear_today_cache()
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
# Cronjob for Weibo's hotkey upload system.

from cronjob.crawler.hotkey_fetcher import HotkeyFetcher
from cronjob.datacenter.cache.cache_controller import CacheController

from util.constant.enum import *
from util.base.time import Time

if __name__ == "__main__":
    now = Time.now_timestamp()

    fetcher = HotkeyFetcher()
    data = fetcher.get_data(ENUM_DATATYPE_JSON, limit=10)

    cacheController = CacheController()
    cacheController.insert_cache(now, data)