Python: module telemetry.core.cros_interface

telemetry.core.cros_interface | index telemetry/core/cros_interface.py

`A wrapper around ssh for common operations on a CrOS-based device`

Modules
`` |  |
logging os | re shutil | stat subprocess | tempfile

Classes
`` |  | __builtin__.object CrOSInterface exceptions.Exception(exceptions.BaseException) LoginException DNSFailureException KeylessLoginRequiredException
class CrOSInterface(__builtin__.object)
`` |  | Methods defined here: Chown(self, filename) CloseConnection(self) CryptohomePath(self, user) `Returns the cryptohome mount point for |user|.` FileExistsOnDevice(self, file_name) FilesystemMountedAt(self, path) `Returns the filesystem mounted at |path|` FormSSHCommandLine(self, args, extra_ssh_args=None) `Constructs a subprocess-suitable command line for `ssh'.` GetChromePid(self) `Returns pid of main chrome browser process.` GetChromeProcess(self) `Locates the the main chrome browser process. Chrome on cros is usually in /opt/google/chrome, but could be in /usr/local/ for developer workflows - debug chrome is too large to fit on rootfs. Chrome spawns multiple processes for renderers. pids wrap around after they are exhausted so looking for the smallest pid is not always correct. We locate the session_manager's pid, and look for the chrome process that's an immediate child. This is the main browser process.` GetFile(self, filename, destfile=None) `Copies a local file |filename| to |destfile| on the device. Args: filename: The name of the local source file. destfile: The name of the file to copy to, and if it is not specified then it is the basename of the source file.` GetFileContents(self, filename) `Get the contents of a file on the device. Args: filename: The name of the file on the device. Returns: A string containing the contents of the file.` GetRemotePort(self) IsCryptohomeMounted(self, username, is_guest) `Returns True iff |user|'s cryptohome is mounted.` IsHTTPServerRunningOnPort(self, port) IsServiceRunning(self, service_name) KillAllMatching(self, predicate) ListProcesses(self) `Returns (pid, cmd, ppid, state) of all processes on the device.` PushContents(self, text, remote_filename) PushFile(self, filename, remote_filename) RestartUI(self, clear_enterprise_policy) RmRF(self, filename) RunCmdOnDevice(self, args, cwd=None, quiet=False) TakeScreenShot(self, screenshot_prefix) `Takes a screenshot, useful for debugging failures.` TryLogin(self) __enter__(self) __exit__(self, *args) __init__(self, hostname=None, ssh_port=None, ssh_identity=None) `# pylint: disable=R0923` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` hostname local ssh_port
class DNSFailureException(LoginException)
`` |  | Method resolution order: DNSFailureException LoginException exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors inherited from LoginException: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class KeylessLoginRequiredException(LoginException)
`` |  | Method resolution order: KeylessLoginRequiredException LoginException exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors inherited from LoginException: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class LoginException(exceptions.Exception)
`` |  | Method resolution order: LoginException exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message

Functions
`` |  | GetAllCmdOutput(args, cwd=None, quiet=False) `Open a subprocess to execute a program and returns its output. Args: args: A string or a sequence of program arguments. The program to execute is the string or the first item in the args sequence. cwd: If not None, the subprocess's current directory will be changed to |cwd| before it's executed. Returns: Captures and returns the command's stdout. Prints the command's stderr to logger (which defaults to stdout).` HasSSH() RunCmd(args, cwd=None, quiet=False) `Opens a subprocess to execute a program and returns its return value. Args: args: A string or a sequence of program arguments. The program to execute is the string or the first item in the args sequence. cwd: If not None, the subprocess's current directory will be changed to |cwd| before it's executed. Returns: Return code from the command execution.`