def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option('--chanid', action='store', type='int', dest='chanid', help='Use chanid with both starttime and tzoffset for manual operation') parser.add_option('--starttime', action='store', type='string', dest='starttime', help='Use starttime with both chanid and tzoffset for manual operation') parser.add_option('--tzoffset', action='store', type='int', dest='tzoffset', help='Use tzoffset with both chanid and starttime for manual operation') parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if len(args) == 1: runjob(jobid=args[0]) elif opts.chanid and opts.starttime and opts.tzoffset is not None: runjob(chanid=opts.chanid, starttime=opts.starttime, tzoffset=opts.tzoffset) else: print 'Script must be provided jobid, or chanid, starttime and timezone offset.' sys.exit(1)
def test_Logging_Basic_002_01(self): """Test if options can be modified from MythTV.MythLog.""" m = MythLog('simple_test') m._setmask("most") # check the modified mask: self.assertEqual(m._MASK, LOGMASK.MOST) # check the default level: self.assertEqual(m._LEVEL, LOGLEVEL.INFO) # check the default file: self.assertTrue('stdout' in repr(m._LOGFILE)) m._setlevel("notice") # check the modified mask: self.assertEqual(m._MASK, LOGMASK.MOST) # check the modified level: self.assertEqual(m._LEVEL, LOGLEVEL.NOTICE) # check the default file: self.assertTrue('stdout' in repr(m._LOGFILE)) m._setfile("/tmp/my_logfile") # check the modified mask: self.assertEqual(m._MASK, LOGMASK.MOST) # check the modified level: self.assertEqual(m._LEVEL, LOGLEVEL.NOTICE) # check the modified file: self.assertTrue(os.path.exists("/tmp/my_logfile"))
def initializeMythDB(self): ''' Import the MythTV database bindings return nothing ''' try: from MythTV import MythDB, MythLog, MythError try: '''Create an instance of each: MythDB ''' MythLog._setlevel( 'none' ) # Some non option -M cannot have any logging on stdout self.mythdb = MythDB() except MythError as e: sys.stderr.write('\n! Error - %s\n' % e.args[0]) filename = os.path.expanduser("~") + '/.mythtv/config.xml' if not os.path.isfile(filename): sys.stderr.write( '\n! Error - A correctly configured (%s) file must exist\n' % filename) else: sys.stderr.write( '\n! Error - Check that (%s) is correctly configured\n' % filename) sys.exit(1) except Exception as e: sys.stderr.write( "\n! Error - Creating an instance caused an error for one of: MythDB. error(%s)\n" % e) sys.exit(1) except Exception as e: sys.stderr.write( "\n! Error - MythTV python bindings could not be imported. error(%s)\n" % e) sys.exit(1)
def test_Logging_Basic_004_01(self): """"Test if setting options works without a MythLog instance.""" MythLog._setmask("most") # check the modified mask: self.assertEqual(MythLog._MASK, LOGMASK.MOST) # check the default level: self.assertEqual(MythLog._LEVEL, LOGLEVEL.INFO) # check the default file: self.assertTrue('stdout' in repr(MythLog._LOGFILE)) MythLog._setlevel("notice") # check the modified mask: self.assertEqual(MythLog._MASK, LOGMASK.MOST) # check the modified level: self.assertEqual(MythLog._LEVEL, LOGLEVEL.NOTICE) # check the default file: self.assertTrue('stdout' in repr(MythLog._LOGFILE)) MythLog._setfile("/tmp/my_logfile") # check the modified mask: self.assertEqual(MythLog._MASK, LOGMASK.MOST) # check the modified level: self.assertEqual(MythLog._LEVEL, LOGLEVEL.NOTICE) # check the modified file: self.assertTrue(os.path.exists("/tmp/my_logfile"))
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option('--chanid', action='store', type='int', dest='chanid', help='Use chanid for manual operation') parser.add_option('--starttime', action='store', type='int', dest='starttime', help='Use starttime for manual operation') parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if len(args) == 1: runjob(jobid=args[0]) elif opts.chanid and opts.starttime: runjob(chanid=opts.chanid, starttime=opts.starttime) else: print 'Script must be provided jobid, or chanid and starttime.' sys.exit(1)
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option("-f", "--helpformat", action="store_true", default=False, dest="fmthelp", help="Print explination of file format string.") parser.add_option("-p", "--printformat", action="store_true", default=False, dest="fmtprint", help="Print current file format string.") parser.add_option("--tformat", action="store", type="string", dest="tformat", help="Use TV format for current task. If no task, store in database.") parser.add_option("--mformat", action="store", type="string", dest="mformat", help="Use Movie format for current task. If no task, store in database.") parser.add_option("--gformat", action="store", type="string", dest="gformat", help="Use Generic format for current task. If no task, store in database.") parser.add_option("--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation") parser.add_option("--starttime", action="store", type="int", dest="starttime", help="Use starttime for manual operation") parser.add_option("--listingonly", action="store_true", default=False, dest="listingonly", help="Use data from listing provider, rather than grabber") parser.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") parser.add_option("--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") parser.add_option("--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.fmthelp: usage_format() sys.exit(0) if opts.fmtprint: print_format() sys.exit(0) if opts.chanid and opts.starttime: export = VIDEO(opts) elif len(args) == 1: try: export = VIDEO(opts, int(args[0])) except Exception, e: Job(int(args[0])).update({'status':304, 'comment':'ERROR: ' + e.args[0]}) MythLog(module='mythvidexport.py').logTB(MythLog.IMPORTANT) sys.exit(1)
def main(): """Startup function.""" parser = OptionParser(usage="usage: %prog [options]") parser.add_option( "--verbose", action="store_true", default=False, help="enable verbose output of MythTV API") parser.add_option( '-f', "--force", action="store_true", default=False, help="non-interactive mode, answer 'yes' to all questions") parser.add_option( '-t', "--title", action="store", type="string", help="limit recordings that match title") opts, _ = parser.parse_args() MythLog._setlevel('unknown' if opts.verbose else 'err') # pylint:disable=protected-access try: backend = MythBE() recs = [ r for r in list(backend.getRecordings()) if r.recgroup == 'Deleted' ] if opts.title: recs = [ r for r in recs if re.findall(opts.title, r.title, re.IGNORECASE) ] if len(recs) == 0: print('no matching recordings found') sys.exit(0) if opts.force: undelete_all(backend, recs) else: interactive_undelete(backend, recs) except MythDBError as e: if e.name == 'DB_CREDENTIALS': print("ERROR: Could not find MythDB host:port OR correct login " "credentials!") sys.exit(-1) else: raise sys.exit(0)
def main(): """Startup function.""" parser = OptionParser(usage="usage: %prog [options]") parser.add_option("--verbose", action="store_true", default=False, help="enable verbose output of MythTV API") parser.add_option( '-f', "--force", action="store_true", default=False, help="non-interactive mode, answer 'yes' to all questions") parser.add_option('-t', "--title", action="store", type="string", help="limit recordings that match title") opts, _ = parser.parse_args() MythLog._setlevel('unknown' if opts.verbose else 'err') # pylint:disable=protected-access try: backend = MythBE() recs = [ r for r in list(backend.getRecordings()) if r.recgroup == 'Deleted' ] if opts.title: recs = [ r for r in recs if re.findall(opts.title, r.title, re.IGNORECASE) ] if len(recs) == 0: print('no matching recordings found') sys.exit(0) if opts.force: undelete_all(backend, recs) else: interactive_undelete(backend, recs) except MythDBError as e: if e.name == 'DB_CREDENTIALS': print("ERROR: Could not find MythDB host:port OR correct login " "credentials!") sys.exit(-1) else: raise sys.exit(0)
def run_debug(): MythLog._setfile('/var/log/mythtv/mythfs.log') MythLog._setlevel('important,general,file') fs = DebugFS() fs.fsinit() banner = 'MythTV Python interactive shell.' import code try: import readline, rlcompleter except: pass else: readline.parse_and_bind("tab: complete") banner += ' TAB completion available.' namespace = globals().copy() namespace.update(locals()) code.InteractiveConsole(namespace).interact(banner) sys.exit()
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option('--jobid', action='store', type='int', dest='jobid') parser.add_option('--chanid', action='store', type='int', dest='chanid') parser.add_option('--starttime', action='store', type='int', dest='starttime') parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') parser.add_option('--title', action='store', type='string', dest='title', help='Title of Show') parser.add_option('--limit', action='store', type='int', dest='limit', default=100, help='Limit of how many recordings to do') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) title = None if opts.jobid: rec = getjob(jobid=opts.jobid) title = rec.title elif opts.chanid and opts.starttime: rec = getjob(chanid=opts.chanid, starttime=opts.starttime) title = rec.title elif opts.title: title = opts.title if title is None: print 'Unable to determine title.' sys.exit(1) timestr = time.strftime("%m-%d-%y %H:%M:%S") title_san = re.sub("\s", ".", title) print title_san try: os.mkdir(log_dir) except OSError, e: pass
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") formatgroup = OptionGroup( parser, "Formatting Options", "These options are used to display and manipulate the output file formats." ) formatgroup.add_option("-f", "--helpformat", action="store_true", default=False, dest="fmthelp", help="Print explination of file format string.") formatgroup.add_option("-p", "--printformat", action="store_true", default=False, dest="fmtprint", help="Print current file format string.") formatgroup.add_option( "--tformat", action="store", type="string", dest="tformat", help="Use TV format for current task. If no task, store in database.") formatgroup.add_option( "--mformat", action="store", type="string", dest="mformat", help="Use Movie format for current task. If no task, store in database." ) formatgroup.add_option( "--gformat", action="store", type="string", dest="gformat", help= "Use Generic format for current task. If no task, store in database.") formatgroup.add_option( "--listingonly", action="store_true", default=False, dest="listingonly", help="Use data from listing provider, rather than grabber") parser.add_option_group(formatgroup) sourcegroup = OptionGroup(parser, "Source Definition", "These options can be used to manually specify a recording to operate on "+\ "in place of the job id.") sourcegroup.add_option("--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation") sourcegroup.add_option("--starttime", action="store", type="string", dest="starttime", help="Use starttime for manual operation") parser.add_option_group(sourcegroup) actiongroup = OptionGroup( parser, "Additional Actions", "These options perform additional actions after the recording has been exported." ) actiongroup.add_option( '--safe', action='store_true', default=False, dest='safe', help='Perform quick sanity check of exported file using file size.') actiongroup.add_option( '--really-safe', action='store_true', default=False, dest='reallysafe', help='Perform slow sanity check of exported file using SHA1 hash.') actiongroup.add_option( "--delete", action="store_true", default=False, help= "Delete source recording after successful export. Enforces use of --safe." ) parser.add_option_group(actiongroup) othergroup = OptionGroup( parser, "Other Data", "These options copy additional information from the source recording.") othergroup.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") othergroup.add_option( "--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") othergroup.add_option( "--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option_group(othergroup) MythLog.loadOptParse(parser) opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.fmthelp: usage_format() sys.exit(0) if opts.fmtprint: print_format() sys.exit(0) if opts.delete: opts.safe = True if opts.chanid and opts.starttime: export = VIDEO(opts) elif len(args) == 1: try: export = VIDEO(opts, int(args[0])) except Exception, e: Job(int(args[0])).update({ 'status': Job.ERRORED, 'comment': 'ERROR: ' + e.args[0] }) MythLog(module='mythvidexport.py').logTB(MythLog.GENERAL) sys.exit(1)
#!/usr/bin/env python from MythTV import MythDB, MythError, MythLog, Frontend from datetime import datetime, timedelta from curses import wrapper, ascii from time import sleep import sys, socket, curses, re #note for ticket, on-screen-keyboard remotely does not have focus MythLog._setlevel('none') frontend = None rplaytype = re.compile('Playback ([a-zA-Z]+)') rrecorded = re.compile('Playback ([a-zA-Z]+) ([\d:]+) of ([\d:]+) ([-0-9\.]+x) (\d*) ([0-9-T:]+)') rlivetv = rrecorded rvideo = re.compile('Playback [a-zA-Z]+ ([\d:]+) ([-0-9\.]+x) .*/(.*) \d+ [\.\d]+') rrname = re.compile('\d+ [0-9-T:]+ (.*)') rlname = re.compile('\d+ [0-9-T: ]+ (.*)') def align(side, window, y, string, flush=0): w = window.getmaxyx()[1]-1 if len(string) > w: string = string[:w] if side == 0: x = 1 elif side == 1: x = (w-len(string))/2+1 elif side == 2: x = w-len(string) window.addstr(y,x,string)
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") sourcegroup = OptionGroup(parser, "Source Definition", "These options can be used to manually specify a recording to operate on "+\ "in place of the job id.") sourcegroup.add_option("--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation, format interger") sourcegroup.add_option("--startdate", action="store", type="string", dest="startdate", help="Use startdate for manual operation, format is year-mm-dd") sourcegroup.add_option("--starttime", action="store", type="string", dest="starttime", help="Use starttime for manual operation, format is hh:mm:ss in UTC") sourcegroup.add_option("--offset", action="store", type="string", dest="offset", help="Use offset(timezone) for manual operation, format is [+/-]hh:mm. Do not adjust for DST") parser.add_option_group(sourcegroup) actiongroup = OptionGroup(parser, "Additional Actions", "These options perform additional actions after the recording has been migrated. "+\ "A safe copy is always performed in that the file is checked to match the "+\ "MythBE hash. The safe copy option will abort the entire process if selected "+\ "along with Other Data and an exception occurs in the process") actiongroup.add_option('--safe', action='store_true', default=False, dest='safe', help='If other data is copied and a failure occurs this will abort the whole process.') actiongroup.add_option("--delete", action="store_true", default=False, help="Delete source recording after successful export. Enforces use of --safe.") parser.add_option_group(actiongroup) othergroup = OptionGroup(parser, "Other Data", "These options copy additional information from the source recording.") othergroup.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") othergroup.add_option("--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") othergroup.add_option("--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option_group(othergroup) MythLog.loadOptParse(parser) opts, args = parser.parse_args() def error_out(): export.delete_vid() if export.thisJob: export.set_job_status(Job.ERRORED) sys.exit(1) if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.delete: opts.safe = True # if a manual channel and time entry then setup the export with opts if opts.chanid and opts.startdate and opts.starttime and opts.offset: try: export = VIDEO(opts) except Exception, e: sys.exit(1)
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") formatgroup = OptionGroup(parser, "Formatting Options", "These options are used to display and manipulate the output file formats.") formatgroup.add_option("-f", "--helpformat", action="store_true", default=False, dest="fmthelp", help="Print explination of file format string.") formatgroup.add_option("-p", "--printformat", action="store_true", default=False, dest="fmtprint", help="Print current file format string.") formatgroup.add_option("--tformat", action="store", type="string", dest="tformat", help="Use TV format for current task. If no task, store in database.") formatgroup.add_option("--mformat", action="store", type="string", dest="mformat", help="Use Movie format for current task. If no task, store in database.") formatgroup.add_option("--gformat", action="store", type="string", dest="gformat", help="Use Generic format for current task. If no task, store in database.") formatgroup.add_option("--listingonly", action="store_true", default=False, dest="listingonly", help="Use data from listing provider, rather than grabber") parser.add_option_group(formatgroup) sourcegroup = OptionGroup(parser, "Source Definition", "These options can be used to manually specify a recording to operate on "+\ "in place of the job id.") sourcegroup.add_option("--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation") sourcegroup.add_option("--starttime", action="store", type="int", dest="starttime", help="Use starttime for manual operation") parser.add_option_group(sourcegroup) actiongroup = OptionGroup(parser, "Additional Actions", "These options perform additional actions after the recording has been exported.") actiongroup.add_option('--safe', action='store_true', default=False, dest='safe', help='Perform quick sanity check of exported file using file size.') actiongroup.add_option('--really-safe', action='store_true', default=False, dest='reallysafe', help='Perform slow sanity check of exported file using SHA1 hash.') actiongroup.add_option("--delete", action="store_true", default=False, help="Delete source recording after successful export. Enforces use of --safe.") parser.add_option_group(actiongroup) othergroup = OptionGroup(parser, "Other Data", "These options copy additional information from the source recording.") othergroup.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") othergroup.add_option("--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") othergroup.add_option("--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option_group(othergroup) MythLog.loadOptParse(parser) opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.fmthelp: usage_format() sys.exit(0) if opts.fmtprint: print_format() sys.exit(0) if opts.delete: opts.safe = True if opts.chanid and opts.starttime: export = VIDEO(opts) elif len(args) == 1: try: export = VIDEO(opts,int(args[0])) except Exception, e: Job(int(args[0])).update({'status':Job.ERRORED, 'comment':'ERROR: '+e.args[0]}) MythLog(module='mythvidexport.py').logTB(MythLog.GENERAL) sys.exit(1)
a = a[2:] if '=' in a: a = a.split('=', 1) param[a[0]] = a[1] else: if len(temp): b = temp.pop(0) if (b[:2] == '--') or (b[:1] == '-'): temp.insert(0, b) param[a] = '' else: param[a] = b else: param[a] = '' MythLog._setlevel(param.get('verbose', 'none')) try: param.pop('verbose') except: pass force = False if 'force' in param: force = True param.pop('force') if len(a) == 0: sys.exit(0) recs = list(MythDB().searchRecorded(**param)) if len(recs) == 0:
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option( '--chanid', action='store', type='int', dest='chanid', help='Use chanid with both starttime and tzoffset for manual operation' ) parser.add_option( '--starttime', action='store', type='string', dest='starttime', help='Use starttime with both chanid and tzoffset for manual operation' ) parser.add_option( '--tzoffset', action='store', type='int', dest='tzoffset', help='Use tzoffset with both chanid and starttime for manual operation' ) parser.add_option( '--overwrite', action='store', type='int', default=1, dest='overwrite', help='Use overwrite to force the output to replace the original file') parser.add_option('--sd', action='store', type='int', default=0, dest='sdonly', help='Use sd to force the output to be SD dimentions') parser.add_option('--burncc', action='store', type='int', default=0, dest='burncc', help='Use burncc to burn the subtitle/cc into the video') parser.add_option('--mkv', action='store', type='int', default=0, dest='usemkv', help='Use mkv instead of mp4') parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if len(args) == 1: runjob(jobid=args[0], overwrite=opts.overwrite, sdonly=opts.sdonly, burncc=opts.burncc, usemkv=opts.usemkv) elif opts.chanid and opts.starttime and opts.tzoffset is not None: runjob(chanid=opts.chanid, starttime=opts.starttime, tzoffset=opts.tzoffset, overwrite=opts.overwrite, sdonly=opts.sdonly, burncc=opts.burncc, usemkv=opts.usemkv) else: print 'Script must be provided jobid, or chanid, starttime and timezone offset.' sys.exit(1)
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") sourcegroup = OptionGroup(parser, "Source Definition", "These options can be used to manually specify a recording to operate on "+\ "in place of the job id.") sourcegroup.add_option( "--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation, format interger") sourcegroup.add_option( "--startdate", action="store", type="string", dest="startdate", help="Use startdate for manual operation, format is year-mm-dd") sourcegroup.add_option( "--starttime", action="store", type="string", dest="starttime", help="Use starttime for manual operation, format is hh:mm:ss in UTC") sourcegroup.add_option( "--offset", action="store", type="string", dest="offset", help= "Use offset(timezone) for manual operation, format is [+/-]hh:mm. Do not adjust for DST" ) parser.add_option_group(sourcegroup) actiongroup = OptionGroup(parser, "Additional Actions", "These options perform additional actions after the recording has been migrated. "+\ "A safe copy is always performed in that the file is checked to match the "+\ "MythBE hash. The safe copy option will abort the entire process if selected "+\ "along with Other Data and an exception occurs in the process") actiongroup.add_option( '--safe', action='store_true', default=False, dest='safe', help= 'If other data is copied and a failure occurs this will abort the whole process.' ) actiongroup.add_option( "--delete", action="store_true", default=False, help= "Delete source recording after successful export. Enforces use of --safe." ) parser.add_option_group(actiongroup) othergroup = OptionGroup( parser, "Other Data", "These options copy additional information from the source recording.") othergroup.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") othergroup.add_option( "--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") othergroup.add_option( "--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option_group(othergroup) MythLog.loadOptParse(parser) opts, args = parser.parse_args() def error_out(): export.delete_vid() if export.thisJob: export.set_job_status(Job.ERRORED) sys.exit(1) if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.delete: opts.safe = True # if a manual channel and time entry then setup the export with opts if opts.chanid and opts.startdate and opts.starttime and opts.offset: try: export = VIDEO(opts) except Exception, e: sys.exit(1)
def main(): parser = OptionParser(usage="usage: %prog [options] [jobid]") parser.add_option("-f", "--helpformat", action="store_true", default=False, dest="fmthelp", help="Print explination of file format string.") parser.add_option("-p", "--printformat", action="store_true", default=False, dest="fmtprint", help="Print current file format string.") parser.add_option( "--tformat", action="store", type="string", dest="tformat", help="Use TV format for current task. If no task, store in database.") parser.add_option( "--mformat", action="store", type="string", dest="mformat", help="Use Movie format for current task. If no task, store in database." ) parser.add_option( "--gformat", action="store", type="string", dest="gformat", help= "Use Generic format for current task. If no task, store in database.") parser.add_option("--chanid", action="store", type="int", dest="chanid", help="Use chanid for manual operation") parser.add_option("--starttime", action="store", type="int", dest="starttime", help="Use starttime for manual operation") parser.add_option( "--listingonly", action="store_true", default=False, dest="listingonly", help="Use data from listing provider, rather than grabber") parser.add_option("--seekdata", action="store_true", default=False, dest="seekdata", help="Copy seekdata from source recording.") parser.add_option("--skiplist", action="store_true", default=False, dest="skiplist", help="Copy commercial detection from source recording.") parser.add_option( "--cutlist", action="store_true", default=False, dest="cutlist", help="Copy manual commercial cuts from source recording.") parser.add_option('-v', '--verbose', action='store', type='string', dest='verbose', help='Verbosity level') opts, args = parser.parse_args() if opts.verbose: if opts.verbose == 'help': print MythLog.helptext sys.exit(0) MythLog._setlevel(opts.verbose) if opts.fmthelp: usage_format() sys.exit(0) if opts.fmtprint: print_format() sys.exit(0) if opts.chanid and opts.starttime: export = VIDEO(opts) elif len(args) == 1: try: export = VIDEO(opts, int(args[0])) except Exception, e: Job(int(args[0])).update({ 'status': 304, 'comment': 'ERROR: ' + e.args[0] }) MythLog(module='mythvidexport.py').logTB(MythLog.IMPORTANT) sys.exit(1)
a = a[2:] if '=' in a: a = a.split('=',1) param[a[0]] = a[1] else: if len(temp): b = temp.pop(0) if (b[:2] == '--') or (b[:1] == '-'): temp.insert(0,b) param[a] = '' else: param[a] = b else: param[a] = '' MythLog._setlevel(param.get('verbose','none')) try: param.pop('verbose') except: pass force = False if 'force' in param: force = True param.pop('force') if len(a) == 0: sys.exit(0) recs = list(MythDB().searchRecorded(**param)) if len(recs) == 0: print 'no matching recordings found'
def __getattr__(self, attr): """Delegate everything but write to the stream""" return getattr(self.out, attr) sys.stdout = OutStreamEncoder(sys.stdout, 'utf8') sys.stderr = OutStreamEncoder(sys.stderr, 'utf8') # Find out if the MythTV python bindings can be accessed and instances can created try: '''If the MythTV python interface is found, required to access Netvision icon directory settings ''' from MythTV import MythDB, MythLog try: '''Create an instance of each: MythDB ''' MythLog._setlevel('none') # Some non option -M cannot have any logging on stdout mythdb = MythDB() except MythError, e: sys.stderr.write(u'\n! Error - %s\n' % e.args[0]) filename = os.path.expanduser("~")+'/.mythtv/config.xml' if not os.path.isfile(filename): sys.stderr.write(u'\n! Error - A correctly configured (%s) file must exist\n' % filename) else: sys.stderr.write(u'\n! Error - Check that (%s) is correctly configured\n' % filename) sys.exit(1) except Exception, e: sys.stderr.write(u"\n! Error - Creating an instance caused an error for one of: MythDB. error(%s)\n" % e) sys.exit(1) except Exception, e: sys.stderr.write(u"\n! Error - MythTV python bindings could not be imported. error(%s)\n" % e) sys.exit(1)
"""Delegate everything but write to the stream""" return getattr(self.out, attr) sys.stdout = OutStreamEncoder(sys.stdout, 'utf8') sys.stderr = OutStreamEncoder(sys.stderr, 'utf8') # Find out if the MythTV python bindings can be accessed and instances can created try: '''If the MythTV python interface is found, required to access Netvision icon directory settings ''' from MythTV import MythDB, MythLog try: '''Create an instance of each: MythDB ''' MythLog._setlevel( 'none') # Some non option -M cannot have any logging on stdout mythdb = MythDB() except MythError, e: sys.stderr.write(u'\n! Error - %s\n' % e.args[0]) filename = os.path.expanduser("~") + '/.mythtv/config.xml' if not os.path.isfile(filename): sys.stderr.write( u'\n! Error - A correctly configured (%s) file must exist\n' % filename) else: sys.stderr.write( u'\n! Error - Check that (%s) is correctly configured\n' % filename) sys.exit(1) except Exception, e: sys.stderr.write(