本文整理汇总了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)
示例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)
示例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)
示例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()))
示例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")
示例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.")
示例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.")
示例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)
示例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...")
示例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
示例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
示例12: main
# 需要导入模块: import config [as 别名]
# 或者: from config import PASSWORD [as 别名]
def main():
""" main method """
client = requests.Session()
reboot(client, ROUTER, USER, PASSWORD)
示例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)
示例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())
示例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 -----