Bug 877733 - bump mozinfo, mozprocess, mozdevice, mozinstall version and mirror to m-c;r=jmaher

This commit is contained in:
Jeff Hammel 2013-06-17 13:23:38 -07:00
parent dccada0f5b
commit 20a56132d3
18 changed files with 142 additions and 189 deletions

View File

@ -147,7 +147,9 @@ def parse_versions(*args):
return retval
def version_tag(directory, version):
return '%s-%s' % (directory, version)
"""return a version tag string given the directory name of the package"""
package = current_package_info[directory]['name']
return '%s-%s' % (package, version)
def setup(**kwargs):
"""monkey-patch function for setuptools.setup"""
@ -321,7 +323,7 @@ def main(args=sys.argv[1:]):
tag = version_tag(directory, version)
if tag not in _tags:
error("Tag for '%s' -- %s -- not in tags")
error("Tag for '%s' -- %s -- not in tags:\n%s" % (directory, version, '\n'.join(sorted(_tags))))
# ensure that the versions to mirror are compatible with what is in m-c
old_package_info = current_package_info.copy()
@ -376,7 +378,8 @@ def main(args=sys.argv[1:]):
finally:
# cleanup
revert(hg_root, untracked)
if options.check:
revert(hg_root, untracked)
shutil.rmtree(tempdir)
print "Diff at %s" % output

View File

@ -171,6 +171,8 @@ class DeviceManagerADB(DeviceManager):
if self.dirExists(destname):
raise DMError("Attempted to push a file (%s) to a directory (%s)!" %
(localname, destname))
if not os.access(localname, os.F_OK):
raise DMError("File not found: %s" % localname)
if self._useRunAs:
remoteTmpFile = self.getTempDir() + "/" + os.path.basename(localname)
@ -233,8 +235,9 @@ class DeviceManagerADB(DeviceManager):
def fileExists(self, filepath):
p = self._runCmd(["shell", "ls", "-a", filepath])
data = p.stdout.readlines()
if (len(data) == 1):
if (data[0].rstrip() == filepath):
if len(data) == 1:
foundpath = data[0].decode('utf-8').rstrip()
if foundpath == filepath:
return True
return False

View File

@ -496,6 +496,9 @@ class DeviceManagerSUT(DeviceManager):
self._logger.warn("launchProcess called without command to run")
return None
if cmd[0] == 'am' and hasattr(self, '_getExtraAmStartArgs'):
cmd = cmd[:2] + self._getExtraAmStartArgs() + cmd[2:]
cmdline = subprocess.list2cmdline(cmd)
if (outputFile == "process.txt" or outputFile == None):
outputFile = self.getDeviceRoot();

View File

@ -50,7 +50,9 @@ class DMCli(object):
{ 'name': 'remote_file', 'nargs': '?' } ],
'help': 'copy file/dir from device' },
'shell': { 'function': self.shell,
'args': [ { 'name': 'command', 'nargs': argparse.REMAINDER } ],
'args': [ { 'name': 'command', 'nargs': argparse.REMAINDER },
{ 'name': '--root', 'action': 'store_true',
'help': 'Run command as root' }],
'help': 'run shell command on device' },
'info': { 'function': self.getinfo,
'args': [ { 'name': 'directive', 'nargs': '?' } ],
@ -107,7 +109,8 @@ class DMCli(object):
'default': 'android.intent.action.VIEW' },
{ 'name': '--url', 'action': 'store' },
{ 'name': '--extra-args', 'action': 'store' },
{ 'name': '--mozenv', 'action': 'store' },
{ 'name': '--mozenv', 'action': 'store',
'help': 'Gecko environment variables to set in "KEY1=VAL1 KEY2=VAL2" format' },
{ 'name': '--no-fail-if-running',
'action': 'store_true',
'help': 'Don\'t fail if application is already running' }
@ -249,9 +252,9 @@ class DMCli(object):
for name in args.process_name:
self.dm.killProcess(name)
def shell(self, args, root=False):
def shell(self, args):
buf = StringIO.StringIO()
self.dm.shell(args.command, buf, root=root)
self.dm.shell(args.command, buf, root=args.root)
print str(buf.getvalue()[0:-1]).rstrip()
def getinfo(self, args):
@ -321,8 +324,15 @@ class DMCli(object):
return errno.ENOENT
def launchfennec(self, args):
mozEnv = None
if args.mozenv:
mozEnv = {}
keyvals = args.mozenv.split()
for keyval in keyvals:
(key, _, val) = keyval.partition("=")
mozEnv[key] = val
self.dm.launchFennec(args.appname, intent=args.intent,
mozEnv=args.mozenv,
mozEnv=mozEnv,
extraArgs=args.extra_args, url=args.url,
failIfRunning=(not args.no_fail_if_running))

