예제 #1
0
파일: application.py 프로젝트: nejomi/awit
def index():

    # Placeholder
    if "user_id" in session:

        username = get_username(int(session["user_id"]))
        currUser = "******" + username + " [" + str(
            session["user_id"]) + "]"

    # Print user id
    else:
        currUser = "******"

    if request.method == "POST":

        statusText = request.form.get("userstatus")

        # if status textarea is empty
        if not statusText:
            return redirect('/')

        add_status(statusText, session["user_id"])
        return render_template("index.html", test=currUser)

    return render_template("index.html", test=currUser)
예제 #2
0
 def newDocument(self):
     template = MarkdownEditor.defaultPath.read_text()
     author = helpers.get_username()
     self.pathnameSrc = None
     self.documentTitle = MarkdownEditor.documentTitleDefault
     self.textEditor.textContent = template.format(
         title=self.documentTitle,
         author=author,
         email='{}@example.com'.format(author.replace(' ', '.')))
     self.documentIsSave = True
예제 #3
0
    def on_post(self, req, resp):
        # Get the username
        body = helpers.get_json(req)
        username = helpers.get_username(body)

        user_hash = redis_db.get(username)
        if not user_hash:
            user_hash = helpers.get_hash()
            redis_db.setex(username, HASH_LIFESPAN_MINS * 60, user_hash)

        resp.status = falcon.HTTP_OK
        resp.body = json.dumps({'hash': user_hash})
def lambda_handler(event, context):
    print(event)
    resourceId = event["detail"]["newEvaluationResult"]["evaluationResultIdentifier"][
        "evaluationResultQualifier"
    ]["resourceId"]
    complianceType = event["detail"]["newEvaluationResult"]["complianceType"]
    try:
        configMessage = event["detail"]["newEvaluationResult"]["annotation"]
    except KeyError:
        configMessage = "No message."
    userName = get_username(resourceId)
    send_mesage(userName, configMessage, complianceType)
예제 #5
0
    def on_post(self, req, resp):
        body = helpers.get_json(req)
        username = helpers.get_username(body)

        user_hash = redis_db.get(username)
        if not user_hash:
            raise falcon.HTTPBadRequest(
                'Hash Missing',
                'A hash does not exist for this username. Run /generate_hash/ first'
            )

        # The URL to the user's profile page
        profile_url = SA_PROFILE_URL + username

        # We can't view user profiles unless we're logged in, so we'll need to use a
        # requests session and set some cookies
        session = requests.Session()
        raw_profile = session.get(profile_url, cookies=SA_COOKIES)

        # Do a regex search to find the user's hash in their profile page
        result = re.search(user_hash, raw_profile.text)

        resp.status = falcon.HTTP_OK
        resp.body = json.dumps({'validated': result is not None})
예제 #6
0
import webbrowser

from helpers import authenticate, get_pin, verify_account, get_username, how_many, start_unfollowing, white_list

#open browser
auth_url = authenticate()
webbrowser.get().open(auth_url)

#ask for pin code
print("Submit the verification PIN you received on twitter:")
pin = get_pin()

#verify account
if not verify_account(pin):
    exit(1)        

#do not unfollow these accounts
whitelist = white_list()

#get username
username = get_username()

#ask how many people to unfollow
print("How many users do you want to unfollow? (400 by default)")
amount = how_many()

#unfollow them
start_unfollowing(username, amount, whitelist)