HaikuPorts
  • Login
  • Preferences
  • Help/Guide
  • Wiki
  • Timeline
  • Roadmap
  • View Tickets
  • Search
  • Port Log
  • Blog

Context Navigation

  • Back to Ticket #450

Ticket #450: try.patch

File try.patch, 2.3 KB (added by jrabbit, 5 years ago)
  • haikuporter

     
    2424import hashlib 
    2525import shutil 
    2626import commands 
    27 from subprocess import check_call, Popen 
     27from subprocess import check_call, Popen, CalledProcessError 
    2828from optparse import OptionParser 
    2929 
    3030# -- HaikuPorts options ------------------------------------------------------- 
    … …  
    626626                if not os.path.exists(self.workDir): 
    627627                        os.mkdir(self.workDir) 
    628628 
    629                 check_call(checkoutCommand, shell=True, cwd=self.workDir) 
    630  
     629                try: 
     630                        check_call(checkoutCommand, shell=True, cwd=self.workDir) 
     631                except (OSError, CalledProcessError), e: 
     632                        if self.prompt_installer(checkoutCommand.split()[0]): 
     633                                check_call(checkoutCommand, shell=True, cwd=self.workDir) 
     634                        else: 
     635                                sys.exit() 
     636                 
    631637                # Set the 'checkout' flag to signal that the checkout is complete 
    632638                # This also tells haikuporter not to attempt an unpack step 
    633639                self.setFlag('checkout') 
    … …  
    685691                        zf.extractall(self.workDir) 
    686692                        zf.close() 
    687693                elif archiveFullPath.split("/")[-1].split(".")[-1] == "xz": 
    688                         Popen(['xz', '-d', '-k', archiveFullPath]) 
     694                        try: 
     695                                Popen(['xz', '-d', '-k', archiveFullPath]) 
     696                        except (OSError, CalledProcessError), e: 
     697                                #run the installoptionalsoftware prompt 
     698                                if self.prompt_installer('xz'): 
     699                                        Popen(['xz', '-d', '-k', archiveFullPath]) 
     700                                else: 
     701                                        sys.exit() 
    689702                        tar = archiveFullPath[:-3] 
    690703                        if tarfile.is_tarfile(tar):  
    691704                                tf = tarfile.open(tar, 'r') 
    … …  
    880893 
    881894                print 'Archive saved to: ' + archiveFile 
    882895 
     896        def prompt_installer(self, name): 
     897                response =  raw_input("Do you want to install %s? [Y/n]" % name) 
     898                apps = {'xz': 'XZ-Utils', 'git': 'Git', 'hg': 'mercurial', 'cvs': 'cvs', 'bzr' : 'bazaar'} #map command to package 
     899                if response in ["y", "Y", "\n", "yes", ''] or  self.options.yes: 
     900                        check_call('installoptionalpackage' + " " + str(apps[name]), shell=True) 
     901                        return True 
     902                else: 
     903                        print "In order to install this package you need to run installoptionalsoftware %s later or let Haikuports install it for you." % apps[name] 
     904                        return False 
    883905 
    884906        def runCommandSequence(self, rawCommandList, dir, packageMode=False): 
    885907                """Run a sequence of shell commands from a bep file""" 

Download in other formats:

  • Original Format

Trac Powered

Powered by Trac 0.13dev-r10686
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/