當前位置: 首頁>>代碼示例>>Python>>正文


Python Pit.get方法代碼示例

本文整理匯總了Python中pit.Pit.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Pit.get方法的具體用法?Python Pit.get怎麽用?Python Pit.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pit.Pit的用法示例。


在下文中一共展示了Pit.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:14,代碼來源:pw2f.py

示例2: main

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:35,代碼來源:gmail2kayac.py

示例3: test_with_mock_editor

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
 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,代碼行數:11,代碼來源:test.py

示例4: test_get_not_exist_key

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
 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,代碼行數:11,代碼來源:test.py

示例5: get_credentials

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:13,代碼來源:pickdata.py

示例6: test_japan_holiday

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:29,代碼來源:tests.py

示例7: connect

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
    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,代碼行數:34,代碼來源:dbUtil.py

示例8: download

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:29,代碼來源:prepare.py

示例9: main

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:27,代碼來源:recog.py

示例10: create_user

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:9,代碼來源:fabfile.py

示例11: main

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
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,代碼行數:28,代碼來源:main.py

示例12: __init__

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
	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,代碼行數:9,代碼來源:api.py

示例13: __init__

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
    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,代碼行數:11,代碼來源:service.py

示例14: __call__

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
 def __call__(self):
     conf = Pit.get('pplog', {'require': {
         'username': '',
         'password': '',
     }})
     return PPlogSecret(
         username=conf['username'],
         password=conf['password'],
         )
開發者ID:TakesxiSximada,項目名稱:pplog-extention,代碼行數:11,代碼來源:pplog.py

示例15: get_Consumersecret

# 需要導入模塊: from pit import Pit [as 別名]
# 或者: from pit.Pit import get [as 別名]
def get_Consumersecret():
    """
    pitからcustomer keyを呼ぶ
      """
    piConf = Pit.get("twitter-consumer", {'require':
                                 {'ckey': 'ConsumerKey',
                                  'csecret': 'ConsumerSecret'
                                  }})
    return(piConf['ckey'], piConf['csecret'])
開發者ID:recuraki,項目名稱:PythonJunkScript,代碼行數:11,代碼來源:basic.py


注:本文中的pit.Pit.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。