Ubuntu Pastebin

Paste from nacc at Wed, 21 Sep 2016 16:20:44 +0000

Download as text
 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
diff --git a/usd-import b/usd-import
index a9e2925..2b8aafc 100755
--- a/usd-import
+++ b/usd-import
@@ -381,6 +381,16 @@ class USDGitRepository:
         tag = self.get_import_tag(version)
         return tag is not None
 
+    @staticmethod
+    def _open_any(paths, *args, **kwargs):
+        for path in paths:
+            try:
+                f = open(path)
+                return f
+            except FileNotFoundError:
+                pass
+        raise FileNotFoundError
+
     # imports a package based upon source package information
     def import_spi(self, spi, parent_overrides, patch_overrides):
         srcpkg = spi.archive_srcpkg
@@ -434,7 +444,17 @@ class USDGitRepository:
                 os.chdir(self._local_repo.workdir)
 
                 try:
-                    with open(patch_override['patch']) as f:
+                    with _open_any(patch_override['patch'],
+                                   os.path.join(os.getcwd(),
+                                           patch_override['patch']
+                                               ),
+                                   os.path.join(
+                                           os.path.dirname(
+                                               os.path.abspath(__file__)
+                                                          ),
+                                           patch_override['patch']
+                                               )
+                                  ) as f:
                         subprocess.run(
                              'patch -p1 < %s' % f.name,
                              check=True,
@@ -442,31 +462,10 @@ class USDGitRepository:
                              env=self._env
                              )
                         fixed_import_tree_hash = ''
+                        f.close()
                 except FileNotFoundError:
-                    try:
-                        with open(os.path.join(os.getcwd(),
-                                           patch_override['patch'])) as f:
-                            subprocess.run(
-                                 'patch -p1 < %s' % f.name,
-                                 check=True,
-                                 shell=True,
-                                 env=self._env
-                                 )
-                            fixed_import_tree_hash = ''
-                    except FileNotFoundError:
-                        try:
-                            with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
-                                           patch_override['patch'])) as f:
-                                subprocess.run(
-                                     'patch -p1 < %s' % f.name,
-                                     check=True,
-                                     shell=True,
-                                     env=self._env
-                                     )
-                                fixed_import_tree_hash = ''
-                        except FileNotFoundError:
-                             logging.error('Unable to find patch file %s' % patch_override['patch'])
-                             sys.exit(1)
+                        logging.error('Unable to find patch file %s' % patch_override['patch'])
+                        sys.exit(1)
 
         changelog_version, previous_changelog_version = \
             self.get_changelog_versions_from_treeish(fixed_import_tree_hash)
Download as text