=== modified file 'awn-settings/awnClass.py' --- awn-settings/awnClass.py 2010-08-24 00:21:51 +0000 +++ awn-settings/awnClass.py 2011-02-13 23:43:42 +0000 @@ -53,9 +53,13 @@ import tempfile import dbus -from bzrlib import branch -from bzrlib.builtins import cmd_branch, cmd_pull -from bzrlib.plugins.launchpad.lp_directory import LaunchpadDirectory +try: + from bzrlib import branch + from bzrlib.builtins import cmd_branch, cmd_pull + from bzrlib.plugins.launchpad.lp_directory import LaunchpadDirectory + support_bzr = True +except: + support_bzr = False defs.i18nize(globals()) @@ -127,8 +131,11 @@ path: a url from a branch return: the http format of a lp: format, or the same url ''' - directory = LaunchpadDirectory() - return directory._resolve(path).replace("bzr+ssh","http") + if support_bzr == True: + directory = LaunchpadDirectory() + return directory._resolve(path).replace("bzr+ssh","http") + else: + return path def read_list(self, file_path): ''' Read a flat file and return the content in a list @@ -148,34 +155,44 @@ path: the path of the branch bzr_dir: the location of the futur tree. ''' - if os.path.exists(path): - print ("Error, the path already exist") + if support_bzr == False: + print (_("Bzr support is not enable, try to install bzr")) else: - try: - bzr_branch = cmd_branch() - status = StringIO() - status = bzr_branch._setup_outf() - bzr_branch.run(from_location=self.lp_path_normalize(bzr_dir), to_location=path) - except socket.gaierror: - print 'Socket error, could not create branch.' + if os.path.exists(path): + print (_("Error, the path already exist")) + else: + try: + bzr_branch = cmd_branch() + status = StringIO() + status = bzr_branch._setup_outf() + bzr_branch.run(from_location=self.lp_path_normalize(bzr_dir), to_location=path) + except socket.gaierror: + print (_('Socket error, could not create branch.')) def update_branch(self, path): ''' Update a local branch path: Location of the branch Return the output of the command ''' - bzr_pull = cmd_pull() - status = StringIO() - status = bzr_pull._setup_outf() - bzr_pull.run(directory=path) + if support_bzr == False: + print (_("Bzr support is not enable, try to install bzr")) + else: + bzr_pull = cmd_pull() + status = StringIO() + status = bzr_pull._setup_outf() + bzr_pull.run(directory=path) def get_revision_from_path(self, path): ''' Return the last revision number of the branch specify with path parameter ''' - tree = branch.Branch.open(path) - revision_number, revision_id = tree.last_revision_info() - return revision_number + if support_bzr == False: + print (_("Bzr support is not enable, try to install bzr")) + return 0 + else: + tree = branch.Branch.open(path) + revision_number, revision_id = tree.last_revision_info() + return revision_number #Sources.list def dict_from_sources_list(self, config=defs.HOME_CONFIG_DIR):