~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to build/mobile/remoteautomation.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-06-07 14:35:53 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110607143553-fbgqhhvh8g8h6j1y
Tags: 2:1.2~a2~cvs20110606t2200-0ubuntu1
* Update to latest trunk snapshot for Thunderbird beta compat

* Remove build/pgo/profileserver.py from debian/clean. The new build
  system has a target depending on this
  - update debian/clean
* Drop debian/patches/autoconf.diff, just generate this at build time
* Refresh debian/patches/build_system_dont_link_libxul.diff
* libipc seems to be renamed to libipc-pipe. Fix genxpi and chrome.manifest
  to fix this 
  - add debian/patches/ipc-pipe_rename.diff
  - update debian/patches/series
* The makefiles in extensions/enigmail/ipc have an incorrect DEPTH
  attribute. Fix this so that they can find the rest of the build system
  - add debian/patches/makefile_depth.diff
  - update debian/patches/series
* Drop debian/patches/makefile-in-empty-xpcom-fix.diff - fixed in the
  current version
* Don't register a class ID multiple times, as this breaks enigmail entirely
  - add debian/patches/dont_register_cids_multiple_times.diff
  - update debian/patches/series
* Look for the Thunderbird 5 SDK
  - update debian/rules
  - update debian/control
* Run autoconf2.13 at build time
  - update debian/rules
  - update debian/control
* Add useless mesa-common-dev build-dep, just to satisfy the build system.
  We should just patch this out entirely really, but that's for another upload
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ***** BEGIN LICENSE BLOCK *****
 
2
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
#
 
4
# The contents of this file are subject to the Mozilla Public License Version
 
5
# 1.1 (the "License"); you may not use this file except in compliance with
 
6
# the License. You may obtain a copy of the License at
 
7
# http://www.mozilla.org/MPL/
 
8
#
 
9
# Software distributed under the License is distributed on an "AS IS" basis,
 
10
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
11
# for the specific language governing rights and limitations under the
 
12
# License.
 
13
#
 
14
# The Original Code is mozilla.org code.
 
15
#
 
16
# The Initial Developer of the Original Code is Joel Maher.
 
17
#
 
18
# Portions created by the Initial Developer are Copyright (C) 2010
 
19
# the Initial Developer. All Rights Reserved.
 
20
#
 
21
# Contributor(s):
 
22
# Joel Maher <joel.maher@gmail.com> (Original Developer)
 
23
# Clint Talbert <cmtalbert@gmail.com>
 
24
#
 
25
# Alternatively, the contents of this file may be used under the terms of
 
26
# either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
# in which case the provisions of the GPL or the LGPL are applicable instead
 
29
# of those above. If you wish to allow use of your version of this file only
 
30
# under the terms of either the GPL or the LGPL, and not to allow others to
 
31
# use your version of this file under the terms of the MPL, indicate your
 
32
# decision by deleting the provisions above and replace them with the notice
 
33
# and other provisions required by the GPL or the LGPL. If you do not delete
 
34
# the provisions above, a recipient may use your version of this file under
 
35
# the terms of any one of the MPL, the GPL or the LGPL.
 
36
#
 
37
# ***** END LICENSE BLOCK *****
 
38
 
 
39
import time
 
40
import sys
 
41
import os
 
42
import socket
 
43
 
 
44
from automation import Automation
 
45
from devicemanager import DeviceManager, NetworkTools
 
46
 
 
47
class RemoteAutomation(Automation):
 
48
    _devicemanager = None
 
49
    
 
50
    def __init__(self, deviceManager, appName = '', remoteLog = None):
 
51
        self._devicemanager = deviceManager
 
52
        self._appName = appName
 
53
        self._remoteProfile = None
 
54
        self._remoteLog = remoteLog
 
55
 
 
56
        # Default our product to fennec
 
57
        self._product = "fennec"
 
58
        Automation.__init__(self)
 
59
 
 
60
    def setDeviceManager(self, deviceManager):
 
61
        self._devicemanager = deviceManager
 
62
        
 
63
    def setAppName(self, appName):
 
64
        self._appName = appName
 
65
 
 
66
    def setRemoteProfile(self, remoteProfile):
 
67
        self._remoteProfile = remoteProfile
 
68
 
 
69
    def setProduct(self, product):
 
70
        self._product = product
 
