当前位置: 首页>>代码示例>>Python>>正文


Python pit.Pit类代码示例

本文整理汇总了Python中pit.Pit的典型用法代码示例。如果您正苦于以下问题:Python Pit类的具体用法?Python Pit怎么用?Python Pit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
    conf = Pit.get('pw2f', {'require':{'last-time':'yyyy-mm-dd hh:mm:ss+hh:mm'}})
    flickr = service.Flickr()
    picasaweb = service.Picasaweb()
    for album in reversed(picasaweb.get_album_list()):
        logging.info('title: %s, published: %s' % (album._title,
                                            album._published))
        if not album._title == '2009-12-29_天狗-硫黄' \
                and album._published > parse_date(conf['last-time']):
            flickr.copy_album_from(picasaweb, album)
        else:
            logging.debug('skip album %s: published:%s' % (album._title, album._published))
开发者ID:sett4,项目名称:pw2f,代码行数:12,代码来源:pw2f.py

示例2: main

def main():
    gmail = Pit.get('gmail', {'require' : {
                'user' : 'Gmail account name',
                'pass' : 'password for Gmail account',
                'fullcount' : '0'
                }})

    kayac = Pit.get('kayac', {'require' : {
                'user' : 'im.kayac.com account name',
                'pass' : 'password for im.kayac.com account'
                }})

    d = feedparser.parse( GMAILATOM % (gmail['user'], gmail['pass']) )
    

    if int(d.feed.fullcount) == int(gmail['fullcount']):
        sys.exit(0)
    
    elif int(d.feed.fullcount) > int(gmail['fullcount']):
        for e in d.entries:
            title = e.title
            author = e.author
            message = '%s <%s> [%[email protected]]' % (title, author, gmail['user'])
            r = notify(message, kayac['user'], kayac['pass'])

        if r['result'] != 'posted':
            print 'failed', r
            sys.exit(2)

    Pit.set('gmail', {'data' : {
                'user' : gmail['user'],
                'pass' : gmail['pass'],
                'fullcount' : str(d.feed.fullcount)}})
开发者ID:ymotongpoo,项目名称:0x7d8,代码行数:33,代码来源:gmail2kayac.py

示例3: test_with_mock_editor

 def test_with_mock_editor(self):
     import os
     ORIGINAL_EDITOR = os.environ.get('EDITOR')
     os.environ["EDITOR"] = "./mock_editor.py"
     Pit.get('test',
             {'require':
              {'login': 'your ID',
               'passwd': 'GoMa'}})
     os.environ["EDITOR"] = ORIGINAL_EDITOR
开发者ID:yoshiori,项目名称:pit,代码行数:9,代码来源:test.py

示例4: test_get_not_exist_key

 def test_get_not_exist_key(self):
     import os
     ORIGINAL_EDITOR = os.environ.get('EDITOR')
     os.environ["EDITOR"] = "./mock_editor.py"
     Pit.get("NOT_EXIST_KEY", 
             {'require': 
              {'login': 'your ID', 
               'passwd': 'GoMa'}})
     os.environ["EDITOR"] = ORIGINAL_EDITOR
开发者ID:yoshiori,项目名称:pit,代码行数:9,代码来源:test.py

示例5: get_credentials

def get_credentials():
    """Get credential information from Pit.
    """
    conf = Pit.get("Google")
    if "login" not in conf.keys():
        # If not exists, exception will be raised
        editor = os.environ["EDITOR"]
        conf = Pit.get(
        'Google', {
                'require':{'login':'Google ID','passwd':'Google PassWord'}})
    return conf
开发者ID:kabe,项目名称:dev,代码行数:11,代码来源:pickdata.py

示例6: test_japan_holiday

def test_japan_holiday():
    token = Pit.get('google.api').get('token')

    japan_holiday = JapanHoliday(token)
    japan_holiday.get_holiday_calender(2015)
    # 2015/10/12[Mon] is 体育の日
    assert japan_holiday.check(now=datetime.datetime(2015, 10, 12, 0, 0, 0)) is True
    assert japan_holiday.check(now=datetime.datetime(2015, 10, 13, 0, 0, 0)) is False
    assert japan_holiday.check(now=datetime.datetime(2015, 10, 11, 0, 0, 0), weekend=False) is False
    assert japan_holiday.check(now=datetime.datetime(2015, 10, 11, 0, 0, 0), weekend=True) is True

    japan_holiday.check(now=datetime.datetime(2016, 10, 2, 0, 0, 0))
    assert type(japan_holiday.today()) == bool
    japan_holiday.today(weekend=True)
    japan_holiday.check()
    japan_holiday.check(now=datetime.datetime(2016, 10, 2, 0, 0, 0))
    japan_holiday.check(now=datetime.datetime(2016, 10, 2, 0, 0, 0), weekend=True)

    # 10000call Within 1 second
    ts = time.time()
    for x in xrange(10000):
        JapanHoliday(token).check(now=datetime.datetime(2016, random.randint(1, 12), 2, 0, 0, 0))
    te = time.time()
    assert te - ts < 1, te - ts

    with pytest.raises(CalenderDoesNotExistError):
        japan_holiday.get_holiday_calender(2017)
开发者ID:subc,项目名称:japan_holiday,代码行数:27,代码来源:tests.py

