当前位置: 首页>>代码示例>>Python>>正文


Python Label.load_from_db方法代码示例

本文整理汇总了Python中label.Label.load_from_db方法的典型用法代码示例。如果您正苦于以下问题:Python Label.load_from_db方法的具体用法?Python Label.load_from_db怎么用?Python Label.load_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在label.Label的用法示例。


在下文中一共展示了Label.load_from_db方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load_from_db

# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import load_from_db [as 别名]
    def test_load_from_db(self):
        label = Label()
        label.load_from_db(1, self.connection)

        self.assertEquals(label.id, 1)
        self.assertEquals(label.day, "SUN, AM")
        self.assertEquals(label.sermon_title, "Test Title")
        self.assertEquals(label.minister, "H.L. Sheppard")
        self.assertEquals(label.date, datetime.date(2014, 1, 1))
开发者ID:cplazas,项目名称:church-scripts,代码行数:11,代码来源:test_label.py

示例2: __init__

# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import load_from_db [as 别名]
class Job:
    
    def __init__(self, id, connection):

        logging.debug (" Initializing Job: %s" % id)

        strSQL = "select * from jobs where id = ?"
        cursor = connection.cursor()
        cursor.execute(strSQL, id)
        row = cursor.fetchone()

        if row:
            self.id = row.id
            self.label_id = row.tapeid
            self.copies = row.copies
            self.status = row.status
            self.printonly = (row.printonly == "y")
            self.dvd = (row.dvd == "y")
            self.master = (row.master == "y")
            self.pulpit = (row.pulpit == "y")
            self.label = Label()
            self.label.load_from_db(self.label_id, connection)

        logging.debug(" Finished initializing Job: %s" % id)

    def get_status_from_db(self, connection):
    
        strSQL = "select status from jobs where id = ?" 
        cursor = connection.cursor()
        cursor.execute(strSQL, self.id)
        row = cursor.fetchone()

        if row:
            self.status = row.status

    def get_status_from_ptburn(self, ptburn_jobs_dir, label_file_dir): 
        # valid statuses: 
        # 0 - on hold 
        # 1 - submitted 
        # 2 - received 
        # 3 - processing 
        # 4 - completed 
        # 5 - failed (error) 
        
        logging.debug(" Getting job status for Job: %s for Service: %s" % (self.id, self.label.get_label_key()))

        job_file_base = "%s%s%s" % (ptburn_jobs_dir, "JOB_", self.id)
        if os.path.exists(job_file_base + ".jrq"):
            self.status = 2
        elif os.path.exists(job_file_base + ".inp"):
            self.status = 3
        elif os.path.exists(job_file_base + ".qrj"):
            self.status = 3
        elif os.path.exists(job_file_base + ".don"):
            # this clean up was being done by the old vbs script -- no longer needed
            #At this point the job is ether successful or failed
            #we should clean up any .prn files associated with this job
            #now that .prn files are being created on a per-job basis
            # Set regex = new RegExp
            # regex.Global = True 
            # regex.IgnoreCase = True 
            # regex.Pattern = ".+\-" & CStr(nID) & "\.prn"
            # Set folder = FSO.GetFolder(strLabelFileDir)
            # Set fc = folder.Files 
            # For Each fl In fc
            #   If  regex.Test(fl.name)  Then
            #       fl.Delete 'delete the file if it exists
            #   End If
            # Next
            self.status = 4
        elif os.path.exists(job_file_base + ".err"):
            #either of these conditions result in an error, the first means there was an acutal error from ptburn 
            self.status = 5
        else:
            #the second means that we couldn't even find the job file for this running job so we flag it as an error 
            self.status = 5
        
        logging.debug("     Job Status: %s" % self.status)

    def set_status_in_db(self, connection):
        logging.debug(" Setting db status for job: %s to status: %s", self.id, self.status)
        strSQL = "update jobs set status = ?, lastupdate = now() where id = ?"
        cursor = connection.cursor()
        cursor.execute(strSQL, self.status, self.id)
        cursor.commit()

    
    def submit_job_to_ptburn(self, audio_files_dir, label_file_dir, ptburn_jobs_dir):
        logging.debug(" Submitting Job: %s for Service: %s To PTBurn." % (self.id, self.label.get_label_key()))

        if self.printonly or self.required_files_exist(audio_files_dir):         
            # do some work
            # first we make the label so it can be referenced in the job
            if self.dvd:
                label_file = "dvd-label.std"
            else:
                if self.master:
                    label_file = "cd-label-master.std"
                else:
                    if self.pulpit:
#.........这里部分代码省略.........
开发者ID:cplazas,项目名称:church-scripts,代码行数:103,代码来源:job.py

示例3: test_get_label_key

# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import load_from_db [as 别名]
    def test_get_label_key(self):
        label = Label()
        label.load_from_db(1, self.connection)

        self.assertEquals(label.get_label_key(), "010114AM")
开发者ID:cplazas,项目名称:church-scripts,代码行数:7,代码来源:test_label.py


注:本文中的label.Label.load_from_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。