git commit, converted over to base.html pulling Status*, rather than every render_template calling it. Tightened up naming for job manager, fixed a few bugs in there with items like div by zero, created the active jobs link/badge in navbar, have it invoked each time by base.html template and it gets active jobs from DB, pa_job_manager now initiliases from an empty DB and can work out where it is at, no loop/thread/or actual job code yet. jobs.py has basics of a NewJob(), so next step is to force that job to be executed in pa_job_manager, but its tea time
This commit is contained in:
28
job.py
28
job.py
@@ -24,17 +24,39 @@ class Job(db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('joblog_id_seq'), primary_key=True )
|
||||
start_time = db.Column(db.DateTime(timezone=True))
|
||||
last_update = db.Column(db.DateTime(timezone=True))
|
||||
name = db.Column(db.String)
|
||||
state = db.Column(db.String)
|
||||
num_passes = db.Column(db.Integer)
|
||||
current_pass = db.Column(db.Integer)
|
||||
num_files = db.Column(db.Integer)
|
||||
current_file_num = db.Column(db.Integer)
|
||||
current_file = db.Column(db.String)
|
||||
wait_for = db.Column(db.Integer)
|
||||
pa_job_state = db.Column(db.String)
|
||||
|
||||
def __repr__(self):
|
||||
return "<id: {}, start_time: {}, last_update: {}, state: {}, num_passes: {}, current_passes: {}, num_files: {}, current_file_num: {}, current_file: {}>".format(self.id, self.start_time, self.last_update, self.state, self.num_passes, self.current_pass, self.num_files, self.num_files, self.current_file_num, self.current_file)
|
||||
return "<id: {}, start_time: {}, last_update: {}, name: {}, state: {}, num_passes: {}, current_passes: {}, num_files: {}, current_file_num: {}, current_file: {}>".format(self.id, self.start_time, self.last_update, self.name, self.state, self.num_passes, self.current_pass, self.num_files, self.num_files, self.current_file_num, self.current_file)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Utility classes for Jobs
|
||||
################################################################################
|
||||
def GetNumActiveJobs():
|
||||
ret = db.engine.execute("select num_active_jobs from pa_job_manager").first();
|
||||
if( ret != None ):
|
||||
return ret.num_active_jobs
|
||||
|
||||
###############################################################################
|
||||
# NewJob takes a name (which will be matched in pa_job_manager.py to run
|
||||
# the appropriate job - which will update the Job() until complete
|
||||
###############################################################################
|
||||
def NewJob(name, num_passes="1", num_files="0", wait_for=None ):
|
||||
job=Job(start_time='now()', last_update='now()', name=name, state="New", num_passes=num_passes, num_files=num_files,
|
||||
current_pass=0, current_file_num=0, current_file='',
|
||||
wait_for=wait_for, pa_job_state="New" )
|
||||
db.session.add(job)
|
||||
db.session.commit()
|
||||
|
||||
################################################################################
|
||||
# /jobs -> show current settings
|
||||
################################################################################
|
||||
@@ -42,7 +64,7 @@ class Job(db.Model):
|
||||
def jobs():
|
||||
page_title='Job actions'
|
||||
jobs = Job.query.all()
|
||||
return render_template("jobs.html", jobs=jobs, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
return render_template("jobs.html", jobs=jobs, page_title=page_title)
|
||||
|
||||
|
||||
###############################################################################
|
||||
@@ -55,7 +77,7 @@ def joblog(id):
|
||||
logs=Joblog.query.filter(Joblog.job_id==id).all()
|
||||
duration=(datetime.now(pytz.utc)-joblog.start_time)
|
||||
duration= duration-timedelta(microseconds=duration.microseconds)
|
||||
return render_template("joblog.html", imp=joblog, logs=logs, duration=duration, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
|
||||
return render_template("joblog.html", job=joblog, logs=logs, duration=duration, page_title=page_title)
|
||||
|
||||
###############################################################################
|
||||
# This func creates a new filter in jinja2 to format the time from the db in a
|
||||
|
||||
Reference in New Issue
Block a user