示例7: connect

    def connect(cls):

        try:

            db_info = Pit.get("db_info")

            host = db_info["host"]
            user = db_info["username"]
            password = db_info["password"]
            db = db_info["db"]

            # Connect to the database
            connection = pymysql.connect(
                host=host,
                user=user,
                password=password,
                db=db,
                charset="utf8mb4",
                cursorclass=pymysql.cursors.DictCursor,
            )

            connection.autocommit(False)

            logger.debug(constants.SEPARATE_LINE)
            logger.debug(constants.DB_CONNECTION_ESTABLISHED_MSG)
            logger.debug(constants.SEPARATE_LINE)
        except IOError:
            raise
        except Exception:
            raise
        else:
            return connection
开发者ID:america,项目名称:Python,代码行数:32,代码来源:dbUtil.py

示例8: download

def download():
    config = Pit.get('flickr.com')
    key = config['api_key']

    api = flickrapi.FlickrAPI(key)

    tags = ['blue', 'red', 'green', 'yellow', 'purple', 'cyan']
    index = 0
    for tag in tags:
        for photo in api.photos_search(tags=tag, sort="relevance", license='2')[0]:
            photo_id = photo.attrib['id']

            try:
                sizes = api.photos_getSizes(photo_id=photo_id)[0]
            except:
                continue
            small = sizes.find('.//size[@label="Small"]')
            url = small.attrib['source']

            print 'downloading {0} as {1}'.format(url, index)
            resp = requests.get(url)
            if resp.status_code != 200:
                continue
            with open('{0}/{1:02d}.jpg'.format(ORIG_DIR, index), 'wb') as f:
                for chunk in resp.iter_content():
                    f.write(chunk)
            index += 1
开发者ID:taichino,项目名称:color_search_sample,代码行数:27,代码来源:prepare.py

示例9: main

def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser()
    parser.add_argument('img')
    args = parser.parse_args(argv)

    setting = Pit.get(
        'iwdcat',
        {'require': {'username': '',
                     'password': '',
                     }})
    auth_token = setting['username'], setting['password']
    url = 'https://gateway.watsonplatform.net/visual-recognition-beta/api/v1/tag/recognize'

    res = requests.post(url, auth=auth_token, files={
            'imgFile': ('sample.jpg', open(args.img, 'rb')),
        })
    if res.status_code == requests.codes.ok:
        data = json.loads(res.text)
        for img in data['images']:
            print('{} - {}'.format(img['image_id'], img['image_name']))
            for label in img['labels']:
                print('    {:30}: {}'.format(label['label_name'], label['label_score']))
    else:
        print(res.status_code)
        print(res.reason)
开发者ID:TakesxiSximada,项目名称:mar,代码行数:25,代码来源:recog.py

示例10: create_user

def create_user():
    with settings(user='root'):
        cuisine.user_ensure('ssmjp')
        append('/etc/sudoers', 'ssmjp ALL=(ALL) ALL')
        cuisine.ssh_authorize('ssmjp', cuisine.file_local_read('~/.ssh/ssmjp.pub'))
        conf = Pit.get('ssmjp-user', { 'require': { 'password': 'Your password' } })
        cuisine.user_passwd('ssmjp', conf['password'])
开发者ID:niratama,项目名称:ssmjp201410,代码行数:7,代码来源:fabfile.py

示例11: main

def main():
    config = Pit.get('lingr.com', {
        'require': {
            'user': 'Your lingr user name',
            'password': 'Your lingr password'
        }
    })
    lingr = Lingr(config['user'], config['password'])

    for event in lingr.stream():
        pynotify.init('lingr')
        title = None
        text = None
        img = None
        if 'message' in event:
            message = event['message']
            title = '%[email protected]%s' % (message['nickname'], message['room'])
            text = message['text']
            img = get_img(message['icon_url'])
        elif 'presence' in event:
            presence = event['presence']
            title = '%[email protected]%s' % (presence['nickname'], presence['room'])
            text = presence['status']
            img = get_img(presence['icon_url'])
        n = pynotify.Notification(title, text, img)
        n.show()
开发者ID:narusemotoki,项目名称:lingrpy,代码行数:26,代码来源:main.py

示例12: __init__

	def __init__(self):
		key = Pit.get('twitter.com')

		self.consumer_key = key['consumer_key']
		self.consumer_secret = key['consumer_secret']
		self.access_token = key['access_token']
		self.access_token_secret = key['access_token_secret']
开发者ID:vim13,项目名称:pymd,代码行数:7,代码来源:api.py

示例13: __init__

    def __init__(self):
        conf = Pit.get('picasaweb', {'require': {'username':'username', 'password':'password'}})
        self.gd_client = gdata.photos.service.PhotosService()
        self.gd_client.email = conf['username']
        self.gd_client.password = conf['password']
        self.gd_client.source = 'pw2f picasaweb plugin'
        self.gd_client.ProgrammaticLogin()

        self.conf = conf
开发者ID:sett4,项目名称:pw2f,代码行数:9,代码来源:service.py

示例14: __call__

 def __call__(self):
     conf = Pit.get('pplog', {'require': {
         'username': '',
         'password': '',
     }})
     return PPlogSecret(
         username=conf['username'],
         password=conf['password'],
         )
开发者ID:TakesxiSximada,项目名称:pplog-extention,代码行数:9,代码来源:pplog.py

示例15: get_Consumersecret

def get_Consumersecret():
    """
    pitからcustomer keyを呼ぶ
      """
    piConf = Pit.get("twitter-consumer", {'require':
                                 {'ckey': 'ConsumerKey',
                                  'csecret': 'ConsumerSecret'
                                  }})
    return(piConf['ckey'], piConf['csecret'])
开发者ID:recuraki,项目名称:PythonJunkScript,代码行数:9,代码来源:basic.py


注:本文中的pit.Pit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。