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


Python config.PASSWORD属性代码示例

本文整理汇总了Python中config.PASSWORD属性的典型用法代码示例。如果您正苦于以下问题:Python config.PASSWORD属性的具体用法?Python config.PASSWORD怎么用?Python config.PASSWORD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在config的用法示例。


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

示例1: get_credentials

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def get_credentials(database):
    settings = database.settings
    creds = settings.get_credentials()
    if creds == (USERNAME, PASSWORD):
        return creds
    elif creds is not None and (USERNAME is None or PASSWORD is None):
        return creds
    elif creds is not None and USERNAME is not None and PASSWORD is not None:
        settings.set_credentials(USERNAME, PASSWORD)
        return (USERNAME, PASSWORD)
    elif creds is None and (USERNAME is None or PASSWORD is None):
        username = base64.b64encode(sha256(str(random.getrandbits(255))).digest())[:20]
        password = base64.b64encode(sha256(str(random.getrandbits(255))).digest())[:20]
        settings.set_credentials(username, password)
        return (username, password)
    elif creds is None and (USERNAME is not None and PASSWORD is not None):
        settings.set_credentials(USERNAME, PASSWORD)
        return (USERNAME, PASSWORD) 
开发者ID:OpenBazaar,项目名称:OpenBazaar-Server,代码行数:20,代码来源:credentials.py

示例2: start

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def start():
    """Start the sneakpeek application."""
    logging.info("Starting application")
    logging.info("Instantiating Reddit instance")
    reddit = praw.Reddit(
        client_id=config.CLIENT["ID"],
        client_secret=config.CLIENT["SECRET"],
        user_agent=config.USER_AGENT,
        username=config.USERNAME,
        password=config.PASSWORD)

    try:
        scan(reddit.subreddit(config.SUBREDDIT))
    except Exception as exception:
        # This should never happen,
        # because it breaks the infinite subreddit monitoring
        # provided by subreddit.stream.submissions()
        logging.critical("Exception occurred while scanning. This should never happen.")
        logging.critical(exception) 
开发者ID:fterh,项目名称:sneakpeek,代码行数:21,代码来源:main.py

示例3: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def __init__(self, local=True):
        
        if local:
        # Class instance connection to Mongo
            self.connection = MongoClient()
    
            if config.AUTH:
                try:
                    self.connection.admin.authenticate(config.USERNAME, config.PASSWORD)
                except:
                    print('Error: Authentication failed. Please check:\n1. MongoDB credentials in config.py\n2. MongoDB uses the correct authentication schema (MONGODB-CR)\nFor more info. see https://github.com/bitslabsyr/stack/wiki/Installation')
                    sys.exit(1)
                
            # App-wide config file for project info access
            self.config_db = self.connection.config
            self.stack_config = self.config_db.config
        else:
            self.connection = MongoClient(config.CT_SERVER)
    
            if config.CT_AUTH:
                try:
                    self.connection.admin.authenticate(config.CT_USERNAME, config.CT_PASSWORD)
                except:
                    print('Error: Authentication failed at the central server. Please check:\n1. MongoDB credentials in config.py\n2. MongoDB uses the correct authentication schema (MONGODB-CR)\nFor more info. see https://github.com/bitslabsyr/stack/wiki/Installation')
                    sys.exit(1) 
开发者ID:bitslabsyr,项目名称:stack,代码行数:27,代码来源:models.py

示例4: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    sdk = SDK(APP_KEY, APP_SECRET, SERVER)
    platform = sdk.platform()
    platform.login(USERNAME, EXTENSION, PASSWORD)

    # Simple GET
    response = platform.get('/account/~/extension/~')
    user = response.json()
    user_id = str(user.id)
    print('User loaded ' + user.name + ' (' + user_id + ')')
    print('Headers ' + str(response.response().headers))

    print(type(response.response()._content))

    # Multipart response
    try:
        multipart_response = platform.get('/account/~/extension/' + user_id + ',' + user_id + '/presence').multipart()
        print('Multipart 1\n' + str(multipart_response[0].json_dict()))
        print('Multipart 2\n' + str(multipart_response[1].json_dict()))
    except ApiException as e:
        print('Cannot load multipart')
        print('URL ' + e.api_response().request().url)
        print('Response' + str(e.api_response().json())) 
开发者ID:ringcentral,项目名称:ringcentral-python,代码行数:25,代码来源:demo.py

