예제 #1
0
def main():
    """
    更新
    """
    parser = ArgumentParser(description=__description__,
                            epilog=__doc__, formatter_class=RawTextHelpFormatter)
    parser.add_argument('-v', '--version',
                        action='version', version=__version__)
    parser.add_argument('-c', '--config',
                        default="config.json", help="run with config file [配置文件路径]")
    get_config(path=parser.parse_args().config)
    # Dynamicly import the dns module as configuration
    dns_provider = str(get_config('dns', 'dnspod').lower())
    dns = getattr(__import__('dns', fromlist=[dns_provider]), dns_provider)
    dns.ID, dns.TOKEN = get_config('id'), get_config('token')
    if get_config('debug'):
        ip.DEBUG = get_config('debug')
        basicConfig(
            level=DEBUG,
            format='%(asctime)s <%(module)s.%(funcName)s> %(lineno)d@%(pathname)s \n[%(levelname)s] %(message)s')
        info("DDNS[%s] run: %s,%s", __version__, os_name, sys.platform)

    proxy = get_config('proxy') or 'DIRECT'
    proxy_list = proxy.strip('; ') .split(';')

    cache = get_config('cache', True) and Cache(CACHE_FILE)
    if cache is False:
        warning("Cache is disabled!")
    elif len(cache) < 1 or get_config.time >= cache.time:
        cache.clear()
        print("=" * 25, ctime(), "=" * 25, sep=' ')
    update_ip('4', cache, dns, proxy_list)
    update_ip('6', cache, dns, proxy_list)
예제 #2
0
def main():
    """
    更新
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', default="config.json")
    get_config(path=parser.parse_args().c)
    # Dynamicly import the dns module as configuration
    dns_provider = str(get_config('dns', 'dnspod').lower())
    dns = getattr(__import__('dns', fromlist=[dns_provider]), dns_provider)
    dns.ID, dns.TOKEN = get_config('id'), get_config('token')
    if get_config('debug'):
        ip.DEBUG = get_config('debug')
        logging.basicConfig(
            level=logging.DEBUG,
            format=
            '%(asctime)s <%(module)s.%(funcName)s> %(lineno)d@%(pathname)s \n[%(levelname)s] %(message)s'
        )
        logging.info("DDNS[%s] run: %s,%s", __version__, os.name, sys.platform)

    proxy = get_config('proxy') or 'DIRECT'
    proxy_list = proxy.strip('; ').split(';')

    cache = get_config('cache', True) and Cache(CACHE_FILE)
    if cache is False:
        print("Cache is disabled!")
    elif len(cache) < 1 or get_config.time >= cache.time:
        cache.clear()
        print("=" * 25, time.ctime(), "=" * 25, sep=' ')
    update_ip('4', cache, dns, proxy_list)
    update_ip('6', cache, dns, proxy_list)
예제 #3
0
def main():
    """
    更新
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', default="config.json")
    get_config(path=parser.parse_args().c)

    if get_config('dns', 'dnspod').startswith('ali'):
        dns = alidns
    elif get_config('dns', 'dnspod').startswith('dnscom'):
        dns = dnscom
    else:
        dns = dnspod
    dns.ID, dns.TOKEN = get_config('id'), get_config('token')
    dns.PROXY = get_config('proxy')
    ip.DEBUG = get_config('debug')

    cache = get_config('cache', True) and Cache(CACHE_FILE)
    if cache is False:
        print("Cache is disabled!")
    elif len(cache) < 1 or get_config.time >= cache.time:
        cache.clear()
        print("=" * 25, time.ctime(), "=" * 25, sep=' ')
    update_ip('4', cache, dns)
    update_ip('6', cache, dns)
