Package timedrive :: Package utils
[frames] | no frames]

Package utils

Submodules

Functions
int
handle_error(err_message)
handles the error produced by duplicity and tries to make a proper response
String
find_file(file_name)
Using the file_name, search in the common places.
Int
time_String2Int(time_string)
Convenience funciton for converting raw time strings to integer format.
 
time_GetCurrentTime()
Convenience function which can retrieve the current time
 
time_Int2String(time_int)
Convenience function for converting time in integer format to raw string.
 
time_String2Pretty(time_string)
Convenience funciton for converting raw time strings to a more readable format.
 
time_Int2Pretty(time_int)
Convenience function for converting time integers to a more readable format.
String
verify_ExcludePattern(exclude_pattern)
Verifies the specified exclude_pattern or path to ensure that it doesn't contain illegal characters.
 
setup_cron(backup_frequency)
Method that creates a listing in the users crontab file so that backups can run unattended.
Boolean
server_available(host, port)
check if a server on a given port is online
IncludeItem Object
findFolder(IncludeList, includeName, includeType=None)
Locates a folder in the includes list
int
getPortProtocol(proto)
Convert protocol name to port
 
backupTypeToText(includeItem)
convert folder backup type to text Note: when text change method textToBackupType
 
textToBackupType(text)
convert text to folder backup type Note: when text change method backupTypeToText
 
locationTypeToText(includeItem)
convert folder location type to text Note: when text change method textToLocationType
 
textToLocationType(text)
convert text to folder location type Note: when text change method locationTypeToText
String
determine_folderName(include)
Get the folder name
String
mount_remote(include)
Get the folder name
Boolean
umount_remote(include)
umount the remote folder, no remove of folder
String
which(program)
This mimics the behavior of the UNIX 'which' command.
Variables
  MANUAL = 0
  DAY = 1
  WEEK = 2
  MONTH = 3
  __package__ = 'timedrive.utils'

Imports: os, time, re, sys, socket, log, includeitem, globals, subprocess, dup_time, archiveurl, duplicity_interface, gui_utils, validate


Function Details

handle_error(err_message)

 

handles the error produced by duplicity and tries to make a proper response

Parameters:
  • err_message (String) - the error message from duplicity
Returns: int
returns -1 if the error can't be process. return 0 if backendException return 1 to 99 if fatal error occured

find_file(file_name)

 

Using the file_name, search in the common places. Return the path for the file or None if the file couldn't be found.

Parameters:
  • file_name (String) - the filename to search
Returns: String
if found the full path with filename, if not found returns None

time_String2Int(time_string)

 

Convenience funciton for converting raw time strings to integer format.

Parameters:
  • time_string (String) - time as string
Returns: Int
return the time

verify_ExcludePattern(exclude_pattern)

 

Verifies the specified exclude_pattern or path to ensure that it doesn't contain illegal characters.

Returns: String
returns the pattern, if an error occured return None

setup_cron(backup_frequency)

 

Method that creates a listing in the users crontab file so that backups can run unattended. If using Mac OS X, crontab must be enabled and the user must have a valid cron file before running.

server_available(host, port)

 

check if a server on a given port is online

Parameters:
  • host (String) - a valid hostname or ip addres
  • port (Int) - a valid port number
Returns: Boolean
if the server on the port is available returns true else false

findFolder(IncludeList, includeName, includeType=None)

 

Locates a folder in the includes list

Parameters:
  • IncludeList (List() of type IncludeItem Object)
  • includeName (String) - the name of the folder or location (field FolderName in IncludeItem Object)
  • includeType (int) - backuptype defined in the IncludeItem Object
Returns: IncludeItem Object
if the given name is found it returns a includeItem else it returns None

getPortProtocol(proto)

 

Convert protocol name to port

Parameters:
  • proto (String) - is the name of the protocol
Returns: int
returns the port of a protocol

backupTypeToText(includeItem)

 

convert folder backup type to text Note: when text change method textToBackupType

Parameters:
  • includeItem (IncludeItem Object)

textToBackupType(text)

 

convert text to folder backup type Note: when text change method backupTypeToText

Parameters:
  • text (String)

locationTypeToText(includeItem)

 

convert folder location type to text Note: when text change method textToLocationType

Parameters:
  • includeItem (IncludeItem Object)

textToLocationType(text)

 

convert text to folder location type Note: when text change method locationTypeToText

Parameters:
  • text (String)

determine_folderName(include)

 

Get the folder name

Parameters:
  • include (IncludeItem Object) - can be of type IncludeLocalItem or IncludeRemoteItem
Returns: String

mount_remote(include)

 

Get the folder name

Parameters:
  • include (IncludeRemoteItem Object)
Returns: String
the string where it's mounted, if none mount is in error state

umount_remote(include)

 

umount the remote folder, no remove of folder

Parameters:
  • include (IncludeRemoteItem Object)
Returns: Boolean
state of the umount response, false is returned if fusermount isn't found

which(program)

 

This mimics the behavior of the UNIX 'which' command.

Parameters:
  • program (String) - can be in the form '/bin/ls' or 'ls'
Returns: String
not found returns None, else returns the location with path