示例5: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    cache = get_file_cache()

    # Create SDK instance
    sdk = SDK(APP_KEY, APP_SECRET, SERVER)
    platform = sdk.platform()

    # Set cached authentication data
    platform.auth().set_data(cache)

    try:
        platform.is_authorized()
        print('Authorized already by cached data')
    except Exception as e:
        platform.login(USERNAME, EXTENSION, PASSWORD)
        print('Authorized by credentials')

    # Perform refresh by force
    platform.refresh()
    print('Refreshed')

    set_file_cache(platform.auth().data())
    print("Authentication data has been cached") 
开发者ID:ringcentral,项目名称:ringcentral-python,代码行数:25,代码来源:demo_cache.py

示例6: send_email

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def send_email(subject, msg):
    try:
        server = smtplib.SMTP('smtp.gmail.com:587')
        server.ehlo()
        server.starttls()
        server.login(config.EMAIL_ADDRESS, config.PASSWORD)
        message = 'Subject: {}\n\n{}'.format(subject, msg)
        server.sendmail(config.EMAIL_ADDRESS, config.EMAIL_ADDRESS, message)
        server.quit()
        print("Success: Email sent!")
    except:
        print("Email failed to send.") 
开发者ID:vprusso,项目名称:youtube_tutorials,代码行数:14,代码来源:send_email.py

示例7: send_email

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def send_email(self):
        try:
            server = smtplib.SMTP('smtp.gmail.com:587')
            server.ehlo()
            server.starttls()
            server.login(config.FROM_EMAIL_ADDRESS, config.PASSWORD)
            message = 'Subject: {}\n\n{}'.format(self.subject, self.msg)
            server.sendmail(config.FROM_EMAIL_ADDRESS,
                            config.TO_EMAIL_ADDRESS,
                            message)
            server.quit()
            print("Success: Email sent!")
        except:
            print("Email failed to send.") 
开发者ID:vprusso,项目名称:youtube_tutorials,代码行数:16,代码来源:email_alert.py

示例8: setUpClass

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def setUpClass(self):
        self.api_base_url                   = config.BASE_URL or 'http://api.dailymotion.com'
        self.api_key                        = config.CLIENT_ID
        self.api_secret                     = config.CLIENT_SECRET
        self.username                       = config.USERNAME
        self.password                       = config.PASSWORD
        self.scope                          = ['manage_videos', 'manage_playlists', 'userinfo']
        self.redirect_uri                   = config.REDIRECT_URI
        self.oauth_authorize_endpoint_url   = config.OAUTH_AUTHORIZE_URL or 'https://api.dailymotion.com/oauth/authorize'
        self.oauth_token_endpoint_url       = config.OAUTH_TOKEN_URL or 'https://api.dailymotion.com/oauth/token'
        self.session_file_directory  = './data'
        if not os.path.exists(self.session_file_directory):
            os.makedirs(self.session_file_directory) 
开发者ID:dailymotion,项目名称:dailymotion-sdk-python,代码行数:15,代码来源:TestDailymotion.py

示例9: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    sdk = SDK(APP_KEY, APP_SECRET, SERVER)
    platform = sdk.platform()
    platform.login(USERNAME, EXTENSION, PASSWORD)

    def on_message(msg):
        print(msg)

    def pubnub():
        try:
            s = sdk.create_subscription()
            s.add_events(['/account/~/extension/~/message-store'])
            s.on(Events.notification, on_message)
            s.register()

            while True:
                sleep(0.1)

        except KeyboardInterrupt:
            print("Pubnub listener stopped...")

    p = Process(target=pubnub)

    try:
        p.start()
    except KeyboardInterrupt:
        p.terminate()
        print("Stopped by User")

    print("Wait for notification...") 
开发者ID:ringcentral,项目名称:ringcentral-python,代码行数:32,代码来源:demo_subscription.py

示例10: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    sdk = SDK(APP_KEY, APP_SECRET, SERVER)
    platform = sdk.platform()
    platform.login(USERNAME, EXTENSION, PASSWORD)

    to_numbers = "1234567890"

    params = {'from': {'phoneNumber': USERNAME},'to': [{'phoneNumber': to_number}],'text': "SMS message"}
    response = platform.post('/restapi/v1.0/account/~/extension/~/sms', params)

    print 'Sent SMS: ' + response.json().uri 
