Commit 99f11333 authored by Nicolas Noe Valladares's avatar Nicolas Noe Valladares
Browse files

Merge branch 'feat-filesys-feedback' of...

Merge branch 'feat-filesys-feedback' of https://gitlab.rc.uab.edu/mmoo97/flask_user_reg into noe-feat-filesys-feedback

Conflicts:
	app/__init__.py
parents 2ce4e9fa 356184e0
......@@ -14,20 +14,60 @@ from flask_wtf import FlaskForm
from flask_bootstrap import Bootstrap
from wtforms import StringField, SubmitField, validators
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.utils import dirsnapshot
def create_app(config_name):
app = Flask(__name__)
Bootstrap(app)
global snap_before
global snap_after
global snap_diff
global observing
observing = False
class MyHandler(FileSystemEventHandler):
def on_modified(self, event):
global snap_before
global snap_after
global snap_diff
global observing
# print(event.src_path + " modified.")
snap_after = dirsnapshot.DirectorySnapshot("flat_db/", True)
snap_diff = dirsnapshot.DirectorySnapshotDiff(snap_before, snap_after)
try:
if ("flat_db/" + time_stamp + ".done" + ".txt") in snap_diff.files_moved[0]:
observing = False
# print("YES!")
except:
pass
# print("Created: ", snap_diff.files_created)
# print("Deleted: ", snap_diff.files_deleted)
# print("Modified: ", snap_diff.files_modified)
# print("Moved: ", snap_diff.files_moved)
def on_created(self, event):
print(event.src_path + " created.")
def create_app(config_name):
app = Flask(__name__) # initialization of the flask appo
Bootstrap(app) # allowing app to use bootstrap
global return_url
return_url = ''
class MainForm(FlaskForm):
class MainForm(FlaskForm): # class for the form itself
fullname = StringField('Full Name: ', [validators.DataRequired(), ])
submit = SubmitField('Submit')
@app.route('/', methods=['GET', 'POST'])
@app.route('/', methods=['GET', 'POST']) # initial route to display the reg page
def index():
global return_url
user = request.remote_user
......@@ -49,6 +89,7 @@ def create_app(config_name):
def success(username, fullname):
global return_url
global snap_before
print(username, fullname, return_url, file=sys.stdout)
# Deliver arguments to script.
......@@ -58,28 +99,45 @@ def create_app(config_name):
try:
# function to write out a flatdb with the name of the file being a timestamp and the content
# of the file beieng blazerID the user submitted from the flask form (fullname)
time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S")
directory = "/home/reggie/flat_db"
directory = "/home/reggie/flat_db/"
complete_file_name = os.path.join(directory, time_stamp + ".txt")
if not os.path.exists(directory):
os.makedirs(directory)
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path='/home/reggie/flat_db', recursive=True)
observer.start()
file = open(complete_file_name, "w")
file.write(fullname)
file.write("Hey")
snap_before = dirsnapshot.DirectorySnapshot("/home/reggie/flat_db", True)
while observing:
# TODO: While loop will go here
time.sleep(5)
observer.stop()
file.close()
<<<<<<< HEAD
# TODO: While loop will go here
while ".done" is not file.name:
time.sleep(10)
=======
>>>>>>> 356184e014552318a785d12a6c54d54a8f76af11
return render_template("errors/registration_failed.html")
# return redirect(return_url, 302)
except:
except Exception as e:
print(e)
flash("Registration Failed. Please try again.")
return redirect(url_for('index'))
@app.errorhandler(403)
def forbidden(error):
return render_template('errors/403.html', title='Forbidden'), 403
......
argh==0.26.2
Click==7.0
dominate==2.3.5
Flask==1.0.2
......@@ -6,18 +7,21 @@ Flask-Login==0.4.1
Flask-Testing==0.7.1
Flask-WTF==0.14.2
itsdangerous==1.1.0
Jinja2>=2.10.1
Jinja2==2.10.1
Mako==1.0.7
MarkupSafe==1.1.1
pathtools==0.1.2
pbr==5.1.3
python-dateutil==1.5
python-editor==1.0.4
pytz==2013.7
PyYAML==5.1.2
six==1.12.0
stevedore==1.30.1
virtualenv==16.4.3
virtualenv-clone==0.5.1
virtualenvwrapper==4.8.4
visitor==0.1.3
watchdog==0.9.0
Werkzeug==0.14.1
WTForms==2.2.1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment