Package lib :: Package cuckoo :: Package common :: Module utils
[hide private]
[frames] | no frames]

Module utils

source code

Classes [hide private]
  TimeoutServer
Timeout server for XMLRPC.
  TimeoutTransport
  Singleton
Singleton.
Functions [hide private]
 
create_folders(root='.', folders=[])
Create directories.
source code
 
create_folder(root='.', folder=None)
Create directory.
source code
 
delete_folder(folder)
Delete a folder and all its subdirectories.
source code
 
convert_char(c)
Escapes characters.
source code
 
is_printable(s)
Test if a string is printable.
source code
 
convert_to_printable(s)
Convert char to printable.
source code
 
datetime_to_iso(timestamp)
Parse a datatime string and returns a datetime in iso format.
source code
 
get_filename_from_path(path)
Cross-platform filename extraction from path.
source code
 
store_temp_file(filedata, filename)
Store a temporary file.
source code
 
logtime(dt)
Formats time like a logger does, for the csv output (e.g.
source code
 
time_from_cuckoomon(s)
Parse time string received from cuckoomon via netlog
source code
 
to_unicode(s)
Attempt to fix non uft-8 string into utf-8.
source code
 
cleanup_value(v)
Cleanup utility function, strips some unwanted parts from values.
source code
 
sanitize_filename(x)
Kind of awful but necessary sanitizing of filenames to get rid of unicode problems.
source code
Variables [hide private]
  HAVE_CHARDET = True
  PRINTABLE_CHARACTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL...
  __package__ = 'lib.cuckoo.common'
Function Details [hide private]

create_folders(root='.', folders=[])

source code 

Create directories.

Parameters:
  • root - root path.
  • folders - folders list to be created.
Raises:

create_folder(root='.', folder=None)

source code 

Create directory.

Parameters:
  • root - root path.
  • folder - folder name to be created.
Raises:

delete_folder(folder)

source code 

Delete a folder and all its subdirectories.

Parameters:
  • folder - path to delete.
Raises:

convert_char(c)

source code 

Escapes characters.

Parameters:
  • c - dirty char.
Returns:
sanitized char.

convert_to_printable(s)

source code 

Convert char to printable.

Parameters:
  • s - string.
Returns:
sanitized string.

datetime_to_iso(timestamp)

source code 

Parse a datatime string and returns a datetime in iso format.

Parameters:
  • timestamp - timestamp string
Returns:
ISO datetime

get_filename_from_path(path)

source code 

Cross-platform filename extraction from path.

Parameters:
  • path - file path.
Returns:
filename.

store_temp_file(filedata, filename)

source code 

Store a temporary file.

Parameters:
  • filedata - content of the original file.
  • filename - name of the original file.
Returns:
path to the temporary file.

logtime(dt)

source code 
Formats time like a logger does, for the csv output
   (e.g. "2013-01-25 13:21:44,590")
@param dt: datetime object
@return: time string

time_from_cuckoomon(s)

source code 

Parse time string received from cuckoomon via netlog

Parameters:
  • s - time string
Returns:
datetime object

to_unicode(s)

source code 

Attempt to fix non uft-8 string into utf-8. It tries to guess input encoding, if fail retry with a replace strategy (so undetectable chars will be escaped).

See Also: fuller list of encodings at http://docs.python.org/library/codecs.html#standard-encodings


Variables Details [hide private]

PRINTABLE_CHARACTERS

Value:
'''abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%\
&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\r
'''