コード例 #1
0
ファイル: controller.py プロジェクト: kourge/accepted
    def GET(self, variables={}):
        name = self.__class__.__name__.replace('Controller', '').lower()
        defaults = {
            'user' : auth.user(), 'admin' : auth.is_admin(), 'path' : web.ctx.path
        }
        defaults.update(variables)

        if auth.user():
            lastonline = LastOnline.get_by_key_name(str(auth.user().user_id())) 
            if not lastonline:
                lastonline = LastOnline(key_name=str(auth.user().user_id()), uid=str(auth.user().user_id())) 
            lastonline.put()

        return jinja_environment.get_template(
            'templates/%s.html' % (name,)
        ).render(defaults)
コード例 #2
0
def get_allergies():
    user = auth.user()
    allergies_str = user["allergies"]

    if allergies_str is None:
        return []

    allergies = allergies_str.split(",")
    return [allergy.strip() for allergy in allergies]
コード例 #3
0
def say_hello():
    user_email = request.headers.get('X-Goog-Authenticated-User-Email')
    user_id = request.headers.get('X-Goog-Authenticated-User-ID')

    verified_email, verified_id = user()

    page = render_template('index.html',
        email=user_email,
        id=user_id,
        verified_email=verified_email,
        verified_id=verified_id)
    return page
コード例 #4
0
ファイル: resumecontroller.py プロジェクト: kourge/accepted
    def dump(self):
        key = str(auth.user().user_id())
        export = {}

        for model in [Profile, SatScore]:
            e = model.get_by_key_name(key)
            if e:
                export.update(db.to_dict(e))

        #for subject in SatSubjectScore.filter('uid =', uid):
        #    pass

        return json.dumps(export)
コード例 #5
0
ファイル: sync.py プロジェクト: dmertl/foursquare-local
def sync():
    """
    Sync local database with Foursquare API
    TODO: On first query, start at user's oldest checkin
    TODO: For existing users, query from date of last checkin - a few seconds
    """
    user = auth.user()
    client = get_client()
    checkins = client.users.checkins()
    for fsq_checkin in checkins['checkins']['items']:
        checkin = _create_checkin(fsq_checkin, user)
        database.db_session.add(checkin)
    database.db_session.commit()
コード例 #6
0
ファイル: profilecontroller.py プロジェクト: kourge/accepted
    def process_profile(self):
        params = web.input()
        keys = ['firstname', 'lastname', 'age', 'school']

        attrs = { k : params[k] for k in keys }
        attrs['age'] = int(attrs['age'])
        attrs['uid'] = self.key
        attrs['email'] = auth.user().email();

        p = Profile.get_by_key_name(self.key)
        if not p:
            p = Profile(key_name=self.key, **attrs)
        else:
            for k, v in attrs.iteritems():
                setattr(p, k, v)

        try:
            p.put()
        except TransactionFailedError:
            # Ideally handle the error
            pass
コード例 #7
0
ファイル: profilecontroller.py プロジェクト: kourge/accepted
 def __init__(self):
     super(self.__class__, self).__init__()
     self.key = str(auth.user().user_id())
コード例 #8
0
ファイル: ruokbot.py プロジェクト: SotongDJ/pykit-tsrmdbot
            if abs(level) > limit:
                fif=open(externa.path("analisi/feel",str(chat_id))+"record.csv","a")
                fif.write(str(chat_id)+","+datetime+","+"-".join(keywos)+","+str(level)+",\""+msg['text']+"\",\""+time.asctime(time.localtime(datetimeInt))+"\"\n")
                fif.close()
                bot.sendMessage(chat_id, "Recorded, Original message:\n\""+msg['text']+"\"")
            elif level != 0:
                bot.sendMessage(chat_id, "Recognized but lower the threshold, Original message:\n\""+msg['text']+"\"")
            elif level == 0:
                bot.sendMessage(chat_id, "Can't recognize, Original message:\n\""+msg['text']+"\"")

        else:
            bot.sendMessage(chat_id, "No action, Original message:\n\""+msg['text']+"\"")
    else:
        bot.sendMessage(chat_id, "No action, No response")
TOKEN = sys.argv[1]  # get token from command-line

bot = telepot.Bot(TOKEN)
bot.message_loop(handle)
#
bot.sendMessage(auth.id(), "Server Starting")
print ('Listening ...')

# Keep the program running.
while 1:
    toyear,tomonth,today,tohour,tomin,tosec,widay,yeday,isds=time.localtime()
    if tomin == 0:
        if tohour in [8,12,18,20]:
            for userid in auth.user():
                bot.sendMessage(userid, "What is your feeling now?")
    time.sleep(60)
コード例 #9
0
ファイル: listcontroller.py プロジェクト: kourge/accepted
 def __init__(self):
     self.key = str(auth.user().user_id())
コード例 #10
0
ファイル: db_handler.py プロジェクト: mpolimen34/L.E.M.o.N
import mysql.connector
import atexit
import auth

mydb = mysql.connector.connect(
  host=auth.host(),
  user=auth.user(),
  password=auth.password(),
  database=auth.database()
)

# print(mydb)

c = mydb.cursor()

def exit_handler(): # closes database upon termination
    conn.close()
atexit.register(exit_handler)

# c.execute("""CREATE TABLE food (
#           id INTEGER PRIMARY KEY,
#           name TEXT,
#           date DATE,
#           time TIME
#           );""")

def insert_new_food(name, heat, date, time, weight):
  with conn: # Commits the change to the database
    c.execute("""INSERT INTO food (name, heat, date, 
              time, weight) VALUES (?, ?, ?, ?, ?);""",
              (name, heat, date, time, weight))