Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove undesired print when quiet=True #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions pyblast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,33 @@ def write(self, data, mode="w", wodesc=False) :

# decorator to time functions
def ftiming(f):
def wrap(*args, **kwargs):
# Receive 'quiet' from kwargs and use it directly
quiet = kwargs.get('quiet', False) # This will not modify kwargs

def wrap(* args, ** kwargs):

funcname = kwargs.pop("funcname", f.__name__)
funcname = funcname or "Unknown funcname"

time1 = time.time()
ret = f(* args, ** kwargs)
ret = f(*args, **kwargs)
time2 = time.time()

print('{:s} function took {:.3f} ms'.format(funcname, (time2-time1) * 1000.0))


# Only print if 'quiet' is False
if not quiet:
print('{:s} function took {:.3f} ms'.format(funcname, (time2 - time1) * 1000.0))

return ret

return wrap

def run_cmdline(cmdline, funcname=None, quiet=False) :
if not quiet : return run_cmdline_loud(cmdline, funcname=funcname)
def run_cmdline(cmdline, funcname=None, quiet=False):
# Pass all original parameters to the function
if not quiet:
return run_cmdline_loud(cmdline, funcname=funcname, quiet=quiet)
return check_output(cmdline, universal_newlines=True, shell=True)

@ftiming
def run_cmdline_loud(cmdline, funcname=None) :
def run_cmdline_loud(cmdline, funcname=None, quiet=False):
return check_output(cmdline, universal_newlines=True, shell=True)

"""
Expand Down