Пример #1
0
def sendToPhone(self,data,email):
    #Get the registration entry
    info = Info.get_by_key_name(email)
    if not info:
        self.response.out.write('error_register')
    else:
        registration_id = info.registration_id
        #Get authentication token pre-stored on datastore with ID 1
        #Alternatively, it's possible to store your authToken in a txt file and read from it (CTP implementation)
        info = Info.get_by_id(1)
        authToken = info.registration_id
        form_fields = {
            "registration_id": registration_id,
            "collapse_key": hash(email), #collapse_key is an arbitrary string (implement as you want)
        }
        form_fields.update(data)
        form_data = urllib.urlencode(form_fields)
        url = "https://android.clients.google.com/c2dm/send"
        #Make a POST request to C2DM server
        result = urlfetch.fetch(url=url,
                                payload=form_data,
                                method=urlfetch.POST,
                                headers={'Content-Type': 'application/x-www-form-urlencoded',
                                         'Authorization': 'GoogleLogin auth=' + authToken})
        if result.status_code == 200:
            self.response.out.write("OK")
        else:
            self.response.out.write("error_c2dm")
        logging.debug(result.status_code)   
Пример #2
0
def sendToPhone(self, data, email):
    #Get the registration entry
    info = Info.get_by_key_name(email)
    if not info:
        self.response.out.write('error_register')
    else:
        registration_id = info.registration_id
        #Get authentication token pre-stored on datastore with ID 1
        #Alternatively, it's possible to store your authToken in a txt file and read from it (CTP implementation)
        info = Info.get_by_id(1)
        authToken = info.registration_id
        form_fields = {
            "registration_id": registration_id,
            "collapse_key": hash(
                email
            ),  #collapse_key is an arbitrary string (implement as you want)
        }
        form_fields.update(data)
        form_data = urllib.urlencode(form_fields)
        url = "https://android.clients.google.com/c2dm/send"
        #Make a POST request to C2DM server
        result = urlfetch.fetch(url=url,
                                payload=form_data,
                                method=urlfetch.POST,
                                headers={
                                    'Content-Type':
                                    'application/x-www-form-urlencoded',
                                    'Authorization':
                                    'GoogleLogin auth=' + authToken
                                })
        if result.status_code == 200:
            self.response.out.write("OK")
        else:
            self.response.out.write("error_c2dm")
        logging.debug(result.status_code)
Пример #3
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     devregid = self.request.get('devregid')
     if not devregid:
         self.response.out.write('Must specify devregid')
     else:
         user = users.get_current_user()
         if user:
             #Store registration_id and an unique key_name with email value
             info = Info(key_name=user.email())
             info.registration_id = devregid   
             info.put()
             self.response.out.write('OK')
         else:
             self.response.out.write('Not authorized')
Пример #4
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     devregid = self.request.get('devregid')
     if not devregid:
         self.response.out.write('Must specify devregid')
     else:
         user = users.get_current_user()
         if user:
             #Store registration_id and an unique key_name with email value
             info = Info(key_name=user.email())
             info.registration_id = devregid
             info.put()
             #Send invitation from [email protected] to user's GTalk
             xmpp.send_invite(user.email())
             self.response.out.write('OK')
         else:
             self.response.out.write('Not authorized')
Пример #5
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     devregid = self.request.get('devregid')
     if not devregid:
         self.response.out.write('Must specify devregid')
     else:
         user = users.get_current_user()
         if user:
             #Store registration_id and an unique key_name with email value
             info = Info(key_name=user.email())
             info.registration_id = devregid   
             info.put()
             #Send invitation from [email protected] to user's GTalk 
             xmpp.send_invite(user.email())
             self.response.out.write('OK')
         else:
             self.response.out.write('Not authorized')
Пример #6
0
def addinfo():
    form = InfoForm()
    if form.validate_on_submit():
        db.session.add(Info(name=form.name.data, value=int(form.value.data)))
        db.session.commit()
        return redirect(url_for("addinfo"))
    template = render_template("admin/index/info/addinfo.html", form=form)
    return checkLogin(template)
Пример #7
0
def main():
    data = Info.select_by_sql("SELECT * FROM info")
    dataPais = []
    for d in data:
        predicado = formatString(d.predicado)
        if predicado == 'Idioma':
            if d.objeto not in dataPais:
                dataPais.append(d.objeto)
    for d in range(0, len(dataPais) - 1):
        op = reconciliar(dataPais[d])
Пример #8
0
 def get(self):
     backend = BACKENDS[DEFAULT_SERVICE]
     title = self.request.get('title')
     # no user-specific storage
     inf = Info.query(Info.title == title).get()
     if inf is None:
         self.response.write('data with title {} not found'.format(title))
         return
     val = backend.get(inf.refs)
     self.response.write(val)
Пример #9
0
def add_data(sub, pred, obj):
    try:
        Info(sujeto = sub.strip(),
        predicado = pred.strip(),
        objeto = obj.strip()
        )
    except Exception as e:
        print sub
        print pred
        print obj
        pass
Пример #10
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     devregid = self.request.get('devregid')
     if not devregid:
         self.response.out.write('Must specify devregid')
     else:
         user = users.get_current_user()
         if user:
             #Remove entry with the associated email value
             info =  Info.get_by_key_name(user.email())
             info.delete()
             self.response.out.write('OK')
         else:
             self.response.out.write('Not authorized') 
