Module shellutils :: Class WinShell
[hide private]

Class WinShell

source code

Shell --+
        |
       WinShell

Basic class for Windows shell

Instance Methods [hide private]
 
__init__(self, client, protocolName) source code
 
isWinOs(self) source code
 
_getOsLanguageDiscoverer(self) source code
 
getShellCmdSeperator(self)
Get the shell command separator character.
source code
 
getCodePage(self)
Get current codepage of remote Windows machine to which the shell client is connected or 437 if codepage was not resolved
source code
 
setCodePage(self, newCodePage=DEFAULT_ENGLISH_CODEPAGE)
Set new codepage on remote Windows machine to which the shell client is connected
source code
 
getShellStatusVar(self)
Returns the shell command exit status code
source code
 
_getOsType(self)
Get the type of the OS running on the target host to which the shell client is connected.
source code
 
_getOsVersion(self)
Get OS Version
source code
 
getWindowsErrorCode(self)
Get the return code for the latest command execution
source code
 
_execute(self, cmd)
Template method for derived shells for exact command execution
source code
 
deleteDirectoryViaShellCommand(self, dirPath)
Delete directory
source code
 
createDirectoryViaShellCommand(self, dirPath)
Create directory
source code
 
copyFileFromRemoteShare(self, remoteFileName, remoteShareName)
Copy file from the remote share resource
source code
 
deleteRemoteFileFromShare(self, remoteFile, remoteShare)
Delete file from the remote share resource
source code
 
putFile(self, localFilePath, share=DEFAULT_WIN_SHARE)
Copy file to the remote share.
source code
 
deleteFile(self, remoteFile, share=DEFAULT_WIN_SHARE)
Delete remote file
source code
 
__composeRemotePath(self, localFilePath, share)
Returns: String of format "\<ip address>\<share>\<file name>
source code
 
copyFileIfNeeded(self, localFile, share=DEFAULT_WIN_SHARE)
Copy file to the share if it does not exist there
source code
 
getSystem32DirectoryName(self)
Get case sensitive name of Windows %SystemRoot%
source code
 
createSystem32Link(self, location=None, lock=1, force=0)
Creates, locks and returns NTFS junction point to %SystemRoot%\System32 using (in fallback order) linkd, mklink and junction commands.
source code
 
removeSystem32Link(self, location=None)
Unlocks and removes NTFS junction point previously created by @createSystem32Link().
source code
 
is64BitMachine(self)
Checks is the discovered machine OS 64 bit.
source code
 
fsObjectExists(self, path)
Indicates whether object by specified path exists on remote file system
source code
 
safecat(self, path, forceSudo=0)
Get file content by specified path
source code
 
rebuildPath(self, folder)
Normalize path to one used in OS client connected to
source code
 
closeClient(self)
Perform cleaning of temporary data on destination system and close the client
source code

Inherited from Shell: canCopyFile, createOutputHandler, determineOsLanguage, execAlternateCmds, execAlternateCmdsList, execCmd, execCmdAsBytes, executeCommandAndDecode, executeCommandAndDecodeByMatcher, getCharsetName, getClientType, getCommandSeparator, getCredentialId, getDefaultCommandTimeout, getLastCmdReturnCode, getOsLanguage, getOsType, getOsVersion, getPort, getXML, isWindowsWithCygwin, resolveHost, resolveIp, setSessionLocale, useCharset

Class Variables [hide private]
  DEFAULT_ENGLISH_CODEPAGE = 437
  DEFAULT_WIN_SHARE = 'admin$\\system32\\drivers\etc'
  __DEFAULT_COMMAND_SEPARATOR = '&'

Inherited from Shell: NO_CMD_RETURN_CODE_ERR_NUMBER

Method Details [hide private]

__init__(self, client, protocolName)
(Constructor)

source code 
Overrides: Shell.__init__

isWinOs(self)

source code 
Overrides: Shell.isWinOs

_getOsLanguageDiscoverer(self)

source code 
Overrides: Shell._getOsLanguageDiscoverer

getShellCmdSeperator(self)

source code 

Get the shell command separator character. This is the character used between commands when more than one command is passed on the same command line.

Overrides: Shell.getShellCmdSeperator

