mozInstall 2.0.1__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,11 @@
1
- Metadata-Version: 1.1
1
+ Metadata-Version: 2.1
2
2
  Name: mozInstall
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: package for installing and uninstalling Mozilla applications
5
5
  Home-page: https://wiki.mozilla.org/Auto-tools/Projects/Mozbase
6
6
  Author: Mozilla Automation and Tools team
7
7
  Author-email: tools@lists.mozilla.org
8
8
  License: MPL 2.0
9
- Description: see https://firefox-source-docs.mozilla.org/mozbase/index.html
10
9
  Keywords: mozilla
11
10
  Platform: UNKNOWN
12
11
  Classifier: Environment :: Console
@@ -17,3 +16,6 @@ Classifier: Operating System :: OS Independent
17
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
17
  Classifier: Programming Language :: Python :: 2.7
19
18
  Classifier: Programming Language :: Python :: 3
19
+
20
+ see https://firefox-source-docs.mozilla.org/mozbase/index.html
21
+
@@ -1,12 +1,11 @@
1
- Metadata-Version: 1.1
1
+ Metadata-Version: 2.1
2
2
  Name: mozInstall
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: package for installing and uninstalling Mozilla applications
5
5
  Home-page: https://wiki.mozilla.org/Auto-tools/Projects/Mozbase
6
6
  Author: Mozilla Automation and Tools team
7
7
  Author-email: tools@lists.mozilla.org
8
8
  License: MPL 2.0
9
- Description: see https://firefox-source-docs.mozilla.org/mozbase/index.html
10
9
  Keywords: mozilla
11
10
  Platform: UNKNOWN
12
11
  Classifier: Environment :: Console
@@ -17,3 +16,6 @@ Classifier: Operating System :: OS Independent
17
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
17
  Classifier: Programming Language :: Python :: 2.7
19
18
  Classifier: Programming Language :: Python :: 3
19
+
20
+ see https://firefox-source-docs.mozilla.org/mozbase/index.html
21
+
@@ -1,4 +1,4 @@
1
1
  mozinfo>=0.7
2
2
  mozfile>=1.0
3
3
  requests
4
- six>=1.10.0
4
+ six>=1.13.0
@@ -3,6 +3,4 @@
3
3
  # License, v. 2.0. If a copy of the MPL was not distributed with this file,
4
4
  # You can obtain one at http://mozilla.org/MPL/2.0/.
5
5
 
6
- from __future__ import absolute_import
7
-
8
6
  from .mozinstall import *
@@ -2,9 +2,6 @@
2
2
  # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
3
  # You can obtain one at http://mozilla.org/MPL/2.0/.
4
4
 
5
- from __future__ import absolute_import, print_function
6
-
7
- from optparse import OptionParser
8
5
  import os
9
6
  import plistlib
10
7
  import shutil
@@ -14,13 +11,12 @@ import tarfile
14
11
  import tempfile
15
12
  import time
16
13
  import zipfile
17
-
18
- import requests
19
-
20
- from six import PY3, reraise
14
+ from optparse import OptionParser
21
15
 
22
16
  import mozfile
23
17
  import mozinfo
18
+ import requests
19
+ from six import PY3, reraise
24
20
 
25
21
  try:
26
22
  import pefile
@@ -136,6 +132,8 @@ def install(src, dest):
136
132
  install_dir = _install_dmg(src, dest)
137
133
  elif src.lower().endswith(".exe"):
138
134
  install_dir = _install_exe(src, dest)
135
+ elif src.lower().endswith(".msix"):
136
+ install_dir = _install_msix(src)
139
137
  elif zipfile.is_zipfile(src) or tarfile.is_tarfile(src):
140
138
  install_dir = mozfile.extract(src, dest)[0]
141
139
 
@@ -216,6 +214,16 @@ def uninstall(install_folder):
216
214
  :param install_folder: Path of the installation folder
217
215
 
218
216
  """
217
+ # Uninstallation for MSIX applications is totally different than
218
+ # any other installs...
219
+ if "WindowsApps" in install_folder:
220
+ # At the time of writing, the package installation directory is always
221
+ # the package full name, so this assumption is valid (for now....).
222
+ packageFullName = install_folder.split("WindowsApps\\")[1].split("\\")[0]
223
+ cmd = f"powershell.exe Remove-AppxPackage -Package {packageFullName}"
224
+ subprocess.check_call(cmd)
225
+ return
226
+
219
227
  install_folder = os.path.realpath(install_folder)
220
228
  assert os.path.isdir(install_folder), (
221
229
  'installation folder "%s" exists.' % install_folder
@@ -351,6 +359,47 @@ def _install_exe(src, dest):
351
359
  return dest
352
360
 
353
361
 
362
+ def _get_msix_install_location(pkg):
363
+ with zipfile.ZipFile(pkg) as zf:
364
+ # First, we pull the app identity out of the AppxManifest...
365
+ with zf.open("AppxManifest.xml") as am:
366
+ for line in am.readlines():
367
+ line = line.decode("utf-8")
368
+ if "<Identity" in line:
369
+ for part in line.split(" "):
370
+ if part.startswith("Name"):
371
+ pkgname = part.split("=")[-1].strip('"\r\n')
372
+
373
+ # ...then we can use it to find the install location
374
+ # with this cmdlet
375
+ cmd = (
376
+ f'powershell.exe "Get-AppxPackage" "-Name" "{pkgname}"'
377
+ )
378
+ for line in (
379
+ subprocess.check_output(cmd)
380
+ .decode("utf-8")
381
+ .splitlines()
382
+ ):
383
+ if line.startswith("InstallLocation"):
384
+ return "C:{}".format(line.split(":")[-1].strip())
385
+
386
+ raise Exception(f"Couldn't find install location of {pkg}")
387
+
388
+
389
+ def _install_msix(src):
390
+ """Install the MSIX package and return the installation path.
391
+
392
+ Arguments:
393
+ src -- MSIX package to install
394
+
395
+ """
396
+ # possibly gets around UAC in vista (still need to run as administrator)
397
+ cmd = f'powershell.exe "Add-AppxPackage" "-Path" "{src}"'
398
+ subprocess.check_call(cmd)
399
+
400
+ return _get_msix_install_location(src)
401
+
402
+
354
403
  def install_cli(argv=sys.argv[1:]):
355
404
  parser = OptionParser(usage="usage: %prog [options] installer")
356
405
  parser.add_option(
@@ -2,9 +2,8 @@
2
2
  # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
3
  # You can obtain one at http://mozilla.org/MPL/2.0/.
4
4
 
5
- from __future__ import absolute_import
6
-
7
5
  import os
6
+
8
7
  from setuptools import setup
9
8
 
10
9
  try:
@@ -13,13 +12,13 @@ try:
13
12
  except IOError:
14
13
  description = None
15
14
 
16
- PACKAGE_VERSION = "2.0.1"
15
+ PACKAGE_VERSION = "2.1.0"
17
16
 
18
17
  deps = [
19
18
  "mozinfo >= 0.7",
20
19
  "mozfile >= 1.0",
21
20
  "requests",
22
- "six >= 1.10.0",
21
+ "six >= 1.13.0",
23
22
  ]
24
23
 
25
24
  setup(
File without changes