summaryrefslogtreecommitdiff
path: root/community/avant-window-navigator/821_820.diff
blob: bd8c5b2798ba49ffb716ea469840b9975615f9ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
=== 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):