Deprecated: Use getCommandSeparator instead

getShellStatusVar(self)

source code 

Returns the shell command exit status code

Overrides: Shell.getShellStatusVar

_getOsType(self)

source code 

Get the type of the OS running on the target host to which the shell client is connected. types: -> str

Raises:
  • Exception - Failed getting machine OS type.
Overrides: Shell._getOsType

_getOsVersion(self)

source code 

Get OS Version

Raises:
  • Exception - Failed getting os type
Overrides: Shell._getOsVersion

getWindowsErrorCode(self)

source code 

Get the return code for the latest command execution

Deprecated: Will be removed from the public access

_execute(self, cmd)

source code 

Template method for derived shells for exact command execution

Raises:
  • Exception - Command execution does not produced output nor return code
Overrides: Shell._execute

deleteDirectoryViaShellCommand(self, dirPath)

source code 

Delete directory

Raises:
  • ValueError - Specified path is empty
  • ValueError - Failed deleting directory

Deprecated: Use methods from file system module instead

createDirectoryViaShellCommand(self, dirPath)

source code 

Create directory

Raises:
  • ValueError - Specified path is empty
  • ValueError - Failed creating directory

Deprecated: Use methods from file system module instead

copyFileFromRemoteShare(self, remoteFileName, remoteShareName)

source code 

Copy file from the remote share resource

Deprecated: Use methods from file system module instead

deleteRemoteFileFromShare(self, remoteFile, remoteShare)

source code 

Delete file from the remote share resource

Deprecated: Use methods from file system module instead

putFile(self, localFilePath, share=DEFAULT_WIN_SHARE)

source code 

Copy file to the remote share. If file exists it will be rewritten.

deleteFile(self, remoteFile, share=DEFAULT_WIN_SHARE)

source code 

Delete remote file

Deprecated: Use methods from file system module instead

__composeRemotePath(self, localFilePath, share)

source code 
Returns:
String of format "\<ip address>\<share>\<file name>

copyFileIfNeeded(self, localFile, share=DEFAULT_WIN_SHARE)

source code 

Copy file to the share if it does not exist there

Returns:
return None if file is not copied

Deprecated: Use methods from file system module instead

getSystem32DirectoryName(self)

source code 

Get case sensitive name of Windows %SystemRoot%

Raises:
  • ValueError - Failed to find system32 folder inside the %SystemRoot%

Deprecated: Use methods from file system module instead

createSystem32Link(self, location=None, lock=1, force=0)

source code 

Creates, locks and returns NTFS junction point to %SystemRoot%\System32 using (in fallback order) linkd, mklink and junction commands.

Parameters:
  • lock - variable to control whether to lock or not the created junction point once it is created, default is 1 (meaning lock it)
  • force - variable to control whether Universal Discovery should decide upon creation of junction point (WinOS + 64bit) or forcibly create it
Raises:
  • ValueError - if creation or locking failed

Deprecated: Use methods from file system module instead

removeSystem32Link(self, location=None)

source code 

Unlocks and removes NTFS junction point previously created by @createSystem32Link().

Raises:
  • ValueError - Unable to delete or unlock junction point

Deprecated: Use methods from file system module instead

is64BitMachine(self)

source code 

Checks is the discovered machine OS 64 bit. 32 or 64 bit family detected by checking existence of %SystemRoot%\SysWOW64 folder

Deprecated: Will be removed from the public access

fsObjectExists(self, path)

source code 

Indicates whether object by specified path exists on remote file system

Overrides: Shell.fsObjectExists

Deprecated: Use methods from file system module instead

safecat(self, path, forceSudo=0)

source code 

Get file content by specified path

Parameters:
  • forceSudo - if true, always uses sudo, if false first tries to run command without sudo
Raises:
  • ValueError - Illegal type command, contains redirect
  • Exception - Failed getting contents of file
Overrides: Shell.safecat

Deprecated: Use file system module for such purposes

rebuildPath(self, folder)

source code 

Normalize path to one used in OS client connected to

Overrides: Shell.rebuildPath

Deprecated: Use file system module for such purposes

closeClient(self)

source code 

Perform cleaning of temporary data on destination system and close the client

Overrides: Shell.closeClient