RemoteSystem Object
The RemoteSystem
object can be used to interact with the system that squishserver runs on. In some cases, the system that the AUT runs on is not the same system the squishserver runs on. This means that RemoteSystem
can not be used to access the AUT's operating system when testing Android, iOS, or remote attachable AUTs in general.
Squish provides a RemoteSystem
object whose methods can be used for file system operations and process execution on the system the squishserver is running on. In order to use the object, the RemoteSystem
library has to be included and an object instance must be created.
RemoteSystem RemoteSystem()
When the object instance is created by the default constructor, a connection to the default squishserver is automatically established. If an error occurs and the connection cannot be established, an exception is raised and no object instance is created.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remotesys = new RemoteSystem(); } catch (e) { test.fail("Connect to squishserver", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; eval { my $con = Squish::RemoteSystem->new(); 1; } or do { my $e = $@; test::fail("Connect to squishserver", $e); };
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remotesys = RemoteSystem() except Exception as e: test.fail("Connect to squishserver", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remotecon = RemoteSystem.new() rescue Exception => e Test.fail("Connect to squishserver", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remotesys [::Squish::RemoteSystem new]} result]} { test fail "Connect to squishserver" $result } }
RemoteSystem RemoteSystem(host, port)
The constructor of the RemoteSystem
object takes two optional arguments that can be used to establish a connection to an arbitrary squishserver. The first parameter is the hostname or IP address, the second parameter is the port number. The following example creates a RemoteSystem
object that is connected to a manually started squishserver on the local system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remotesys = new RemoteSystem("localhost", 4322); } catch (e) { test.fail("Connect to squishserver", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; eval { my $con = Squish::RemoteSystem->new("localhost", 4322); 1; } or do { my $e = $@; test::fail("Connect to squishserver", $e); };
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remotesys = RemoteSystem("localhost", 4322) except Exception as e: test.fail("Connect to squishserver", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remotecon = RemoteSystem.new("localhost", 4322) rescue Exception => e Test.fail("Connect to squishserver", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remotesys [::Squish::RemoteSystem new localhost 4322]} result]} { test fail "Connect to squishserver" $result } }
The following exceptions can occur when the constructor of the object is called.
Exception | Description |
---|---|
Runtime Error | When a connection cannot be established. |
Type/Value/Argument Error (JavaScript/Python/Ruby) | When a parameter is missing. |
Note: The exceptions for Perl and Tcl don`t have a specific exception type. Only a message, describing the error, is given.
Once the RemoteSystem
object is created, the following methods are available.
list RemoteSystem.execute(cmd)
list RemoteSystem.execute(cmd, cwd)
list RemoteSystem.execute(cmd, cwd, env)
list RemoteSystem.execute(cmd, cwd, env, options)
The execute method can be used to run an application or shell command. As the first parameter a list/array of the command and all parameters must be given. The three following parameters are optional.
The cwd
parameter specifies the working directory for executing the provided command.
The env
parameter allows to set or remove environment variables. To remove an environment variable use an empty string as value.
The options
parameter offers additional, sometimes less often used options. Please find the supported options for this below.
Note: RemoteSystem.execute is a synchronous operation that returns only when the executed command is finished or the process is started as a background task. When the process is started as a background task there no longer is an association to the RemoteSystem object.
RemoteSystem.execute Options
The following table lists all possible options.
Parameter | Type | Default | Description |
---|---|---|---|
cmd | List/Array | Mandatory | Array with command to execute and parameters. |
cwd | String | Empty | Working directory for the started process. |
env | Dictionary | Empty | Key/Value pairs of environment variables. |
options | Dictionary | Empty | Dictionary of all options. |
options.keepLineEnding | Boolean | True | If provided and set to false, line endings in stdout/stderr output of the started process will be converted to '\n' (Unix) newlines. |
options.clearenv | Boolean | False | If provided and set to true, the process will be started with a minimal environment. However, on most OS it is not possible to remove all environment variables because then some functionality or tools provided by the operating system would not work any more. |
options.timeout | Integer | 30 | Value is a timeout in seconds. It is used to limit the execution time of the started process. |
options.encoding | String | UTF-8 | Name of the encoding of the stdout/stderr output of the started process. See below for a supported encodings. |
RemoteSystem.execute Return Values
The following table lists the return values. The returned value is a simple list/array with three elements. The order is always the same.
Name | Type | Description |
---|---|---|
exitcode | String/Unicode | Exit code of the process. |
stdout | String/Unicode | Stdout output of the process. |
stderr | String/Unicode | Stderr output of the process. |
Note: The return value in JavaScript is an object with properties.
RemoteSystem.execute Examples
Example for each language. The example adds one environment variable, deletes one and then gets the environment variable list from windows. The maximum run time for the command is 10 seconds, for the encoding the Windows IBM850 codepage is used. Also the line endings are transformed to "\n" line endings.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remotesys = new RemoteSystem(); cmd = ["cmd", "/c", "set"]; cwd = ""; env = {}; env["MYTESTENV"] = "test string"; env["COMPUTERNAME"] = ""; options = {}; options.keepLineEnding = false; options.clearenv = false; options.timeout = 10; options.encoding = "IBM850" execresult = remotesys.execute(cmd, cwd, env, options); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; my $cmd = ["cmd", "/c", "set"]; my $cwd = ""; my $env = { "MYTESTENV" => "test string", "COMPUTERNAME" => "" }; my $options = { "keepLineEnding" => 0, "clearenv" => 0, "timeout" => 10, "encoding" => "IBM850" }; eval { my $remotecon = Squish::RemoteSystem->new(); my ($exitcode,$stdout,$stderr) = $remotecon->execute($cmd, $cwd, $env, $options); 1; } or do { test::fail("RemoteSystem error", $@); };
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remotesys = RemoteSystem() cmd = [ "cmd", "/c", "set" ] cwd = "" env = { "MYTESTENV": "test string", "COMPUTERNAME": "" } options = { "keepLineEnding": False, "clearenv": False, "timeout": 10, "encoding": "IBM850" } (exitcode, stdout, stderr) = remotesys.execute(cmd, cwd, env, options) test.verify(exitcode == "0", "Command not executed") except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remotesys = RemoteSystem.new() cmd = ["cmd", "/c", "set"] cwd = "" env = { "MYTESTENV" => "test string", "COMPUTERNAME" => "" } options = { "keepLineEnding" => false, "clearenv" => false, "timeout" => 10, "encoding" => "IBM850" } exitcode, stdout, stderr = remotesys.execute(cmd, cwd, env, options) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { set cmd [list cmd /c set] set cwd "" set env [dict create] set options [dict create keepNewLine 0 clearenv 0 timeout 10 encoding IBM850] if {[catch {set remotesys [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch {foreach {exitcode stdout stderr} [$remotesys execute $cmd $cwd $env $options] {break}} result] } { test fail "RemoteSystem error" $result } }
Note: When the command is executed on Windows and runs in a console window, the encoding must match the codepage of the console that is used. See https://msdn.microsoft.com/de-de/library/windows/desktop/dd317756(v=vs.85).aspx for Windows codepage numbers and their names. The name of the codepage is the name for the encoding option.
Note: Linux encoding is mostly UTF-8.
RemoteSystem.execute Encodings
The following list is a sub set of possible encodings.
UTF-8 | UTF-16 | ISO 8859-1 to 10 |
ISO 8859-13 to 16 | ISO 2022-JP | Shift-JIS |
IBM 874 | IBM 866 | IBM 850 |
Windows-1250 to 1258 | Big5 | KOI8-R |
Note: For a complete list of supported encodings, see https://doc.qt.io/qt-6/qtextcodec.html#details
RemoteSystem.execute Exceptions
The following exceptions can occur when a command is executed.
Exception | Description |
---|---|
Runtime Error | Encoding not supported. The exception is raised when the wanted encoding is not supported. |
Runtime Error | Working directory not found. The exception is raised when the working directory is not found. |
Runtime Error | Program not started after timeout. The exception is raised when the program to execute does not start within 10 seconds. |
String RemoteSystem.getEnvironmentVariable(variableName)
The getEnvironmentVariable
method can be used to retrieve the content of environment variables from the remote system. The variableName
parameter is used to specify the name of the environment variable on the remote system.
Note: If the retrieved environment variable is not set on the remote system, the function will return an empty string. There is no way to differentiate if the variable is set to an empty string or not set at all.
The following example retrieves the environment variable HOMEDRIVE and logs the result.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.log(remoteOS.getEnvironmentVariable("HOMEDRIVE")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::log($remoteOS->getEnvironmentVariable("HOMEDRIVE")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.log(remoteOS.getEnvironmentVariable("HOMEDRIVE")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.log(remoteOS.getEnvironmentVariable("HOMEDRIVE")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test log [$remoteOS getEnvironmentVariable "HOMEDRIVE"] } result] } { test fail "RemoteSystem error" $result } }
String RemoteSystem.getOSName()
The getOSName
method can be used to retrieve the name of the operating system of the remote system. When the OS can not be determined the function returns "Unknown".
Possible names include:
"Android"
— Android"Darwin"
— macOS and iOS"Linux"
— Linux"QNX"
— QNX"SunOS"
— Solaris"Windows"
— Windows
The following example retrieves the name of the operating system and logs the result.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.log(remoteOS.getOSName()); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::log($remoteOS->getOSName()); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.log(remoteOS.getOSName()) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.log(remoteOS.getOSName()) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } else { test log [$remoteOS getOSName] } }
StringList RemoteSystem.listFiles(path)
The listFiles
method can be used to retrieve a directory listing of a certain path from the remote system. The path
parameter is used to specify the path on the remote system that is retrieved. This method returns a list of file and folder names (it does not return the full paths). It does not work recursively and therefore doesn't show the content of subfolders. If the path does not exist or is not a directory an exception is raised.
The following example retrieves all directory and file names of the "/"-Directory (which under Windows should be the homedrive).
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); dirList = remoteOS.listFiles("/"); for (var i = 0; i < dirList.length; i++) { test.log(dirList[i]); } } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); my @dirList = $remoteOS->listFiles("/"); my $dirListLength = @dirList; for (my $i = 0; $i < $dirListLength; $i++) { test::log($dirList[$i]); } 1; } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() dirList = remoteOS.listFiles("/") for remoteFile in dirList: test.log(remoteFile) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() dirList = remoteOS.listFiles("/") dirList.each do |remoteFile| Test.log remoteFile end rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { set dirList [$remoteOS listFiles "/"]] } result] } { test fail "RemoteSystem error" $result } if { [catch { foreach remoteFile $dirList { test log $remoteFile } } result ] } { test fail "RemoteSystem error" $result } }
Variant RemoteSystem.stat(path, propertyName)
The stat
method can be used to retrieve different properties of a certain path from the remote system. The path
parameter is used to specify the path on the remote system and the propertyName
is used to specify which property should be retrieved. The property name must be chosen from a predefined list of property names (property names are case-sensitive). Depending on the property this method returns different result types. If the path does not exist or the property is unknown an exception is raised.
The following list shows the supported properties and the returned types.
Property Name | Return Type |
---|---|
exists | Boolean |
isDir | Boolean |
isFile | Boolean |
isSymLink | Boolean |
isReadable | Boolean |
isWritable | Boolean |
isExecutable | Boolean |
isHidden | Boolean |
lastModified | Timestamp |
lastRead | Timestamp |
size | Integer |
The following example prints if the given path is a directory or file. And prints the timestamp when the directory was last read.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.log(remoteOS.stat("/", "isDir")); test.log(remoteOS.stat("/", "isFile")); test.log(remoteOS.stat("/", "lastRead")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::log($remoteOS->stat("/", "isDir")); test::log($remoteOS->stat("/", "isFile")); test::log($remoteOS->stat("/", "lastRead")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.log(str(remoteOS.stat("/", "isDir"))) test.log(str(remoteOS.stat("/", "isFile"))) test.log(remoteOS.stat("/", "lastRead")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.log(remoteOS.stat("/", "isDir")? "true" : "false") Test.log(remoteOS.stat("/", "isFile")? "true" : "false" ) Test.log(remoteOS.stat("/", "lastRead")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test log [$remoteOS stat "/" "isDir" ] } result] } { test fail "RemoteSystem error" $result } if { [catch { test log [$remoteOS stat "/" "isFile" ] } result] } { test fail "RemoteSystem error" $result } if { [catch { test log [$remoteOS stat "/" "lastRead" ] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.exists(path)
The exists
method can be used to check if a certain path on the remote system exists. The path
parameter is used to specify the path on the remote system that will be checked.
The following example prints if the two given paths exists.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.log(remoteOS.exists("/")); test.log(remoteOS.exists("/some/nonexisting/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::log($remoteOS->exists("/")); test::log($remoteOS->exists("/some/nonexisting/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.log(str(remoteOS.exists("/"))) test.log(str(remoteOS.exists("/some/nonexisting/path"))) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.log(remoteOS.exists("/")? "true" : "false") Test.log(remoteOS.exists("/some/nonexisting/path")? "true" : "false") rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test log [$remoteOS exists "/"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test log [expr ![$remoteOS exists "/some/nonexisting/path"]] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.deleteFile(path)
The deleteFile
method can be used to delete a file on the remote system. The path
parameter is used to specify the path of the file on the remote system. If the provided file cannot be deleted or the path doesn't lead to a file an exception is raised.
The following example shows how to use the deleteFile method. You will have to replace the path if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.deleteFile("/some/nonexisting/filepath")); test.verify(!remoteOS.exists("/some/nonexisting/filepath")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->deleteFile("/some/nonexisting/filepath")); test::verify(!$remoteOS->exists("/some/nonexisting/filepath")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.deleteFile("/some/nonexisting/filepath")) test.verify(!remoteOS.exists("/some/nonexisting/filepath")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.deleteFile("/some/nonexisting/filepath")) Test.verify(!remoteOS.exists("/some/nonexisting/filepath")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS deleteFile "/some/nonexisting/filepath"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [expr ![$remoteOS exists "/some/nonexisting/filepath"]] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.deleteDirectory(path)
Boolean RemoteSystem.deleteDirectory(path, recursive)
The deleteDirectory
method can be used to delete a directory on the remote system. The path
parameter is used to specify the path of the folder on the remote system. The optional boolean parameter recursive
can be used to specify whether subdirectories and files inside the directories should be deleted too. If the recursive
flag is not set and the specified directory contains files or folders the deletion operation will fail and an exception will be raised. Additionally if some of the specified files and folders cannot be deleted an exception will be raised.
The following example shows how to use the deleteDirectory method. You will have to replace the path if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.deleteDirectory("/some/nonexisting/path")); test.verify(!remoteOS.exists("/some/nonexisting/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->deleteDirectory("/some/nonexisting/path")); test::verify(!$remoteOS->exists("/some/nonexisting/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.deleteDirectory("/some/nonexisting/path")) test.verify(!remoteOS.exists("/some/nonexisting/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.deleteDirectory("/some/nonexisting/path")) Test.verify(!remoteOS.exists("/some/nonexisting/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS deleteDirectory "/some/nonexisting/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [expr ![$remoteOS exists "/some/nonexisting/path"]] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.createDirectory(path)
The createDirectory
method can be used to create a directory on the remote system. The path
parameter is used to specify the path of the folder on the remote system. This method will only create the new folder if the parent directory already exists. If you want to create multiple directories in one go you can use createPath Boolean RemoteSystem.createPath(path). If the folder cannot be created an exception will be raised.
The following example shows how to use the createDirectory method. You will have to replace the path if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.createDirectory("/some/nonexisting/path")); test.verify(remoteOS.exists("/some/nonexisting/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->createDirectory("/some/nonexisting/path")); test::verify($remoteOS->exists("/some/nonexisting/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.createDirectory("/some/nonexisting/path")) test.verify(remoteOS.exists("/some/nonexisting/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.createDirectory("/some/nonexisting/path")) Test.verify(remoteOS.exists("/some/nonexisting/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS createDirectory "/some/nonexisting/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS exists "/some/nonexisting/path"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.createPath(path)
The createPath
method can be used to create directories on the remote system. The path
parameter is used to specify the path of the directories on the remote system. This method will create all folders that are missing on the remote system from the specified path. If the path cannot be created an exception will be raised.
The following example shows how to use the createPath method. You will have to replace the path if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.createPath("/some/nonexisting/path")); test.verify(remoteOS.exists("/some/nonexisting/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->createPath("/some/nonexisting/path")); test::verify($remoteOS->exists("/some/nonexisting/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.createPath("/some/nonexisting/path")) test.verify(remoteOS.exists("/some/nonexisting/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.createPath("/some/nonexisting/path")) Test.verify(remoteOS.exists("/some/nonexisting/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS createPath "/some/nonexisting/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS exists "/some/nonexisting/path"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.rename(oldPath, newPath)
The rename
method can be used to rename and move files and directories on the remote system. The oldPath
parameter is used to specify the old or current path of the directory or file on the remote system. The newPath
parameter is used to specify the new or desired path of the directory or file on the remote system. The operation will fail if the new path is already existing. If the old path doesn't exist or the file or folder cannot be renamed an exception will be raised.
The following example shows how to use the rename method. You will have to replace the paths if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.rename("/some/old/path", "/some/new/path")); test.verify(remoteOS.exists("/some/new/path")); test.verify(!remoteOS.exists("/some/old/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->rename("/some/old/path", "/some/new/path")); test::verify($remoteOS->exists("/some/new/path")); test::verify(!$remoteOS->exists("/some/old/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.rename("/some/old/path", "/some/new/path")) test.verify(remoteOS.exists("/some/new/path")) test.verify(!remoteOS.exists("/some/old/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.rename("/some/old/path", "/some/new/path")) Test.verify(remoteOS.exists("/some/new/path")) Test.verify(!remoteOS.exists("/some/old/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS rename "/some/old/path" "/some/new/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS exists "/some/new/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [expr ![$remoteOS exists "/some/old/path"]] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.createTextFile(path, content)
Boolean RemoteSystem.createTextFile(path, content, encoding)
The createTextFile
method can be used to create a text file on the remote system. The path
parameter is used to specify the path and name of the file that is to be created on the remote system. The content
parameter is used to specify the content of the file that is created as a string. The optional parameter encoding
can be used to specify the encoding of the text file. The default encoding is UTF-8, see above for a possible encodings. This operation will fail if the supplied path already exists (so this function will not overwrite existing files). If the file already exists, the encoding is not supported or the file cannot be created an exception will be raised.
The following example shows how to use the createTextFile method. You will have to replace the path if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.createTextFile("/some/path/to/a/textfile", "Content...")); test.verify(remoteOS.exists("/some/path/to/a/textfile")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->createTextFile("/some/path/to/a/textfile", "Content...")); test::verify($remoteOS->exists("/some/path/to/a/textfile")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.createTextFile("/some/path/to/a/textfile", "Content...")) test.verify(remoteOS.exists("/some/path/to/a/textfile")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.createTextFile("/some/path/to/a/textfile", "Content...")) Test.verify(remoteOS.exists("/some/path/to/a/textfile")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS createTextFile "/some/path/to/a/textfile" "Content..."] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS exists "/some/path/to/a/textfile"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.upload(localPath, remotePath)
The upload
method can be used to upload a file from the local system (i.e., the system the runner is running on) to the remote system (i.e., the system the server is running on). The localPath
parameter is used to specify the path of the source file on the local system, while the remotePath
parameter is used to specify the path of the target location for the file on the remote system. This operation will fail if the supplied remote path already exists (so this function will not overwrite existing files). Additionally if the local path does not exist or the file is not transferred correctly an exception will be raised.
The following example shows how to use the upload method. You will have to replace the paths if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.upload("/some/local/path", "/some/remote/path")); test.verify(remoteOS.exists("/some/remote/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->upload("/some/local/path", "/some/remote/path")); test::verify($remoteOS->exists("/some/remote/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.upload("/some/local/path", "/some/remote/path")) test.verify(remoteOS.exists("/some/remote/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.upload("/some/local/path", "/some/remote/path")) Test.verify(remoteOS.exists("/some/remote/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS upload "/some/local/path" "/some/remote/path"] } result] } { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS exists "/some/remote/path"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.download(remotePath, localPath)
The download
method can be used to download a file from the remote system (i.e., the system the server is running on) to the local system (i.e., the system the runner is running on). The remotePath
parameter is used to specify the path of the source file on the remote system, while the localPath
parameter is used to specify the path of the target location for the file on the local system. This operation will fail if the supplied local path already exists (so this function will not overwrite existing files). Additionally if the remote path does not exist, the local file cannot be created or the file is not transferred correctly an exception will be raised.
The following example shows how to use the download method. You will have to replace the paths if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.download("/some/remote/path", "/some/local/path")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->download("/some/remote/path", "/some/local/path")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.download("/some/remote/path", "/some/local/path")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.download("/some/remote/path", "/some/local/path")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS download "/some/remote/path" "/some/local/path"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.copy(sourcePath, destinationPath)
The copy
method can be used to copy files or folders inside the remote system. The sourcePath
parameter is used to specify the path of the source file or folder on the remote system, while the destinationPath
parameter is used to specify the path of the destination location for the file or folder on the remote system. If you copy a single file the destination path can either be a file or folder. If you copy a folder the destination path has to be a folder, otherwise an exception will be raised. This operation will fail if one of the files involved in a copy operation already exists in the destination location (it will not overwrite existing files). Additionally if any of the files involved cannot be copied correctly an exception will be raised.
The following example shows how to use the copy method. You will have to replace the paths if you want to try the example.
Note: Depending on your setup this test might alter files or folders on your local or remote system.
source(findFile('scripts', 'javascript/remotesystem.js')); function main() { try { remoteOS = new RemoteSystem(); test.verify(remoteOS.copy("/some/remote/path/a", "/some/remote/path/b")); } catch (e) { test.fail("RemoteSystem error", e.toString()); }; }
use warnings; use strict; use Squish::RemoteSystem; sub main { eval { my $remoteOS = Squish::RemoteSystem->new(); test::verify($remoteOS->copy("/some/remote/path/a", "/some/remote/path/b")); } or do { test::fail("RemoteSystem error", $@); }; }
# -*- coding: utf-8 -*- from remotesystem import RemoteSystem def main(): try: remoteOS = RemoteSystem() test.verify(remoteOS.copy("/some/remote/path/a", "/some/remote/path/b")) except Exception as e: test.fail("RemoteSystem error", str(e))
# encoding: UTF-8 require 'squish' require "squish/remotesystem" include Squish def main begin remoteOS = RemoteSystem.new() Test.verify(remoteOS.copy("/some/remote/path/a", "/some/remote/path/b")) rescue Exception => e Test.fail("RemoteSystem error", e.to_s) end end
package require squish::remotesystem proc main {} { if {[catch {set remoteOS [::Squish::RemoteSystem new]} result]} { test fail "RemoteSystem error" $result } if { [catch { test verify [$remoteOS copy "/some/remote/path/a" "/some/remote/path/b"] } result] } { test fail "RemoteSystem error" $result } }
Boolean RemoteSystem.close()
The close
method can be used to close the connection from an instance of RemoteSystem
to the squishserver. Use this if you wish to stop using an instance and explicitly clean up its resources.
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.