[Apt-offline-devel] [SCM] Offline APT Package Manager branch, master, updated. 0.9.6-39-g07c765e

Ritesh Raj Sarraf rrs at researchut.com
Tue Mar 16 19:40:40 UTC 2010


The following commit has been merged in the master branch:
commit c8c59ca45574fb27f91bc30a3673fe9476f230db
Merge: 40de43b763cfa53d567e3f90227e2c696bc85c03 e09ead32d97dea08ce1b9ed5024992516121a98d
Author: Ritesh Raj Sarraf <rrs at researchut.com>
Date:   Wed Mar 17 01:07:18 2010 +0530

    Merge branch 'thread'
    
    * thread:
      some fixes to MyThread class
      Initialize bug_fetched before it is referenced
      use MyThread class

diff --combined apt_offline_core/AptOfflineCoreLib.py
index 37e2539,f7ad38c..428a82d
--- a/apt_offline_core/AptOfflineCoreLib.py
+++ b/apt_offline_core/AptOfflineCoreLib.py
@@@ -320,11 -320,10 +320,11 @@@ def errfunc(errno, errormsg, filename)
          be well accessible.
          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, 401, 10060, 104, 101010]
          # 104, 'Connection reset by peer'
          # 504 is for gateway timeout
          # 404 is for URL error. Page not found.
 +        # 401 is for Restricted pages
          # 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
@@@ -349,7 -348,8 +349,7 @@@
                  log.err("Explicit program termination %s\n" % (errno))
                  sys.exit(errno)
          else:
 -                log.err("I don't understand this error code %s\n" % (errno))
 -                sys.exit(errno)
 +                log.err("I don't understand this error code %s\nPlease file a bug report" % (errno))
          
          
  def get_pager_cmd(pager_cmd = None):
@@@ -523,190 -523,174 +523,174 @@@ def fetcher( args )
                  log.msg("WARNING: Else higher number of threads executed could cause\n")
                  log.msg("WARNING: network congestion and timeouts.\n\n")
          
-         def run(request, response, func=find_first_match):
+         def abc(request, response, func=find_first_match):
                  '''Get items from the request Queue, process them
                  with func(), put the results along with the
                  Thread's name into the response Queue.
                  Stop running when item is None.'''
-                 while 1:
-                         tuple_item_key = request.get()
-                         if tuple_item_key is None:
-                                 break
-                         (key, item) = tuple_item_key
+                 #while 1:
+                 #tuple_item_key = request.get()
+                 #if tuple_item_key is None:
+                 #        break
+                 #(key, item) = tuple_item_key
+                 
+                 (key, item) = request
+                 
+                 #INFO: Everything
+                 (url, file, download_size, checksum) = stripper(item)
+                 thread_name = threading.currentThread().getName()
+                 log.verbose("Thread is %s\n" % (thread_name) )
+                 
+                 if url.endswith(".deb"):
+                         try:
+                                 PackageName = file.split("_")[0]
+                         except IndexError:
+                                 log.err("Not getting a package name here is problematic. Better bail out.\n")
+                                 sys.exit(1)
                          
-                         #INFO: Everything
-                         (url, file, download_size, checksum) = stripper(item)
-                         thread_name = threading.currentThread().getName()
-                         log.verbose("Thread is %s\n" % (thread_name) )
+                         #INFO: For Package version, we don't want to fail
+                         try:
+                                 PackageVersion = file.split("_")[1]
+                         except IndexError:
+                                 PackageVersion = "NA"
+                                 log.verbose("Weird!! Package version not present. Is it really a deb file?\n")
                          
