diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-07-18 11:10:18 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-07-18 11:10:18 -0300 |
commit | 365fa1603a977040a1891880a66118f196a54ac0 (patch) | |
tree | 9a7305fedaadcf47c7ab09caf8d0548c43940a71 /scripts/profiling/sync/profile-sync.py | |
parent | 03b4ed07d1c55770d9c5b0ed8e7d42dd08f80272 (diff) | |
parent | 4739fd00ba7dd57ef840a953c707c331be4a058f (diff) |
Merge branch 'release-0.6.0'0.6.0
Diffstat (limited to 'scripts/profiling/sync/profile-sync.py')
-rw-r--r-- | scripts/profiling/sync/profile-sync.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/profiling/sync/profile-sync.py b/scripts/profiling/sync/profile-sync.py new file mode 100644 index 00000000..fdd5b5a6 --- /dev/null +++ b/scripts/profiling/sync/profile-sync.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + + +import argparse +import logging + + +from util import StatsLogger, ValidateUserHandle +from client_side_db import get_soledad_instance +#from plot import plot + + +# create a logger +logger = logging.getLogger(__name__) +LOG_FORMAT = '%(asctime)s %(message)s' +logging.basicConfig(format=LOG_FORMAT, level=logging.INFO) + + +# main program + +if __name__ == '__main__': + + # parse command line + parser = argparse.ArgumentParser() + parser.add_argument( + 'user@provider', action=ValidateUserHandle, help='the user handle') + parser.add_argument( + '-b', dest='basedir', required=False, default=None, + help='soledad base directory') + parser.add_argument( + '-p', dest='passphrase', required=False, default=None, + help='the user passphrase') + parser.add_argument( + '-l', dest='logfile', required=False, default='/tmp/profile.log', + help='the file to which write the log') + args = parser.parse_args() + + # get the password + passphrase = args.passphrase + if passphrase is None: + passphrase = getpass.getpass( + 'Password for %s@%s: ' % (args.username, args.provider)) + + # get the basedir + basedir = args.basedir + if basedir is None: + basedir = tempfile.mkdtemp() + logger.info('Using %s as base directory.' % basedir) + + # get the soledad instance + s = get_soledad_instance( + args.username, args.provider, passphrase, basedir) + for i in xrange(10): + s.create_doc({}) + + sl = StatsLogger( + "soledad-sync", args.logfile, procs=["python"], interval=0.001) + sl.start() + s.sync() + sl.stop() + + #plot(args.logfile) |