开发者ID:ringcentral,项目名称:ringcentral-python,代码行数:13,代码来源:demo_sms.py

示例11: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    sdk = SDK(APP_KEY, APP_SECRET, SERVER)
    platform = sdk.platform()
    platform.login(USERNAME, EXTENSION, PASSWORD)

    # Step 1. Get MMS-enabled phone number

    phone_numbers = platform.get('/account/~/extension/~/phone-number', {'perPage': 'max'}).json().records

    mms_number = None

    for phone_number in phone_numbers:
        if 'MmsSender' in phone_number.features:
            mms_number = phone_number.phoneNumber

    print 'MMS Phone Number: ' + mms_number

    # Step 2. Send MMS

    attachment = (
        'test.png',
        urllib.urlopen('https://developers.ringcentral.com/assets/images/ico_case_crm.png').read(),
        'image/png'
    )

    builder = sdk.create_multipart_builder()
    builder.set_body({
        'from': {'phoneNumber': mms_number},
        'to': [{'phoneNumber': MOBILE}],
        'text': 'MMS from Python'  # this is optional
    })
    builder.add(attachment)

    request = builder.request('/account/~/extension/~/sms')

    response = platform.send_request(request)
    print 'Sent MMS: ' + response.json().uri 
开发者ID:ringcentral,项目名称:ringcentral-python,代码行数:39,代码来源:demo_mms.py

示例12: main

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
    """ main method """
    client = requests.Session()
    reboot(client, ROUTER, USER, PASSWORD) 
开发者ID:mkorz,项目名称:b618reboot,代码行数:6,代码来源:reboot_router.py

示例13: get_account

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def get_account():
    """Method that provides the connection to Reddit API using OAuth.
        :return: Reddit instance.
    """
    return praw.Reddit(client_id=config.CLIENT_ID,
                       client_secret=config.CLIENT_SECRET,
                       user_agent=config.USER_AGENT,
                       username=config.USERNAME,
                       password=config.PASSWORD) 
开发者ID:Jonarzz,项目名称:DotaResponsesRedditBot,代码行数:11,代码来源:account.py

示例14: connect_to_ap

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def connect_to_ap():
    station = network.WLAN(network.STA_IF)
    if not station.active():
        station.active(True)
        if not station.isconnected():
            print('Connecting....')
            station.connect(config.SSID, config.PASSWORD)
            while not station.isconnected():
                time.sleep(1)
                print('.', end='')
            print('')
    print('ifconfig =', station.ifconfig()) 
开发者ID:mozilla-iot,项目名称:webthing-upy,代码行数:14,代码来源:connect.py

示例15: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def __init__(self):
        cmd.Cmd.__init__(self)
        self.trader = Robinhood()

        # Robinhood now uses 2FA
        # The workflow we use is as follows
        # If we find auth token in auth.data - try to see if it still works
        # If yes, continue
        # If no, try to refresh the token using refresh token
        # If it still fails, we need to relogin with 2FA
        try:
            data = open(self.auth_file).read()
            auth_data = json.loads(data)
            if 'auth_token' in auth_data:
              self.trader.device_token = auth_data['device_token']
              self.trader.auth_token = auth_data['auth_token']
              self.trader.refresh_token = auth_data['refresh_token']
              self.trader.headers['Authorization'] = 'Bearer ' + self.trader.auth_token
              try:
                self.trader.user()
              except:
                del self.trader.headers['Authorization']
                self.trader.relogin_oauth2()
                self._save_auth_data()
        except:
            challenge_type = 'email'
            if CHALLENGE_TYPE == 'sms':
              challenge_type = 'sms'
            self.trader.login(username = USERNAME, password = PASSWORD, challenge_type = challenge_type)
            self._save_auth_data()

        try:
            data = open(self.instruments_cache_file).read()
            self.instruments_cache = json.loads(data)
            for k in self.instruments_cache:
                self.instruments_reverse_cache[self.instruments_cache[k]] = k
        except:
            pass

        try:
            data = open(self.watchlist_file).read()
            self.watchlist = json.loads(data)
        except:
            pass

    # nytime = parser.parse('2018-06-15T23:14:15Z').astimezone(to_zone)
    # from dateutil import parser

    # ----- basic commands ----- 
开发者ID:anilshanbhag,项目名称:RobinhoodShell,代码行数:51,代码来源:shell.py


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