Example #1
0
 def __init__(self):
     self.Da = Programcurd()
     self.getConfig = Configread()
     self.num_prg = self.getConfig.num_programs() + 1
     for i in range(self.num_prg):
         if i != 0:
             jbdetails = {}
             self.Da.updateProgramdetails(i, **jbdetails)
def removeprogram():
    try:
        data = request.get_json()
        pjobd = {"": ""}
        schedaoobj = Programcurd()
        remprogram(data.get('prgid'))
        schedaoobj.updateProgramdetails(data.get('prgid'), **pjobd)
    except Exception as ex:
        traceback.print_exc()
    return "Welcome! %s" % jsonify(request.json)
def scheduleprogram():
    try:
        data = request.get_json()
        jobd = '{' + data.get('jobdetails') + '}'
        pjobd = json.loads(jobd)
        schedaoobj = Programcurd()
        schedaoobj.updateProgramdetails(data.get('prgid'), **pjobd)
        addprogram(data.get('prgid'), data.get('day_of_week'),
                   str(int(data.get('hour'))), str(int(data.get('minute'))))
    except Exception as ex:
        traceback.print_exc()
    return "job details: %s" % data.get('prgid'), 200
def getprogram():
    try:
        data = request.get_json()
        job = scheduler.get_job(data.get('prgid'))
        schedaoobj = Programcurd()
        jobd = schedaoobj.getProgramdetails(int(data.get('prgid')))
        print(
            "name: %s, id: %s, trigger: %s, next run: %s, handler: %s, argument: %s, Job Details: %s"
            % (job.name, job.id, job.trigger, job.next_run_time, job.func,
               job.args, jobd))
    except AttributeError as ex:
        print("Getting none rows")
        #traceback.print_exc()
    return "Welcome!"
Example #5
0
    def __init__(self, prgid):
        self.prgid = prgid
        self.jobs_hash = {}
        self.db = Programcurd()
        self.jobs_hash = self.db.getProgramdetails(self.prgid)
        self.raincheck = Weatherservice()
        self.rainstatus = self.raincheck.getRainStatus()
        try:
            if self.rainstatus == "False":
                for key, value in self.jobs_hash.items():
                    Runzonejob(key, value)

        except Exception as ex:
            traceback.print_exc()

        finally:
            print("completed the job")
            pass