View File

@ -4,7 +4,7 @@
from setuptools import setup
PACKAGE_VERSION = '0.25'
PACKAGE_VERSION = '0.26'
setup(name='mozdevice',
version=PACKAGE_VERSION,

View File

@ -2,15 +2,18 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from mozdevice import devicemanager
from mozdevice import devicemanagerSUT
import types
import unittest
import mozlog
from mozdevice import devicemanager
from mozdevice import devicemanagerSUT
ip = ''
port = 0
heartbeat_port = 0
log_level = mozlog.ERROR
class DeviceManagerTestCase(unittest.TestCase):
"""DeviceManager tests should subclass this.
@ -26,7 +29,8 @@ class DeviceManagerTestCase(unittest.TestCase):
return
def setUp(self):
self.dm = devicemanagerSUT.DeviceManagerSUT(host=ip, port=port)
self.dm = devicemanagerSUT.DeviceManagerSUT(host=ip, port=port,
logLevel=log_level)
self.dmerror = devicemanager.DMError
self.nettools = devicemanager.NetworkTools
self._setUp()

View File

@ -5,8 +5,10 @@
from optparse import OptionParser
import os
import re
import unittest
import sys
import unittest
import mozlog
import dmunit
import genfiles
@ -17,8 +19,7 @@ def main(ip, port, heartbeat_port, scripts, directory, isTestDevice, verbose):
dmunit.port = port
dmunit.heartbeat_port = heartbeat_port
if verbose:
from mozdevice.devicemanagerSUT import DeviceManagerSUT
DeviceManagerSUT.debug = 4
dmunit.log_level = mozlog.DEBUG
suite = unittest.TestSuite()

View File

@ -26,6 +26,8 @@ class MockAgent(object):
self.thread = Thread(target=self._serve_thread)
self.thread.start()
self.should_stop = False
@property
def port(self):
return self._sock.getsockname()[1]
@ -42,12 +44,21 @@ class MockAgent(object):
# send response and prompt separately to test for bug 789496
# FIXME: Improve the mock agent, since overloading the meaning
# of 'response' is getting confusing.
if response is None:
if response is None: # code for "shut down"
conn.shutdown(socket.SHUT_RDWR)
conn.close()
conn = None
elif type(response) is int:
time.sleep(response)
elif type(response) is int: # code for "time out"
max_timeout = 15.0
timeout = 0.0
interval = 0.1
while not self.should_stop and timeout < max_timeout:
time.sleep(interval)
timeout += interval
if timeout >= max_timeout:
raise Exception("Maximum timeout reached! This should not "
"happen")
return
else:
# pull is handled specially, as we just pass back the full
# command line

View File

@ -50,6 +50,7 @@ class BasicTest(unittest.TestCase):
except mozdevice.DMError:
exceptionThrown = True
self.assertEqual(exceptionThrown, True)
a.should_stop = True
a.wait()
def test_shell(self):

View File

@ -1,62 +0,0 @@
Throughout [mozmill](https://developer.mozilla.org/en/Mozmill)
and other Mozilla python code, checking the underlying
platform is done in many different ways. The various checks needed
lead to a lot of copy+pasting, leaving the reader to wonder....is this
specific check necessary for (e.g.) an operating system? Because
information is not consolidated, checks are not done consistently, nor
is it defined what we are checking for.
[MozInfo](https://github.com/mozilla/mozbase/tree/master/mozinfo)
proposes to solve this problem. MozInfo is a bridge interface,
making the underlying (complex) plethora of OS and architecture
combinations conform to a subset of values of relavence to
Mozilla software. The current implementation exposes relavent key,
values: `os`, `version`, `bits`, and `processor`. Additionally, the
service pack in use is available on the windows platform.
# API Usage
MozInfo is a python package. Downloading the software and running
`python setup.py develop` will allow you to do `import mozinfo`
from python.
[mozinfo.py](https://github.com/mozilla/mozbase/blob/master/mozinfo/mozinfo.py)
is the only file contained is this package,
so if you need a single-file solution, you can just download or call
this file through the web.
The top level attributes (`os`, `version`, `bits`, `processor`) are
available as module globals:
if mozinfo.os == 'win': ...
In addition, mozinfo exports a dictionary, `mozinfo.info`, that
contain these values. mozinfo also exports:
- `choices`: a dictionary of possible values for os, bits, and
processor
- `main`: the console_script entry point for mozinfo
- `unknown`: a singleton denoting a value that cannot be determined
`unknown` has the string representation `"UNKNOWN"`. unknown will evaluate
as `False` in python:
if not mozinfo.os: ... # unknown!
# Command Line Usage
MozInfo comes with a command line, `mozinfo` which may be used to
diagnose one's current system.
Example output:
os: linux
version: Ubuntu 10.10
bits: 32
processor: x86
Three of these fields, os, bits, and processor, have a finite set of
choices. You may display the value of these choices using
`mozinfo --os`, `mozinfo --bits`, and `mozinfo --processor`.
`mozinfo --help` documents command-line usage.

View File

@ -2,4 +2,53 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
interface to transform introspected system information to a format palatable to
Mozilla
Module variables:
.. attribute:: bits
32 or 64
.. attribute:: isBsd
Returns ``True`` if the operating system is BSD
.. attribute:: isLinux
Returns ``True`` if the operating system is Linux
.. attribute:: isMac
Returns ``True`` if the operating system is Mac
.. attribute:: isWin
Returns ``True`` if the operating system is Windows
.. attribute:: os
Operating system [``'win'``, ``'mac'``, ``'linux'``, ...]
.. attribute:: processor
Processor architecture [``'x86'``, ``'x86_64'``, ``'ppc'``, ...]
.. attribute:: version
Operating system version string. For windows, the service pack information is also included
.. attribute:: info
Returns information identifying the current system.
* :attr:`bits`
* :attr:`os`
* :attr:`processor`
* :attr:`version`
"""
from mozinfo import *

View File

@ -4,19 +4,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
file for interface to transform introspected system information to a format
pallatable to Mozilla
Information:
- os : what operating system ['win', 'mac', 'linux', ...]
- bits : 32 or 64
- processor : processor architecture ['x86', 'x86_64', 'ppc', ...]
- version : operating system version string
For windows, the service pack information is also included
"""
# TODO: it might be a good idea of adding a system name (e.g. 'Ubuntu' for
# linux) to the information; I certainly wouldn't want anyone parsing this
# information and having behaviour depend on it
@ -26,6 +13,13 @@ import platform
import re
import sys
try:
import json
except ImportError:
import simplejson as json
import mozfile
# keep a copy of the os module since updating globals overrides this
_os = os
@ -58,7 +52,10 @@ if system in ["Microsoft", "Windows"]:
service_pack = os.sys.getwindowsversion()[4]
info['service_pack'] = service_pack
elif system == "Linux":
(distro, version, codename) = platform.dist()
if hasattr(platform, "linux_distribution"):
(distro, version, codename) = platform.linux_distribution()
else:
(distro, version, codename) = platform.dist()
version = "%s %s" % (distro, version)
if not processor:
processor = machine
@ -111,7 +108,15 @@ def sanitize(info):
# method for updating information
def update(new_info):
"""update the info"""
"""Update the info.
new_info can either be a dict or a path/url
to a json file containing a dict."""
if isinstance(new_info, basestring):
f = mozfile.load(new_info)
new_info = json.loads(f.read())
f.close()
info.update(new_info)
sanitize(info)
globals().update(info)
@ -144,21 +149,12 @@ def main(args=None):
# args are JSON blobs to override info
if args:
try:
from json import loads
except ImportError:
try:
from simplejson import loads
except ImportError:
def loads(string):
"""*really* simple json; will not work with unicode"""
return eval(string, {'true': True, 'false': False, 'null': None})
for arg in args:
if _os.path.exists(arg):
string = file(arg).read()
else:
string = arg
update(loads(string))
update(json.loads(string))
# print out choices if requested
flag = False

View File

@ -2,21 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import os
from setuptools import setup
PACKAGE_VERSION = '0.4'
# get documentation from the README
try:
here = os.path.dirname(os.path.abspath(__file__))
description = file(os.path.join(here, 'README.md')).read()
except (OSError, IOError):
description = ''
PACKAGE_VERSION = '0.5'
# dependencies
deps = []
deps = ['mozfile >= 0.6']
try:
import json
except ImportError:
@ -24,8 +15,8 @@ except ImportError:
setup(name='mozinfo',
version=PACKAGE_VERSION,
description="file for interface to transform introspected system information to a format pallatable to Mozilla",
long_description=description,
description="Library to get system information for use in Mozilla testing",
long_description="see http://mozbase.readthedocs.org",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='mozilla',
author='Mozilla Automation and Testing Team',

View File

@ -1,60 +0,0 @@
[Mozinstall](https://github.com/mozilla/mozbase/tree/master/mozinstall) is a
python package for installing and uninstalling Mozilla applications on
various platforms.
For example, depending on the platform, Firefox can be distributed as a
zip, tar.bz2, exe, or dmg file or cloned from a repository. Mozinstall takes
the hassle out of extracting and/or running these files and for convenience
returns the full path to the install directory. In the case that mozinstall
is invoked from the command line, the binary path will be printed to stdout.
To remove an installed application the uninstaller can be used. It requires
the installation path of the application and will remove all the installed
files. On Windows the uninstaller will be tried first.
# Usage
Mozinstall can be used as API or via the CLI commands.
## API
An application can be installed by running the commands below. The install
method will return the installation path of the application.
import mozinstall
path = mozinstall.install(%installer%, %install_folder%)
To retrieve the real binary call get_binary with the path and
the application name as arguments:
mozinstall.get_binary(path, 'firefox')
If the application is not needed anymore the uninstaller will remove all
traces from the system:
mozinstall.uninstall(path)
## CLI
The installer can also be used as a command line tool:
$ mozinstall -d firefox %installer%
Whereby the directory option is optional and will default to the current
working directory. If the installation was successful the path to the
binary will be printed to stdout.
Also the uninstaller can be called via the command line:
$ mozuninstall %install_path%
# Error Handling
Mozinstall throws different types of exceptions:
- mozinstall.InstallError is thrown when the installation fails for any reason. A traceback is provided.
- mozinstall.InvalidBinary is thrown when the binary cannot be found.
- mozinstall.InvalidSource is thrown when the source is not a recognized file type (zip, exe, tar.bz2, tar.gz, dmg).
# Dependencies
Mozinstall depends on the [mozinfo](https://github.com/mozilla/mozbase/tree/master/mozinfo)
package which is also found in the mozbase repository.

View File

@ -11,17 +11,16 @@ try:
except IOError:
description = None
PACKAGE_VERSION = '1.4'
PACKAGE_VERSION = '1.6'
deps = ['mozinfo == 0.4',
deps = ['mozinfo >= 0.4',
'mozfile'
]
setup(name='mozInstall',
version=PACKAGE_VERSION,
description="This is a utility package for installing and uninstalling "
"Mozilla applications on various platforms.",
long_description=description,
description="package for installing and uninstalling Mozilla applications",
long_description="see http://mozbase.readthedocs.org/",
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=['Environment :: Console',
'Intended Audience :: Developers',
@ -40,10 +39,14 @@ setup(name='mozInstall',
include_package_data=True,
zip_safe=False,
install_requires=deps,
# we have to generate two more executables for those systems that cannot run as Administrator
# and the filename containing "install" triggers the UAC
entry_points="""
# -*- Entry points: -*-
[console_scripts]
mozinstall = mozinstall:install_cli
mozuninstall = mozinstall:uninstall_cli
moz_add_to_system = mozinstall:install_cli
moz_remove_from_system = mozinstall:uninstall_cli
""",
)

View File

@ -4,7 +4,7 @@
from setuptools import setup
PACKAGE_VERSION = '0.10'
PACKAGE_VERSION = '0.11'
setup(name='mozprocess',
version=PACKAGE_VERSION,

View File

@ -27,7 +27,7 @@ ifeq ($(UNAME), Darwin)
AR = ar
ARFLAGS = rcv
SHLD = libtool
CFLAGS = -v -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -fPIC -Wall -ansi -pedantic
CFLAGS = -v -arch i386 -fPIC -Wall -ansi -pedantic
LDFLAGS = -arch_only i386
endif
ifeq ($(WIN32), 1)

View File

@ -2,4 +2,4 @@
# see https://bugzilla.mozilla.org/show_bug.cgi?id=790765#c51
[test_mozprocess.py]
skip-if = os == 'win'
disabled = bug 877864