Beispiel #1
0
def forgotpassword():
    form = formForgotPass()
    refreshUserData()
    if 'Username' in session:
        return redirect(url_for('errorpage'), message = 'Not allowed!')
    if request.method == 'GET':
        return RenderTemplate('forgotpassword.html', form=form)
    else:
        if form.validate_on_submit():
            username = form.username.data
            refreshUserData()
            try:
                connection = dbapi2.connect(dsn)
                cursor = connection.cursor()
                statement = """SELECT p.emailaddress, u.password FROM person AS p
                                    INNER JOIN users AS u ON u.username = p.username
                                    WHERE p.username = '******'
                """ % username
                cursor.execute(statement)
                row = cursor.fetchone()
                if row:
                    mailsender.sendMail(row[1], row[0])
                    flash('Your password has been sent to your email address. Please check your inbox.')
                    return RenderTemplate('forgotpassword.html', form=form)
                else:
                    flash('This username is not registered to our website!')
                    return RenderTemplate('forgotpassword.html', form=form)
            except dbapi2.DatabaseError as e:
                connection.rollback()
                return str(e)
            finally:
                connection.close()
        for error in form.errors:
            flash(form.errors[error][0])
        return RenderTemplate('forgotpassword.html', form=form)
Beispiel #2
0
def send_report_weibo(content):
    #re=["*****@*****.**","*****@*****.**"]
    re=["*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**"]
    se="*****@*****.**"
    tit="微博访问统计报表 %s" %(datetime.today().strftime('%Y-%m-%d'))
    #print tit
    con=content
    mailsender.sendMail(re,se,tit,con)
Beispiel #3
0
def myFunc():
    global head
    threading.Timer(5.0, myFunc).start()
    response = s.get('https://collegeplacements.com/news/')
    if (response.status_code == 200):
        soup = BeautifulSoup(response.content, features="lxml")
        elm = soup.select_one('#post-8445 > header > h1 > a')
        if (elm.get_text() == head):
            pass
        else:
            head = elm.get_text()
            print(type(head))
            sendMail(head.encode('ascii', 'ignore').decode('ascii'))
    else:
        print('Not working Properly')
Beispiel #4
0
def main():
    config = get_config()
    acs_client = client.AcsClient(config['access_key_id'],
                                  config['access_key_secret'],
                                  config['region_id'])
    try:
        current_ip = get_out_ip(get_real_url())
        mailsender.sendMail("单纯运行获取到树莓派IP:" + current_ip)
        for domain in config['domains']:
            rr, domain_name = get_domain_parts(domain)
            record_id, record_ip = get_record(acs_client, domain_name, rr)
            if record_id is None:
                add_record(acs_client, rr, domain_name, current_ip,
                           config['ttl'])
            else:
                if record_ip != current_ip:
                    update_record(acs_client, record_id, rr, current_ip,
                                  config['ttl'])
                    mailsender.sendMail(current_ip)
    except Exception as e:
        mailsender.sendMail(e)
        raise
 def sendResultToMail(self, receivers):
     mailsender.sendMail(receivers, self.topic, self.textresult)
Beispiel #6
0
def send_report_sina(content):
    re=["*****@*****.**","*****@*****.**","*****@*****.**","*****@*****.**"]
    se="*****@*****.**"
    tit="全站访问统计报表 %s" %(datetime.today().strftime('%Y-%m-%d'))
    con=content
    mailsender.sendMail(re,se,tit,con)
Beispiel #7
0
          print " - (%s) Already removed: %s" % (fileId, dFileResp.status_code)
          dbconn.removeFileId(fileId)
        else:
          print " ? (%s) What?? %s" % (fileId, dFileResp.status_code)
      except Exception, e:
        print e
        continue

      #print "(%s) %s/%s" % (fileId, getDirTree(dfile["parent_id"]), dfile['name'])
      #print fileId
  except Exception, e:
    print e


if __name__=="__main__": 
  dirNameCache = {}
  signal.signal(signal.SIGINT, signal_handler)
  client = putio.Client(OAUTH_KEY)
  sourceDirId = getSourceDirId()
  removeDownloadedFiles()
  removeRemoteEmptyDirs(sourceDirId, PUTIO_SOURCEDIR)
  msg = ""
  if isinstance(removed_files, types.ListType) and len(removed_files) > 0:
    msg = msg + "Removed Files\n-----------------\n" + "\n".join(removed_files) + "\n\n"
  if isinstance(removed_empty_dirs, types.ListType) and len(removed_empty_dirs) > 0:
    msg = msg + "\nRemoved Empty Dirs\n-----------------\n" + "\n".join(removed_empty_dirs) + "\n\n"

  if len(msg) > 0:
    mailsender.sendMail(REPORT_FROM, REPORT_TO, SMTP_HOST, SMTP_USER, SMTP_PASS, "[PutioSync] Clean-up Completed", msg)

