diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/models.py')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/models.py | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index 02cfaf7086..770ce40ae0 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py | |||
@@ -39,40 +39,6 @@ class BuildEnvironment(models.Model): | |||
39 | created = models.DateTimeField(auto_now_add = True) | 39 | created = models.DateTimeField(auto_now_add = True) |
40 | updated = models.DateTimeField(auto_now = True) | 40 | updated = models.DateTimeField(auto_now = True) |
41 | 41 | ||
42 | |||
43 | def get_artifact_type(self, path): | ||
44 | if self.betype == BuildEnvironment.TYPE_LOCAL: | ||
45 | try: | ||
46 | import magic | ||
47 | |||
48 | # fair warning: this is a mess; there are multiple competeing and incompatible | ||
49 | # magic modules floating around, so we try some of the most common combinations | ||
50 | |||
51 | try: # we try ubuntu's python-magic 5.4 | ||
52 | m = magic.open(magic.MAGIC_MIME_TYPE) | ||
53 | m.load() | ||
54 | return m.file(path) | ||
55 | except AttributeError: | ||
56 | pass | ||
57 | |||
58 | try: # we try python-magic 0.4.6 | ||
59 | m = magic.Magic(magic.MAGIC_MIME) | ||
60 | return m.from_file(path) | ||
61 | except AttributeError: | ||
62 | pass | ||
63 | |||
64 | try: # we try pip filemagic 1.6 | ||
65 | m = magic.Magic(flags=magic.MAGIC_MIME_TYPE) | ||
66 | return m.id_filename(path) | ||
67 | except AttributeError: | ||
68 | pass | ||
69 | |||
70 | return "binary/octet-stream" | ||
71 | except ImportError: | ||
72 | return "binary/octet-stream" | ||
73 | raise Exception("FIXME: artifact type not implemented for build environment type %s" % be.get_betype_display()) | ||
74 | |||
75 | |||
76 | def get_artifact(self, path): | 42 | def get_artifact(self, path): |
77 | if self.betype == BuildEnvironment.TYPE_LOCAL: | 43 | if self.betype == BuildEnvironment.TYPE_LOCAL: |
78 | return open(path, "r") | 44 | return open(path, "r") |