Exemplo n.º 1
0
def FetchInfo(id):
    profile1 = PyMongo.getProfile1(id)
    #print profile1

    profile2 = PyMongo.getProfile2(id)
    #print profile2

    name = profile1[0]
    gender = profile1[1]
    city = profile2[0]
    age = profile2[1]
    purpose = profile2[2]
    time = profile2[3]
    sm = 0

    if (city == "Sangli"):
        sm += (10)
    elif (city == "Miraj"):
        sm += (30)
    elif (city == "Pune"):
        sm += (50)
    elif (city == "Mumbai"):
        sm += (70)
    #elif(60 < age < 80 or purpose == "Urgent"):
    #execfile('SMS.py')

    if (0 < age < 20):
        sm += 20
    elif (20 <= age < 40):
        sm += 40
    elif (40 <= age < 60):
        sm += 60

    if (purpose == "Meeting"):
        sm += 50
    elif (purpose == "Invitation"):
        sm += 30
    elif (purpose == "Personal"):
        sm += 10

    print sm
    print purpose
    print city
    print age

    if (sm > 150 or 60 < age < 80 or purpose == "Urgent"):
        SMS.SendSMS(name, gender, city, purpose, mobile="9604091697")

    else:
        new_profile1 = PyMongo.getProfile1(id)
        new_profile2 = PyMongo.getProfile2(id)
        PyMongo.SCInsert(id, sm, time)
        PyMongo.SCSchedule()
Exemplo n.º 2
0
def SCSchedule():
    l = []

    for obj in db.sc.find():
        l.append(obj)

    #print(l)
    m = []
    m = sorted(l[2:], key=lambda x: x['p'], reverse=True)
    #l.sort(key=attrgetter('p'),reverse=True)
    #print "hello m"
    #print m

    n = []
    n.append(l[0])
    if len(l) >= 2:
        n.append(l[1])
    for i in m:
        n.append(i)
    #print "hello n"
    #print(n)
    #db.sc.remove({},{justOne:True},reverse=True)

    #db.sc.remove({},{justOne:True})

    db.sc.remove()
    token = 1
    for obj in n:
        #print(obj[1])
        #db.sc.insert_one(dict(obj[0]),dict(obj[1]),dict(obj[3]),dict(obj[4]))
        str1 = obj['uid']
        #str2=str(obj['i'])
        str3 = str(obj['p'])
        str4 = str(obj['at'])
        db.sc.insert_one({'uid': float(str1), 'p': float(str3), 'at': str4})
        profile = getProfile1(int(str1))
        #print(profile + str1 )
        mobile = profile[2]
        SMS.SendSMS(profile[0], profile[1], '', token, mobile)
        token += 1
Exemplo n.º 3
0
 def __init__(self, com_port):
     self.com = com_port
     self.phone = None
     self.wait = defines.wait_time
     self.sms_module = SMS.SendSMS(self.com)
     self.log_file = new_log_file(defines.at_log)