Beispiel #8
0
def syncFiles(parent_id, target_base_folder):
  rfiles = client.request("/files/list?parent_id=" + str(parent_id))["files"]
  for rfile in rfiles:
    rfile["name"] = rfile["name"].replace(":", " ")
    rfile["name"] = rfile["name"].replace("S.H.I.E.L.D", "SHIELD")
    rfile["name"] = rfile["name"].replace("[", "_")
    rfile["name"] = rfile["name"].replace("]", "_")
    if rfile["content_type"] == "application/x-directory":
      syncFiles(rfile["id"], target_base_folder + "/" + rfile["name"])
    else:
      infoLine = ("\n"
                 "\nTarget.......: " + target_base_folder + "/" + rfile["name"] + ""
                 "\nFilesize.....: " + str(rfile["size"]) + ""
                 "\nCRC32........: " + rfile["crc32"] + ""
                 "\nContent-Type.: " + rfile["content_type"] + "")
      infoLine = infoLine.encode('utf8')
      print infoLine
      if checkIfDownloaded(str(rfile["id"])):
        print "Status.......: Already downloaded" 
      else:
        print "Status.......: Starting/continuing to download" 
        if not os.path.isdir(target_base_folder):
          os.makedirs(target_base_folder)
        #downloadUrl = client.request("/files/" + str(rfile["id"]) + "/download", return_url=True)
        downloadUrl =  client.request("/files/" + str(rfile["id"]) + "/download", method="HEAD", raw=True).url
        print downloadUrl
        #if downloadfile.downloadfile(downloadUrl, rfile["name"], target_base_folder, rfile["size"], BW_LIMIT):
        if downloadfile.downloadfilearia(downloadUrl, rfile["name"], target_base_folder, rfile["size"], BW_LIMIT):
          if os.path.getsize(target_base_folder + "/" + rfile["name"]) >= rfile["size"]:
            markAsDownloaded(str(rfile["id"]) + "\n")
            subj = "[PutioSync] Download complete: " + rfile["name"]
            mailsender.sendMail(REPORT_FROM, REPORT_TO, SMTP_HOST, SMTP_USER, SMTP_PASS, subj, infoLine)

    # !!!!!!!
    # before doing actual work
    # make sure file is downloaded, and directory is created
    #
    #print "======> " + str(parent_id) + ":" + str(sourceDirId)
    if str(parent_id) == str(sourceDirId):
      #
      # continue if path is moved before or not exists at all
      #
      if not os.path.exists(target_base_folder + "/" + rfile["name"]):
        print "Move State...: Already moved to library"
        continue
      #
      # continue if it is a directory and there are .part files in it
      #
      if os.path.isdir(target_base_folder + "/" + rfile["name"]):
        if isThereUnfinishedDownloads(target_base_folder + "/" + rfile["name"]):
          print "Move State...: Unfinised files exists"
          continue

      #
      # mv finished downloads to library (assumption is: if not a tvshow, then it should be a movie)
      #
      tvshow = parseTvShowName(rfile["name"])
      if tvshow != False:
        print "Series Name....: " + tvshow["series_name"]
        fileTargetFolder = TVSHOWS_BASEDIR + "/" + tvshow["series_name"] + "/" + str(tvshow["season_number"])
        print "Moving State...: To " + fileTargetFolder
        print "==>> mv \"" + target_base_folder + "/" + rfile["name"] + "\" \"" + fileTargetFolder + "/" + rfile["name"] + "\""
        if not os.path.isdir(fileTargetFolder): os.makedirs(fileTargetFolder)
        #os.renames(target_base_folder + "/" + rfile["name"], fileTargetFolder + "/" + rfile["name"])
        subprocess.call(["/usr/bin/rsync", "-a", "--remove-source-files", target_base_folder + "/" + rfile["name"], fileTargetFolder])
        subprocess.call(["/bin/rm", "-Rf", target_base_folder + "/" + rfile["name"]])
        continue
      movie = tmdb.isAMovie(rfile["name"])
      if movie != False:
        fileTargetFolder = MOVIES_BASEDIR
        print "Movie Name.....: " + movie["title"]
        print "Moving State...: To " + fileTargetFolder
        print "==>> mv \"" + target_base_folder + "/" + rfile["name"] + "\" \"" + fileTargetFolder + "/" + rfile["name"] + "\""
        if not os.path.isdir(fileTargetFolder): os.makedirs(fileTargetFolder)
        #os.renames(target_base_folder + "/" + rfile["name"], fileTargetFolder + "/" + rfile["name"])
        subprocess.call(["/usr/bin/rsync", "-a", "--remove-source-files", target_base_folder + "/" + rfile["name"], fileTargetFolder])
        subprocess.call(["/bin/rm", "-Rf", target_base_folder + "/" + rfile["name"]])