utils

Module: utils

Utility functions.

Authors:

Copyright 2015, Sage Bionetworks (http://sagebase.org), Apache v2.0 License

Functions

mhealthx.utils.rename_file(old_file, new_filename='', new_path='', file_append='', create_file=False)

Rename (and optionally copy) a file / path / file_append.

old_file : string
old file name (full path)
new_filename : string
new file name (not the full path)
new_path : string
replacement path
file_append : string
append to file names
create_file : Boolean
copy file (or just create a string)?
new_filepath : string
new file name (full path, if remove_path not set)
>>> from mhealthx.utils import rename_file
>>> old_file = '/homedir/wav/test1.wav'
>>> new_filename = ''
>>> new_path = '.'
>>> file_append = '.csv'
>>> create_file = True
>>> new_filepath = rename_file(old_file, new_filename, new_path, file_append, create_file)
mhealthx.utils.run_command(command, flag1='', arg1='', flags='', args=[], flagn='', argn='', closing='')

Run a generic command.

command : string
name of command: “SMILExtract”
flag1 : string
optional first command line flag
arg1 : string
optional first argument, handy for iterating over in the pipeline
flags : string or list of strings
command line flags precede their respective args: [“-C”, “-I”, “-O”]
args : string or list of strings
command line arguments: [“config.conf”, “input.wav”, “output.csv”]
flagn : string
optional last command line flag
argn : string
optional last argument, handy for iterating over in the pipeline
closing : string
closing string in command
command_line : string
full command line
args : list of strings
command line arguments
arg1 : string
optional first argument, handy for iterating over in the pipeline
argn : string
optional last argument, handy for iterating over in the pipeline
>>> from mhealthx.utils import run_command
>>> command = 'ls'
>>> flag1 = ''
>>> arg1 = ''
>>> flags = ['-l', '']
>>> args = ['/software', '/desk']
>>> flagn = ''
>>> argn = ''
>>> closing = '> test.txt'
>>> command_line, args, arg1, argn = run_command(command, flag1, arg1, flags, args, flagn, argn, closing)