예제 #4
0
    def __init__(self,
                 util,
                 listeners,
                 rows,
                 columns,
                 voice_assistant,
                 d=None,
                 turn_page=None,
                 page_in_title=True,
                 show_loading=False):
        """ Initializer
        
        :param util: utility object
        :param listeners: file browser listeners
        :param rows: menu rows
        :param d: dictionary with menu button flags
        :param turn_page: turn page callback
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.bounding_box = util.screen_rect
        self.player = None
        self.turn_page = turn_page
        self.page_in_title = page_in_title
        self.show_loading = show_loading

        self.cache = Cache(self.util)
        self.layout = BorderLayout(self.bounding_box)
        self.layout.set_percent_constraints(PERCENT_TOP_HEIGHT,
                                            PERCENT_BOTTOM_HEIGHT, 0, 0)
        Screen.__init__(self, util, "", PERCENT_TOP_HEIGHT, voice_assistant,
                        "menu_screen_screen_title", True, self.layout.TOP)

        color_dark_light = self.config[COLORS][COLOR_DARK_LIGHT]
        self.menu_layout = self.layout.CENTER

        if d:
            self.menu_button_layout = self.get_menu_button_layout(d)
            self.img_rect = self.menu_button_layout.image_rectangle

        listeners[GO_LEFT_PAGE] = self.previous_page
        listeners[GO_RIGHT_PAGE] = self.next_page

        try:
            self.navigator = BookNavigator(util, self.layout.BOTTOM, listeners,
                                           color_dark_light, d[4])
            Container.add_component(self, None)
            Container.add_component(self, self.navigator)
        except:
            Container.add_component(self, None)

        self.total_pages = 0
        self.current_page = 1
        self.menu = None
def main():
    """
    更新
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', default="config.json")
    get_config(path=parser.parse_args().c)
    # Dynamicly import the dns module as configuration
    dns_provider = str(get_config('dns', 'dnspod').lower())
    dns = getattr(__import__('dns', fromlist=[dns_provider]), dns_provider)
    dns.ID, dns.TOKEN = get_config('id'), get_config('token')
    dns.DOMAIN = get_config('domain')

    ip.DEBUG = get_config('debug')

    proxy = get_config('proxy') or 'DIRECT'
    proxy_list = proxy.strip('; ') .split(';')


    print ("=" * 26, "=" * len(time.ctime()), "=" * 26, "\n", sep='')

    print(" " * 30, "%s" % (dns.DOMAIN.encode("utf8")).rjust( len(time.ctime())/2 - 2),"\n",sep="")

    print ("=" * 25, time.ctime(), "=" * 25, "\n", sep=' ')


    cache = get_config('cache', True) and Cache(CACHE_FILE)

    print("[OGetting]  [Address]")

    # address = get_ip("4")
    print("[Now]".rjust(10) + "  [" +  get_ip("4") + "]")
    cache = False;

    if cache is False:
        # print("Cache is disabled!")
        print ("[Cache]".rjust(10),"[Disabled]",sep="  ")
    elif len(cache) < 1 or get_config.time >= cache.time:
        cache.clear()
        # print ("=" * 25, time.ctime(), "=" * 25, sep=' ')
        print ("[Cache]".rjust(10),"[Cleared]",sep="  ")

    update_ip('4', cache, dns, proxy_list)
    # update_ip('6', cache, dns, proxy_list)
    print('[Session]'.rjust(10)+"  [End]", end=" ")
    print("\n")
    print ("_" * 25, time.ctime(), "_" * 25, sep=' ')
    print ("_" * 26, "_" * len(time.ctime()), "_" * 26, "\n", sep='')

    print("\n")
예제 #6
0
 def __init__(self, listeners, util, site_parser, voice_assistant):
     """ Initializer
     
     :param listeners: screen listeners
     :param util: utility object 
     :param site_parser: site parser        
     """
     FilePlayerScreen.__init__(self, listeners, util, self.get_playlist,
                               voice_assistant)
     self.config = util.config
     self.current_playlist = None
     self.parser = site_parser
     self.cache = Cache(self.util)
     self.current_book_state = None
     self.current_track_index = 0
     self.playlist = self.get_playlist()
     self.audio_files = self.get_audio_files_from_playlist()
     self.loading_listeners = []
     self.reset_loading_listeners = []
     self.LOADING = util.config[LABELS][KEY_LOADING]
예제 #7
0
파일: run.py 프로젝트: xcxnig/DDNS
def main():
    """
    更新
    """
    init_config(__description__, __doc__, __version__)
    # Dynamicly import the dns module as configuration
    dns_provider = str(get_config('dns', 'dnspod').lower())
    dns = getattr(__import__('dns', fromlist=[dns_provider]), dns_provider)
    dns.Config.ID = get_config('id')
    dns.Config.TOKEN = get_config('token')
    dns.Config.TTL = get_config('ttl')
    if get_config('debug'):
        ip.DEBUG = get_config('debug')
        basicConfig(
            level=DEBUG,
            format=
            '%(asctime)s <%(module)s.%(funcName)s> %(lineno)d@%(pathname)s \n[%(levelname)s] %(message)s'
        )
        print("DDNS[", __version__, "] run:", os_name, sys.platform)
        if get_config("config"):
            print("Configuration was loaded from <==",
                  path.abspath(get_config("config")))
        print("=" * 25, ctime(), "=" * 25, sep=' ')

    proxy = get_config('proxy') or 'DIRECT'
    proxy_list = proxy if isinstance(
        proxy, list) else proxy.strip('; ').replace(',', ';').split(';')

    cache = get_config('cache', True) and Cache(CACHE_FILE)
    if cache is False:
        info("Cache is disabled!")
    elif get_config("config_modified_time") is None or get_config(
            "config_modified_time") >= cache.time:
        warning("Cache file is out of dated.")
        cache.clear()
    elif not cache:
        debug("Cache is empty.")
    update_ip('4', cache, dns, proxy_list)
    update_ip('6', cache, dns, proxy_list)
