本文整理汇总了Python中parse_rest.datatypes.Object类的典型用法代码示例。如果您正苦于以下问题:Python Object类的具体用法?Python Object怎么用?Python Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run():
while True:
try:
citations = Object.factory("citations")
violations = Object.factory("violations")
users = Object.factory("user")
# violations = Object.factory("violations")
tomorrow_datetime = datetime.date.today() + datetime.timedelta(days=1)
tomorrow = '{dt.month}/{dt.day}/{dt.year} 0:00:00'.format(dt = tomorrow_datetime)
tomorrows_citations = citations.Query.filter(court_date=tomorrow,proactive_outreach=False)
for citation in tomorrows_citations:
try:
user = users.Query.get(first_name=citation.first_name,last_name=citation.last_name,birthdate=citation.date_of_birth)
reachout_sms = "Hey! It's a reminder from ProactiveLaw that you have a court date tomorrow in " + citation.court_location + " at " + citation.court_address + " to get more information call them at " + court_numbers[citation.court_location]
message = client.messages.create(body=reachout_sms,
to=user.phone_number, # Replace with your phone number
from_="+13142549337") # Replace with your Twilio number
# print message.sid
citation.proactive_outreach = True;
citation.save()
except:
print "No court date or not enough information"
warrant_violations = violations.Query.filter(status="FTA WARRANT ISSUED",proactive_outreach=False)
for violation in warrant_violations:
try:
citation = citations.Query.get(citation_number=violation.citation_number)
user = users.Query.get(first_name=citation.first_name,last_name=citation.last_name,birthdate=citation.date_of_birth)
amount_owed = violation.fine_amount + violation.court_cost
reachout_sms = "Hey! It's a notification from ProactiveLaw that a warrant " + violation.warrant_number + " has been issued for your arrest for violation: " + violation.violation_number + " " + violation.violation_description + ", you owe $" + str(amount_owed) + " to the court " + citation.court_location + " at " + citation.court_address + " to get more information call them at " + court_numbers[citation.court_location] + ". To Pay now respond with PAY " + violation.violation_number
message = client.messages.create(body=reachout_sms,
to=user.phone_number, # Replace with your phone number
from_="+13142549337") # Replace with your Twilio number
violation.proactive_outreach = True;
violation.save()
except:
print "No court date or not enough information"
payment_violations = violations.Query.filter(status="CONT FOR PAYMENT",proactive_outreach=False)
for violation in payment_violations:
try:
citation = citations.Query.get(citation_number=violation.citation_number)
user = users.Query.get(first_name=citation.first_name,last_name=citation.last_name,birthdate=citation.date_of_birth)
amount_owed = violation.fine_amount + violation.court_cost
reachout_sms = "Hey! It's a notification from ProactiveLaw that a payment is owed for violation: " + violation.violation_number + " " + violation.violation_description + ", you owe $" + str(amount_owed) + " to the court " + citation.court_location + " at " + citation.court_address + " to get more information call them at " + court_numbers[citation.court_location] + ". To Pay now respond with PAY " + violation.violation_number
message = client.messages.create(body=reachout_sms,
to=user.phone_number, # Replace with your phone number
from_="+13142549337") # Replace with your Twilio number
violation.proactive_outreach = True;
violation.save()
except:
print "No court date or not enough information"
# sys.exit(0)
except:
print "error"
time.sleep(5)
示例2: __init__
def __init__(self, **kwargs):
dictionary = kwargs.pop("dictionary", None)
Object.__init__(self, **kwargs)
if dictionary:
for attribute in self.required_attributes:
setattr(self, attribute, dictionary[attribute])
for attribute in self.optional_attributes:
if attribute in dictionary:
setattr(self, attribute, dictionary[attribute])
示例3: __init__
def __init__(self, source_url):
ParseObject.__init__(self)
obj = Content._embedly_client.oembed(source_url)
self.object_description = obj['description'] if 'description' in obj else None
self.title = obj['title'] if 'title' in obj else None
self.url = source_url
self.thumbnail_url = obj['thumbnail_url'] if 'thumbnail_url' in obj else None
self.provider_name = obj['provider_name'] if 'provider_name' in obj else None
self.type = obj['type'] if 'type' in obj else 'unknown'
示例4: __init__
def __init__(self, **kwargs):
logging.info("sipMessage() __init__ sipMessage")
print 'sipMessage() __init__ sipMessage'
self.hasSDP = False
self.sipHeaderInfo = {}
self.sipMsgSdpInfo = {}
self.sipMsgMethodInfo = ''
self.sipMsgCallId = ''
self.sipMsgCallId = kwargs
assert "sipMsgCallId" in kwargs
Object.__init__(self, **kwargs)
示例5: add_door_event
def add_door_event():
doorEvent = ParseObject()
opened = request.args.get('opened', '');
if opened == '1':
doorEvent.opened = True
elif opened == '0':
doorEvent.opened = False
else:
return 'Invalid request.'
doorEvent.save()
response = {}
response['opened'] = doorEvent.opened
response['createdAt'] = str(doorEvent.createdAt)
return json.dumps(response)
示例6: getSinglePost
def getSinglePost(objectId):
settings_local.initParse()
className="Posts"
Posts=Object.factory(className)
SinglePost=Posts.Query.get(objectId=objectId)
print SinglePost.Image1.url
return SinglePost
示例7: findTest
def findTest():
global testIDs, testIDsNames
testNames = []
testIDs = []
testNameIDs = {}
testIDsNames = {}
myClassName = 'Tests'
myClass = Object.factory(myClassName)
word= myClass.Query.all()
splitword = str(word).split(':')
length = len(splitword)
for k in range (1,length-1):
line = splitword[k]
splitword[k] = line[:-9]
testIDs.append(splitword[k])
testIDs.append(splitword[length-1][:-2])
length = len(testIDs)
for k in range (0, length - 1):
name = myClass.Query.get(objectId = testIDs[k])
testNames.append(name.name)
name = myClass.Query.get(objectId = testIDs[length-1])
testNames.append(name.name)
for k in range (0, length):
testNameIDs[testNames[k]] = testIDs[k]
for k in range (0, length):
testIDsNames[testIDs[k]] = testNames[k]
print('FUNCTION: findTest COMPLETE')
print(time.asctime( time.localtime(time.time()) ))
return testIDs, testNames, testNameIDs
示例8: Login
def Login(userIDClass):
global username, userDetails
username = usernameEntry.get()
password = passwordEntry.get()
myClassName = 'User'
myClass = Object.factory(myClassName)
username = str(username.lower())
Id = userDetails[username]
print(Id)
data = myClass.Query.get(objectId = Id)
teacher = data.teacher
print(teacher)
if username in userDetails:
print('Logging in')
try:
User.login(username, password)
print('Logged in')
currentUserLabel.config(text = 'Logged in as '+username+'. Class: '+userIDClass[Id])
if teacher == False:
outputUserResults()
newWordButton.config(state = DISABLED)
quizSelectButton.config(state = NORMAL)
else:
newWordButton.config(state = NORMAL)
quizSelectButton.config(state = DISABLED)
resultsList.delete(0, END)
findTeachersPupils(Id)
except:
print('Incorrect password')
currentUserLabel.config(text = 'Incorrect password')
else:
currentUserLabel.config(text = 'That is an invalid username')
print('That is an invalid username')
print('FUNCTION: userLogin COMPLETE')
print(time.asctime( time.localtime(time.time()) ))
示例9: userIDsAndNames
def userIDsAndNames():
global userIDtoName, userIDs, userDetails
names = []
userIDs = []
userDetails = {}
userIDtoName = {}
myClassName = 'User'
myClass = Object.factory(myClassName)
details = myClass.Query.all()
splitword = str(details).split(':')
length = len(splitword)
for k in range (1,length-1):
line = splitword[k]
names.append(line[:-24])
lastLine = str(splitword[length-1])[:-18]
names.append(lastLine)
splitword = str(details).split('Id ')
length = len(splitword)
for k in range (1,length-1):
line = splitword[k].split(')>,')
userIDs.append(line[0])
lastLine = str(splitword[length-1])[:-3]
userIDs.append(lastLine)
length = len(userIDs)
for k in range(0,length):
userDetails[names[k]] = userIDs[k]
userIDtoName[userIDs[k]] = names[k]
print('FUNCTION: userIDsAndNames COMPLETE')
print(time.asctime( time.localtime(time.time()) ))
return userDetails, names, userIDs
示例10: pupilResultsToTeacher
def pupilResultsToTeacher(sameGroupID):
global resultIDs, testIDsNames, userDetails, userIDtoName, results, pupilUserName
results = []
value = str(classPupilsList.curselection())
strip = value.strip(',')
value = int(strip[1])
pupilID = sameGroupID[value]
pupilName = userIDtoName[pupilID]
pupilUserName = pupilName
myClassName = 'Results'
myClass = Object.factory(myClassName)
length = len(resultIDs)
for k in range(1, length):
obj = myClass.Query.get(objectId = resultIDs[k])
user = obj.userName
if user == pupilName:
testID = obj.testID
average = obj.average
average = '%.1f' % average
attempts = obj.attempts
testName = testIDsNames[testID]
string = (str(testName)+': Average = '+str(average)+'; Attempts = '+str(attempts))
results.append(string)
print('Results collected')
print(results)
pupilResultsList.delete(0, END)
length = len(results)
for k in range(0, length):
pupilResultsList.insert(k+1, results[k])
示例11: outputUserResults
def outputUserResults():
global username, resultIDs, testIDsNames
myClassName = 'Results'
myClass = Object.factory(myClassName)
results = []
length = len(resultIDs)
for k in range(1, length):
obj = myClass.Query.get(objectId = resultIDs[k])
user = obj.userName
if user == username:
testID = obj.testID
average = obj.average
average = '%.1f' % average
attempts = obj.attempts
testName = testIDsNames[testID]
string = (str(testName)+': Average = '+str(average)+'; Attempts = '+str(attempts))
results.append(string)
print('Results collected')
resultsList.delete(0, END)
length = len(results)
for k in range(0, length):
resultsList.insert(k+1, results[k])
length = len(results)
resultsList.config(height = length)
print('FUNCTION outputUserResults COMPLETE')
print(time.asctime( time.localtime(time.time()) ))
示例12: main
def main():
soup = BeautifulSoup(requests.get('https://www.mturk.com/mturk/viewhits?searchWords=&pageNumber=4&searchSpec=HITGroupSearch%23T%231%2310%23-1%23T%23%21%23%21NumHITs%211%21%23%21&sortType=NumHITs%3A1&selectedSearchType=hitgroups').text, "html.parser")
titles = soup.findAll('a', {"class" : "capsulelink"})
num_results = int(soup.findAll('td', {"class" : "title_orange_text"})[0].text.strip()[8:-7])
print("\nTotal number of HITs: " + str(num_results))
count = 0
page = 1
requestErrors = 0
privateCount = 0
register("DKJjvfvhnCGRK0cAdOpJN9MwR7zhIpuYya5xvbuF", "d8hIYrBrcW4r2ujEkL79vE03FmLxE2QCJgSwuXYv")
HITClass = ParseObject.factory("HIT")
all_hits = HITClass.Query.all()
batcher = ParseBatcher()
batcher.batch_delete(all_hits)
while (count < 200):
soup = BeautifulSoup(requests.get('https://www.mturk.com/mturk/viewhits?searchWords=&pageNumber=' + str(page) + '&searchSpec=HITGroupSearch%23T%231%2310%23-1%23T%23%21%23%21NumHITs%211%21%23%21&sortType=NumHITs%3A1&selectedSearchType=hitgroups').text, "html.parser")
titles = soup.findAll('a', {"class" : "capsulelink"})
for t in titles:
time.sleep(.3)
count = count + 1
print("\n" + str(count) + "\nTitle: " + t.text.strip())
linkA = t.parent.parent.findAll('span')[1].a
# check if the link is public
if linkA.has_attr('href'):
link = linkA['href']
hitPage = BeautifulSoup(requests.get('https://www.mturk.com' + link).text, "html.parser")
form = hitPage.findAll('form', {'name' : 'hitForm'})
# Check for error
if len(form) >= 3:
form = form[2]
requester = form.find("input", {'name' : 'prevRequester'})['value']
print('Requester: ' + requester)
reward = form.find("input", {'name' : 'prevReward'})['value']
print('Reward: ' + reward)
groupID = form.find("input", {'name' : 'groupId'})['value']
print('Group id: ' + groupID)
anyObject = HIT(requester=requester, reward=float(reward[3:]),
title=t.text.strip(), groupID=groupID)
anyObject.save()
else:
requestErrors = requestErrors + 1
print(link)
print(form)
else:
link = linkA['id']
print(link)
privateCount = privateCount + 1
page = page + 1
print("\n\nErrors: " + str(requestErrors))
print("Private HITs: " + str(privateCount))
示例13: create_event_users_in_Parse
def create_event_users_in_Parse(self):
# For now, just grab first ones; later, check by array_eventsRegistered.
"""
Create zE0000_User objects by "batch_save"-ing them to Parse using
ParsePy's ParseBatcher(). Event User objects are _User objects whose
array_eventsRegistered contains the eventNum of this current event.
"""
eu_ClassName = "zE" + _Event.STR_EVENT_SERIAL_NUM + "_User"
eu_Class = Object.factory(eu_ClassName)
# # Get the correct class name from the ep = Event Prefix (passed in).
# eventUser_ClassName = ep + "_User"
# eventUser_Class = Object.factory(eventUser_ClassName)
# add some Users to this Event
qset_all_users = User.Query.all().order_by("userNum")
li_meu = list(qset_all_users.filter(sex = "M").limit(
_Event.MEN))
li_feu = list(qset_all_users.filter(sex = "F").limit(
_Event.WOMEN))
li_mgeu = list(qset_all_users.filter(sex = "MG").limit(
self.num_m_ghosts))
li_fgeu = list(qset_all_users.filter(sex = "FG").limit(
self.num_f_ghosts))
li_users_at_event = li_meu + li_feu + li_mgeu + li_fgeu
count_eu = len(li_users_at_event)
li_eu_obj_to_upload = []
for index, obj_User in enumerate(li_users_at_event):
new_EU_object = eu_Class(
user_objectId = obj_User.objectId,
event_userNum = index + 1,
username = obj_User.username,
first = obj_User.username.split(" ")[0],
last = obj_User.username.split(" ")[-1],
sex = obj_User.sex
)
li_eu_obj_to_upload.append(new_EU_object)
# Batch upload in chunks no larger than 50,
# and sleep to avoid timeouts
batch_upload_to_Parse(eu_ClassName, li_eu_obj_to_upload)
pass
示例14: __init__
def __init__(self, options, columns):
super(ParseFdw, self).__init__(options, columns)
self.columns = columns
try:
self.application_id = options['application_id']
self.rest_api_key = options['rest_api_key']
self.className = options['class_name']
except KeyError:
log_to_postgres("You must specify an application_id, rest_api_key and class_name options when creating this FDW.", ERROR)
register(self.application_id, self.rest_api_key)
self.object = Object.factory(self.className)
示例15: getResultIDs
def getResultIDs():
global resultIDs
resultIDs =[]
myClassName = 'Results'
myClass = Object.factory(myClassName)
returned = str(myClass.Query.all())
splited = returned.split('Results:')
length = len(splited)
for k in range(0, length-1):
resultIDs.append(splited[k][:-4])
resultIDs.append(splited[length - 1][:-2])
print('FUNCTION getRestultIDs COMPLETE')
print(time.asctime( time.localtime(time.time()) ))