Thread: [Pypt-offline-general] SF.net SVN: pypt-offline: [162] trunk/pypt_core.py (Page 2)
Status: Beta
Brought to you by:
riteshsarraf
From: <rit...@us...> - 2007-07-29 20:46:40
|
Revision: 162 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=162&view=rev Author: riteshsarraf Date: 2007-07-29 13:46:42 -0700 (Sun, 29 Jul 2007) Log Message: ----------- * Some more formatting fixes * Another Vim v/s Eclipse Editor fight Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-07-29 13:38:20 UTC (rev 161) +++ trunk/pypt_core.py 2007-07-29 20:46:42 UTC (rev 162) @@ -521,10 +521,10 @@ log.err("%s\n" % (e.reason)) if hasattr(e, 'code') and hasattr(e, 'reason'): errfunc(e.code, e.reason, file) + + except socket.timeout: + errfunc(101010, "Socket timeout.", file) - except socket.timeout: - errfunc(101010, "Socket timeout.", file) - def copy_first_match(cache_dir, filename, dest_dir, checksum): # aka new_walk_tree_copy() '''Walks into "reposiotry" looking for "filename". If found, copies it to "dest_dir" but first verifies their md5 "checksum".''' @@ -734,7 +734,7 @@ elif key == 'Upgrade': PackageName = file.split("_")[0] if cache_dir is None: - log.msg("Downloading %s - %d KB\n" % (file, size/1024)) + log.msg("Downloading %s - %d KB\n" % (file, size/1024 ) ) if FetcherInstance.download_from_web(url, file, download_path) != True: errlist.append(PackageName) @@ -758,7 +758,7 @@ else: if find_first_match(cache_dir, file, download_path, checksum) == False: - log.msg("Downloading %s - %d KB\n" % (PackageName, size/1024)) + log.msg("Downloading %s - %d KB\n" % (PackageName, size/1024 ) ) if FetcherInstance.download_from_web(url, file, download_path) != True: errlist.append(PackageName) @@ -852,7 +852,7 @@ exit_status = response.get() if exit_status == False: - log.msg("Downloading %s\n" % (PackageName) ) + log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) if FetcherInstance.download_from_web(url, file, download_path) == True: log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 09:52:06
|
Revision: 163 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=163&view=rev Author: riteshsarraf Date: 2007-08-02 02:52:09 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * The beginning of Offline BugReport support in syncer() Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-07-29 20:46:42 UTC (rev 162) +++ trunk/pypt_core.py 2007-08-02 09:52:09 UTC (rev 163) @@ -1102,8 +1102,18 @@ sys.exit(1) file = zipfile.ZipFile(install_file_path, "r") + bugs_number = [] for filename in file.namelist(): + if filename.endswith(pypt_bug_file_format): + bugs_number += filename + if bugs_number: + printf("I found %d number of bugs.\n" % len(bugs_number) ) + pass + + + for filename in file.namelist(): + data = open(filename, "wb") data.write(file.read(filename)) data.close() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 19:52:16
|
Revision: 165 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=165&view=rev Author: riteshsarraf Date: 2007-08-02 12:52:19 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * Use a while loop to display the choices * Let's make Yes and No to be much simpler * We now can look into the zip archive and search for the file. TODO is to find out what's the best way to display the output - I hope I can use less/more in the more pythonic way Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 19:11:41 UTC (rev 164) +++ trunk/pypt_core.py 2007-08-02 19:52:19 UTC (rev 165) @@ -1113,53 +1113,60 @@ for each_bug in bugs_number: each_bug = each_bug.split('.')[1] log.msg("%s\n" % (each_bug) ) - response = raw_input("What would you like to do next:\t (y, N, Bug Number, ?)" ) - response = response.rstrip("\r") - if response == "?": - log.msg("(yY) Yes. Proceed with installation\n") - log.msg("(nN) No, Abort.\n") - log.msg("(Bug Number) Display the bug report.\n") - log.msg("(?) Display this help message.\n") - elif respone == 'y' or response == 'Y': - pass - elif response == 'n' or response == 'N': - pass - elif response == 'Number': - pass - - printf("I found %d number of bugs.\n" % len(bugs_number) ) - pass + response = '?' + while response == '?': + response = raw_input("What would you like to do next:\t (y, N, Bug Number, ?)" ) + response = response.rstrip("\r") + if response == "?": + log.msg("(Y) Yes. Proceed with installation\n") + log.msg("(N) No, Abort.\n") + log.msg("(Bug Number) Display the bug report from the Offline Bug Reports.\n") + log.msg("(?) Display this help message.\n") + + elif response.startswith('y') or response.startswith('Y'): + for filename in file.namelist(): + + data = open(filename, "wb") + data.write(file.read(filename)) + data.close() + + #FIXME: Fix this tempfile feature + # Access to the temporary file is not being allowed + # It's throwing a Permission denied exception + #try: + # import tempfile + #except ImportError: + # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") + # sys.exit(1) + #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) + #data.write(file.read(filename)) + #data = file.read(filename) + + if pypt_magic.file(os.path.abspath(filename)) == "application/x-bzip2": + archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 1) + elif pypt_magic.file(os.path.abspath(filename)) == "application/x-gzip": + archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 2) + elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + if os.access(target_path, os.W_OK): + shutil.copy(filename, target_path) + log.msg("%s file synced.\n" % (filename)) + os.unlink(filename) + + elif response.startswith('n') or response.startswith('N'): + log.err("Exiting gracefully on user request.\n\n") + sys.exit(1) + + elif response.isdigit() is True: + for full_bug_file_name in bugs_number: + if response in full_bug_file_name: + bug_file_to_display = full_bug_file_name + break + file.read(bug_file_to_display) + # retval = subprocess.call(['less', filename]) + # Do an open in the zip file for the appropriate but report + #for x in bugs_number: - for filename in file.namelist(): - - data = open(filename, "wb") - data.write(file.read(filename)) - data.close() - - #FIXME: Fix this tempfile feature - # Access to the temporary file is not being allowed - # It's throwing a Permission denied exception - #try: - # import tempfile - #except ImportError: - # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") - # sys.exit(1) - #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) - #data.write(file.read(filename)) - #data = file.read(filename) - - # retval = subprocess.call(['less', filename]) - - if pypt_magic.file(os.path.abspath(filename)) == "application/x-bzip2": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 1) - elif pypt_magic.file(os.path.abspath(filename)) == "application/x-gzip": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 2) - elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(filename, target_path) - log.msg("%s file synced.\n" % (filename)) - os.unlink(filename) elif arg_type == 2: archive_file_types = ['application/x-bzip2', 'application/gzip', 'application/zip'] @@ -1379,9 +1386,9 @@ if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too - if os.geteuid() != 0: - log.err("\nYou need superuser privileges to execute this option\n") - sys.exit(1) + #if os.geteuid() != 0: + # log.err("\nYou need superuser privileges to execute this option\n") + # sys.exit(1) if os.path.isfile(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 1) elif os.path.isdir(options.install_upgrade) is True: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 20:11:07
|
Revision: 166 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=166&view=rev Author: riteshsarraf Date: 2007-08-02 13:11:09 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * Added a helper function which detects the correct pager. Taken from IPython Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 19:52:19 UTC (rev 165) +++ trunk/pypt_core.py 2007-08-02 20:11:09 UTC (rev 166) @@ -621,7 +621,23 @@ else: log.err("Aieee! I don't understand this errorcode\n" % (errno)) sys.exit(errno) + +def get_pager_cmd(pager_cmd = None): + if os.name == 'posix': + default_pager_cmd = 'less -r' + elif os.name in ['nt', 'dos']: + default_pager_cmd = 'type' + + if pager_cmd is None: + try: + pager_cmd = os.environ['PAGER'] + except: + pager_cmd = default_pager_cmd + + return pager_cmd + + def fetcher(ArgumentOptions, arg_type = None): ''' uri - The uri data whill will contain the information This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 21:35:05
|
Revision: 167 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=167&view=rev Author: riteshsarraf Date: 2007-08-02 14:34:41 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * Scraped the pager_cmd() and introduced a class instead Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 20:11:09 UTC (rev 166) +++ trunk/pypt_core.py 2007-08-02 21:34:41 UTC (rev 167) @@ -637,7 +637,40 @@ return pager_cmd +class PagerCmd: + def __init__(self, pager_cmd = None): + if os.name == 'posix': + self.default_pager_cmd = 'less -r' + elif os.name in ['nt', 'dos']: + self.default_pager_cmd = 'type' + + if pager_cmd is None: + try: + self.pager_cmd = os.environ['PAGER'] + except: + self.pager_cmd = self.default_pager_cmd + + def send_to_pager(self, String = None): + if String is None: + return False + else: + try: + retval = None # None is correct. On success, None is returned + pager = os.popen(self.pager_cmd, 'w') + pager.write(String.read() ) + #pager.close() + retval = pager.close() + except IOError,msg: # broken pipe when user quits + if msg.args == (32,'Broken pipe'): + retval = None + else: + retval = 1 + except OSError: + retval = 1 + return retval + + def fetcher(ArgumentOptions, arg_type = None): ''' uri - The uri data whill will contain the information @@ -1178,10 +1211,15 @@ if response in full_bug_file_name: bug_file_to_display = full_bug_file_name break - file.read(bug_file_to_display) + display_pager = PagerCmd() + #file.read(bug_file_to_display) + display_pager.send_to_pager(file.read(bug_file_to_display) ) # retval = subprocess.call(['less', filename]) # Do an open in the zip file for the appropriate but report #for x in bugs_number: + else: + log.err('Incorrect choice. Exiting\n') + sys.exit(1) elif arg_type == 2: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 21:36:46
|
Revision: 168 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=168&view=rev Author: riteshsarraf Date: 2007-08-02 14:36:48 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * Use absolute paths. The file was not being saved at the desired location Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 21:34:41 UTC (rev 167) +++ trunk/pypt_core.py 2007-08-02 21:36:48 UTC (rev 168) @@ -699,7 +699,7 @@ if ArgumentOptions.deb_bugs: if ArgumentOptions.zip_it: - FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes, ArgumentOptions.zip_upgrade_file, lock=True) + FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes, ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, lock=True) else: FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes) @@ -799,11 +799,11 @@ if ArgumentOptions.zip_it: log.success("\n%s done.\n" % (PackageName) ) - FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) + FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) os.unlink(os.path.join(download_path, file)) if bug_fetched: - if FetchBugReportsDebian.AddToArchive(ArgumentOptions.zip_upgrade_file): + if FetchBugReportsDebian.AddToArchive(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file): log.verbose("Archived bug reports for package %s to archive %s\n" % (PackageName, ArgumentOptions.zip_upgrade_file) ) else: @@ -830,7 +830,7 @@ log.verbose("Couldn't fetch bug reports for package %s.\n" % (PackageName) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't add %s to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) sys.exit(1) else: @@ -847,7 +847,7 @@ log.err("Couldn't fetch bug reports for package %s.\n" % (PackageName) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't add %s to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) sys.exit(1) else: @@ -942,7 +942,7 @@ if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, full_file_path) is True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, full_file_path) is True: log.success("%s copied from local cache directory %s.%s\n" % (PackageName, cache_dir, LINE_OVERWRITE_MID) ) else: log.err("Couldn't add %s to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_MID) ) @@ -987,7 +987,7 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: @@ -1010,7 +1010,7 @@ #file = file[len(file) - 1] #file = download_path + "/" + file if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: @@ -1056,7 +1056,7 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: @@ -1071,7 +1071,7 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_upgrade_file, file) != True: + if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-02 22:20:23
|
Revision: 169 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=169&view=rev Author: riteshsarraf Date: 2007-08-02 15:20:22 -0700 (Thu, 02 Aug 2007) Log Message: ----------- * Let's cut the crap of joining names and keep it fuckin' simple Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 21:36:48 UTC (rev 168) +++ trunk/pypt_core.py 2007-08-02 22:20:22 UTC (rev 169) @@ -697,12 +697,6 @@ #INFO: For the Progress Bar #progbar = ProgressBar(width = 30) - if ArgumentOptions.deb_bugs: - if ArgumentOptions.zip_it: - FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes, ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, lock=True) - else: - FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes) - if ArgumentOptions.download_dir is None: if os.access("pypt-downloads", os.W_OK) is True: download_path = os.path.abspath("pypt-downloads") @@ -716,7 +710,16 @@ errfunc(1, '') else: download_path = os.path.abspath(ArgumentOptions.download_dir) + + zip_update_file = os.path.join(os.path.abspath(download_path), ArgumentOptions.zip_update_file) + zip_upgrade_file = os.path.join(os.path.abspath(download_path), ArgumentOptions.zip_upgrade_file) + if ArgumentOptions.deb_bugs: + if ArgumentOptions.zip_it: + FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes, zip_upgrade_file, lock=True) + else: + FetchBugReportsDebian = FetchBugReports(pypt_bug_file_format, bugTypes) + FetchData = {} if ArgumentOptions.fetch_update: try: @@ -730,7 +733,7 @@ FetchData['Update'].append(item) if os.access(os.path.join(download_path, ArgumentOptions.zip_update_file), os.F_OK): - log.err("%s already present.\nRemove it first.\n" % (ArgumentOptions.zip_update_file) ) + log.err("%s already present.\nRemove it first.\n" % (zip_update_file) ) sys.exit(1) @@ -746,7 +749,7 @@ FetchData['Upgrade'].append(item) if os.access(os.path.join(download_path, ArgumentOptions.zip_upgrade_file), os.F_OK): - log.err("%s already present.\nRemove it first.\n" % (ArgumentOptions.zip_upgrade_file) ) + log.err("%s already present.\nRemove it first.\n" % (zip_upgrade_file) ) sys.exit(1) del raw_data_list @@ -775,8 +778,8 @@ else: log.success("\n%s done.\n" % (PackageName) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_update_file, file) != True: - log.verbose("%s added to archive %s.\n" % (file, ArgumentOptions.zip_update_file) ) + if FetcherInstance.compress_the_file(zip_update_file, file) != True: + log.verbose("%s added to archive %s.\n" % (file, zip_update_file) ) os.unlink(os.path.join(download_path, file) ) # Remove it because we don't need the file once it is zipped. #sys.exit(1) pass @@ -799,12 +802,12 @@ if ArgumentOptions.zip_it: log.success("\n%s done.\n" % (PackageName) ) - FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) + FetcherInstance.compress_the_file(zip_upgrade_file, file) os.unlink(os.path.join(download_path, file)) if bug_fetched: - if FetchBugReportsDebian.AddToArchive(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file): - log.verbose("Archived bug reports for package %s to archive %s\n" % (PackageName, ArgumentOptions.zip_upgrade_file) ) + if FetchBugReportsDebian.AddToArchive(zip_upgrade_file): + log.verbose("Archived bug reports for package %s to archive %s\n" % (PackageName, zip_upgrade_file) ) else: if find_first_match(cache_dir, file, download_path, checksum) == False: @@ -830,11 +833,11 @@ log.verbose("Couldn't fetch bug reports for package %s.\n" % (PackageName) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't add %s to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't add %s to archive %s.\n" % (file, zip_upgrade_file) ) sys.exit(1) else: - log.verbose("%s added to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) + log.verbose("%s added to archive %s.\n" % (file, zip_upgrade_file) ) os.unlink(os.path.join(download_path, file)) elif True: @@ -847,11 +850,11 @@ log.err("Couldn't fetch bug reports for package %s.\n" % (PackageName) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't add %s to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't add %s to archive %s.\n" % (file, zip_upgrade_file) ) sys.exit(1) else: - log.verbose("%s added to archive %s.\n" % (file, ArgumentOptions.zip_upgrade_file) ) + log.verbose("%s added to archive %s.\n" % (file, zip_upgrade_file) ) os.unlink(os.path.join(download_path, file)) else: #Copy the bug report to the target download_path folder @@ -907,11 +910,11 @@ if FetcherInstance.download_from_web(url, file, download_path) == True: log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.zip_update_file, file) != True: - log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_update_file, LINE_OVERWRITE_MID) ) + if FetcherInstance.compress_the_file(zip_update_file, file) != True: + log.err("Couldn't archive %s to file %s.%s\n" % (file, zip_update_file, LINE_OVERWRITE_MID) ) sys.exit(1) else: - log.verbose("%s added to archive %s.%s\n" % (file, ArgumentOptions.zip_update_file, LINE_OVERWRITE_FULL) ) + log.verbose("%s added to archive %s.%s\n" % (file, zip_update_file, LINE_OVERWRITE_FULL) ) os.unlink(os.path.join(download_path, file) ) else: errlist.append(file) @@ -942,10 +945,10 @@ if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, full_file_path) is True: + if FetcherInstance.compress_the_file(zip_upgrade_file, full_file_path) is True: log.success("%s copied from local cache directory %s.%s\n" % (PackageName, cache_dir, LINE_OVERWRITE_MID) ) else: - log.err("Couldn't add %s to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_MID) ) + log.err("Couldn't add %s to archive %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_MID) ) sys.exit(1) #INFO: If no zip option enabled, simply copy the downloaded package file @@ -987,11 +990,11 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't archive %s to file %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: - log.verbose("%s added to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + log.verbose("%s added to archive %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) os.unlink(os.path.join(download_path, file) ) #INFO: You're and idiot. @@ -1010,11 +1013,11 @@ #file = file[len(file) - 1] #file = download_path + "/" + file if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't archive %s to file %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: - log.verbose("%s added to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + log.verbose("%s added to archive %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) os.unlink(os.path.join(download_path, file) ) else: # Since zip file option is not enabled let's copy the file to the target folder @@ -1056,11 +1059,11 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't archive %s to file %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: - log.verbose("%s added to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + log.verbose("%s added to archive %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) os.unlink(os.path.join(download_path, file) ) else: @@ -1071,11 +1074,11 @@ log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if ArgumentOptions.zip_it: - if FetcherInstance.compress_the_file(ArgumentOptions.download_dir+"/"+ArgumentOptions.zip_upgrade_file, file) != True: - log.err("Couldn't archive %s to file %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + if FetcherInstance.compress_the_file(zip_upgrade_file, file) != True: + log.err("Couldn't archive %s to file %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) sys.exit(1) else: - log.verbose("%s added to archive %s.%s\n" % (file, ArgumentOptions.zip_upgrade_file, LINE_OVERWRITE_SMALL) ) + log.verbose("%s added to archive %s.%s\n" % (file, zip_upgrade_file, LINE_OVERWRITE_SMALL) ) os.unlink(os.path.join(download_path, file) ) log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-03 10:07:28
|
Revision: 170 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=170&view=rev Author: riteshsarraf Date: 2007-08-03 03:07:11 -0700 (Fri, 03 Aug 2007) Log Message: ----------- * Minor changes. Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-02 22:20:22 UTC (rev 169) +++ trunk/pypt_core.py 2007-08-03 10:07:11 UTC (rev 170) @@ -1223,6 +1223,8 @@ else: log.err('Incorrect choice. Exiting\n') sys.exit(1) + else: + log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") elif arg_type == 2: @@ -1443,16 +1445,20 @@ if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too - #if os.geteuid() != 0: - # log.err("\nYou need superuser privileges to execute this option\n") - # sys.exit(1) + try: + if os.geteuid() != 0: + log.err("\nYou need superuser privileges to execute this option\n") + sys.exit(1) + except AttributeError: + log.err("Are you really running the install command on a Debian box?\n") + sys.exit(1) if os.path.isfile(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 1) elif os.path.isdir(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 2) else: log.err("Aieee! %s is unsupported format\n" % (options.install_upgrade)) - sys.exit(0) + sys.exit(0) except KeyboardInterrupt: log.err("\nInterrupted by user. Exiting!\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-05 21:19:42
|
Revision: 171 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=171&view=rev Author: riteshsarraf Date: 2007-08-05 14:19:44 -0700 (Sun, 05 Aug 2007) Log Message: ----------- * Resolved some conflicts for subversion trunk version Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-03 10:07:11 UTC (rev 170) +++ trunk/pypt_core.py 2007-08-05 21:19:44 UTC (rev 171) @@ -638,6 +638,7 @@ return pager_cmd class PagerCmd: + """ Tries to automatically detect and set the pager on the running OS""" def __init__(self, pager_cmd = None): if os.name == 'posix': @@ -652,13 +653,14 @@ self.pager_cmd = self.default_pager_cmd def send_to_pager(self, String = None): + """Writes the String to the pager""" if String is None: return False else: try: retval = None # None is correct. On success, None is returned pager = os.popen(self.pager_cmd, 'w') - pager.write(String.read() ) + pager.write(String) #pager.close() retval = pager.close() except IOError,msg: # broken pipe when user quits @@ -1160,21 +1162,36 @@ if filename.endswith(pypt_bug_file_format): bugs_number.append(filename) + def display_options(): + + log.msg("(Y) Yes. Proceed with installation\n") + log.msg("(N) No, Abort.\n") + log.msg("(R) Redisplay the list of bugs.\n") + log.msg("(Bug Number) Display the bug report from the Offline Bug Reports.\n") + log.msg("(?) Display this help message.\n") + + def get_response(): + response = raw_input("What would you like to do next:\t (y, N, Bug Number, R, ?)" ) + response = response.rstrip("\r") + + return response + if bugs_number: - log.msg("\n\nFollowing are the list of bugs present.\n") - for each_bug in bugs_number: - each_bug = each_bug.split('.')[1] - log.msg("%s\n" % (each_bug) ) - response = '?' - while response == '?': - response = raw_input("What would you like to do next:\t (y, N, Bug Number, ?)" ) - response = response.rstrip("\r") - + def list_bugs(): + log.msg("\n\nFollowing are the list of bugs present.\n") + for each_bug in bugs_number: + each_bug = each_bug.split('.')[1] + log.msg("%s\n" % (each_bug) ) + + # Display the list of bugs + list_bugs() + display_options() + response = get_response() + + while True: if response == "?": - log.msg("(Y) Yes. Proceed with installation\n") - log.msg("(N) No, Abort.\n") - log.msg("(Bug Number) Display the bug report from the Offline Bug Reports.\n") - log.msg("(?) Display this help message.\n") + display_options() + response = get_response() elif response.startswith('y') or response.startswith('Y'): for filename in file.namelist(): @@ -1210,21 +1227,32 @@ sys.exit(1) elif response.isdigit() is True: + found = False for full_bug_file_name in bugs_number: if response in full_bug_file_name: bug_file_to_display = full_bug_file_name + found = True break - display_pager = PagerCmd() - #file.read(bug_file_to_display) - display_pager.send_to_pager(file.read(bug_file_to_display) ) - # retval = subprocess.call(['less', filename]) - # Do an open in the zip file for the appropriate but report - #for x in bugs_number: + if found == False: + log.err("Incorrect bug number %s provided.\n" % (response) ) + response = get_response() + + if found: + display_pager = PagerCmd() + retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) + if retval == 1: + log.err("Broken pager. Can't display the bug details.\n") + # Redisplay the menu + # FIXME: See a pythonic possibility of cleaning the screen at this stage + response = get_response() + + elif response.startswith('r') or response.startswith('R'): + list_bugs() + response = get_response() + else: log.err('Incorrect choice. Exiting\n') sys.exit(1) - else: - log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") elif arg_type == 2: @@ -1440,25 +1468,25 @@ # We're a directory syncer(options, 2) else: - log.err("Aieee! %s is unsupported format\n" % (options.install_update)) - sys.exit(0) + log.err("%s file not found\n" % (options.install_update)) + sys.exit(0) if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too - try: - if os.geteuid() != 0: - log.err("\nYou need superuser privileges to execute this option\n") - sys.exit(1) - except AttributeError: - log.err("Are you really running the install command on a Debian box?\n") - sys.exit(1) + #try: + # if os.geteuid() != 0: + # log.err("\nYou need superuser privileges to execute this option\n") + # sys.exit(1) + #except AttributeError: + # log.err("Are you really running the install command on a Debian box?\n") + # sys.exit(1) if os.path.isfile(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 1) elif os.path.isdir(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 2) else: - log.err("Aieee! %s is unsupported format\n" % (options.install_upgrade)) - sys.exit(0) + log.err("%s file not found\n" % (options.install_upgrade)) + sys.exit(0) except KeyboardInterrupt: log.err("\nInterrupted by user. Exiting!\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-05 21:25:39
|
Revision: 172 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=172&view=rev Author: riteshsarraf Date: 2007-08-05 14:25:42 -0700 (Sun, 05 Aug 2007) Log Message: ----------- * I don't know. Somehow some of the changes got lost by svn's memory. Anyway, since I'm using Mercurial now, I still can provide the changes but not the diff :-( Changes from Mercurial: rrs@learner:~/devel/eclipse/pypt-offline$ hg log -l 10 -v changeset: 134:e1a86c56d820 branch: trunk tag: tip user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 02:22:47 2007 +0530 files: pypt_core.py description: * Separate response from display of options. Thus we now have get_response() * Make sensible display of options, bugs lists et cetera changeset: 133:3a9309f6067f branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 02:12:30 2007 +0530 files: pypt_core.py description: * There is no point in trying to print a bug report for an invalid bug * number entered changeset: 132:cf26c6c29036 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 02:08:25 2007 +0530 files: pypt_core.py description: * Always collect the response when you do a display_options() * If a bug number is invalid, print an error changeset: 131:428efd07f2cb branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 01:43:12 2007 +0530 files: pypt_core.py description: * Handle broken pager. If pager is not found, still show the prompt to the user and let him decide changeset: 130:180ac45f2355 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 01:40:10 2007 +0530 files: pypt_core.py description: * Added some documentation to the PagerCmd class * Only string is written to the pager changeset: 129:be54735f82a2 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 01:30:29 2007 +0530 files: pypt_core.py description: * Move display_options() a little out of the scope * Add list_bugs(). User can re-request for a list of bugs * Error message should be more clear changeset: 128:4b32427620cd branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 00:43:52 2007 +0530 files: pypt_core.py description: * Introduced display_options(). * Once the user goes through the bug report, redisplay the menu again. changeset: 127:e6441f44bab4 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 06 00:36:51 2007 +0530 files: pypt_core.py description: Minor Fix Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-05 21:19:44 UTC (rev 171) +++ trunk/pypt_core.py 2007-08-05 21:25:42 UTC (rev 172) @@ -1253,6 +1253,8 @@ else: log.err('Incorrect choice. Exiting\n') sys.exit(1) + else: + log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") elif arg_type == 2: @@ -1486,7 +1488,7 @@ syncer(options.install_upgrade, apt_package_target_path, 2) else: log.err("%s file not found\n" % (options.install_upgrade)) - sys.exit(0) + sys.exit(0) except KeyboardInterrupt: log.err("\nInterrupted by user. Exiting!\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-09 13:37:59
|
Revision: 175 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=175&view=rev Author: riteshsarraf Date: 2007-08-09 06:38:00 -0700 (Thu, 09 Aug 2007) Log Message: ----------- * Implemented bug report functionality for directories also in syncer(). * Till now it was doing only for zip files * Moved some functions out of the scope for arg 1 because it gets utilized by arg 2 also Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-09 09:50:42 UTC (rev 174) +++ trunk/pypt_core.py 2007-08-09 13:38:00 UTC (rev 175) @@ -1163,6 +1163,26 @@ 2 => install_file_path is a Folder''' archive = Archiver() + + def display_options(): + + log.msg("(Y) Yes. Proceed with installation\n") + log.msg("(N) No, Abort.\n") + log.msg("(R) Redisplay the list of bugs.\n") + log.msg("(Bug Number) Display the bug report from the Offline Bug Reports.\n") + log.msg("(?) Display this help message.\n") + + def get_response(): + response = raw_input("What would you like to do next:\t (y, N, Bug Number, R, ?)" ) + response = response.rstrip("\r") + return response + + def list_bugs(): + log.msg("\n\nFollowing are the list of bugs present.\n") + for each_bug in bugs_number: + each_bug = each_bug.split('.')[1] + log.msg("%s\n" % (each_bug) ) + if arg_type == 1: try: import zipfile @@ -1182,26 +1202,7 @@ if filename.endswith(pypt_bug_file_format): bugs_number.append(filename) - def display_options(): - - log.msg("(Y) Yes. Proceed with installation\n") - log.msg("(N) No, Abort.\n") - log.msg("(R) Redisplay the list of bugs.\n") - log.msg("(Bug Number) Display the bug report from the Offline Bug Reports.\n") - log.msg("(?) Display this help message.\n") - - def get_response(): - response = raw_input("What would you like to do next:\t (y, N, Bug Number, R, ?)" ) - response = response.rstrip("\r") - - return response - if bugs_number: - def list_bugs(): - log.msg("\n\nFollowing are the list of bugs present.\n") - for each_bug in bugs_number: - each_bug = each_bug.split('.')[1] - log.msg("%s\n" % (each_bug) ) # Display the list of bugs list_bugs() @@ -1279,6 +1280,80 @@ elif arg_type == 2: archive_file_types = ['application/x-bzip2', 'application/gzip', 'application/zip'] + + bugs_number = [] + for filename in os.listdir(install_file_path): + if filename.endswith(pypt_bug_file_format): + bugs_number.append(filename) + + if bugs_number: + #Give the choice to the user + list_bugs() + display_options() + response = get_response() + + while True: + if response == "?": + display_options() + response = get_response() + + elif response.startswith('y') or response.startswith('Y'): + + for eachfile in os.listdir(install_file_path): + archive_type = None + try: + import pypt_magic + except ImportError: + log.err("Aieeee! module not found.\n") + sys.exit(1) + + if pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/x-bzip2": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 1) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/gzip": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 2) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/zip": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + if os.access(target_path, os.W_OK): + shutil.copy(os.path.join(install_file_path, eachfile), target_path) + log.msg("%s file synced.\n" % (eachfile)) + else: + log.err("Aieeee! I don't understand filetype %s\n" % (eachfile)) + + elif response.startswith('n') or response.startswith('N'): + log.err("Exiting gracefully on user request.\n\n") + sys.exit(1) + + elif response.isdigit() is True: + found = False + for full_bug_file_name in bugs_number: + if response in full_bug_file_name: + bug_file_to_display = full_bug_file_name + found = True + break + if found == False: + log.err("Incorrect bug number %s provided.\n" % (response) ) + response = get_response() + + if found: + display_pager = PagerCmd() + retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) + if retval == 1: + log.err("Broken pager. Can't display the bug details.\n") + # Redisplay the menu + # FIXME: See a pythonic possibility of cleaning the screen at this stage + response = get_response() + + elif response.startswith('r') or response.startswith('R'): + list_bugs() + response = get_response() + + else: + log.err('Incorrect choice. Exiting\n') + sys.exit(1) + else: + log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") + for eachfile in os.listdir(install_file_path): archive_type = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-09 14:16:23
|
Revision: 176 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=176&view=rev Author: riteshsarraf Date: 2007-08-09 07:16:23 -0700 (Thu, 09 Aug 2007) Log Message: ----------- * change exit values * when no bugs are found, proceed with the installation Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-09 13:38:00 UTC (rev 175) +++ trunk/pypt_core.py 2007-08-09 14:16:23 UTC (rev 176) @@ -1245,7 +1245,7 @@ elif response.startswith('n') or response.startswith('N'): log.err("Exiting gracefully on user request.\n\n") - sys.exit(1) + sys.exit(0) elif response.isdigit() is True: found = False @@ -1276,7 +1276,28 @@ sys.exit(1) else: log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") - + response = raw_input("Continue with Installation. Y/N ?") + response = response.rstrip("\r") + if response.endswith('y') or reponse.endswith('Y'): + log.verbose("Continuing with syncing the files.\n") + for filename in file.namelist(): + + data = open(filename, "wb") + data.write(file.read(filename)) + data.close() + + if pypt_magic.file(os.path.abspath(filename)) == "application/x-bzip2": + archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 1) + elif pypt_magic.file(os.path.abspath(filename)) == "application/x-gzip": + archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 2) + elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + if os.access(target_path, os.W_OK): + shutil.copy(filename, target_path) + log.msg("%s file synced.\n" % (filename)) + os.unlink(filename) + else: + log.msg("Exiting gracefully on user request.\n") + sys.exit(0) elif arg_type == 2: archive_file_types = ['application/x-bzip2', 'application/gzip', 'application/zip'] @@ -1322,7 +1343,7 @@ elif response.startswith('n') or response.startswith('N'): log.err("Exiting gracefully on user request.\n\n") - sys.exit(1) + sys.exit(0) elif response.isdigit() is True: found = False @@ -1353,27 +1374,34 @@ sys.exit(1) else: log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") + response = raw_input("Continue with Installation. Y/N?") + response = response.rstrip("\r") + + if response.startswith('y') or response.startswith('Y'): - for eachfile in os.listdir(install_file_path): - - archive_type = None - try: - import pypt_magic - except ImportError: - log.err("Aieeee! module not found.\n") - - if pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/x-bzip2": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 1) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/gzip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 2) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/zip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(os.path.join(install_file_path, eachfile), target_path) - log.msg("%s file synced.\n" % (eachfile)) + for eachfile in os.listdir(install_file_path): + archive_type = None + try: + import pypt_magic + except ImportError: + log.err("Aieeee! module not found.\n") + sys.exit(1) + + if pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/x-bzip2": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 1) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/gzip": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 2) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/zip": + archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) + elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + if os.access(target_path, os.W_OK): + shutil.copy(os.path.join(install_file_path, eachfile), target_path) + log.msg("%s file synced.\n" % (eachfile)) + else: + log.err("Aieeee! I don't understand filetype %s\n" % (eachfile)) else: - log.err("Aieeee! I don't understand filetype %s\n" % (eachfile)) + log.msg("Exiting gracefully on user request.\n") + sys.exit(0) def main(): '''Here we basically do the sanity checks, some validations @@ -1472,7 +1500,7 @@ os.environ['LANG'] = old_environ else: parser.error("This argument is supported only on Unix like systems with apt installed\n") - sys.exit(0) + sys.exit(1) if options.set_upgrade or options.upgrade_type: if not (options.set_upgrade and options.upgrade_type): @@ -1501,7 +1529,7 @@ parser.error("Invalid upgrade argument type selected\nPlease use one of, upgrade/dist-upgrade/dselect-upgrade\n") else: parser.error("This argument is supported only on Unix like systems with apt installed\n") - sys.exit(0) + sys.exit(1) if options.set_install_packages or options.set_install: if not (options.set_install_packages and options.set_install): @@ -1527,7 +1555,7 @@ log.err("FATAL: Something is wrong with the apt system.\n") else: parser.error("This argument is supported only on Unix like systems with apt installed\n") - sys.exit(0) + sys.exit(1) if options.fetch_update and options.fetch_upgrade: if os.access(options.fetch_update, os.F_OK) and os.access(options.fetch_upgrade, os.F_OK): @@ -1579,7 +1607,7 @@ syncer(options, 2) else: log.err("%s file not found\n" % (options.install_update)) - sys.exit(0) + sys.exit(1) if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too @@ -1596,8 +1624,8 @@ syncer(options.install_upgrade, apt_package_target_path, 2) else: log.err("%s file not found\n" % (options.install_upgrade)) - sys.exit(0) + sys.exit(1) except KeyboardInterrupt: log.err("\nInterrupted by user. Exiting!\n") - sys.exit(1) + sys.exit(0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-09 18:08:34
|
Revision: 177 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=177&view=rev Author: riteshsarraf Date: 2007-08-09 11:08:37 -0700 (Thu, 09 Aug 2007) Log Message: ----------- * Some RCS goofups Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-09 14:16:23 UTC (rev 176) +++ trunk/pypt_core.py 2007-08-09 18:08:37 UTC (rev 177) @@ -1203,7 +1203,6 @@ bugs_number.append(filename) if bugs_number: - # Display the list of bugs list_bugs() display_options() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-09 21:07:56
|
Revision: 178 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=178&view=rev Author: riteshsarraf Date: 2007-08-09 14:07:59 -0700 (Thu, 09 Aug 2007) Log Message: ----------- * Added documentation about ANSI Color Codes for ANSI Compliant Terminals * Now it is just a matter of writing the proper call of colors. * And here comes another Vim v/s Eclipse Editor Indentation problem. Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-09 18:08:37 UTC (rev 177) +++ trunk/pypt_core.py 2007-08-09 21:07:59 UTC (rev 178) @@ -163,6 +163,53 @@ White = 15 Light Red = 12 Light Cyan = 11 + + #FIXME: The Windows Command Interpreter does support colors natively. I think that support has been since Win2k. + + That's all for Windows Command Interpreter. + + + As for ANSI Compliant Terminals (which most Linux/Unix Terminals are.)..... + I think the ANSI Color Codes would be good enough for my requirements to print colored text on an ANSI compliant terminal. + + The ANSI Terminal Specification gives programs the ability to change the text color or background color. + An ansi code begins with the ESC character [^ (ascii 27) followed by a number (or 2 or more separated by a semicolon) and a letter. + + In the case of colour codes, the trailing letter is "m"... + + So as an example, we have ESC[31m ... this will change the foreground colour to red. + + The codes are as follows: + + For Foreground Colors + 1m - Hicolour (bold) mode + 4m - Underline (doesn't seem to work) + 5m - BLINK!! + 8m - Hidden (same colour as bg) + 30m - Black + 31m - Red + 32m - Green + 33m - Yellow + 34m - Blue + 35m - Magenta + 36m - Cyan + 37m - White + + For Background Colors + + 40m - Change Background to Black + 41m - Red + 42m - Green + 43m - Yellow + 44m - Blue + 45m - Magenta + 46m - Cyan + 47m - White + + 7m - Change to Black text on a White bg + 0m - Turn off all attributes. + + Now for example, say I wanted blinking, yellow text on a magenta background... I'd type ESC[45;33;5m ''' def __init__(self, verbose, color = None, lock = None): @@ -206,8 +253,8 @@ sys.stderr.write(msg) sys.stderr.flush() - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + if self.color: + WConio.textcolor(15) #Once the error is displayed, change back to the normal color if self.lock: self.DispLock.release() @@ -224,8 +271,8 @@ sys.stdout.write(msg) sys.stdout.flush() - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + if self.color: + WConio.textcolor(15) #Once the error is displayed, change back to the normal color if self.lock: self.DispLock.release() @@ -244,8 +291,8 @@ sys.stdout.write(msg) sys.stdout.flush() - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + if self.color: + WConio.textcolor(15) #Once the error is displayed, change back to the normal color if self.lock: self.DispLock.release() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-10 12:18:10
|
Revision: 179 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=179&view=rev Author: riteshsarraf Date: 2007-08-10 05:18:13 -0700 (Fri, 10 Aug 2007) Log Message: ----------- * This commit bring the color support for both the platforms - POSIX * Compliant ones and Windows. * For some reasons (which I'm yet to root cause), log.err('Red') doesn't * print in red. * After this commit, testing it on Windows still remains to be done. Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-09 21:07:59 UTC (rev 178) +++ trunk/pypt_core.py 2007-08-10 12:18:13 UTC (rev 179) @@ -43,11 +43,11 @@ except ImportError: pass -WindowColor = True -try: - import WConio -except ImportError: - WindowColor = False +#WindowColor = True +#try: +# import WConio +#except ImportError: +# WindowColor = False '''This is the core module. It does the main job of downloading packages/update packages,\nfiguring out if the packages are in the local cache, handling exceptions and many more stuff''' @@ -212,67 +212,85 @@ Now for example, say I wanted blinking, yellow text on a magenta background... I'd type ESC[45;33;5m ''' - def __init__(self, verbose, color = None, lock = None): - + def __init__(self, verbose, lock = None): + if verbose is True: self.VERBOSE = True else: self.VERBOSE = False - self.color = color + self.color_syntax = '\033[1;' if lock is None or lock != 1: self.DispLock = False else: self.DispLock = threading.Lock() self.lock = True + + if os.name == 'posix': + self.platform = 'posix' + self.color = {'Red': '31m', 'Black': '30m', + 'Green': '32m', 'Yellow': '33m', + 'Blue': '34m', 'Magneta': '35m', + 'Cyan': '36m', 'White': '37m', + 'Bold_Text': '1m', 'Underline': '4m', + 'Blink': '5m', 'SwitchOffAttributes': '0m'} + + elif os.name in ['nt', 'dos']: + self.platform = 'microsoft' + self.color = {'Red': 4, 'Black': 0, + 'Green': 2, 'White': 15, + 'LightRed': 12, 'LightCyan': 11, + 'SwitchOffAttributes': 15} + else: + self.platform = None + self.color = None + + def set_color(self, color): + '''Check the platform and set the color''' + if self.platform == 'posix': + sys.stdout.write(self.color_syntax + self.color[color]) + elif self.platform in ['n', 'dos']: + WConio.textcolor(self.color[color]) + def msg(self, msg): - 'Print general messages' + '''Print general messages. If locking is available use them.''' if self.lock: self.DispLock.acquire(True) - - if self.color: - WConio.textcolor(15) - + + self.set_color('White') sys.stdout.write(msg) sys.stdout.flush() + self.set_color('SwitchOffAttributes') if self.lock: self.DispLock.release() def err(self, msg): - 'Print messages with an error' + '''Print messages with an error. If locking is available use them.''' if self.lock: self.DispLock.acquire(True) - if self.color: - WConio.textcolor(4) - + self.set_color('Red') sys.stderr.write(msg) sys.stderr.flush() - - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + self.set_color('SwitchOffAttributes') if self.lock: self.DispLock.release() def success(self, msg): - 'Print messages with a success' + '''Print messages with a success. If locking is available use them.''' if self.lock: self.DispLock.acquire(True) - if self.color: - WConio.textcolor(2) - + self.set_color('Green') sys.stdout.write(msg) sys.stdout.flush() - - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + self.set_color('SwitchOffAttributes') if self.lock: self.DispLock.release() @@ -280,23 +298,22 @@ # For the rest, we need to check the options also def verbose(self, msg): - 'Print verbose messages' + '''Print verbose messages. If locking is available use them.''' if self.lock: self.DispLock.acquire(True) if self.VERBOSE is True: - if self.color: - WConio.textcolor(11) - + + self.set_color('Cyan') sys.stdout.write(msg) sys.stdout.flush() - if self.color: - WConio.textcolor(15) #Once the error is displayed, change back to the normal color + self.set_color('SwitchOffAttributes') if self.lock: self.DispLock.release() + class Archiver: def __init__(self, lock=None): if lock is None or lock != 1: @@ -1517,7 +1534,7 @@ # The log implementation # Instantiate the class global log - log = Log(options.verbose, WindowColor, lock = True) + log = Log(options.verbose, lock = True) log.msg("pypt-offline %s\n" % (version)) log.msg("Copyright %s\n" % (copyright)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-10 23:08:05
|
Revision: 181 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=181&view=rev Author: riteshsarraf Date: 2007-08-10 16:08:03 -0700 (Fri, 10 Aug 2007) Log Message: ----------- * Change No Bugs log level to 'msg' * Display the bugs subject line also along with the bug number Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-10 22:04:27 UTC (rev 180) +++ trunk/pypt_core.py 2007-08-10 23:08:03 UTC (rev 181) @@ -258,7 +258,7 @@ if self.platform == 'posix': sys.stdout.write(self.color_syntax + self.color[color]) - sys.stderr.write(self.color_syntax + self.color(color)) + sys.stderr.write(self.color_syntax + self.color[color]) elif self.platform == 'microsoft': WConio.textcolor(self.color[color]) @@ -1252,9 +1252,10 @@ def list_bugs(): log.msg("\n\nFollowing are the list of bugs present.\n") - for each_bug in bugs_number: - each_bug = each_bug.split('.')[1] - log.msg("%s\n" % (each_bug) ) + for each_bug in bugs_number.keys(): + bug_num = each_bug.split('.')[1] + bug_subject = bugs_number[each_bug] + log.msg("%s\t%s\n" % (bug_num, bug_subject) ) if arg_type == 1: try: @@ -1270,10 +1271,17 @@ sys.exit(1) file = zipfile.ZipFile(install_file_path, "r") - bugs_number = [] + bugs_number = {} for filename in file.namelist(): if filename.endswith(pypt_bug_file_format): - bugs_number.append(filename) + bug_subject_file = file.read(filename) + bug_subject = bug_subject_file.split('\r') + del bug_subject_file + for subject in bug_subject: + if subject.startswith('#'): + subject = subject.lstrip(subject.split(":")[0]) + break + bugs_number[filename] = subject if bugs_number: # Display the list of bugs @@ -1347,10 +1355,10 @@ log.err('Incorrect choice. Exiting\n') sys.exit(1) else: - log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") + log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") response = raw_input("Continue with Installation. Y/N ?") response = response.rstrip("\r") - if response.endswith('y') or reponse.endswith('Y'): + if response.endswith('y') or response.endswith('Y'): log.verbose("Continuing with syncing the files.\n") for filename in file.namelist(): @@ -1445,7 +1453,7 @@ log.err('Incorrect choice. Exiting\n') sys.exit(1) else: - log.verbose("Great!!! No bugs found for all the packages that were downloaded.\n") + log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") response = raw_input("Continue with Installation. Y/N?") response = response.rstrip("\r") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-11 17:47:25
|
Revision: 182 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=182&view=rev Author: riteshsarraf Date: 2007-08-11 10:47:20 -0700 (Sat, 11 Aug 2007) Log Message: ----------- * Handle socket timeouts. We need to retry for a certain amount for a file untill finally giving up on it. * We also need to make sure that when in between a read of a particular file, we need to retry in case of a timeout. We can't just omit it on 1st timeout. * pypt-offline is supposed to be run at places where internet will be expensive. So obviously it will also be slow. Slow with timeouts..... ;-) * socket exception looks to be errcode 10054 * minor cleanups Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-10 23:08:03 UTC (rev 181) +++ trunk/pypt_core.py 2007-08-11 17:47:20 UTC (rev 182) @@ -72,6 +72,9 @@ LINE_OVERWRITE_MID = " " * 30 LINE_OVERWRITE_FULL = " " * 60 LINE_OVERWRITE_SMALL = " " * 15 + +# How many times should we retry on socket timeouts +SOCKET_TIMEOUT_RETRY = 5 class MD5Check: @@ -579,8 +582,27 @@ #INFO: Add the download thread into the Global ProgressBar Thread self.addItem(size) + socket_counter = 0 while i < size: - data.write (temp.read(block_size)) + socket_timeout = None + try: + data.write (temp.read(block_size)) + except socket.timeout, timeout: + print timeout + socket_timeout = True + socket_counter += 1 + except socket.error, error: + print error + socket_timeout = True + socket_counter += 1 + if socket_counter == SOCKET_TIMEOUT_RETRY: + errfunc(10054, "Max timeout retry count reached. Discontinuing file %s.\n", file) + return False + #break + if socket_timeout is True: + errfunc(10054, "Socket Timeout. Retry - %d\n" % (socket_counter) , file) + continue + increment = min(block_size, size - i) i += block_size counter += 1 @@ -594,21 +616,15 @@ #FIXME: Find out optimal fix for this exception handling except OSError, (errno, strerror): - #log.err("%s\n" %(download_dir)) errfunc(errno, strerror, download_dir) except urllib2.HTTPError, errstring: - #log.err("%s\n" % (file)) errfunc(errstring.code, errstring.msg, file) except urllib2.URLError, errstring: - #We pass error code "1" here becuase URLError - # doesn't pass any error code. # URLErrors shouldn't be ignored, hence program termination if errstring.reason.args[0] == 10060: errfunc(errstring.reason.args[0], errstring.reason, url) - #errfunc(1, errstring.reason) - #pass except IOError, e: if hasattr(e, 'reason'): @@ -617,7 +633,7 @@ errfunc(e.code, e.reason, file) except socket.timeout: - errfunc(101010, "Socket timeout.", file) + errfunc(10054, "Socket timeout.", file) def copy_first_match(cache_dir, filename, dest_dir, checksum): # aka new_walk_tree_copy() '''Walks into "reposiotry" looking for "filename". @@ -684,13 +700,12 @@ This function does the job of behaving accordingly as per the error codes. ''' - error_codes = [-3, 13, 504, 404, 10060, 104, 101010] + error_codes = [-3, 13, 504, 404, 10060, 104, 10054] # 104, 'Connection reset by peer' # 504 is for gateway timeout # 404 is for URL error. Page not found. # 10060 is for Operation Time out. There can be multiple reasons for this timeout - # 101010 - Dummy error code for socket timeouts. FIXME: Find the - # correct socket timeout error code + # 10054 is for Socket Timeout. Socket Timeout are seen during network congestion #TODO: Find out what these error codes are for # and better document them the next time you find it out. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-12 02:55:02
|
Revision: 183 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=183&view=rev Author: riteshsarraf Date: 2007-08-11 19:55:04 -0700 (Sat, 11 Aug 2007) Log Message: ----------- * String Formatting changes Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-11 17:47:20 UTC (rev 182) +++ trunk/pypt_core.py 2007-08-12 02:55:04 UTC (rev 183) @@ -69,9 +69,9 @@ bugTypes = ["Resolved bugs", "Normal bugs", "Minor bugs", "Wishlist items", "FIXED"] #These are spaces which will overwrite the progressbar left mess +LINE_OVERWRITE_SMALL = " " * 10 LINE_OVERWRITE_MID = " " * 30 LINE_OVERWRITE_FULL = " " * 60 -LINE_OVERWRITE_SMALL = " " * 15 # How many times should we retry on socket timeouts SOCKET_TIMEOUT_RETRY = 5 @@ -588,15 +588,13 @@ try: data.write (temp.read(block_size)) except socket.timeout, timeout: - print timeout socket_timeout = True socket_counter += 1 except socket.error, error: - print error socket_timeout = True socket_counter += 1 if socket_counter == SOCKET_TIMEOUT_RETRY: - errfunc(10054, "Max timeout retry count reached. Discontinuing file %s.\n", file) + errfunc(101010, "Max timeout retry count reached. Discontinuing download.\n", file) return False #break if socket_timeout is True: @@ -633,7 +631,7 @@ errfunc(e.code, e.reason, file) except socket.timeout: - errfunc(10054, "Socket timeout.", file) + errfunc(10054, "Socket timeout.\n", file) def copy_first_match(cache_dir, filename, dest_dir, checksum): # aka new_walk_tree_copy() '''Walks into "reposiotry" looking for "filename". @@ -656,7 +654,7 @@ try: shutil.copy(os.path.join(path, file), dest_dir) except shutil.Error: - log.verbose("%s already available in dest_dir. Skipping copy!!!\n\n" % (file)) + log.verbose("%s already available in dest_dir. Skipping copy!!!\n" % (file)) return True return False @@ -700,11 +698,12 @@ This function does the job of behaving accordingly as per the error codes. ''' - error_codes = [-3, 13, 504, 404, 10060, 104, 10054] + error_codes = [-3, 13, 504, 404, 10060, 104, 101010] # 104, 'Connection reset by peer' # 504 is for gateway timeout # 404 is for URL error. Page not found. # 10060 is for Operation Time out. There can be multiple reasons for this timeout + # 101010 is for socket max retry count # 10054 is for Socket Timeout. Socket Timeout are seen during network congestion #TODO: Find out what these error codes are for @@ -712,9 +711,13 @@ # 13 is for "Permission Denied" when you don't have privileges to access the destination if errno in error_codes: log.err("%s - %s - %s.%s\n" % (filename, errno, errormsg, LINE_OVERWRITE_MID)) - log.verbose(" Will still try with other package uris\n\n") + log.verbose("Will still try with other package uris\n") pass + elif errno == 10054: + log.verbose("%s - %s - %s.%s\n" % (filename, errno, errormsg, LINE_OVERWRITE_SMALL) ) + pass + elif errno == 407 or errno == 2: # These, I believe are from OSError/IOError exception. # I'll document it as soon as I confirm it. @@ -882,11 +885,11 @@ PackageName += " - " + temp_file[len(temp_file) - 1] del temp_file - log.msg("Downloading %s\n" % (PackageName) ) + log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if FetcherInstance.download_from_web(url, file, download_path) != True: errlist.append(file) else: - log.success("\n%s done.\n" % (PackageName) ) + log.success("%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) if ArgumentOptions.zip_it: if FetcherInstance.compress_the_file(zip_update_file, file) != True: log.verbose("%s added to archive %s.\n" % (file, zip_update_file) ) @@ -897,7 +900,7 @@ elif key == 'Upgrade': PackageName = file.split("_")[0] if cache_dir is None: - log.msg("Downloading %s - %d KB\n" % (file, size/1024 ) ) + log.msg("Downloading %s - %d KB%s\n" % (file, size/1024, LINE_OVERWRITE_FULL) ) if FetcherInstance.download_from_web(url, file, download_path) != True: errlist.append(PackageName) @@ -911,7 +914,7 @@ log.verbose("Couldn't fetch bug reports for package %s.\n" % (PackageName) ) if ArgumentOptions.zip_it: - log.success("\n%s done.\n" % (PackageName) ) + log.success("%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) FetcherInstance.compress_the_file(zip_upgrade_file, file) os.unlink(os.path.join(download_path, file)) @@ -921,12 +924,12 @@ else: if find_first_match(cache_dir, file, download_path, checksum) == False: - log.msg("Downloading %s - %d KB\n" % (PackageName, size/1024 ) ) + log.msg("Downloading %s - %d KB%s\n" % (PackageName, size/1024, LINE_OVERWRITE_MID) ) if FetcherInstance.download_from_web(url, file, download_path) != True: errlist.append(PackageName) else: - log.success("\n%s done.\n" % (PackageName) ) + log.success("%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) if os.access(os.path.join(cache_dir, file), os.F_OK): log.verbose("%s file is already present in cache-dir %s. Skipping copy.\n" % (file, cache_dir) ) #INFO: The file is already there. else: @@ -1015,7 +1018,7 @@ exit_status = response.get() if exit_status == False: - log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) + log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) if FetcherInstance.download_from_web(url, file, download_path) == True: log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) @@ -1068,7 +1071,7 @@ shutil.copy(full_file_path, download_path) log.success("%s copied from local cache directory %s.%s\n" % (PackageName, cache_dir, LINE_OVERWRITE_MID) ) except shutil.Error: - log.verbose("%s already available in %s. Skipping copy!!!%s\n\n" % (file, download_path, LINE_OVERWRITE_MID) ) + log.verbose("%s already available in %s. Skipping copy!!!%s\n" % (file, download_path, LINE_OVERWRITE_MID) ) if bug_fetched == 1: for x in os.listdir(os.curdir): @@ -1080,7 +1083,7 @@ # The file is corrupted and we need to download a new copy from the internet else: log.verbose("%s MD5 checksum mismatch. Skipping file.%s\n" % (file, LINE_OVERWRITE_FULL) ) - log.msg("Downloading %s - %d KB%s\n" % (PackageName, download_size/1024, LINE_OVERWRITE_FULL) ) + log.msg("Downloading %s - %d KB%s\n" % (PackageName, download_size/1024, LINE_OVERWRITE_MID) ) if FetcherInstance.download_from_web(url, file, download_path) == True: log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) ) @@ -1090,7 +1093,7 @@ shutil.copy(file, cache_dir) log.verbose("%s copied to local cache directory %s.%s\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_MID) ) except shutil.Error: - log.verbose("Couldn't copy %s to %s.%s\n\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_FULL) ) + log.verbose("Couldn't copy %s to %s.%s\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_FULL) ) #Fetch bug reports if ArgumentOptions.deb_bugs: @@ -1135,7 +1138,7 @@ shutil.copy(full_file_path, download_path) log.success("%s copied from local cache directory %s.%s\n" % (file, cache_dir, LINE_OVERWRITE_SMALL) ) except shutil.Error: - log.verbose("%s already available in dest_dir. Skipping copy!!!%s\n\n" % (file, LINE_OVERWRITE_SMALL) ) + log.verbose("%s already available in dest_dir. Skipping copy!!!%s\n" % (file, LINE_OVERWRITE_SMALL) ) # And also the bug reports if bug_fetched == 1: @@ -1148,7 +1151,7 @@ #INFO: This block gets executed if the file is not found in local cache_dir or cache_dir is None # We go ahead and try to download it from the internet log.verbose("%s not available in local cache %s.%s\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_MID) ) - log.msg("Downloading %s - %d KB%s\n" % (PackageName, download_size/1024, LINE_OVERWRITE_FULL) ) + log.msg("Downloading %s - %d KB%s\n" % (PackageName, download_size/1024, LINE_OVERWRITE_MID) ) if FetcherInstance.download_from_web(url, file, download_path) == True: #INFO: This block gets executed if md5checksum is allowed @@ -1160,7 +1163,7 @@ shutil.copy(file, ArgumentOptions.cache_dir) log.verbose("%s copied to local cache directory %s.%s\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_MID) ) except shutil.Error: - log.verbose("%s already available in %s. Skipping copy!!!%s\n\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_MID) ) + log.verbose("%s already available in %s. Skipping copy!!!%s\n" % (file, ArgumentOptions.cache_dir, LINE_OVERWRITE_MID) ) if ArgumentOptions.deb_bugs: if FetchBugReportsDebian.FetchBugsDebian(PackageName): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-12 20:31:06
|
Revision: 184 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=184&view=rev Author: riteshsarraf Date: 2007-08-12 13:31:08 -0700 (Sun, 12 Aug 2007) Log Message: ----------- * It was very wrong to put a try: without a proper exception clause. Never do it. * Fixed TarGzipBZ2_Uncompress() call. It was stupidly wrong written. * Some string formatting fixes * Pass syncer a more descriptive variable name and identify whether bug parsing is required or not. For updates, we don't do bug parsing. * Put the imports more properly. The import doesn't need to be done separately under each if * Unclutter the code for pypt_magic parsing. Introduced the magic_check_and_uncompress() * In magic_check_and_uncompress, for bug report files, we don't need to do anything to them and should safely ignore them Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-12 02:55:04 UTC (rev 183) +++ trunk/pypt_core.py 2007-08-12 20:31:08 UTC (rev 184) @@ -378,17 +378,17 @@ except ImportError: return False - try: - read_from = bz2.BZ2File(archive_file, 'r') - except: - return False + #try: + read_from = bz2.BZ2File(archive_file, 'r') + #except: + # return False - try: - write_to = open (os.path.join(path, filename), 'wb') - except: - return False + #try: + write_to = open (os.path.join(path, target_file), 'wb') + #except: + # return False - if TarGzipBZ2_Uncomprerssed(read_from, write_to) != True: + if self.TarGzipBZ2_Uncompress(read_from, write_to) != True: raise ArchiveError write_to.close() read_from.close() @@ -400,17 +400,17 @@ except ImportError: return False - try: - read_from = gzip.GzipFile(file, 'r') - except: - return False + #try: + read_from = gzip.GzipFile(file, 'r') + #except: + # return False - try: - write_to = open(os.path.join(path,filename), 'wb') - except: - return False + #try: + write_to = open(os.path.join(path,filename), 'wb') + #except: + # return False - if TarGzipBZ2_Uncomprerssed(read_from, write_to) != True: + if self.TarGzipBZ2_Uncompress(read_from, write_to) != True: raise ArchiveError write_to.close() read_from.close() @@ -418,10 +418,10 @@ elif archive_type is 3: # FIXME: This looks odd. Where are we writing to a file ??? - try: - zip_file = zipfile.ZipFile(file, 'rb') - except: - return False + #try: + zip_file = zipfile.ZipFile(file, 'rb') + #except: + # return False for filename in zip_file.namelist(): data = zip_file.read() @@ -730,7 +730,7 @@ sys.exit(errno) else: - log.err("Aieee! I don't understand this errorcode\n" % (errno)) + log.err("Error: I don't understand this errorcode\n" % (errno)) sys.exit(errno) def get_pager_cmd(pager_cmd = None): @@ -819,7 +819,7 @@ os.mkdir("pypt-downloads") download_path = os.path.abspath("pypt-downloads") except: - log.err("Aieeee! I couldn't create a directory") + log.err("Error: I couldn't create a directory") errfunc(1, '') else: download_path = os.path.abspath(ArgumentOptions.download_dir) @@ -1243,18 +1243,27 @@ for error in errlist: log.err("%s failed.\n" % (error)) -def syncer(install_file_path, target_path, arg_type=None): - '''Syncer does the work of syncing the downloaded files. +def syncer(install_file_path, target_path, path_type=None, bug_parse_required=None): + ''' + Syncer does the work of syncing the downloaded files. It syncs "install_file_path" which could be a valid file path or a zip archive to "target_path" - arg_type defines whether install_file_path is a zip file + path_type defines whether install_file_path is a zip file or a folder path + # path_type 1 => install_file_path is a File - 2 => install_file_path is a Folder''' + 2 => install_file_path is a Folder + ''' archive = Archiver() + try: + import pypt_magic + except ImportError: + log.err("Error: Module pypt_magic not found.\n") + sys.exit(1) + def display_options(): log.msg("(Y) Yes. Proceed with installation\n") @@ -1275,231 +1284,235 @@ bug_subject = bugs_number[each_bug] log.msg("%s\t%s\n" % (bug_num, bug_subject) ) - if arg_type == 1: + def magic_check_and_uncompress(archive_file=None, target_path=None, filename=None, Mode=None): + + if pypt_magic.file(archive_file) == "application/x-bzip2": + retval = archive.decompress_the_file(archive_file, target_path, filename, 1) + elif pypt_magic.file(archive_file) == "application/x-gzip": + retval = archive.decompress_the_file(archive_file, target_path, filename, 2) + elif pypt_magic.file(archive_file) == "application/zip": + retval = archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) + elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + if os.access(target_path, os.W_OK): + shutil.copy(filename, target_path) + retval = True + else: + log.err("ERROR: Cannot write to target path %s.\n" % (target_path) ) + elif filename.endswith(pypt_bug_file_format): + retval = False # We intentionally put the bug report files as not printed. + else: + log.err("ERROR: I couldn't understand file type %s.\n" % (filename) ) + if retval is True: + log.msg("%s file synced.\n" % (filename)) + os.unlink(archive_file) + + if path_type == 1: + try: import zipfile except ImportError: - log.err("Aieeee! Module zipfile not found.\n") + log.err("Error: Module zipfile not found.\n") sys.exit(1) - try: - import pypt_magic - except ImportError: - log.err("Aieeee! Module pypt_magic not found.\n") - sys.exit(1) - file = zipfile.ZipFile(install_file_path, "r") - bugs_number = {} - for filename in file.namelist(): - if filename.endswith(pypt_bug_file_format): - bug_subject_file = file.read(filename) - bug_subject = bug_subject_file.split('\r') - del bug_subject_file - for subject in bug_subject: - if subject.startswith('#'): - subject = subject.lstrip(subject.split(":")[0]) - break - bugs_number[filename] = subject + if bug_parse_required is True: - if bugs_number: - # Display the list of bugs - list_bugs() - display_options() - response = get_response() - - while True: - if response == "?": - display_options() - response = get_response() + bugs_number = {} + for filename in file.namelist(): + if filename.endswith(pypt_bug_file_format): + bug_subject_file = file.read(filename) + bug_subject = bug_subject_file.split('\r') + del bug_subject_file + for subject in bug_subject: + if subject.startswith('#'): + subject = subject.lstrip(subject.split(":")[0]) + break + bugs_number[filename] = subject - elif response.startswith('y') or response.startswith('Y'): + if bugs_number: + # Display the list of bugs + list_bugs() + display_options() + response = get_response() + + while True: + if response == "?": + display_options() + response = get_response() + + elif response.startswith('y') or response.startswith('Y'): + for filename in file.namelist(): + + data = open(filename, "wb") + data.write(file.read(filename)) + data.close() + + #FIXME: Fix this tempfile feature + # Access to the temporary file is not being allowed + # It's throwing a Permission denied exception + #try: + # import tempfile + #except ImportError: + # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") + # sys.exit(1) + #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) + #data.write(file.read(filename)) + #data = file.read(filename) + + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + sys.exit(0) + + elif response.startswith('n') or response.startswith('N'): + log.err("Exiting gracefully on user request.\n\n") + sys.exit(0) + + elif response.isdigit() is True: + found = False + for full_bug_file_name in bugs_number: + if response in full_bug_file_name: + bug_file_to_display = full_bug_file_name + found = True + break + if found == False: + log.err("Incorrect bug number %s provided.\n" % (response) ) + response = get_response() + + if found: + display_pager = PagerCmd() + retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) + if retval == 1: + log.err("Broken pager. Can't display the bug details.\n") + # Redisplay the menu + # FIXME: See a pythonic possibility of cleaning the screen at this stage + response = get_response() + + elif response.startswith('r') or response.startswith('R'): + list_bugs() + response = get_response() + + else: + log.err('Incorrect choice. Exiting\n') + sys.exit(1) + else: + log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") + response = raw_input("Continue with Installation. Y/N ?") + response = response.rstrip("\r") + if response.endswith('y') or response.endswith('Y'): + log.verbose("Continuing with syncing the files.\n") for filename in file.namelist(): data = open(filename, "wb") data.write(file.read(filename)) data.close() - #FIXME: Fix this tempfile feature - # Access to the temporary file is not being allowed - # It's throwing a Permission denied exception - #try: - # import tempfile - #except ImportError: - # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") - # sys.exit(1) - #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) - #data.write(file.read(filename)) - #data = file.read(filename) - - if pypt_magic.file(os.path.abspath(filename)) == "application/x-bzip2": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 1) - elif pypt_magic.file(os.path.abspath(filename)) == "application/x-gzip": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 2) - elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(filename, target_path) - log.msg("%s file synced.\n" % (filename)) - os.unlink(filename) - - elif response.startswith('n') or response.startswith('N'): - log.err("Exiting gracefully on user request.\n\n") + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + else: + log.msg("Exiting gracefully on user request.\n") sys.exit(0) + elif bug_parse_required is False: + + for filename in file.namelist(): + + data = open(filename, "wb") + data.write(file.read(filename)) + data.close() + + #FIXME: Fix this tempfile feature + # Access to the temporary file is not being allowed + # It's throwing a Permission denied exception + #try: + # import tempfile + #except ImportError: + # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") + # sys.exit(1) + #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) + #data.write(file.read(filename)) + #data = file.read(filename) + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + else: + log.err("ERROR: Inappropriate argument sent to syncer during data fetch. Do you need to fetch bugs or not?\n") + sys.exit(1) + + elif path_type == 2: + archive_file_types = ['application/x-bzip2', 'application/gzip', 'application/zip'] + + if bug_parse_required is True: + bugs_number = [] + for filename in os.listdir(install_file_path): + if filename.endswith(pypt_bug_file_format): + bugs_number.append(filename) - elif response.isdigit() is True: - found = False - for full_bug_file_name in bugs_number: - if response in full_bug_file_name: - bug_file_to_display = full_bug_file_name - found = True - break - if found == False: - log.err("Incorrect bug number %s provided.\n" % (response) ) + if bugs_number: + #Give the choice to the user + list_bugs() + display_options() + response = get_response() + + while True: + if response == "?": + display_options() response = get_response() - - if found: - display_pager = PagerCmd() - retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) - if retval == 1: - log.err("Broken pager. Can't display the bug details.\n") - # Redisplay the menu - # FIXME: See a pythonic possibility of cleaning the screen at this stage + + elif response.startswith('y') or response.startswith('Y'): + + for eachfile in os.listdir(install_file_path): + archive_type = None + + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + + elif response.startswith('n') or response.startswith('N'): + log.err("Exiting gracefully on user request.\n\n") + sys.exit(0) + + elif response.isdigit() is True: + found = False + for full_bug_file_name in bugs_number: + if response in full_bug_file_name: + bug_file_to_display = full_bug_file_name + found = True + break + if found == False: + log.err("Incorrect bug number %s provided.\n" % (response) ) + response = get_response() + + if found: + display_pager = PagerCmd() + retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) + if retval == 1: + log.err("Broken pager. Can't display the bug details.\n") + # Redisplay the menu + # FIXME: See a pythonic possibility of cleaning the screen at this stage + response = get_response() + + elif response.startswith('r') or response.startswith('R'): + list_bugs() response = get_response() - - elif response.startswith('r') or response.startswith('R'): - list_bugs() - response = get_response() - - else: - log.err('Incorrect choice. Exiting\n') - sys.exit(1) - else: - log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") - response = raw_input("Continue with Installation. Y/N ?") - response = response.rstrip("\r") - if response.endswith('y') or response.endswith('Y'): - log.verbose("Continuing with syncing the files.\n") - for filename in file.namelist(): - - data = open(filename, "wb") - data.write(file.read(filename)) - data.close() - - if pypt_magic.file(os.path.abspath(filename)) == "application/x-bzip2": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 1) - elif pypt_magic.file(os.path.abspath(filename)) == "application/x-gzip": - archive.decompress_the_file(os.path.abspath(filename), target_path, filename, 2) - elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(filename, target_path) - log.msg("%s file synced.\n" % (filename)) - os.unlink(filename) + + else: + log.err('Incorrect choice. Exiting\n') + sys.exit(1) else: - log.msg("Exiting gracefully on user request.\n") - sys.exit(0) + log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") + response = raw_input("Continue with Installation. Y/N?") + response = response.rstrip("\r") - elif arg_type == 2: - archive_file_types = ['application/x-bzip2', 'application/gzip', 'application/zip'] - - bugs_number = [] - for filename in os.listdir(install_file_path): - if filename.endswith(pypt_bug_file_format): - bugs_number.append(filename) - - if bugs_number: - #Give the choice to the user - list_bugs() - display_options() - response = get_response() - - while True: - if response == "?": - display_options() - response = get_response() - - elif response.startswith('y') or response.startswith('Y'): - + if response.startswith('y') or response.startswith('Y'): + for eachfile in os.listdir(install_file_path): archive_type = None - try: - import pypt_magic - except ImportError: - log.err("Aieeee! module not found.\n") - sys.exit(1) - if pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/x-bzip2": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 1) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/gzip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 2) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/zip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(os.path.join(install_file_path, eachfile), target_path) - log.msg("%s file synced.\n" % (eachfile)) - else: - log.err("Aieeee! I don't understand filetype %s\n" % (eachfile)) - - elif response.startswith('n') or response.startswith('N'): - log.err("Exiting gracefully on user request.\n\n") + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + else: + log.msg("Exiting gracefully on user request.\n") sys.exit(0) + elif bug_parse_required is False: + for eachfile in os.listdir(install_file_path): + archive_type = None - elif response.isdigit() is True: - found = False - for full_bug_file_name in bugs_number: - if response in full_bug_file_name: - bug_file_to_display = full_bug_file_name - found = True - break - if found == False: - log.err("Incorrect bug number %s provided.\n" % (response) ) - response = get_response() - - if found: - display_pager = PagerCmd() - retval = display_pager.send_to_pager(file.read(bug_file_to_display) ) - if retval == 1: - log.err("Broken pager. Can't display the bug details.\n") - # Redisplay the menu - # FIXME: See a pythonic possibility of cleaning the screen at this stage - response = get_response() - - elif response.startswith('r') or response.startswith('R'): - list_bugs() - response = get_response() - - else: - log.err('Incorrect choice. Exiting\n') - sys.exit(1) + magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) else: - log.msg("Great!!! No bugs found for all the packages that were downloaded.\n") - response = raw_input("Continue with Installation. Y/N?") - response = response.rstrip("\r") - - if response.startswith('y') or response.startswith('Y'): - - for eachfile in os.listdir(install_file_path): - archive_type = None - try: - import pypt_magic - except ImportError: - log.err("Aieeee! module not found.\n") - sys.exit(1) - - if pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/x-bzip2": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 1) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/gzip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 2) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "application/zip": - archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) - elif pypt_magic.file(os.path.join(install_file_path, eachfile)) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": - if os.access(target_path, os.W_OK): - shutil.copy(os.path.join(install_file_path, eachfile), target_path) - log.msg("%s file synced.\n" % (eachfile)) - else: - log.err("Aieeee! I don't understand filetype %s\n" % (eachfile)) - else: - log.msg("Exiting gracefully on user request.\n") - sys.exit(0) + log.err("ERROR: Inappropriate argument sent to syncer during data fetch. Do you need to fetch bugs or not?\n") + sys.exit(1) def main(): '''Here we basically do the sanity checks, some validations @@ -1693,33 +1706,37 @@ if options.install_update: #INFO: Comment these lines to do testing on Windows machines too - if os.geteuid() != 0: - log.err("\nYou need superuser privileges to execute this option\n") - sys.exit(1) + #try: + # if os.geteuid() != 0: + # log.err("\nYou need superuser privileges to execute this option\n") + # sys.exit(1) + #except AttributeError: + # log.err("Are you really running the install command on a Debian box?\n") + # sys.exit(1) if os.path.isfile(options.install_update) is True: # Okay! We're a file. It should be a zip file - syncer(options, 1) + syncer(options.install_update, apt_update_target_path, 1, bug_parse_required = False) elif os.path.isdir(options.install_update) is True: # We're a directory - syncer(options, 2) + syncer(options.install_update, apt_update_target_path, 1, bug_parse_required = False) else: log.err("%s file not found\n" % (options.install_update)) sys.exit(1) if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too - #try: - # if os.geteuid() != 0: - # log.err("\nYou need superuser privileges to execute this option\n") - # sys.exit(1) - #except AttributeError: - # log.err("Are you really running the install command on a Debian box?\n") - # sys.exit(1) + try: + if os.geteuid() != 0: + log.err("\nYou need superuser privileges to execute this option\n") + sys.exit(1) + ... [truncated message content] |
From: <rit...@us...> - 2007-08-13 20:51:02
|
Revision: 185 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=185&view=rev Author: riteshsarraf Date: 2007-08-13 13:51:03 -0700 (Mon, 13 Aug 2007) Log Message: ----------- rrs@learner:~/devel/eclipse/pypt-offline$ hg log -l 6 -v changeset: 164:0e25f5b1fd9a branch: trunk tag: tip user: Ritesh Raj Sarraf <rr...@re...> date: Tue Aug 14 02:10:06 2007 +0530 files: pypt_core.py description: * Updated all magic_check_and_uncompress() call's with proper arguments * Catch IOError in Archiver changeset: 163:6305da9154bd branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Tue Aug 14 01:47:37 2007 +0530 files: pypt_core.py description: * We were checking for the wrong file in pypt_magic.file() * Same was for shutil.copy * Fixed the temporary file write stull. tempfile is much better to do it. changeset: 162:97589b94d83a branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Tue Aug 14 01:23:15 2007 +0530 files: pypt_core.py description: * When the target path is not writable, we indeed need to errorout and exit. changeset: 161:01818b3bab35 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Tue Aug 14 01:05:25 2007 +0530 files: pypt_core.py description: * Let's hope that this way of trying to get the bug's subject works * properly everywhere. changeset: 160:ae2409fc7057 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 13 04:50:22 2007 +0530 files: pypt_core.py description: * String Formatiing updates changeset: 159:93d78fc4d770 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Mon Aug 13 02:33:20 2007 +0530 files: pypt_core.py description: * Fixed variable vame error Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-12 20:31:08 UTC (rev 184) +++ trunk/pypt_core.py 2007-08-13 20:51:03 UTC (rev 185) @@ -29,6 +29,7 @@ import optparse import array import socket +import tempfile from array import array @@ -55,7 +56,7 @@ version = "0.7.0" copyright = "(C) 2005 - 2007 Ritesh Raj Sarraf - RESEARCHUT (http://www.researchut.com/)" terminal_license = "This program comes with ABSOLUTELY NO WARRANTY.\n\ -This is free software, and you are welcome to redistribute it under certain conditions.\n" +This is free software, and you are welcome to redistribute it under certain conditions.\n\n\n" errlist = [] supported_platforms = ["Linux", "GNU/kFreeBSD", "GNU"] @@ -378,15 +379,15 @@ except ImportError: return False - #try: - read_from = bz2.BZ2File(archive_file, 'r') - #except: - # return False + try: + read_from = bz2.BZ2File(archive_file, 'r') + except IOError: + return False - #try: - write_to = open (os.path.join(path, target_file), 'wb') - #except: - # return False + try: + write_to = open (os.path.join(path, target_file), 'wb') + except IOError: + return False if self.TarGzipBZ2_Uncompress(read_from, write_to) != True: raise ArchiveError @@ -400,15 +401,15 @@ except ImportError: return False - #try: - read_from = gzip.GzipFile(file, 'r') - #except: - # return False + try: + read_from = gzip.GzipFile(archive_file, 'r') + except IOError: + return False - #try: - write_to = open(os.path.join(path,filename), 'wb') - #except: - # return False + try: + write_to = open(os.path.join(path,target_file), 'wb') + except IOError: + return False if self.TarGzipBZ2_Uncompress(read_from, write_to) != True: raise ArchiveError @@ -1292,19 +1293,19 @@ retval = archive.decompress_the_file(archive_file, target_path, filename, 2) elif pypt_magic.file(archive_file) == "application/zip": retval = archive.decompress_the_file(os.path.join(install_file_path, eachfile), target_path, eachfile, 3) - elif pypt_magic.file(filename) == "PGP armored data" or pypt_magic.file(filename) == "application/x-dpkg": + elif pypt_magic.file(archive_file) == "PGP armored data" or pypt_magic.file(archive_file) == "application/x-dpkg": if os.access(target_path, os.W_OK): - shutil.copy(filename, target_path) + shutil.copy(archive_file, target_path + filename) retval = True else: - log.err("ERROR: Cannot write to target path %s.\n" % (target_path) ) + log.err("ERROR: Cannot write to target path %s\n" % (target_path) ) + sys.exit(1) elif filename.endswith(pypt_bug_file_format): retval = False # We intentionally put the bug report files as not printed. else: log.err("ERROR: I couldn't understand file type %s.\n" % (filename) ) if retval is True: log.msg("%s file synced.\n" % (filename)) - os.unlink(archive_file) if path_type == 1: @@ -1320,14 +1321,17 @@ bugs_number = {} for filename in file.namelist(): if filename.endswith(pypt_bug_file_format): - bug_subject_file = file.read(filename) - bug_subject = bug_subject_file.split('\r') - del bug_subject_file - for subject in bug_subject: - if subject.startswith('#'): - subject = subject.lstrip(subject.split(":")[0]) + temp = tempfile.NamedTemporaryFile() + temp.file.write(file.read(filename)) + temp.file.flush() + temp.file.seek(0) #Let's go back to the start of the file + for bug_subject_identifier in temp.file.readlines(): + if bug_subject_identifier.startswith('#'): + subject = bug_subject_identifier.lstrip(bug_subject_identifier.split(":")[0]) + subject = subject.rstrip("\n") break bugs_number[filename] = subject + temp.file.close() if bugs_number: # Display the list of bugs @@ -1343,23 +1347,13 @@ elif response.startswith('y') or response.startswith('Y'): for filename in file.namelist(): - data = open(filename, "wb") - data.write(file.read(filename)) - data.close() + data = tempfile.NamedTemporaryFile() + data.file.write(file.read(filename)) + data.file.flush() + archive_file = data.name - #FIXME: Fix this tempfile feature - # Access to the temporary file is not being allowed - # It's throwing a Permission denied exception - #try: - # import tempfile - #except ImportError: - # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") - # sys.exit(1) - #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) - #data.write(file.read(filename)) - #data = file.read(filename) - - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + magic_check_and_uncompress(archive_file, target_path, filename) + data.file.close() sys.exit(0) elif response.startswith('n') or response.startswith('N'): @@ -1401,11 +1395,13 @@ log.verbose("Continuing with syncing the files.\n") for filename in file.namelist(): - data = open(filename, "wb") - data.write(file.read(filename)) - data.close() - - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + data = tempfile.NamedTemporaryFile() + data.file.write(file.read(filename)) + data.file.flush() + archive_file = data.name + + magic_check_and_uncompress(archive_file, target_path, filename) + data.file.close() else: log.msg("Exiting gracefully on user request.\n") sys.exit(0) @@ -1413,22 +1409,13 @@ for filename in file.namelist(): - data = open(filename, "wb") - data.write(file.read(filename)) - data.close() + data = tempfile.NamedTemporaryFile() + data.file.write(file.read(filename)) + data.file.flush() + archive_file = data.name - #FIXME: Fix this tempfile feature - # Access to the temporary file is not being allowed - # It's throwing a Permission denied exception - #try: - # import tempfile - #except ImportError: - # sys.stderr.write("Aieeee! Module pypt_magic not found.\n") - # sys.exit(1) - #data = tempfile.NamedTemporaryFile('wb', -1, '', '', os.curdir) - #data.write(file.read(filename)) - #data = file.read(filename) - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + magic_check_and_uncompress(archive_file, target_path, filename) + data.file.close() else: log.err("ERROR: Inappropriate argument sent to syncer during data fetch. Do you need to fetch bugs or not?\n") sys.exit(1) @@ -1458,7 +1445,7 @@ for eachfile in os.listdir(install_file_path): archive_type = None - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + magic_check_and_uncompress(archive_file, target_path, filename) elif response.startswith('n') or response.startswith('N'): log.err("Exiting gracefully on user request.\n\n") @@ -1501,7 +1488,7 @@ for eachfile in os.listdir(install_file_path): archive_type = None - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + magic_check_and_uncompress(archive_file, target_path, filename) else: log.msg("Exiting gracefully on user request.\n") sys.exit(0) @@ -1509,7 +1496,7 @@ for eachfile in os.listdir(install_file_path): archive_type = None - magic_check_and_uncompress(os.path.abspath(filename), target_path, filename) + magic_check_and_uncompress(archive_file, target_path, filename) else: log.err("ERROR: Inappropriate argument sent to syncer during data fetch. Do you need to fetch bugs or not?\n") sys.exit(1) @@ -1593,7 +1580,7 @@ if os.geteuid() != 0: parser.error("This option requires super-user privileges. Execute as root or use sudo/su") else: - log.msg("Generating database of files that are needed for an update.\n") + log.msg("\n\nGenerating database of files that are needed for an update.\n") #FIXME: Unicode Fix # This is only a workaround. @@ -1622,17 +1609,17 @@ parser.error("This option requires super-user privileges. Execute as root or use sudo/su") #TODO: Use a more Pythonic way for it if options.upgrade_type == "upgrade": - log.msg("Generating database of files that are needed for an upgrade.\n") + log.msg("\n\nGenerating database of files that are needed for an upgrade.\n") os.environ['__pypt_set_upgrade'] = options.set_upgrade if os.system('/usr/bin/apt-get -qq --print-uris upgrade > $__pypt_set_upgrade') != 0: log.err("FATAL: Something is wrong with the apt system.\n") elif options.upgrade_type == "dist-upgrade": - log.msg("Generating database of files that are needed for a dist-upgrade.\n") + log.msg("\n\nGenerating database of files that are needed for a dist-upgrade.\n") os.environ['__pypt_set_upgrade'] = options.set_upgrade if os.system('/usr/bin/apt-get -qq --print-uris dist-upgrade > $__pypt_set_upgrade') != 0: log.err("FATAL: Something is wrong with the apt system.\n") elif options.upgrade_type == "dselect-upgrade": - log.msg("Generating database of files that are needed for a dselect-upgrade.\n") + log.msg("\n\nGenerating database of files that are needed for a dselect-upgrade.\n") os.environ['__pypt_set_upgrade'] = options.set_upgrade if os.system('/usr/bin/apt-get -qq --print-uris dselect-upgrade > $__pypt_set_upgrade') != 0: log.err("FATAL: Something is wrong with the apt system.\n") @@ -1650,7 +1637,7 @@ if os.geteuid() != 0: parser.error("This option requires super-user privileges. Execute as root or use sudo/su") - log.msg("Generating database of the package and its dependencies.\n") + log.msg("\n\nGenerating database of the package and its dependencies.\n") os.environ['__pypt_set_install'] = options.set_install os.environ['__pypt_set_install_packages'] = '' @@ -1726,13 +1713,13 @@ if options.install_upgrade: #INFO: Comment these lines to do testing on Windows machines too - try: - if os.geteuid() != 0: - log.err("\nYou need superuser privileges to execute this option\n") - sys.exit(1) - except AttributeError: - log.err("Are you really running the install command on a Debian box?\n") - sys.exit(1) + #try: + # if os.geteuid() != 0: + # log.err("\nYou need superuser privileges to execute this option\n") + # sys.exit(1) + #except AttributeError: + # log.err("Are you really running the install command on a Debian box?\n") + # sys.exit(1) if os.path.isfile(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 1, bug_parse_required = True) elif os.path.isdir(options.install_upgrade) is True: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-17 11:14:51
|
Revision: 186 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=186&view=rev Author: riteshsarraf Date: 2007-08-17 04:14:50 -0700 (Fri, 17 Aug 2007) Log Message: ----------- C:\Eclipse\Workspace\pypt-offline>hg log -l 2 -v changeset: 166:a0954cf2b81a branch: trunk tag: tip user: Ritesh Raj Sarraf <rr...@re...> date: Fri Aug 17 16:41:35 2007 +0530 files: pypt_core.py description: * Add option --test-windows to avoid the call of os.geteuid() on Windows. changeset: 165:a4e7b8f2b038 branch: trunk user: Ritesh Raj Sarraf <rr...@re...> date: Fri Aug 17 16:33:03 2007 +0530 files: pypt_core.py description: * Put all imports at the top-level. This has already hurt much. Things are done for good. Folloow standard practices. Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-13 20:51:03 UTC (rev 185) +++ trunk/pypt_core.py 2007-08-17 11:14:50 UTC (rev 186) @@ -31,12 +31,16 @@ import socket import tempfile -from array import array +import zipfile +import bz2 +import gzip -#INFO: Set the default timeout to 15 seconds for the packages that are being downloaded. -socket.setdefaulttimeout(30) +import debianbts +import pypt_magic +from array import array + #INFO: They aren't on Windows try: from fcntl import ioctl @@ -50,6 +54,10 @@ except ImportError: WindowColor = False +#INFO: Set the default timeout to 15 seconds for the packages that are being downloaded. +socket.setdefaulttimeout(30) + + '''This is the core module. It does the main job of downloading packages/update packages,\nfiguring out if the packages are in the local cache, handling exceptions and many more stuff''' @@ -62,9 +70,6 @@ supported_platforms = ["Linux", "GNU/kFreeBSD", "GNU"] apt_update_target_path = '/var/lib/apt/lists/' apt_package_target_path = '/var/cache/apt/archives/' -# Dummy paths while testing on Windows -#apt_update_target_path = 'C:\\temp' -#apt_package_target_path = 'C:\\temp' pypt_bug_file_format = "__pypt__bug__report" bugTypes = ["Resolved bugs", "Normal bugs", "Minor bugs", "Wishlist items", "FIXED"] @@ -86,7 +91,6 @@ def md5_check(self, file, checksum): data = open(file, 'rb') - #local = md5_string(data) if checksum == self.md5_string(data): return True return False @@ -242,10 +246,6 @@ elif os.name in ['nt', 'dos']: self.platform = None - #try: - # import WConio - #except ImportError: - # self.platform = None if WindowColor is True: self.platform = 'microsoft' @@ -346,11 +346,6 @@ '''Condenses all the files into one single file for easy transfer''' try: - import zipfile - except ImportError: - return False - - try: if self.lock: self.ZipLock.acquire(True) filename = zipfile.ZipFile(zip_file_name, "a") @@ -374,10 +369,6 @@ if archive_type is 1: - try: - import bz2 - except ImportError: - return False try: read_from = bz2.BZ2File(archive_file, 'r') @@ -396,10 +387,6 @@ return True elif archive_type is 2: - try: - import gzip - except ImportError: - return False try: read_from = gzip.GzipFile(archive_file, 'r') @@ -419,10 +406,10 @@ elif archive_type is 3: # FIXME: This looks odd. Where are we writing to a file ??? - #try: - zip_file = zipfile.ZipFile(file, 'rb') - #except: - # return False + try: + zip_file = zipfile.ZipFile(file, 'rb') + except IOError: + return False for filename in zip_file.namelist(): data = zip_file.read() @@ -444,16 +431,9 @@ if self.lock: Archiver.__init__(self, lock) self.ArchiveFile = ArchiveFile - #ArchiveFiles = Archiver(True) - #import debianbts def FetchBugsDebian(self, PackageName, Filename=None): - try: - import debianbts - except ImportError: - return False - if Filename != None: try: file_handle = open(Filename, 'a') @@ -895,7 +875,6 @@ if FetcherInstance.compress_the_file(zip_update_file, file) != True: log.verbose("%s added to archive %s.\n" % (file, zip_update_file) ) os.unlink(os.path.join(download_path, file) ) # Remove it because we don't need the file once it is zipped. - #sys.exit(1) pass elif key == 'Upgrade': @@ -1259,12 +1238,6 @@ archive = Archiver() - try: - import pypt_magic - except ImportError: - log.err("Error: Module pypt_magic not found.\n") - sys.exit(1) - def display_options(): log.msg("(Y) Yes. Proceed with installation\n") @@ -1308,12 +1281,6 @@ log.msg("%s file synced.\n" % (filename)) if path_type == 1: - - try: - import zipfile - except ImportError: - log.err("Error: Module zipfile not found.\n") - sys.exit(1) file = zipfile.ZipFile(install_file_path, "r") if bug_parse_required is True: @@ -1562,6 +1529,7 @@ action="store", type="string", metavar="pypt-offline-upgrade.zip") parser.add_option("", "--fetch-bug-reports", dest="deb_bugs", help="Fetch bug reports from the BTS", action="store_true") + parser.add_option("", "--test-windows", dest="test_windows", help="This switch is used while doing testing on windows.", action="store_true") #global options, args (options, args) = parser.parse_args() @@ -1692,14 +1660,19 @@ sys.exit(1) if options.install_update: - #INFO: Comment these lines to do testing on Windows machines too - #try: - # if os.geteuid() != 0: - # log.err("\nYou need superuser privileges to execute this option\n") - # sys.exit(1) - #except AttributeError: - # log.err("Are you really running the install command on a Debian box?\n") - # sys.exit(1) + if options.test_windows: + # Dummy paths while testing on Windows + apt_update_target_path = 'C:\\temp' + apt_package_target_path = 'C:\\temp' + pass + else: + try: + if os.geteuid() != 0: + log.err("\nYou need superuser privileges to execute this option\n") + sys.exit(1) + except AttributeError: + log.err("Are you really running the install command on a Debian box?\n") + sys.exit(1) if os.path.isfile(options.install_update) is True: # Okay! We're a file. It should be a zip file @@ -1712,14 +1685,20 @@ sys.exit(1) if options.install_upgrade: - #INFO: Comment these lines to do testing on Windows machines too - #try: - # if os.geteuid() != 0: - # log.err("\nYou need superuser privileges to execute this option\n") - # sys.exit(1) - #except AttributeError: - # log.err("Are you really running the install command on a Debian box?\n") - # sys.exit(1) + if options.test_windows: + # Dummy paths while testing on Windows + apt_update_target_path = 'C:\\temp' + apt_package_target_path = 'C:\\temp' + pass + else: + try: + if os.geteuid() != 0: + log.err("\nYou need superuser privileges to execute this option\n") + sys.exit(1) + except AttributeError: + log.err("Are you really running the install command on a Debian box?\n") + sys.exit(1) + if os.path.isfile(options.install_upgrade) is True: syncer(options.install_upgrade, apt_package_target_path, 1, bug_parse_required = True) elif os.path.isdir(options.install_upgrade) is True: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-17 11:22:38
|
Revision: 187 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=187&view=rev Author: riteshsarraf Date: 2007-08-17 04:22:40 -0700 (Fri, 17 Aug 2007) Log Message: ----------- * Put proper variable assignments where required Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-17 11:14:50 UTC (rev 186) +++ trunk/pypt_core.py 2007-08-17 11:22:40 UTC (rev 187) @@ -1663,7 +1663,6 @@ if options.test_windows: # Dummy paths while testing on Windows apt_update_target_path = 'C:\\temp' - apt_package_target_path = 'C:\\temp' pass else: try: @@ -1687,7 +1686,6 @@ if options.install_upgrade: if options.test_windows: # Dummy paths while testing on Windows - apt_update_target_path = 'C:\\temp' apt_package_target_path = 'C:\\temp' pass else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-17 14:10:43
|
Revision: 188 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=188&view=rev Author: riteshsarraf Date: 2007-08-17 07:10:46 -0700 (Fri, 17 Aug 2007) Log Message: ----------- * The variables need to be referenced as the global variables. Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-17 11:22:40 UTC (rev 187) +++ trunk/pypt_core.py 2007-08-17 14:10:46 UTC (rev 188) @@ -74,6 +74,7 @@ pypt_bug_file_format = "__pypt__bug__report" bugTypes = ["Resolved bugs", "Normal bugs", "Minor bugs", "Wishlist items", "FIXED"] + #These are spaces which will overwrite the progressbar left mess LINE_OVERWRITE_SMALL = " " * 10 LINE_OVERWRITE_MID = " " * 30 @@ -1543,6 +1544,12 @@ log.msg("Copyright %s\n" % (copyright)) log.msg(terminal_license) + if options.test_windows: + global apt_package_target_path + global apt_update_target_path + apt_package_target_path = 'C:\\temp' + apt_update_target_path = 'C:\\temp' + if options.set_update: if platform.system() in supported_platforms: if os.geteuid() != 0: @@ -1661,8 +1668,6 @@ if options.install_update: if options.test_windows: - # Dummy paths while testing on Windows - apt_update_target_path = 'C:\\temp' pass else: try: @@ -1678,15 +1683,13 @@ syncer(options.install_update, apt_update_target_path, 1, bug_parse_required = False) elif os.path.isdir(options.install_update) is True: # We're a directory - syncer(options.install_update, apt_update_target_path, 1, bug_parse_required = False) + syncer(options.install_update, apt_update_target_path, 2, bug_parse_required = False) else: log.err("%s file not found\n" % (options.install_update)) sys.exit(1) if options.install_upgrade: if options.test_windows: - # Dummy paths while testing on Windows - apt_package_target_path = 'C:\\temp' pass else: try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-17 16:11:57
|
Revision: 189 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=189&view=rev Author: riteshsarraf Date: 2007-08-17 09:11:59 -0700 (Fri, 17 Aug 2007) Log Message: ----------- * If the $LANG environment variable is not set, just don't spit an exception Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-17 14:10:46 UTC (rev 188) +++ trunk/pypt_core.py 2007-08-17 16:11:59 UTC (rev 189) @@ -1562,7 +1562,10 @@ # When using locales, we get translation files. But apt doesn't extract the URI properly. # Once the extraction problem is root-caused, we can fix this easily. os.environ['__pypt_set_update'] = options.set_update - old_environ = os.environ['LANG'] + try: + old_environ = os.environ['LANG'] + except KeyError: + old_environ = "C" os.environ['LANG'] = "C" log.verbose("Set environment variable for LANG from %s to %s temporarily.\n" % (old_environ, os.environ['LANG']) ) if os.system('/usr/bin/apt-get -qq --print-uris update > $__pypt_set_update') != 0: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2007-08-20 13:54:30
|
Revision: 190 http://pypt-offline.svn.sourceforge.net/pypt-offline/?rev=190&view=rev Author: riteshsarraf Date: 2007-08-20 06:54:32 -0700 (Mon, 20 Aug 2007) Log Message: ----------- * Much simpler to decide a True or a False Modified Paths: -------------- trunk/pypt_core.py Modified: trunk/pypt_core.py =================================================================== --- trunk/pypt_core.py 2007-08-17 16:11:59 UTC (rev 189) +++ trunk/pypt_core.py 2007-08-20 13:54:32 UTC (rev 190) @@ -223,9 +223,7 @@ def __init__(self, verbose, lock = None): - if verbose is True: - self.VERBOSE = True - else: self.VERBOSE = False + self.VERBOSE = bool(verbose) self.color_syntax = '\033[1;' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |