[Pypt-offline-general] SF.net SVN: pypt-offline: [171] trunk/pypt_core.py
Status: Beta
Brought to you by:
riteshsarraf
|
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.
|