Ticket #7560: jamu-exit-codes.patch
File jamu-exit-codes.patch, 15.6 KB (added by , 14 years ago) |
---|
-
mythplugins/mythvideo/mythvideo/scripts/jamu.py
397 397 import xml 398 398 except Exception: 399 399 print '''The python module xml must be installed.''' 400 sys.exit( False)400 sys.exit(1) 401 401 if xml.__version__ < u'41660': 402 402 print ''' 403 403 \n! Warning - The module xml (v41660 or greater) must be installed. Your version is different (v%s) than what Jamu was tested with. Jamu may not work on your installation.\nIt is recommended that you upgrade.\n''' % xml.__version__ … … 408 408 except Exception: 409 409 print ''' 410 410 The module MySQLdb (v1.2.2 or greater) must be installed.''' 411 sys.exit( False)411 sys.exit(1) 412 412 if MySQLdb.__version__ < u'1.2.2': 413 413 print ''' 414 414 \n! Warning - The module MySQLdb (v1.2.2 or greater) must be installed. Your version is different (v%s) than what Jamu was tested with. Jamu may not work on your installation.\nIt is recommended that you upgrade.\n''' % MySQLdb.__version__ … … 462 462 The modules tvdb_api.py (v1.0.0 or greater), tvdb_ui.py, tvdb_exceptions.py and cache.py must be 463 463 in the same directory as ttvdb.py. They should have been included with the distribution of ttvdb.py. 464 464 ''' 465 sys.exit( False)465 sys.exit(1) 466 466 467 467 imdb_lib = True 468 468 try: # Check if the installation is equiped to directly search IMDB for movies … … 471 471 sys.stderr.write("\n! Error: To search for movies movies the IMDbPy library must be installed."\ 472 472 "Check your installation's repository or check the following link."\ 473 473 "from (http://imdbpy.sourceforge.net/?page=download)\n") 474 sys.exit( False)474 sys.exit(1) 475 475 476 476 if imdb_lib: 477 477 if imdb.__version__ < "3.8": 478 478 sys.stderr.write("\n! Error: You version the IMDbPy library (%s) is too old. You must use version 3.8 of higher." % imdb.__version__) 479 479 sys.stderr.write("Check your installation's repository or check the following link."\ 480 480 "from (http://imdbpy.sourceforge.net/?page=download)\n") 481 sys.exit( False)481 sys.exit(1) 482 482 483 483 484 484 def isValidPosixFilename(name, NAME_MAX=255): … … 642 642 sys.stderr.write(u"\n! Error: The local Storage group (%s) directory (%s) does not exist or there is a permissions restriction\n" % (key, directory)) 643 643 storagegroup_ok = False 644 644 if not storagegroup_ok: 645 sys.exit( False)645 sys.exit(1) 646 646 # end getStorageGroups 647 647 648 648 # Start of code used to access themoviedb.com api … … 1361 1361 sys.stderr.write( 1362 1362 "\n! Error: The specified user configuration file (%s) is not a file\n" % useroptions 1363 1363 ) 1364 sys.exit( False)1364 sys.exit(1) 1365 1365 cfg = ConfigParser.SafeConfigParser() 1366 1366 cfg.read(useroptions) 1367 1367 for section in cfg.sections(): … … 1400 1400 tmp =cfg.get(section, option).split(',') 1401 1401 if len(tmp)%2 and len(cfg.get(section, option)) != 0: 1402 1402 sys.stderr.write(u"\n! Error: For (%s) 'ep_name_massage' values must be in pairs\n" % option) 1403 sys.exit( False)1403 sys.exit(1) 1404 1404 tmp_array=[] 1405 1405 i=0 1406 1406 while i != len(tmp): … … 1472 1472 ################### Used to create the example configuration file "jamu-example-conf" 1473 1473 # for key in keys: # Used to create the example configuration file "jamu-example-conf" 1474 1474 # print "#%s: %s" % (key, self.config[key]) 1475 # sys.exit( True)1475 # sys.exit(0) 1476 1476 ################## 1477 1477 1478 1478 for key in keys: … … 1513 1513 localip = gethostbyname(localhostname) # Get the local hosts IP address 1514 1514 except: 1515 1515 sys.stderr.write("\n! Error: There is no valid address-to-host mapping for the host (%s)\nThe Jamu Janitor (-MJ) option cannot be used while this issue remains un-resolved.\n" % localhostname) 1516 sys.exit( False)1516 sys.exit(1) 1517 1517 1518 1518 # Get all curently mounted NFS shares 1519 1519 tmp_mounts = callCommandLine("mount -l | grep '//'").split('\n') … … 1566 1566 # Make sure Jamu is being run on a MythTV backend 1567 1567 if not mythdb.getSetting('BackendServerIP', hostname = localhostname): 1568 1568 sys.stderr.write(u"\n! Error: Jamu must be run on a MythTV backend. Local host (%s) is not a MythTV backend.\n" % localhostname) 1569 sys.exit( False)1569 sys.exit(1) 1570 1570 1571 1571 global dir_dict 1572 1572 for key in dir_dict.keys(): … … 1625 1625 self.config[key] = storagegroups[u'mythvideo'] 1626 1626 if not len(self.config[key]): 1627 1627 sys.stderr.write(u"\n! Error: There must be a directory for Videos and each graphic type. The (%s) directory is missing.\n" % (key)) 1628 sys.exit( False)1628 sys.exit(1) 1629 1629 1630 1630 # Make sure that the directory sets for Videos and other graphics directories are RW able 1631 1631 accessable = True … … 1636 1636 accessable = False 1637 1637 1638 1638 if not accessable: 1639 sys.exit( False)1639 sys.exit(1) 1640 1640 1641 1641 # Check if any Video files are on a NFS shares 1642 1642 if not self.config['mythtvNFS']: # Maybe the NFS check is to be skipped 1643 1643 if self._checkNFS(self.config['mythvideo'], self.config['video_file_exts']): 1644 1644 sys.stderr.write(u"\n! Error: Your video files reside on a NFS mount.\nIn the case where you have more than one MythTV backend using the same directories to store either video files\nor graphics any Jamu's option (-M) can adversly effect your MythTV database by mistakenly adding videos\nfor other backends or with the Janitor (-J) option mistakenly remove graphics files.\n\nIf you only have one backend or do not mix the Video or graphic file directories between backends and still want to use\nJamu add the options (N) to your option string e.g. (-MJN), which will skip this check.\n\n") 1645 sys.exit( False)1645 sys.exit(1) 1646 1646 # end _getMythtvDirectories 1647 1647 1648 1648 … … 1736 1736 if self.config['mythtvmeta']: 1737 1737 if mythdb == None or mythvideo == None: 1738 1738 sys.stderr.write(u"\n! Error: The MythTV python interface is not installed or Cannot connect to MythTV Backend. MythTV meta data cannot be updated\n\n") 1739 sys.exit( False)1739 sys.exit(1) 1740 1740 try: 1741 1741 import Image 1742 1742 self.config['image_library'] = Image … … 1746 1746 1747 1747 In Debian/Ubuntu it is packaged as 'python-imaging'. 1748 1748 http://www.pythonware.com/products/pil/\n""") 1749 sys.exit( False)1749 sys.exit(1) 1750 1750 1751 1751 if not _can_int(self.config['min_poster_size']): 1752 1752 sys.stderr.write(u"\n! Error: The poster minimum value must be an integer (%s)\n" % self.config['min_poster_size']) 1753 sys.exit( False)1753 sys.exit(1) 1754 1754 else: 1755 1755 self.config['min_poster_size'] = int(self.config['min_poster_size']) 1756 1756 1757 1757 if self.config['maximum'] != None: 1758 1758 if _can_int(self.config['maximum']) == False: 1759 1759 sys.stderr.write(u"\n! Error: Maximum option is not an integer (%s)\n" % self.config['maximum']) 1760 sys.exit( False)1760 sys.exit(1) 1761 1761 1762 1762 if self.config['mythtvdir']: 1763 1763 if mythdb == None or mythvideo == None: 1764 1764 sys.stderr.write(u"\n! Error: MythTV python interface is not available\n") 1765 sys.exit( False)1765 sys.exit(1) 1766 1766 if self.config['mythtvdir'] or self.config['mythtvmeta']: 1767 1767 self._addMythtvUserFileTypes() # add user filetypes from the "videotypes" table 1768 1768 self._getMythtvDirectories() 1769 1769 if self.config['mythtvjanitor']: # Check for graphic directory conflicts with other plugins 1770 1770 if self._JanitorConflicts(): 1771 sys.exit( False)1771 sys.exit(1) 1772 1772 if not self.config['mythtvNFS']: 1773 1773 global graphicsDirectories, image_extensions 1774 1774 dirs = [] … … 1779 1779 # Check if any Graphics files are on NFS shares 1780 1780 if self._checkNFS(dirs, image_extensions): 1781 1781 sys.stderr.write(u"\n! Error: Your metadata graphics reside on a NFS mount.\nIn the case where you have more than one MythTV backend using the same directories to store your graphics\nthe Jamu's Janitor option (-MJ) will be destructive removing graphics used by the other backend(s).\n\nIf you only have one backend or do not mix the graphics directories between backends and still want to use\nJamu's Janitor use the options (-MJN) which will skip this check.\n\n") 1782 sys.exit( False)1782 sys.exit(1) 1783 1783 1784 1784 if self.config['posterresize'] != False or self.config['fanartresize'] != False: 1785 1785 if _useImageMagick("-version"): 1786 1786 sys.stderr.write(u"\n! Error: ImageMagick is not installed, graphics cannot be resized. posterresize(%s), fanartresize(%s)\n" % (str(self.config['posterresize']), str(self.config['fanartresize']))) 1787 sys.exit( False)1787 sys.exit(1) 1788 1788 1789 1789 if self.config['mythtvmeta'] and len(args) == 0: 1790 1790 args=[''] 1791 1791 1792 1792 if len(args) == 0: 1793 1793 sys.stderr.write(u"\n! Error: At least a video directory, SID or season name must be supplied\n") 1794 sys.exit( False)1794 sys.exit(1) 1795 1795 1796 1796 if os.path.isfile(args[0]) or os.path.isdir(args[0]) or args[0][-1:] == '*': 1797 1797 self.config['video_dir'] = [] … … 1812 1812 if len(args) > 3: 1813 1813 sys.stderr.write("\n! Error: Too many arguments (%d), maximum is three.\n" % len(args)) 1814 1814 print "! args:", args 1815 sys.exit( False)1815 sys.exit(1) 1816 1816 if len(args) == 3 and _can_int(args[1]) and _can_int(args[2]): 1817 1817 self.config['season_num'] = args[1] 1818 1818 self.config['episode_num'] = args[2] 1819 1819 elif len(args) == 3: 1820 1820 sys.stderr.write(u"\n! Error: Season name(%s), season number(%s), episode number (%s) combination is invalid\n" % (args[0], args[1], args[2])) 1821 sys.exit( False)1821 sys.exit(1) 1822 1822 elif len(args) == 2 and _can_int(args[1]): 1823 1823 self.config['season_num'] = args[1] 1824 1824 else: … … 1846 1846 for lang in valid_languages: valid_langs+= lang+', ' 1847 1847 valid_langs=valid_langs[:-2] 1848 1848 sys.stderr.write(u"\n! Error: Specified language(%s) must match one of the following languages supported by thetvdb.com wiki:\n (%s)\n" % (self.config['local_language'], valid_langs)) 1849 sys.exit( False)1849 sys.exit(1) 1850 1850 global UI_search_language 1851 1851 UI_search_language = self.config['local_language'] 1852 1852 … … 2672 2672 sys.stderr.write( 2673 2673 u'\n! Error: There must be at least "season and episode numbers" or "episode name" to request a filename\n' 2674 2674 ) 2675 sys.exit( False)2675 sys.exit(1) 2676 2676 2677 2677 # Special logic must be used if the (-MG) guessing option has been requested 2678 2678 if not self.config['sid'] and self.config['mythtv_guess']: … … 2694 2694 sys.stderr.write( 2695 2695 u'\n! Error: The episode was not found for series(%s), Episode name(%s)\n' % (series_name, episode_name) 2696 2696 ) 2697 sys.exit( False)2697 sys.exit(1) 2698 2698 2699 2699 sid=self.config['sid'] 2700 2700 … … 2991 2991 2992 2992 if len(validFiles) == 0: 2993 2993 sys.stderr.write(u"\n! Error: No valid video files found\n") 2994 sys.exit( False)2994 sys.exit(1) 2995 2995 2996 2996 path_flag = self.config['metadatadir'] 2997 2997 for cfile in validFiles: … … 3445 3445 tmp_files=tmp_array[0].replace(u'file://', u'') 3446 3446 if not os.path.isfile(tmp_files): 3447 3447 sys.stderr.write(u'\n! Error: The graphic file does not exist (%s)\n' % tmp_files) 3448 sys.exit( False)3448 sys.exit(1) 3449 3449 3450 3450 # Fix file extentions in all caps or 4 character JPEG extentions 3451 3451 fileExtension = (_getExtention(tmp_files)).lower() … … 4111 4111 # Destinations must all be directories 4112 4112 if not os.path.isdir(file_dir): 4113 4113 sys.stderr.write(u"\n! Error: Destinations must all be directories.\nThis destination is not a directory (%s)\n" % (file_dir,)) 4114 sys.exit( False)4114 sys.exit(1) 4115 4115 else: 4116 4116 tmp_dir = file_dir 4117 4117 for directory in self.config['mythvideo']: … … 4120 4120 break 4121 4121 else: 4122 4122 sys.stderr.write(u"\n! Error: Destinations must all be a mythvideo directory or subdirectory.\nThis destination (%s) is not one of the Mythvideo directories(%s)\n" % (file_dir, self.config['mythvideo'], )) 4123 sys.exit( False)4123 sys.exit(1) 4124 4124 # Verify that a target file is really a video file. 4125 4125 if file_dir[-1:] != '*': # Skip wildcard file name targets 4126 4126 if os.access(file_dir, os.F_OK | os.R_OK | os.W_OK): # Confirm that the file actually exists … … 4131 4131 break 4132 4132 else: 4133 4133 sys.stderr.write(u"\n! Error: Target files must be video files(%s).\nSupported video file extentions(%s)\n" % (file_dir, self.config['video_file_exts'],)) 4134 sys.exit( False)4134 sys.exit(1) 4135 4135 count+=1 4136 4136 4137 4137 # Stats counters … … 4326 4326 4327 4327 if not len(directories): 4328 4328 sys.stderr.write(u"\n! Error: There must be a video directory specified in MythTv\n") 4329 sys.exit( False)4329 sys.exit(1) 4330 4330 4331 4331 allFiles = self._findFiles(directories, self.config['recursive'] , verbose = self.config['debug_enabled']) 4332 4332 validFiles = self._processNames(allFiles, verbose = self.config['debug_enabled'], movies=True) … … 4681 4681 except MySQLdb.Error, e: 4682 4682 logger.error(u"SELECT intid FROM videometadata WHERE inetref = 99999999 and category = %d failed: %d: %s" % (category_id, e.args[0], e.args[1])) 4683 4683 c.close() 4684 sys.exit( False)4684 sys.exit(1) 4685 4685 intids=[] 4686 4686 while True: 4687 4687 row = c.fetchone() … … 5381 5381 validFiles = self._moveVideoFiles(self.config['video_dir']) 5382 5382 else: 5383 5383 sys.stderr.write(u"\n! Error: When specifying target (file or directory) to move to a destination (directory) they must always be in pairs (target and destination directory).\nYou specified an uneven number of variables (%d) for target and destination pairs.\nVariable count (%s)\n" % (len(self.config['video_dir']), self.config['video_dir'])) 5384 sys.exit( False)5384 sys.exit(1) 5385 5385 5386 5386 # Check if only missing inetref video's should be processed 5387 5387 if self.config['mythtv_inetref']: 5388 5388 validFiles = self._findMissingInetref() 5389 5389 if validFiles == None: 5390 5390 sys.stderr.write(u"\n! Warning: There were no missing interef video files found.\n\n") 5391 sys.exit( True)5391 sys.exit(0) 5392 5392 elif not len(validFiles): 5393 5393 sys.stderr.write(u"\n! Warning: There were no missing interef video files found.\n\n") 5394 sys.exit( True)5394 sys.exit(0) 5395 5395 5396 5396 # Verify that the proper fields are present 5397 5397 db_version = mythdb.getSetting('DBSchemaVer') … … 5399 5399 for field in ['season', 'episode', 'coverfile', 'screenshot', 'banner', 'fanart']: 5400 5400 if not field in field_names: 5401 5401 sys.stderr.write(u"\n! Error: Your MythTv data base scheme version (%s) does not have the necessary fields at least (%s) is missing\n\n" % (db_version, field)) 5402 sys.exit( False)5402 sys.exit(1) 5403 5403 5404 5404 # Check if this is a Scheduled and Recorded graphics download request 5405 5405 if self.config['mythtv_watched']: 5406 5406 self._downloadScheduledRecordedGraphics() 5407 sys.exit( True)5407 sys.exit(0) 5408 5408 5409 5409 # Check if this is just a Janitor (clean up unused graphics files) request 5410 5410 if self.config['mythtvjanitor']: 5411 5411 self._graphicsCleanup() 5412 sys.exit( True)5412 sys.exit(0) 5413 5413 5414 5414 directories=self.config['mythvideo'] 5415 5415 5416 5416 if not len(directories): 5417 5417 sys.stderr.write(u"\n! Error: There must be a video directory specified in MythTv\n") 5418 sys.exit( False)5418 sys.exit(1) 5419 5419 5420 5420 # Set statistics 5421 5421 num_processed=0 … … 5440 5440 5441 5441 if len(validFiles) == 0: 5442 5442 sys.stderr.write(u"\n! Error: No valid video files found\n") 5443 sys.exit( False)5443 sys.exit(1) 5444 5444 5445 5445 tv_series_season_format=u"%s/%s Season %d.%s" 5446 5446 tv_series_format=u"%s/%s.%s" … … 6272 6272 6273 6273 if opts.usage: # Display usage information 6274 6274 sys.stdout.write(usage_txt+'\n') 6275 sys.exit( True)6275 sys.exit(0) 6276 6276 6277 6277 if opts.examples: # Display example information 6278 6278 sys.stdout.write(examples_txt+'\n') 6279 sys.exit( True)6279 sys.exit(0) 6280 6280 6281 6281 if opts.version == True: # Display program information 6282 6282 sys.stdout.write(u"\nTitle: (%s); Version: (%s); Author: (%s)\n%s\n" % ( 6283 6283 __title__, __version__, __author__, __purpose__ )) 6284 sys.exit( True)6284 sys.exit(0) 6285 6285 6286 6286 # Apply any command line switches 6287 6287 configuration.changeVariable('local_language', opts.language) … … 6319 6319 else: 6320 6320 configuration.validate_setVariables(['FAKE SERIES NAME','FAKE EPISODE NAME']) 6321 6321 configuration.displayOptions() 6322 sys.exit( True)6322 sys.exit(0) 6323 6323 6324 6324 # Validate specific variables 6325 6325 configuration.validate_setVariables(series_season_ep)