本文整理汇总了Python中users.Users类的典型用法代码示例。如果您正苦于以下问题:Python Users类的具体用法?Python Users怎么用?Python Users使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Users类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
class UUS:
def __init__(self):
self.__LOG_TAG__ = "UUS"
self.rss_list = URL_list()
self.html_list = URL_list()
self.users = Users()
def to_str(self):
return "rss_list:\n"+self.rss_list.to_str()+'\n\nhtml_list:\n'+self.html_list.to_str()
def print_users(self, p_users):
for user in self.users.get_users():
print str(user.get_id()) + " " + str(user.get_nick()) + " " + str(user.get_url_list())
print
def get_url_split(self, p_url):
"RSS|http://www.hardware.com.br/feeds/global.xml"
ret = "", ""
try:
ret = p_url.split('|')
except:
log.error(self.__LOG_TAG__, "Error getting URL type")
return ret[0], ret[1]
def update(self, p_user):
user_id = p_user.get_id()
user_urls = p_user.get_url_list()
for url in user_urls:
url_type, url_link = self.get_url_split(url)
if url_type == "RSS":
self.rss_list.add_link(url_link)
self.rss_list.add_user(url_link, user_id)
elif url_type == "HTML":
self.html_list.add_link(url_link)
self.html_list.add_user(url_link, user_id)
else:
log.error(self.__LOG_TAG__, "URL type[%s] invalid" % (url_type))
def maintenance_url_lists(self):
#atualizar tabela user
self.users.update_users()
#atualizar tabela url de acordo com nova tabela user
for user in self.users.get_users():
user_status = user.get_status()
if user_status == 0:
#status 0 = funcionando. nao fazer nada.
pass
elif (user_status == 1) or (user_status == 2):
#novo ou alterado. atualizar.
self.update(user)
elif (user_status == 3):
#block(user)
pass
elif (user_status == 9):
#delete(user)
pass
else:
log.error(self.__LOG_TAG__, "Error: invalid status[%s]" % (user_status))
开发者ID:guikingma,项目名称:Jarbas,代码行数:60,代码来源:user_url_system.py
示例2: add_user
def add_user():
"""
Register a user, looking up username and password in request.form.
Validates the username and password.
Returns:
A JSON string about the registration status.
"""
username = request.form['username']
password = request.form['password']
confirmation = request.form['confirmPassword']
if not confirmed_password_valid(password, confirmation):
return fail_registration(
"Your password and confirmation didn't match up.")
if password.strip() == '':
return fail_registration("Passwords can not be blank.")
if ' ' in password:
return fail_registration("Passwords can not have spaces")
users = Users(g.database_service)
if not users.is_valid_username(username):
error = """
Username %s is not valid.
Either it's taken, it has a space, or it's blank.
""" % (username)
return fail_registration(error)
new_user = users.register_user(username, password)
session['user_id'] = new_user.get_id()
return success_registration()
开发者ID:rahulraj,项目名称:web_projects,代码行数:28,代码来源:__init__.py
示例3: register_security_answer
def register_security_answer():
# auth user
request_data = request.get_json(force=True)
try:
user = auth()
except AuthenticationFailed:
return rAuthError
try:
params = get_from_request_data(["service_info"])
service_info = params["service_info"]
except MissingRequestParams:
return rMissingServiceInfo
service_name = service_info.get("service_name")
question = service_info.get("question")
answer = service_info.get("answer")
if None in [service_name, question, answer]:
return rMissingParams(["service_name", "question", "answer"])
try:
Users.register_security_answer(username, service_name, question, answer)
except RuntimeError as e:
return rInternalServerError
return "OK"
开发者ID:rikonor,项目名称:vanguard-api,代码行数:27,代码来源:api.py
示例4: enroll_in_service
def enroll_in_service():
# Lets assume for now the only service we support is vanguard
# For that reason, all service info validation logic shall be in this sole handler
# required: service_name, username, password
request_data = request.get_json(force=True)
try:
user = auth()
except AuthenticationFailed:
return rAuthError
service_info = request_data.get("service_info")
if service_info is None:
return "Please provide service information for enrollment", 400
service_name = service_info.get("service_name")
username = service_info.get("username")
password = service_info.get("password")
if None in [service_name, username, password]:
return "Please provide service information for enrollment", 400
try:
Users.enroll_in_service(username, service_info)
except RuntimeError as e:
print "ERROR:", e
return rInternalServerError
return "OK"
开发者ID:rikonor,项目名称:vanguard-api,代码行数:29,代码来源:api.py
示例5: register
def register():
"""
Sending a GET request returns the register.html page.
Sending a POST request validates, then registers the user.
If successful, the user is immediately brought to the sticky note page.
"""
if request.method == 'GET':
return render_template('register.html')
else:
username = request.form['username']
password = request.form['password']
confirmation = request.form['confirmPassword']
if not confirmed_password_valid(password, confirmation):
return fail_registration(
"Your password and confirmation didn't match up.")
if len(password) == 0:
return fail_registration("Passwords can not be blank.")
if ' ' in password:
return fail_registration("Passwords can not have spaces")
with closing(shelve.open(users_file)) as user_shelf:
users = Users(user_shelf)
if not users.is_valid_user(username):
flash("Username %s is not valid." % (username))
flash("Either it's taken, it has a space, or it's blank")
return render_template('register.html')
users.register_user(username, password)
session['username'] = username
return redirect(url_for('notes'))
开发者ID:rahulraj,项目名称:web_projects,代码行数:28,代码来源:main.py
示例6: register
def register():
form = RegistrationForm(request.form)
if request.method == 'POST' and form.validate():
user = Users(form.firstname.data, form.lastname.data, form.email.data, form.password.data)
user.add_user(user)
flash('Thanks for registering')
return redirect('/')
return render_template('register.j2', form=form)
开发者ID:JohnPreston,项目名称:dummy-3tier,代码行数:8,代码来源:views.py
示例7: login
def login():
dsn = app.config['dsn']
page = Users(dsn)
if request.method == 'GET':
return render_template('user/login.html')
else:
username = request.form['username']
password = request.form['password']
return page.login(username, password)
开发者ID:itucsdb1525,项目名称:itucsdb1525,代码行数:9,代码来源:server.py
示例8: add_members
def add_members(obj, srcId, dstId):
# delete all the existing members first (objects' creator should be here)
for mbr in map(lambda m: m['id'], obj.get_members(dstSys, dstId)):
obj.del_member(dstSys, dstId, mbr)
# return an user_id in the destination system according to a given member dict from the source system
usr = Users()
uidByMember = lambda mbr: get_user(dstSys, usr.by_id(srcSys, mbr['id']))
for mbr in obj.get_members(srcSys, srcId):
obj.add_member(dstSys, dstId, uidByMember(mbr), mbr['access_level'])
开发者ID:alces,项目名称:gitlab-rest-client,代码行数:9,代码来源:copyGroup.py
示例9: updateUser
def updateUser():
conn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='******',db='github')
cur = conn.cursor()
with open("/Users/dreamteam/Documents/study/sonar/results/oss developer evaluation/update_star_num.csv") as seed:
reader = csv.reader(seed)
next(reader,None)
mUsers = Users(conn,cur,1,'1','1',"2016-03-01 00:00:00")
for line in reader:
mUsers.getFollowerAndStar(str(line[1]))
开发者ID:roadfar,项目名称:CasualContributor,代码行数:9,代码来源:main.py
示例10: get_category_info
def get_category_info(category):
result = Objects.get_object_info(category)
owners = list()
for owner in category.owners.all():
user_extension = Users.get_user_extension(owner.username)
if user_extension:
owners.append(Users.get_user_info(user_extension))
result["owners"] = owners
return result
开发者ID:appleface2050,项目名称:WorkCode_Bakup,代码行数:10,代码来源:forums.py
示例11: UsersTest
class UsersTest(unittest.TestCase):
def setUp(self):
""" Using dicts instead of Shelve objects to speed up testing. """
self.fake_database = FakeDatabaseService()
self.users = Users(self.fake_database)
self.username = 'test_user'
self.password = 'test_password'
def test_confirm_passwords(self):
self.assertTrue(confirmed_password_valid('foo', 'foo'))
self.assertFalse(confirmed_password_valid('foo', 'bar'))
def test_simple_add_users(self):
self.assertFalse(self.users.has_user(self.username))
self.users.register_user(self.username, self.password)
self.assertTrue(self.users.has_user(self.username))
self.assertTrue( \
self.users.try_login_user(self.username, self.password) is not None)
def test_login_before_register(self):
self.assertTrue( \
self.users.try_login_user(self.username, self.password) is None)
def test_login_with_wrong_password(self):
self.users.register_user(self.username, self.password)
self.assertTrue( \
self.users.try_login_user(self.username, 'bad_password') is None)
开发者ID:rahulraj,项目名称:web_projects,代码行数:27,代码来源:users_test.py
示例12: person_page
def person_page():
now = datetime.datetime.now()
uses = Users(app.config['dsn'])
if request.method == 'GET':
now = datetime.datetime.now()
return render_template('persons.html', current_time=now.ctime())
elif 'persons_to_control' in request.form:
searchList = uses.control_user(request.form['username'],request.form['password']);
if searchList == 1:
return redirect(url_for('person_page'))
else:
return redirect(url_for('home_page2'))
开发者ID:itucsdb1501,项目名称:itucsdb1501,代码行数:12,代码来源:server.py
示例13: get_post_win_count_by_user
def get_post_win_count_by_user(user_id):
try:
user = Users.get_user_by_id(user_id)
user_extension = Users.get_user_extension(user.username)
count = 0
for fp in ForumPost.objects.all():
if user_extension in fp.win_users.all():
count += 1
return count
except Exception as ex:
Logs.print_current_function_name_and_line_number(ex)
return 0
开发者ID:appleface2050,项目名称:WorkCode_Bakup,代码行数:12,代码来源:forums.py
示例14: login
def login():
from users import Users
if request.method == "POST":
if not Users.authentification(str(request.form["username"]), str(request.form["password"])):
return render_template("login.html", citation=getCitation(), message="Invalid credential.")
else:
print Users.get_by_pseudonyme(request.form["username"])
# login_user(Users.get_by_pseudonyme(request.form["username"]))
return redirect(request.args.get("next") or "/")
else:
return render_template("login.html", citation=getCitation())
开发者ID:PXke,项目名称:Home1.0,代码行数:13,代码来源:views.py
示例15: sign_up
def sign_up():
dsn = app.config['dsn']
page = Users(dsn)
if request.method == 'GET':
return render_template('user/signup.html')
else:
username = request.form['username']
password = request.form['password']
if username and password:
return page.sign_up(username, password)
else:
flash("You must enter a username and a password!")
return render_template('user/signup.html')
开发者ID:itucsdb1525,项目名称:itucsdb1525,代码行数:13,代码来源:server.py
示例16: run
def run(conn,cur,repo_id,repo_name,repo_fullname,deadline):
try:
# mIssues = Issues(conn,cur,repo_id,repo_fullname)
# mIssues.get_issues(1)
# mIssues.get_issue_comments(1)
# mCommits = Commits(conn,cur,repo_id,repo_fullname)
# mCommits.get_commits(1)
# mCommits.get_commit_comments(1)
mUsers = Users(conn,cur,repo_id,repo_name,repo_fullname,deadline)
# # starts from 0
# mUsers.updateUsers(0)
# mUsers.connectUser()
mUsers.getFollowerAndStar(0)
except MySQLdb.Error, e:
print "Mysql Error!", e;
开发者ID:roadfar,项目名称:CasualContributor,代码行数:15,代码来源:main.py
示例17: auth
def auth():
"""
Call this in the beginning of a handler in order to authenticate the request
"""
params = get_from_request_data(["username", "password"])
user = Users.find_user(params["username"])
if user is None:
raise UserNotFound
authenticated = Users.auth_user(params["username"], params["password"])
if authenticated is not True:
raise AuthenticationFailed
return user
开发者ID:rikonor,项目名称:vanguard-api,代码行数:15,代码来源:api.py
示例18: generateLeaderboard
def generateLeaderboard(self):
leaderboard = []
leaderboard_a = []
cntr = 0
for user in Users.query().fetch():
u = user.get(user.key.id())
p = user.get_points_sum(user.key.id())
leaderboard.append(Leaderboard_entry_m(
user=u,
points=p
))
if p > 0:
cntr += 1
logging.info("total playing count: " + str(cntr))
leaderboard.sort(key=lambda x: x.points, reverse=True)
lb_m = Leaderboard_m(leaderboard=leaderboard[:20])
if Leaderboard().query().get():
lb = Leaderboard().query().get()
lb.leaderboard = lb_m
lb.put()
else:
lb = Leaderboard(leaderboard=lb_m)
lb.put()
# lb_short = Leaderboard_m(leaderboard=lb_m.leaderboard[:20])
memcache.add(key="leaderboard", value=lb_m, time=500)
开发者ID:gugcz,项目名称:devfest-rpg,代码行数:34,代码来源:game.py
示例19: stats
def stats(self):
data = memcache.get('stats')
if data is not None:
return data
else:
self.users = Users()
users = [0, 0, 0]
points = [0, 0, 0]
for user in Users.query().fetch():
if user.faction:
users[user.faction-1] += 1
points[user.faction-1] += user.get_points_sum(user.key.id())
faUsers = []
for usr in users:
faUsers.append(FactionUsers_m(users=usr))
stats = []
for usr in points:
stats.append(Stats_m(points=usr))
logging.info("%s", users)
fa_stats = FactionStats_m(users=faUsers, stats=stats)
memcache.add(key="stats", value=fa_stats, time=160)
return fa_stats
开发者ID:gugcz,项目名称:devfest-rpg,代码行数:27,代码来源:game.py
示例20: setup_groups
def setup_groups(self):
"""
add groups for configured users
"""
system_users = Users(self.root_dir)
for users in self.xml_state.get_users():
if not system_users.group_exists(users.group_name):
options = []
if users.group_id:
options.append('-g')
options.append(users.group_id)
log.info('Adding group %s', users.group_name)
system_users.group_add(
users.group_name, options
)
开发者ID:k0da,项目名称:kiwi-1,代码行数:16,代码来源:system_setup.py
注:本文中的users.Users类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论