コード例 #1
0
ファイル: job.py プロジェクト: homecontrol/server
 def sql_load(sql, job_id = None, order_by = None):
     Job.sql_create(sql)
     
     if job_id != None:
         sql.execute("SELECT id, name, description, cron "
                     "FROM jobs WHERE id=? LIMIT 0,1", (job_id,))
         
     else:
         if order_by == None: order_by = "name"
         sql.execute("SELECT id, name, description, cron "
                     "FROM jobs ORDER BY ?", (order_by,))
         
     result = sql.fetchall()
     
     if job_id != None and result == None:
         raise Exception("Could not find job id %i" % job_id)
         return None
     
     jobs = []
     for data in result:
         job = Job()
         (job.id, job.name, job.description, job.cron) = data
         
         if job.cron != None:
             job.cron = json.loads(job.cron)
         
         sql.execute("SELECT signal_id FROM jobs_signals "
                     "WHERE job_id=? ORDER BY Position ASC", (job.id,))
         
         for (signal_id,) in sql.fetchall():
             job.add_signal(Signal.sql_load(sql, signal_id=signal_id))
             
         if job_id != None: return job
         jobs.append(job)
         
     return jobs
コード例 #2
0
ファイル: scheduler.py プロジェクト: homecontrol/server
 def load_signals(self, handler, order_by = "name"):
     
     signals = Signal.sql_load(self.sql(), order_by=order_by)
     handler.send_json_response(signals)