-                         if url.endswith(".deb"):
-                                 try:
-                                         PackageName = file.split("_")[0]
-                                 except IndexError:
-                                         log.err("Not getting a package name here is problematic. Better bail out.\n")
-                                         sys.exit(1)
-                                 
-                                 #INFO: For Package version, we don't want to fail
-                                 try:
-                                         PackageVersion = file.split("_")[1]
-                                 except IndexError:
-                                         PackageVersion = "NA"
-                                         log.verbose("Weird!! Package version not present. Is it really a deb file?\n")
-                                 
-                                 response.put(func(Str_CacheDir, file) ) 
-                                 #INFO: find_first_match() returns False or a file name with absolute path
-                                 full_file_path = response.get()
-                                 #INFO: If we find the file in the local Str_CacheDir, we'll execute this block.
-                                 if full_file_path != False:
-                                         # We'll first check for its md5 checksum
-                                         if Bool_DisableMD5Check is False:
-                                                 if FetcherInstance.CheckHashDigest(full_file_path, checksum) is True:
-                                                         log.verbose("Checksum correct for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
-                                                         if Bool_BugReports:
-                                                                 bug_fetched = 0
-                                                                 log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
-                                                                 if FetchBugReportsDebian.FetchBugsDebian(PackageName) in [1,2]:
-                                                                         log.verbose("Fetched bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
-                                                                         bug_fetched = 1
-                                                                 else:
-                                                                         log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
-                                                         if Str_BundleFile:
-                                                                 if FetcherInstance.compress_the_file(Str_BundleFile, full_file_path) is True:
-                                                                         log.success("%s copied from local cache directory %s.%s\n" % (PackageName, Str_CacheDir, LINE_OVERWRITE_MID) )
-                                                                 else:
-                                                                         log.err("Couldn't add %s to archive %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_MID) )
-                                                                         sys.exit(1)
-                                                         #INFO: If no zip option enabled, simply copy the downloaded package file
-                                                         # along with the downloaded bug reports.
-                                                         else:
-                                                                 try:
-                                                                         shutil.copy(full_file_path, Str_DownloadDir)
-                                                                         log.success("%s copied from local cache directory %s.%s\n" % (PackageName, Str_CacheDir, LINE_OVERWRITE_MID) )
-                                                                 except shutil.Error:
-                                                                         log.verbose("%s already available in %s. Skipping copy!!!%s\n" % (file, Str_DownloadDir, LINE_OVERWRITE_MID) )
-                                                                 
-                                                                 if bug_fetched == 1:
-                                                                         for x in os.listdir(os.curdir):
-                                                                                 if (x.startswith(PackageName) and x.endswith(apt_bug_file_format) ):
-                                                                                         shutil.move(x, Str_DownloadDir)
-                                                                                         log.verbose("Moved %s file to %s folder.%s\n" % (x, Str_DownloadDir, LINE_OVERWRITE_FULL) )
-                                                 #INFO: Damn!! The md5chesum didn't match :-(
-                                                 # The file is corrupted and we need to download a new copy from the internet
-                                                 else:
-                                                         log.verbose("%s checksum mismatch. Skipping file.%s\n" % (file, LINE_OVERWRITE_FULL) )
-                                                         log.msg("Downloading %s - %s %s\n" % (PackageName, log.calcSize(download_size/1024), LINE_OVERWRITE_MID) )
-                                                         if FetcherInstance.download_from_web(url, file, Str_DownloadDir) == True:
-                                                                 log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
-                                                                 
-                                                                 #Add to Str_CacheDir if possible
-                                                                 if Str_CacheDir and os.access(Str_CacheDir, os.W_OK) == True:
-                                                                         try:
-                                                                                 shutil.copy(file, Str_CacheDir)
-                                                                                 log.verbose("%s copied to local cache directory %s.%s\n" % (file, Str_CacheDir, LINE_OVERWRITE_MID) )
-                                                                         except shutil.Error:
-                                                                                 log.verbose("Couldn't copy %s to %s.%s\n" % (file, Str_CacheDir, LINE_OVERWRITE_FULL) )
-                                                                 else:
-                                                                         log.verbose("cache_dir %s is not writeable. Skipping copy to it.\n" % (Str_CacheDir) )
-                                                                 
-                                                                 #Fetch bug reports
-                                                                 if Bool_BugReports:
-                                                                         log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
-                                                                         if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
-                                                                                 log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                                                         else:
-                                                                                 log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                                                 if Str_BundleFile:
-                                                                         if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
-                                                                                 log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                                 sys.exit( 1 )
-                                                                         else:
-                                                                                 log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                                 os.unlink( os.path.join( Str_DownloadDir, file ) )
-                                         #INFO: You're and idiot.
-                                         # You should NOT disable md5checksum for any files
-                                         else:
+                         
+                         #INFO: find_first_match() returns False or a file name with absolute path
+                         full_file_path = func(Str_CacheDir, file)
+                         #INFO: If we find the file in the local Str_CacheDir, we'll execute this block.
+                         if full_file_path != False:
+                                 # We'll first check for its md5 checksum
+                                 if Bool_DisableMD5Check is False:
+                                         if FetcherInstance.CheckHashDigest(full_file_path, checksum) is True:
+                                                 log.verbose("Checksum correct for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
+                                                 
+                                                 bug_fetched = False
                                                  if Bool_BugReports:
-                                                         bug_fetched = 0
-                                                         log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
-                                                         if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
-                                                                 log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                                                 bug_fetched = 1
+                                                         log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
+                                                         if FetchBugReportsDebian.FetchBugsDebian(PackageName) in [1,2]:
+                                                                 log.verbose("Fetched bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
+                                                                 bug_fetched = True
                                                          else:
-                                                                 log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                     
-                                                 #FIXME: Don't know why this was really required. If this has no changes, delete it.
-                                                 #file = full_file_path.split("/")
-                                                 #file = file[len(file) - 1]
-                                                 #file = download_path + "/" + file
+                                                                 log.verbose("Couldn't fetch bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
+                                                                 
                                                  if Str_BundleFile:
-                                                         if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
-                                                                 log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                 sys.exit( 1 )
+                                                         if FetcherInstance.compress_the_file(Str_BundleFile, full_file_path) is True:
+                                                                 log.success("%s copied from local cache directory %s.%s\n" % (PackageName, Str_CacheDir, LINE_OVERWRITE_MID) )
                                                          else:
-                                                                 log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                 os.unlink( os.path.join( Str_DownloadDir, file ) )
+                                                                 log.err("Couldn't add %s to archive %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_MID) )
+                                                                 sys.exit(1)
+                                                 #INFO: If no zip option enabled, simply copy the downloaded package file
+                                                 # along with the downloaded bug reports.
                                                  else:
-                                                         # Since zip file option is not enabled let's copy the file to the target folder
                                                          try:
-                                                                 shutil.copy( full_file_path, Str_DownloadDir )
-                                                                 log.success( "%s copied from local cache directory %s.%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_SMALL ) )
+                                                                 shutil.copy(full_file_path, Str_DownloadDir)
+                                                                 log.success("%s copied from local cache directory %s.%s\n" % (PackageName, Str_CacheDir, LINE_OVERWRITE_MID) )
                                                          except shutil.Error:
-                                                                 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:
-                                                                 for x in os.listdir( os.curdir ):
-                                                                         if ( x.startswith( PackageName ) and x.endswith( apt_bug_file_format ) ):
-                                                                                 shutil.move( x, Str_DownloadDir )
-                                                                                 log.verbose( "Moved %s file to %s folder.%s\n" % ( x, Str_DownloadDir, LINE_OVERWRITE_MID ) )
-                                         
-                                 else:
-                                         #INFO: This block gets executed if the file is not found in local Str_CacheDir or Str_CacheDir 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, Str_CacheDir, LINE_OVERWRITE_MID ) )
-                                         log.msg( "Downloading %s %s - %s %s\n" % ( PackageName, PackageVersion, log.calcSize( download_size / 1024 ), LINE_OVERWRITE_MID ) )
-                                         if FetcherInstance.download_from_web( url, file, Str_DownloadDir ) == True:
-                                                 #INFO: This block gets executed if md5checksum is allowed
-                                                 if Bool_DisableMD5Check is False:
-                                                         #INFO: Debian moved to SHA256. So we use that now. Older systems could have md5
-                                                         log.verbose( "File %s has checksum %s\n" % ( file, checksum ) )
-                                                         if FetcherInstance.CheckHashDigest( file, checksum ) is True:
-                                                                 if Str_CacheDir and os.access( Str_CacheDir, os.W_OK ) == True:
-                                                                         try:
-                                                                                 shutil.copy( file, Str_CacheDir )
-                                                                                 log.verbose( "%s copied to local cache directory %s.%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_MID ) )
-                                                                         except shutil.Error:
-                                                                                 log.verbose( "%s already available in %s. Skipping copy!!!%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_MID ) )
-                                                                 else:
-                                                                         log.verbose( "Str_CacheDir %s is not writeable. Skipping copy to it.\n" % ( Str_CacheDir ) )
-                                             
-                                                                 if Bool_BugReports:
-                                                                         log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
-                                                                         if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
-                                                                                 log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                                                         else:
-                                                                                 log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                             
-                                                                 if Str_BundleFile:
-                                                                         if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
-                                                                                 log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                                 sys.exit( 1 )
-                                                                         else:
-                                                                                 log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
-                                                                                 os.unlink( os.path.join( Str_DownloadDir, file ) )
-                                                                 log.success( "\r%s %s done.%s\n" % ( PackageName, PackageVersion, LINE_OVERWRITE_FULL ) )
+                                                                 log.verbose("%s already available in %s. Skipping copy!!!%s\n" % (file, Str_DownloadDir, LINE_OVERWRITE_MID) )
+                                                         
+                                                         if bug_fetched is True:
+                                                                 for x in os.listdir(os.curdir):
+                                                                         if (x.startswith(PackageName) and x.endswith(apt_bug_file_format) ):
+                                                                                 shutil.move(x, Str_DownloadDir)
+                                                                                 log.verbose("Moved %s file to %s folder.%s\n" % (x, Str_DownloadDir, LINE_OVERWRITE_FULL) )
+                                         #INFO: Damn!! The md5chesum didn't match :-(
+                                         # The file is corrupted and we need to download a new copy from the internet
+                                         else:
+                                                 log.verbose("%s checksum mismatch. Skipping file.%s\n" % (file, LINE_OVERWRITE_FULL) )
+                                                 log.msg("Downloading %s - %s %s\n" % (PackageName, log.calcSize(download_size/1024), LINE_OVERWRITE_MID) )
+                                                 if FetcherInstance.download_from_web(url, file, Str_DownloadDir) == True:
+                                                         log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
+                                                         
+                                                         #Add to Str_CacheDir if possible
+                                                         if Str_CacheDir and os.access(Str_CacheDir, os.W_OK) == True:
+                                                                 try:
+                                                                         shutil.copy(file, Str_CacheDir)
+                                                                         log.verbose("%s copied to local cache directory %s.%s\n" % (file, Str_CacheDir, LINE_OVERWRITE_MID) )
+                                                                 except shutil.Error:
+                                                                         log.verbose("Couldn't copy %s to %s.%s\n" % (file, Str_CacheDir, LINE_OVERWRITE_FULL) )
                                                          else:
-                                                                 #INFO MD5 Checksum is incorrect.
-                                                                 log.err( "%s Checksum mismatch.\n" % ( PackageName ) )
-                                                                 errlist.append( PackageName )
+                                                                 log.verbose("cache_dir %s is not writeable. Skipping copy to it.\n" % (Str_CacheDir) )
+                                                         
+                                                         #Fetch bug reports
+                                                         if Bool_BugReports:
+                                                                 log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
+                                                                 if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
+                                                                         log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
+                                                                 else:
+                                                                         log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
+                                                         if Str_BundleFile:
+                                                                 if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
+                                                                         log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                                         sys.exit( 1 )
+                                                                 else:
+                                                                         log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                                         os.unlink( os.path.join( Str_DownloadDir, file ) )
+                                 #INFO: You're and idiot.
+                                 # You should NOT disable md5checksum for any files
+                                 else:
+                                         bug_fetched = False
+                                         if Bool_BugReports:
+                                                 log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
+                                                 if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
+                                                         log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
+                                                         bug_fetched = True
+                                                 else:
+                                                         log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
+                             
+                                         #FIXME: Don't know why this was really required. If this has no changes, delete it.
+                                         #file = full_file_path.split("/")
+                                         #file = file[len(file) - 1]
+                                         #file = download_path + "/" + file
+                                         if Str_BundleFile:
+                                                 if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
+                                                         log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                         sys.exit( 1 )
                                                  else:
+                                                         log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                         os.unlink( os.path.join( Str_DownloadDir, file ) )
+                                         else:
+                                                 # Since zip file option is not enabled let's copy the file to the target folder
+                                                 try:
+                                                         shutil.copy( full_file_path, Str_DownloadDir )
+                                                         log.success( "%s copied from local cache directory %s.%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_SMALL ) )
+                                                 except shutil.Error:
+                                                         log.verbose( "%s already available in dest_dir. Skipping copy!!!%s\n" % ( file, LINE_OVERWRITE_SMALL ) )
+                             
+                                                 # And also the bug reports
+                                                 if bug_fetched is True:
+                                                         for x in os.listdir( os.curdir ):
+                                                                 if ( x.startswith( PackageName ) and x.endswith( apt_bug_file_format ) ):
+                                                                         shutil.move( x, Str_DownloadDir )
+                                                                         log.verbose( "Moved %s file to %s folder.%s\n" % ( x, Str_DownloadDir, LINE_OVERWRITE_MID ) )
+                                 
+                         else:
+                                 #INFO: This block gets executed if the file is not found in local Str_CacheDir or Str_CacheDir 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, Str_CacheDir, LINE_OVERWRITE_MID ) )
+                                 log.msg( "Downloading %s %s - %s %s\n" % ( PackageName, PackageVersion, log.calcSize( download_size / 1024 ), LINE_OVERWRITE_MID ) )
+                                 if FetcherInstance.download_from_web( url, file, Str_DownloadDir ) == True:
+                                         #INFO: This block gets executed if md5checksum is allowed
+                                         if Bool_DisableMD5Check is False:
+                                                 #INFO: Debian moved to SHA256. So we use that now. Older systems could have md5
+                                                 log.verbose( "File %s has checksum %s\n" % ( file, checksum ) )
+                                                 if FetcherInstance.CheckHashDigest( file, checksum ) is True:
+                                                         if Str_CacheDir and os.access( Str_CacheDir, os.W_OK ) == True:
+                                                                 try:
+                                                                         shutil.copy( file, Str_CacheDir )
+                                                                         log.verbose( "%s copied to local cache directory %s.%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_MID ) )
+                                                                 except shutil.Error:
+                                                                         log.verbose( "%s already available in %s. Skipping copy!!!%s\n" % ( file, Str_CacheDir, LINE_OVERWRITE_MID ) )
+                                                         else:
+                                                                 log.verbose( "Str_CacheDir %s is not writeable. Skipping copy to it.\n" % ( Str_CacheDir ) )
+                                     
                                                          if Bool_BugReports:
                                                                  log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
                                                                  if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
                                                                          log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
                                                                  else:
                                                                          log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
-                                                         
+                                     
                                                          if Str_BundleFile:
                                                                  if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
                                                                          log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
@@@ -714,59 -698,64 +698,64 @@@
                                                                  else:
                                                                          log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
                                                                          os.unlink( os.path.join( Str_DownloadDir, file ) )
-                                             
                                                          log.success( "\r%s %s done.%s\n" % ( PackageName, PackageVersion, LINE_OVERWRITE_FULL ) )
+                                                 else:
+                                                         #INFO MD5 Checksum is incorrect.
+                                                         log.err( "%s Checksum mismatch.\n" % ( PackageName ) )
+                                                         errlist.append( PackageName )
                                          else:
-                                                 errlist.append( PackageName )
+                                                 if Bool_BugReports:
+                                                         log.verbose("Fetching bug reports for package %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) )
+                                                         if FetchBugReportsDebian.FetchBugsDebian( PackageName ) in [1, 2]:
+                                                                 log.verbose( "Fetched bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
+                                                         else:
+                                                                 log.verbose( "Couldn't fetch bug reports for package %s.%s\n" % ( PackageName, LINE_OVERWRITE_MID ) )
                                                  
-                         else:
-                                 #INFO: We are a package update
-                                 PackageName = url
-                                 log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) 
-                                 if FetcherInstance.download_from_web(url, file, Str_DownloadDir) == True:
-                                         log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
-                                         if Str_BundleFile:
-                                                 if FetcherInstance.compress_the_file(Str_BundleFile, file) != True:
-                                                         log.err("Couldn't archive %s to file %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_MID) )
-                                                         sys.exit(1)
-                                                 else:
-                                                         log.verbose("%s added to archive %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_FULL) )
-                                                         os.unlink(os.path.join(Str_DownloadDir, file) )
+                                                 if Str_BundleFile:
+                                                         if FetcherInstance.compress_the_file( Str_BundleFile, file ) != True:
+                                                                 log.err( "Couldn't archive %s to file %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                                 sys.exit( 1 )
+                                                         else:
+                                                                 log.verbose( "%s added to archive %s.%s\n" % ( file, Str_BundleFile, LINE_OVERWRITE_SMALL ) )
+                                                                 os.unlink( os.path.join( Str_DownloadDir, file ) )
+                                     
+                                                 log.success( "\r%s %s done.%s\n" % ( PackageName, PackageVersion, LINE_OVERWRITE_FULL ) )
                                  else:
-                                         errlist.append(url)
+                                         errlist.append( PackageName )
+                                         
+                 else:
+                         #INFO: We are a package update
+                         PackageName = url
+                         log.msg("Downloading %s.%s\n" % (PackageName, LINE_OVERWRITE_MID) ) 
+                         if FetcherInstance.download_from_web(url, file, Str_DownloadDir) == True:
+                                 log.success("\r%s done.%s\n" % (PackageName, LINE_OVERWRITE_FULL) )
+                                 if Str_BundleFile:
+                                         if FetcherInstance.compress_the_file(Str_BundleFile, file) != True:
+                                                 log.err("Couldn't archive %s to file %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_MID) )
+                                                 sys.exit(1)
+                                         else:
+                                                 log.verbose("%s added to archive %s.%s\n" % (file, Str_BundleFile, LINE_OVERWRITE_FULL) )
+                                                 os.unlink(os.path.join(Str_DownloadDir, file) )
+                         else:
+                                 errlist.append(url)
                          
          # Create two Queues for the requests and responses
          requestQueue = Queue.Queue()
          responseQueue = Queue.Queue()
-         # Pool of NUMTHREADS Threads that run run().
-         thread_pool = [
-                        threading.Thread(
-                                         target=run,
-                                         args=(requestQueue, responseQueue)
-                                         )
-                        for i in range(Int_NumOfThreads)
-                        ]
-         
-         # Start the threads.
-         for t in thread_pool: t.start()
+         
+         
+         ConnectThread = AptOfflineLib.MyThread(abc, requestQueue, responseQueue, Int_NumOfThreads)
+         
+         ConnectThread.startThreads()
          
          # Queue up the requests.
          #for item in raw_data_list: requestQueue.put(item)
          for key in FetchData.keys():
                  for item in FetchData.get(key):
-                         requestQueue.put( (key, item) )
-         
-         # Shut down the threads after all requests end.
-         # (Put one None "sentinel" for each thread.)
-         for t in thread_pool: requestQueue.put(None)
-         
-         # Don't end the program prematurely.
-         # (Note that because Queue.get() is blocking by
-         # defualt this isn't strictly necessary. But if
-         # you were, say, handling responses in another
-         # thread, you'd want something like this in your
-         # main thread.)
-         for t in thread_pool: t.join()
+                         ConnectThread.populateQueue( (key, item) )
+         ConnectThread.stopThreads()
+         ConnectThread.stopQueue()
+         
                  
          # Print the failed files
          if len(errlist) > 0:
@@@ -966,8 -955,6 +955,8 @@@ def installer( args )
                          else:
                                  log.err( "Cannot write to target path %s\n" % ( apt_package_target_path ) )
                                  sys.exit( 1 )
 +                elif filename.endswith( apt_bug_file_format ):
 +                        pass
                  elif AptOfflineMagicLib.file( archive_file ) == "ASCII text":
                          filename = os.path.join(apt_update_target_path, filename)
                          if os.access( apt_update_target_path, os.W_OK ):
@@@ -976,11 -963,15 +965,11 @@@
                          else:
                                  log.err( "Cannot write to target path %s\n" % ( apt_update_target_path ) )
                                  sys.exit( 1 )
 -                elif filename.endswith( apt_bug_file_format ):
 -                        retval = False # We intentionally put the bug report files as not printed.
                  else:
                          log.err( "I couldn't understand file type %s.\n" % ( filename ) )
                  
                  if retval:
                          log.verbose( "%s file synced to %s.\n" % ( filename, apt_update_target_path ) )
 -                else:
 -                        log.err("Failed to sync %s\n" % (filename) )
          
          if os.path.isfile(install_file_path):
                  #INFO: For now, we support zip bundles only
@@@ -1137,27 -1128,6 +1126,27 @@@
                                  temp.close()
                  
                  bugs_number = {}
 +                
 +                def DirInstallPackages(InstallDirPath):
 +                        for eachfile in os.listdir( InstallDirPath ):
 +                                
 +                                filename = eachfile
 +                                FullFileName = os.path.abspath(os.path.join(InstallDirPath, eachfile) )
 +                        
 +                                #INFO: Take care of Src Pkgs
 +                                found = False
 +                                for item in SrcPkgDict.keys():
 +                                        if filename in SrcPkgDict[item]:
 +                                                found = True
 +                                                break
 +                                if found is True:
 +                                        shutil.copy2(filename, Str_InstallSrcPath)
 +                                        log.msg("Installing src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
 +                                        continue
 +                                
 +                                magic_check_and_uncompress( FullFileName, filename )
 +                        return True
 +                                
                  if Bool_SkipBugReports:
                          log.verbose("Skipping bug report check as requested")
                  else:
@@@ -1183,18 -1153,25 +1172,18 @@@
                                  if response == "?":
                                          display_options()
                                          response = get_response()
 +                                        
                                  elif response.startswith( 'y' ) or response.startswith( 'Y' ):
 -                                        for eachfile in os.listdir( install_file_path ):
 -                                                
 -                                                #INFO: Take care of Src Pkgs
 -                                                found = False
 -                                                for item in SrcPkgDict.keys():
 -                                                        if filename in SrcPkgDict[item]:
 -                                                                found = True
 -                                                                break
 -                                                if found is True:
 -                                                        shutil.copy2(filename, Str_InstallSrcPath)
 -                                                        log.msg("Installing src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
 -                                                        continue
 -                                                
 -                                                archive_type = None
 -                                                magic_check_and_uncompress( archive_file, filename )
 +                                        if DirInstallPackages(install_file_path) is True:
 +                                                sys.exit(0)
 +                                        else:
 +                                                log.err("Failed during install operation on %s.\n" % (install_file_path) )
 +                                                sys.exit(1)
 +                                        
                                  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:
@@@ -1224,8 -1201,28 +1213,8 @@@
                                          sys.exit( 1 )
                  else:
                          log.verbose( "Great!!! No bugs found for all the packages that were downloaded.\n\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 ):
 -                                filename = eachfile
 -                                eachfile = os.path.abspath(os.path.join(install_file_path, eachfile) )
 -                                
 -                                #INFO: Take care of Src Pkgs
 -                                found = False
 -                                for item in SrcPkgDict.keys():
 -                                        if filename in SrcPkgDict[item]:
 -                                                found = True
 -                                                break
 -                                if found is True:
 -                                        shutil.copy2(eachfile, Str_InstallSrcPath)
 -                                        log.msg("Installed src package file %s to %s.\n" % (filename, Str_InstallSrcPath) )
 -                                        continue
 -                                
 -                                magic_check_and_uncompress( eachfile, filename )
 -                        #else:
 -                        #        log.msg( "Exiting gracefully on user request.\n" )
 -                        #        sys.exit( 0 )
 +                        DirInstallPackages(install_file_path)
 +                        
          if Bool_Untrusted:
                  log.err("Disabling apt gpg check can risk your machine to compromise.\n")
                  for x in os.listdir(apt_update_target_path):
@@@ -1488,7 -1485,7 +1477,7 @@@ def setter(args)
                          if BuildDependency:
                                  log.msg("Generating Build-Dependency for source packages %s.\n" % (self.package_list) )
                                  if self.ReleaseType is not None:
 -                                        os.environ['__apt_set_install_release'] = self.WriteTo
 +                                        os.environ['__apt_set_install_release'] = self.ReleaseType
                                          if self.__ExecSystemCmd( '/usr/bin/apt-get -qq --print-uris -t $__apt_set_install_release build-dep $__apt_set_install_src_packages >> $__apt_set_install' ) is False:
                                                  log.err( "FATAL: Something is wrong with the apt system.\n" )
                                  else:

-- 
Offline APT Package Manager



More information about the Apt-offline-devel mailing list