71
        
 
72
    def setRemoteLog(self, logfile):
 
73
        self._remoteLog = logfile
 
74
 
 
75
    # Set up what we need for the remote environment
 
76
    def environment(self, env = None, xrePath = None, crashreporter = True):
 
77
        # Because we are running remote, we don't want to mimic the local env
 
78
        # so no copying of os.environ
 
79
        if env is None:
 
80
            env = {}
 
81
 
 
82
        if crashreporter:
 
83
            env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
 
84
            env['MOZ_CRASHREPORTER'] = '1'
 
85
        else:
 
86
            env['MOZ_CRASHREPORTER_DISABLE'] = '1'
 
87
 
 
88
        return env
 
89
 
 
90
    def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime, debuggerInfo, symbolsDir):
 
91
        # maxTime is used to override the default timeout, we should honor that
 
92
        status = proc.wait(timeout = maxTime)
 
93
 
 
94
        print proc.stdout
 
95
 
 
96
        if (status == 1 and self._devicemanager.processExist(proc.procName)):
 
97
            # Then we timed out, make sure Fennec is dead
 
98
            proc.kill()
 
99
 
 
100
        return status
 
101
 
 
102
    def buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs):
 
103
        # If remote profile is specified, use that instead
 
104
        if (self._remoteProfile):
 
105
            profileDir = self._remoteProfile
 
106
 
 
107
        cmd, args = Automation.buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs)
 
108
        # Remove -foreground if it exists, if it doesn't this just returns
 
109
        try:
 
110
            args.remove('-foreground')
 
111
        except:
 
112
            pass
 
113
#TODO: figure out which platform require NO_EM_RESTART
 
114
#        return app, ['--environ:NO_EM_RESTART=1'] + args
 
115
        return app, args
 
116
 
 
117
    def getLanIp(self):
 
118
        nettools = NetworkTools()
 
119
        return nettools.getLanIp()
 
120
 
 
121
    def Process(self, cmd, stdout = None, stderr = None, env = None, cwd = '.'):
 
122
        if stdout == None or stdout == -1 or stdout == subprocess.PIPE:
 
123
          stdout = self._remoteLog
 
124
 
 
125
        return self.RProcess(self._devicemanager, cmd, stdout, stderr, env, cwd)
 
126
 
 
127
    # be careful here as this inner class doesn't have access to outer class members    
 
128
    class RProcess(object):
 
129
        # device manager process
 
130
        dm = None
 
131
        def __init__(self, dm, cmd, stdout = None, stderr = None, env = None, cwd = '.'):
 
132
            self.dm = dm
 
133
            self.stdoutlen = 0
 
134
            self.proc = dm.launchProcess(cmd, stdout, cwd, env, True)
 
135
            if (self.proc is None):
 
136
              raise Exception("unable to launch process")
 
137
            exepath = cmd[0]
 
138
            name = exepath.split('/')[-1]
 
139
            self.procName = name
 
140
 
 
141
            # Setting timeout at 1 hour since on a remote device this takes much longer
 
142
            self.timeout = 3600
 
143
            time.sleep(15)
 
144
 
 
145
        @property
 
146
        def pid(self):
 
147
            hexpid = self.dm.processExist(self.procName)
 
148
            if (hexpid == None):
 
149
                hexpid = "0x0"
 
150
            return int(hexpid, 0)
 
151
    
 
152
        @property
 
153
        def stdout(self):
 
154
            t = self.dm.getFile(self.proc)
 
155
            if t == None: return ''
 
156
            tlen = len(t)
 
157
            retVal = t[self.stdoutlen:]
 
158
            self.stdoutlen = tlen
 
159
            return retVal.strip('\n').strip()
 
160
 
 
161
        def wait(self, timeout = None):
 
162
            timer = 0
 
163
            interval = 5
 
164
 
 
165
            if timeout == None:
 
166
                timeout = self.timeout
 
167
 
 
168
            while (self.dm.processExist(self.procName)):
 
169
                t = self.stdout
 
170
                if t != '': print t
 
171
                time.sleep(interval)
 
172
                timer += interval
 
173
                if (timer > timeout):
 
174
                    break
 
175
 
 
176
            if (timer >= timeout):
 
177
                return 1
 
178
            return 0
 
179
 
 
180
        def kill(self):
 
181
            self.dm.killProcess(self.procName)