예제 #8
0
파일: main.py 프로젝트: gorilla001/test
    def __init__(self):
        handlers = [
            (r'/', IndexHandler),  # 首页
            # (r'/wx', WxHandler),  # 微信授权页面
            (r'/pay/wx', PayHandler),  # 支付
            # (r'/pay_test', PayWeixinTestHandler),  # 微信支付测试页
            (r'/api/address', address.AddressHandler),
            (r'/api/recom_item', recom_item.DetailHandler),
            (r'/api/home', home.HomeHandler),
            (r'/api/itemlist', home.ItemHandler),
            (r'/api/auth/login', auth.LoginHandler),
            (r'/api/order', order.OrderHandler),
            (r'/api/util/smscode', util.SmscodeHandler),
            (r'/api/util/region', util.RegionHandler),

            # (r'/download/yc', YcDownloadHandler),  # 有菜下载
            (r'/coupon', CouponHandler),  # 有菜优惠券
            (r'/api/coupon', coupon.CouponHandler),  # 有菜获取优惠券接口
            (r'/api/update_mobile', coupon.UpdateMobileHandler),  # 更改红包领取手机号
            (r'/coupon/info', CouponInfoHandler),  # 有菜优惠券说明
        ]
        settings = dict(
            debug=options.debug,
            xsrf_cookies=True,
            login_url='/login',
            cookie_secret='alA9P3tIUGFe3boFVM2A2tmusiRsrTGdgm8Vrk=',
            static_path=os.path.join(ROOT_PATH, 'static') if options.debug else
            os.path.join(os.path.dirname(ROOT_PATH), 'static'),
            template_path=os.path.join(ROOT_PATH, 'templates'),
            db={
                'hamlet': motor.MotorClient(MONGO_HAMLET['master']).hamlet,
                'store': motor.MotorClient(MONGO_STORE['master']).store,
                'youcai': motor.MotorClient(MONGO_YOUCAI['master']).youcai
            },
            cache=Cache(CACHE_SERVER),
            session_manager=SessionManager(SESSION_SECRET, SESSION_SERVER,
                                           SESSION_TIMEOUT, not options.debug))
        super(YoucaiWeb, self).__init__(handlers, **settings)
예제 #9
0
def main():
    """
    更新
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', default="config.json")
    get_config(path=parser.parse_args().c)
    # Dynamicly import the dns module as configuration
    dns_provider = str(get_config('dns', 'dnspod').lower())
    dns = getattr(__import__('dns', fromlist=[dns_provider]), dns_provider)
    dns.ID, dns.TOKEN = get_config('id'), get_config('token')
    dns.PROXY = get_config('proxy')

    ip.DEBUG = get_config('debug')

    cache = get_config('cache', True) and Cache(CACHE_FILE)
    if cache is False:
        print("Cache is disabled!")
    elif len(cache) < 1 or get_config.time >= cache.time:
        cache.clear()
        print ("=" * 25, time.ctime(), "=" * 25, sep=' ')
    update_ip('4', cache, dns)
    update_ip('6', cache, dns)
예제 #10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.config = config
        self.bot_config = self.config['bot']
        self.session = aiohttp.ClientSession()
        self.logger = logger
        self.cache = Cache()
        self.database = Database(self.config['database'])
        self.pool = None
        self.debug = debug
        self.title = self.bot_config['title']

        self.base_extensions = self.bot_config['extensions']['base']
        self.debug_extensions = self.bot_config['extensions']['debug']

        if self.debug:
            self.bot_extensions = self.base_extensions + self.debug_extensions
            self.token = self.bot_config['debug_token']
            self.prefix = self.bot_config['debug_prefix']
        else:
            self.bot_extensions = self.base_extensions
            self.token = self.bot_config['production_token']
            self.prefix = self.bot_config['production_prefix']
예제 #11
0
import openpyxl

from const import (
    HttpStatus, )
from config import (
    QIANBIDAO_USER,
    QIANBIDAO_PASSWORD,
    RECEIPTS,
)
from util.http import HttpClient
from util.mail import mail_multipart
from util.cache import Cache
from util.decorators import singleton, retry

cache = Cache(default_values={'qianbidao': {'last_id': '55c433b917a672bd'}})


class QianBiDaoCrawler(object):

    QianBiDaoAppHeaders = {
        'User-Agent': 'PencilNews/1.3.0 (iPhone; iOS 11.2.5; Scale/2.00)',
        'Accept-Encoding': 'br, gzip, deflate',
        'Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9',
        'Authority': 'api.pencilnews.cn',
    }
    login_url = 'https://api.pencilnews.cn/user/login'

    def __init__(self, username, password):
        self.httpclient = HttpClient(default_headers=self.QianBiDaoAppHeaders)
        self.username = username