Пример #11
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/plain'
     devregid = self.request.get('devregid')
     if not devregid:
         self.response.out.write('Must specify devregid')
     else:
         user = users.get_current_user()
         if user:
             #Remove entry with the associated email value
             info = Info.get_by_key_name(user.email())
             info.delete()
             self.response.out.write('OK')
         else:
             self.response.out.write('Not authorized')
Пример #12
0
    def post(self):
        try:
            parser = reqparse.RequestParser()
            parser.add_argument('title')
            parser.add_argument('content')
            parser.add_argument('username')

            data = parser.parse_args()

            title = data['title']
            content = data['content']
            id = 2  # 이거 나중에 맨 마지막 글 아이디 찾아서 바꿔줘야함!
            date = datetime.now()
            date = str(date.year) + "-" + str(date.month) + "-" + str(
                date.day) + " " + str(date.hour) + ":" + str(
                    date.minute) + ":" + str(date.second)
            # print(date)
            views = 0
            likes = 0
            writer = data['username']
            reply = [""]

            i = Info(title=title,
                     content=content,
                     id=id,
                     date=date,
                     views=views,
                     likes=likes,
                     writer=writer,
                     reply=reply)
            i.save()  # Database 안에 document 저장

            return {"message": "글 작성에 성공했습니다."}

        except:
            raise Exception("글 작성에 실패했습니다.")
Пример #13
0
    def get(self):
        First_Name = self.request.get('first_name')
        email = self.request.get('email')
        city_name = self.request.get('city')
        state_name = self.request.get('state')
        zip_code = self.request.get('zip')

        b1 = Info()
        b1.First = First_Name
        b1.Email = email
        b1.City = city_name
        b1.State = state_name
        b1.Zip = zip_code
        self.response.write(
            "<script>confirm('your form has been submitted')</script>")
        file = open('contact.html')
        self.response.write(file.read())
Пример #14
0
async def compare(loop):
    valid_name = []
    all_name = []
    unvalid_name = []
    await create_pool(
        loop=loop,
        host='127.0.0.1',
        port=3306,
        user="******",
        password="******",
        db="data")
    valid_persons = Info()
    all_persons = Input()
    valid_list = await valid_persons.findAll()
    count1, time = count(valid_list)
    all_list = await all_persons.findAll()
    for person in valid_list:
        valid_name.append(person["name"])
    for person in all_list:
        all_name.append(person["name"])
    allnumber, validnumber = len(all_name), len(valid_name)
    length = allnumber - validnumber

    if (length > 0):
        for i in all_name:
            t = 0
            for j in valid_name:
                if (j == i):
                    t += 1
            if (t == 0):
                unvalid_name.append(i)
    unvalid_list = []
    for i in unvalid_name:
        for person in all_list:
            if (person["name"] == i):
                unvalid_list.append(person)
    return valid_list, unvalid_list, allnumber, validnumber, count1, time
Пример #15
0
def main():
    gen = Generator()
    titulos = select(p.sujeto for p in Info)
    for titulo in titulos:
        editorail = None
        direccion = None
        email = None
        alternativo = []
        pais = None
        inicio = None
        fin = None
        web = None
        desc = None
        notas = None
        frecuencia = None
        formatos = []
        idioma = []
        DOI = None
        temas = []
        paisl = []
        subtemas = []
        dbpIdioma = []
        dataJournal = Info.select(lambda p: p.sujeto == titulo)
        for data in dataJournal:
            predicado = gen.formatString(data.predicado)
            objeto = data.objeto
            if (predicado == "Entidad editora") or (predicado == "Editorial"):
                editorail = objeto
            if (predicado == "Direccion del editor"):
                direccion = objeto
            if (predicado == "Correo electronico"):
                email = objeto
            if (predicado == "Otros Títulos") or (predicado
                                                  == "Tiitulo posterior"):
                alternativo.append(objeto)
            if (predicado == "Pais"):
                pai = {"propio": objeto, "recon": data.reconciliation}
                paisl.append(pai)
            if (predicado == "Ano de inicio"):
                inicio = objeto
            if (predicado == "Ano de Terminacion"):
                fin = objeto
            if (predicado == "Web de la revista"):
                web = objeto
            if (predicado == "Descripcion"):
                desc = objeto
            if (predicado == "Notas"):
                notas = objeto
            if (predicado == "Periodicidad") or (predicado == "Frecuencia"):
                frecuencia = objeto
            if (predicado == "formatos") or (predicado == "Soporte"):
                formatos.append(objeto)
            if (predicado == "Idioma"):
                pai = {"propio": objeto, "recon": data.reconciliation}
                idioma.append(pai)
            if (predicado == "DOI"):
                DOI = objeto
            if (predicado == "Materias") or (predicado == "Temas"):
                temas.append(objeto)
            if (predicado == "Subtemas"):
                subtemas.append(objeto)
        gen.resourceOrg(titulo, alternativo, paisl, web, desc, editorail,
                        direccion, email, formatos, idioma, notas, temas,
                        subtemas, DOI)
Пример #16
0
 def get(self):
     self.response.content_type = 'application/json'
     self.response.write(json.dumps({'titles': [i.title for i in Info.query()]}))