本文整理匯總了Python中settings.PASSWORD屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.PASSWORD屬性的具體用法?Python settings.PASSWORD怎麽用?Python settings.PASSWORD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類settings
的用法示例。
在下文中一共展示了settings.PASSWORD屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: search
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def search(vector, k=10):
"""
vector: numpy array vector
Return: predicted name of the face and search time
"""
db = DBObject(db=DB_NAME, user=USER, password=PASSWORD)
q = 'SELECT name from images order by vector <-> %s asc limit %s'
_vector = AsIs('cube(ARRAY[' + ','.join(str(vector).strip('[|]').split()) + '])')
start = time.time()
try:
results = db.make_query(q, (_vector, str(k)),q_type='query')
except Exception as e:
raise e
total = time.time() - start
return ' '.join(results[0][0].split('_')[:-1]), total
示例2: soap_get_password_order
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def soap_get_password_order(client):
method_url = METHOD_ORDER_URL[settings.LIVE] + 'getPassword'
svc_url = SVC_ORDER_URL[settings.LIVE]
header_value = soap_set_wsa_headers(method_url, svc_url)
response = client.service.getPassword(
UserId=settings.USERID[settings.LIVE],
Password=settings.PASSWORD[settings.LIVE],
PassKey=settings.PASSKEY[settings.LIVE],
_soapheaders=[header_value]
)
print
response = response.split('|')
status = response[0]
if (status == '100'):
# login successful
pass_dict = {'password': response[1], 'passkey': settings.PASSKEY[settings.LIVE]}
return pass_dict
else:
raise Exception(
"BSE error 640: Login unsuccessful for Order API endpoint"
)
## fire SOAP query to get password for Upload API endpoint
## used by all functions except create_transaction_bse() and cancel_transaction_bse()
示例3: soap_get_password_upload
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def soap_get_password_upload(client):
method_url = METHOD_UPLOAD_URL[settings.LIVE] + 'getPassword'
svc_url = SVC_UPLOAD_URL[settings.LIVE]
header_value = soap_set_wsa_headers(method_url, svc_url)
response = client.service.getPassword(
MemberId=settings.MEMBERID[settings.LIVE],
UserId=settings.USERID[settings.LIVE],
Password=settings.PASSWORD[settings.LIVE],
PassKey=settings.PASSKEY[settings.LIVE],
_soapheaders=[header_value]
)
print
response = response.split('|')
status = response[0]
if (status == '100'):
# login successful
pass_dict = {'password': response[1], 'passkey': settings.PASSKEY[settings.LIVE]}
return pass_dict
else:
raise Exception(
"BSE error 640: Login unsuccessful for upload API endpoint"
)
## fire SOAP query to post the order
示例4: accuracy
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def accuracy(k=10):
db = DBObject(db=DB_NAME, user=USER, password=PASSWORD)
q = 'SELECT name, vector from dev'
start = time.time()
dev_images = db.make_query(q, q_type='query')
total = time.time() - start
q = 'SELECT name from train order by %s <-> vector asc limit %s'
count = 0
for image in dev_images:
name, vector = image
_name = '_'.join(name.split('_')[:-1])
vector = [float(elem) for elem in list(vector.strip('(|)').split(', '))]
_vector = AsIs('cube(ARRAY[' + str(vector).strip('[|]') + '])')
candidates = db.make_query(q, (_vector, str(k)), q_type='query')
most_likely_name = most_common_or_first([candidate[0] for candidate in candidates])
if most_likely_name.startswith(_name):
count += 1
return 1.0*count/len(dev_images), total
示例5: prepare_db
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def prepare_db():
"""
Create a database with name in .env
"""
try:
con = psycopg2.connect(dbname='postgres', user=USER, password=PASSWORD)
except psycopg2.Error as e:
raise e
logging.info('Connected to database postgres')
con.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = con.cursor()
try:
cur.execute('CREATE DATABASE ' + DB_NAME)
except psycopg2.Error as e:
logging.info('DROP OLD DATABASE')
logging.info('CREATE NEW DATABASE')
cur.execute('DROP DATABASE ' + DB_NAME)
cur.execute('CREATE DATABASE ' + DB_NAME)
cur.close()
con.close()
con = psycopg2.connect(dbname=DB_NAME, user=USER, password=PASSWORD)
cur = con.cursor()
cur.execute('CREATE EXTENSION CUBE')
cur.execute('CREATE TABLE images (id serial, name text, url text, vector cube);')
con.commit()
cur.close()
con.close()
示例6: insert_features
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def insert_features(path, table):
batches, predictions = get_batch_predictions(path)
name2vector = {}
for i, prediction in enumerate(predictions):
name2vector[batches.filenames[i].split('/')[-1]] = prediction
db = DBObject(db=DB_NAME, user=USER, password=PASSWORD)
save_to_db(table, name2vector, db)
示例7: login
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def login(driver):
'''
Logs into the BSEStar web portal using login credentials defined in settings
'''
try:
line = "https://www.bsestarmf.in/Index.aspx"
driver.get(line)
print("Opened login page")
# enter credentials
userid = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "txtUserId")))
memberid = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "txtMemberId")))
password = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "txtPassword")))
userid.send_keys(settings.USERID[settings.LIVE])
memberid.send_keys(settings.MEMBERID[settings.LIVE])
password.send_keys(settings.PASSWORD[settings.LIVE])
submit = driver.find_element_by_id("btnLogin")
submit.click()
print("Logged in")
return driver
except (TimeoutException, NoSuchElementException, StaleElementReferenceException,
ErrorInResponseException, ElementNotVisibleException):
print("Retrying in login")
return login(driver)
except (BadStatusLine):
print("Retrying for BadStatusLine in login")
driver = init_driver()
return login(driver)
示例8: loginGitStar
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def loginGitStar(self):
r=requests.post("http://gitstar.top:88/api/user/login",params={'username':settings.NAME,'password':settings.PASSWORD})
self.cookie = r.headers['Set-Cookie']
示例9: get_notifications
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def get_notifications(self, old_count):
# changes in followers
# notification
new_count = self.followers
notifications = []
if old_count != new_count:
if self.username == USERNAME:
notification_url = URL + '/user/followers'
target = 'you'
else:
notification_url = URL + '/users/' + self.username + '/followers'
target = self.username
if new_count > old_count:
params = {'per_page': self.followers}
start_page = old_count // 100
end_page = new_count // 100
followers = []
with requests.Session() as s:
for i in range(start_page + 1, end_page + 2):
params['page'] = i
new_page = s.get(notification_url, headers=HEADERS,
params=params, auth=(USERNAME, PASSWORD)).json()
#print("Length of page {} : {}".format(i, len(new_page)))
followers += new_page
start_index = old_count % 100
context = "follow"
#print("Len of followers:" + str(len(followers)))
#print("Len of list:" + str(len(followers[start_index:])))
for user_blob in followers[start_index:]:
protagonist = user_blob['login']
notifications += [Notification.generate_message(protagonist, context, target)]
else:
message = '{} users unfollowed {}'.format(old_count - new_count, target)
notifications += [Notification(message)]
return notifications
示例10: get_blob
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def get_blob(handle):
if handle == USERNAME:
user_url = URL + '/user'
else:
user_url = URL + '/users/' + handle
# print("User = " + USERNAME + " : " + user_url)
user = requests.get(user_url, headers=HEADERS, auth=(USERNAME, PASSWORD)).json()
return user
示例11: get_repos
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def get_repos(handle):
if handle == USERNAME:
repo_url = URL + '/user/repos'
else:
repo_url = URL + '/users/' + handle + '/repos'
repo_response = requests.get(repo_url, headers=HEADERS, auth=(USERNAME, PASSWORD)).json()
repos = [Repo.from_Repository(repo) for repo in repo_response]
return repos
示例12: from_name
# 需要導入模塊: import settings [as 別名]
# 或者: from settings import PASSWORD [as 別名]
def from_name(cls, repo_name, owner_name):
url = URL + '/repos/' + owner_name + "/" + repo_name
# print("Repo = " + repo_name + ' : ' + url)
repo = requests.get(url, headers=HEADERS, auth=(USERNAME, PASSWORD)).json()
# handle pagination
#owner = owner_name
#name = repo_name
#forks = repo['forks_count']
#watchers = repo['watchers_count']
#stars = repo['stargazers_count']
#return cls(name, owner, forks, watchers, stars)
return cls.from_Repository(repo)