From bb5d70dbbe3d569f13935f807a7d2ce60e0d3c4f Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Mon, 24 Nov 2014 08:31:18 -0500 Subject: [PATCH 01/79] Modified to correctly install script --- .gitignore | 2 + scripts/{olog => olog.py} | 91 +++++++++++++++++++++++++++++++++------ setup.py | 11 ++++- 3 files changed, 89 insertions(+), 15 deletions(-) rename scripts/{olog => olog.py} (66%) diff --git a/.gitignore b/.gitignore index e69136d..62b45be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +pyOlog.egg-info /target/ *.pyc *.swp build +dist diff --git a/scripts/olog b/scripts/olog.py similarity index 66% rename from scripts/olog rename to scripts/olog.py index f82667a..0c3888f 100644 --- a/scripts/olog +++ b/scripts/olog.py @@ -3,12 +3,21 @@ import os, sys -from argparse import ArgumentParser, FileType, RawDescriptionHelpFormatter +import argparse +import subprocess from ConfigParser import SafeConfigParser + from getpass import getpass, getuser from pyOlog import LogEntry, Logbook, Tag, Attachment, OlogClient +try: + import keyring +except ImportError: + have_keyring = False +else: + have_keyring = True + description = """\ Command line utility for making OLog entries. @@ -34,6 +43,10 @@ """ +class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, + argparse.RawDescriptionHelpFormatter): + pass + def get_option(cfg, base, opt): """Check if option base/opt is in config cfg""" if cfg.has_option(base, opt): @@ -41,6 +54,17 @@ def get_option(cfg, base, opt): else: return None +def get_screenshot(root = False, itype = 'png'): + """Open ImageMagick and get screngrab as png.""" + if root: + opts = '-window root' + else: + opts = '' + image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), + shell = True, + stdout = subprocess.PIPE) + return image.communicate()[0] + def olog(): """Command line utility for making Olog entries""" @@ -69,8 +93,8 @@ def olog(): # Parse Command Line Options - parser = ArgumentParser(epilog = description, - formatter_class=RawDescriptionHelpFormatter) + parser = argparse.ArgumentParser(epilog = description, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-l', '--logbooks', dest = 'logbooks', help = "Logbook Name(s)", nargs = '*', default = default_logbooks) @@ -81,8 +105,8 @@ def olog(): default = default_username, help = "Username for Olog Access") parser.add_argument('-f', '--file', dest = 'text', - type=FileType('r'), - default=sys.stdin, + type=argparse.FileType('r'), + default=None, help = "Filename of log entry text.") parser.add_argument('--url', dest = 'url', help = "Base URL for Olog Access", @@ -93,6 +117,15 @@ def olog(): parser.add_argument('-p', '--passwd', dest = 'passwd', help = "Password for logging entry") group = parser.add_mutually_exclusive_group() + group.add_argument('-s','--screenshot', dest = 'screenshot', + help = 'Take screenshot of whole screen', + default = False, + action = 'store_true') + group.add_argument('-g', '--grap', dest = 'grab', + help = 'Grab area of screen and add as attatchment.', + default = False, + action = 'store_true') + group = parser.add_mutually_exclusive_group() group.add_argument('-v', action = 'store_true', dest = 'verbose', help = "Verbose output", default = False) group.add_argument('-q', action = 'store_true', dest = 'quiet', @@ -100,6 +133,8 @@ def olog(): args = parser.parse_args() + # Check for + if args.url is None: parser.error('The URL must be specified') if args.logbooks is None: @@ -111,10 +146,6 @@ def olog(): for f in files: print("Reading config from {}".format(f)) - # Get the text for the log entry - with args.text as file: - text = file.read() - logbooks = [Logbook(n) for n in args.logbooks] if args.tags is not None: tags = [Tag(n) for n in args.tags] @@ -126,6 +157,29 @@ def olog(): else: attachments = None + # Grab Screenshot + + if args.screenshot or args.grab: + if not args.quiet and args.grab: + print("Select area of screen to add to log entry.", + file = sys.stderr) + screenshot = Attachment(get_screenshot(args.screenshot), 'screenshot.png') + if attachments is None: + attachments = [screenshot] + else: + attachments.append(screenshot) + + # Get the text for the log entry + if args.text is not None: + with args.text as file: + text = file.read() + else: + if not args.quiet: + print("Type log entry below (Enter -END- to end):", + file = sys.stderr) + sentinel = '-END-' + text = '\n'.join(iter(raw_input, sentinel)) + # First create the log entry log_entry = LogEntry(text, args.user, logbooks, @@ -134,18 +188,29 @@ def olog(): # Now get the password + passwd = None if args.passwd is None: if default_passwd is None: - passwd = getpass('Olog Password for {}:'.format(args.user)) + if have_keyring: + passwd = keyring.get_password('olog', args.user) + if passwd is None: + passwd = getpass('Olog Password for {}:'.format(args.user)) else: passwd = default_passwd else: passwd = args.passwd - + # Now do the log entry client = OlogClient(args.url, args.user, passwd) client.log(log_entry) - + +def main(): + try: + olog() + except KeyboardInterrupt: + print('\nAborted.\n') + sys.exit() + if __name__ == '__main__': - olog() + main() diff --git a/setup.py b/setup.py index c8f4649..4f9a2d3 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,10 @@ @author: shroffk ''' -from distutils.core import setup +try: + from setuptools import setup +except ImportError: + from distutils.core import setup setup(name='pyOlog', @@ -17,5 +20,9 @@ author_email='shroffk@bnl.gov', packages=['pyOlog'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], - scripts=['scripts/olog', 'scripts/ologgrab'] + scripts=['scripts/olog.py', 'scripts/ologgrab'], + entry_points = { + 'console_scripts': [ + 'olog = olog:main'] + } ) From 35048a9076d3fa17a2e76f59735ec9d7bf4a3301 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Mon, 24 Nov 2014 08:31:40 -0500 Subject: [PATCH 02/79] Added option to supply filename for attachmnet to allow use of string --- pyOlog/OlogDataTypes.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index f39223c..ff071b7 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -145,18 +145,26 @@ class Attachment(object): TODO this is not thread safe ''' - def __init__(self, file): + def __init__(self, file, filename = None): ''' Create Attachment + + file can either be a file object or a string. For a + string, the filename must be specified. + >> Attachment(file=open('/home/usr/databrowser.plt') >> Attachment(file=open('test.jpg','rb') + >> Attachment(file=string, filename = 'mydata.png') ''' self.__file=file - + self.__filename=filename def getFile(self): return self.__file def getFilePost(self): - basename = os.path.basename(self.__file.name) + if self.__filename is None: + basename = os.path.basename(self.__file.name) + else: + basename = os.path.basename(self.__filename) mtype = mimetypes.guess_type(basename)[0] if mtype is None: mtype = 'application/octet-stream' From df2a513ee9345c976b4d386376eda646769d9b99 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 08:41:22 -0500 Subject: [PATCH 03/79] Added conda-recipie (not tested yet) --- conda-recipie/build.sh | 3 +++ conda-recipie/meta.yaml | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 conda-recipie/build.sh create mode 100644 conda-recipie/meta.yaml diff --git a/conda-recipie/build.sh b/conda-recipie/build.sh new file mode 100755 index 0000000..dc32638 --- /dev/null +++ b/conda-recipie/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +${PYTHON} setup.py build +${PYTHON} setup.py install diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml new file mode 100644 index 0000000..ada4ad3 --- /dev/null +++ b/conda-recipie/meta.yaml @@ -0,0 +1,28 @@ + +package: + name: pyOlog + version: "0.1.0" + +source: + git_url: https://github.com/NSLS-II-CSX/pyOlog.git + +build: + number: 0 + +requirements: + build: + - python + - setuptools + - requests + + run: + - python + +test: + imports: + - pyOlog + +about: + home: http://olog.github.io/ + license: BSD + summary: Python client for the OLog From 08fa22e9fe21e1a252e535ba7bc0236dd9d47acf Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 08:41:48 -0500 Subject: [PATCH 04/79] Added blank files for API and IPython extension --- pyOlog/api.py | 0 pyOlog/ipy.py | 1 + 2 files changed, 1 insertion(+) create mode 100644 pyOlog/api.py create mode 100644 pyOlog/ipy.py diff --git a/pyOlog/api.py b/pyOlog/api.py new file mode 100644 index 0000000..e69de29 diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pyOlog/ipy.py @@ -0,0 +1 @@ + From 9755a93e272d57d6ac4954c2c5053a380c9ac28b Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 13:16:18 -0500 Subject: [PATCH 05/79] Initial Rebuild --- pyOlog/OlogClient.py | 138 ++++++++++++++++++++++++++++++---------- pyOlog/OlogDataTypes.py | 16 +++-- pyOlog/__init__.py | 4 +- pyOlog/_conf.py | 25 +++++--- scripts/olog.py | 74 ++++----------------- setup.py | 2 +- 6 files changed, 147 insertions(+), 112 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 6eaa4b8..f169c7c 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -6,20 +6,42 @@ @author: shroffk ''' +import logging, sys +fmt = logging.Formatter("%(asctime)-15s [%(name)5s:%(levelname)s] %(message)s") +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +handler = logging.StreamHandler(sys.stdout) +handler.setFormatter(fmt) +logger.addHandler(handler) + +from getpass import getpass + import requests -from json import JSONEncoder, JSONDecoder -from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment -from _conf import _conf -import json +from requests.adapters import HTTPAdapter from requests import auth -import logging + +import json +from json import JSONEncoder, JSONDecoder + from urllib import urlencode +from urllib3.poolmanager import PoolManager + from collections import OrderedDict -import tempfile +import tempfile import ssl -from requests.adapters import HTTPAdapter -from urllib3.poolmanager import PoolManager + +from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment +from _conf import _conf + +try: + import keyring +except ImportError: + have_keyring = False +else: + have_keyring = True + class OlogClient(object): ''' @@ -32,25 +54,56 @@ class OlogClient(object): __logbooksResource = '/resources/logbooks' __attachmentResource = '/resources/attachments' - def __init__(self, url=None, username=None, password=None): + def __init__(self, url=None, username=None, password=None, interactive = True): ''' - Constructor + Initialize OlogClient and configure session + + :param url: The base URL of the Olog glassfish server. + :param username: The username for authentication. + :param password: The password for authentication. + :param interactive: If true then if no password is found, ask for it on th + console + + If :param username: is None, then the username will be read from the config + file. If no :param username: is avaliable then the session is opened without + authentication. + + If :param password: is None then the password will be read from the config file + if this is not set, then if the keyring package is avaliable it will be read + from the gnome keyring. Failing that, if interactive is true, it will be asked + for on the command line. ''' - try: - requests_log = logging.getLogger("requests") - requests_log.setLevel(logging.INFO) - self.__url = self.__getDefaultConfig('url', url) - self.__username = self.__getDefaultConfig('username', username) - self.__password = self.__getDefaultConfig('password', password) - if self.__username and self.__password: - self.__auth = auth.HTTPBasicAuth(self.__username, self.__password) + + self.__url = self.__getDefaultConfig('url', url) + self.__username = self.__getDefaultConfig('username', username) + self.__password = self.__getDefaultConfig('password', password) + + logger.info("Using base URL %s", self.__url) + + if self.__username and not self.__password: + # Try to get password from keyring + if have_keyring: + logger.info("Checking keyring for username %s", self.__username) + self.__password = keyring.get_password('olog', self.__username) + if self.__password: + logger.info("Password obtained from keyring.") else: - self.__auth = None - self.__session = requests.Session() - self.__session.mount('https://', Ssl3HttpAdapter()) - self.__session.get(self.__url + self.__tagsResource, verify=False, headers=self.__jsonheader).raise_for_status() - except: - raise + logger.info("No password in keyring.") + else: + logger.info("No keyring avaliable") + # If this did not work (no passwd or no keyring) + if self.__password is None and interactive: + self.__password = getpass('Olog Password for {}:'.format(self.__username)) + if self.__username and self.__password: + logger.info("Using username %s for authentication.", self.__username) + self.__auth = auth.HTTPBasicAuth(self.__username, self.__password) + else: + logger.info("No authentiation configured.") + self.__auth = None + + self.__session = requests.Session() + self.__session.mount('https://', Ssl3HttpAdapter()) + self.__session.get(self.__url + self.__tagsResource, verify=False, headers=self.__jsonheader).raise_for_status() def __getDefaultConfig(self, arg, value): ''' @@ -63,7 +116,10 @@ def __getDefaultConfig(self, arg, value): def log(self, logEntry): ''' - create a logEntry + Create a log entry + + :param logEntry: An instance of LogEntry to add to the Olog + ''' resp = self.__session.post(self.__url + self.__logsResource, data=LogEntryEncoder().encode(logEntry), @@ -85,7 +141,9 @@ def log(self, logEntry): def createLogbook(self, logbook): ''' - Create Logbook + Create a Logbook + + :param logbook: An instance of Logbook to create in the Olog. ''' self.__session.put(self.__url + self.__logbooksResource + '/' + logbook.getName(), data=LogbookEncoder().encode(logbook), @@ -96,7 +154,9 @@ def createLogbook(self, logbook): def createTag(self, tag): ''' - Create Tag + Create a Tag + + :param tag: An instance of Tag to create in the Olog. ''' url = self.__url + self.__tagsResource + '/' + tag.getName() self.__session.put(url, @@ -107,7 +167,9 @@ def createTag(self, tag): def createProperty(self, property): ''' - Create Property + Create a Property + + :param property: An instance of Property to create in the Olog. ''' url = self.__url + self.__propertiesResource + '/' + property.getName() p = PropertyEncoder().encode(property) @@ -156,7 +218,9 @@ def find(self, **kwds): def listAttachments(self, logEntryId): ''' - Search for attachments on logentry _id_ + Search for attachments on a logentry + + :param logEntryId: The ID of the log entry to list the attachments. ''' resp = self.__session.get(self.__url+self.__attachmentResource+'/'+str(logEntryId), verify=False, @@ -178,7 +242,7 @@ def listAttachments(self, logEntryId): def listTags(self): ''' - List all tags. + List all tags in the Olog. ''' resp = self.__session.get(self.__url + self.__tagsResource, verify=False, @@ -192,7 +256,7 @@ def listTags(self): def listLogbooks(self): ''' - List all logbooks + List all logbooks in the Olog. ''' resp = self.__session.get(self.__url + self.__logbooksResource, verify=False, @@ -206,7 +270,7 @@ def listLogbooks(self): def listProperties(self): ''' - List all Properties and their attributes + List all Properties and their attributes in the Olog. ''' resp = self.__session.get(self.__url + self.__propertiesResource, verify=False, @@ -221,7 +285,15 @@ def listProperties(self): def delete(self, **kwds): ''' - Method to delete a logEntry, logbook, property, tag + Method to delete a logEntry, logbook, property, tag. + + :param logEntryId: ID of log entry to delete. + :param logbookName: The name (as a string) of the logbook to delete. + :param tagName: The name (as a string) of the tag to delete. + :param propertyName: The name (as a string) of the property to delete. + + Example: + delete(logEntryId = int) >>> delete(logEntryId=1234) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index ff071b7..901d217 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -10,6 +10,8 @@ import os import mimetypes +from _conf import _conf + class LogEntry(object): ''' A LogEntry consists of some Text description, an owner and an associated logbook @@ -30,9 +32,13 @@ def __init__(self, text, owner, logbooks, tags=None, attachments=None, propertie attachments=[Attachment(open('databrowser.plt'))] ) ''' - self.Text = str(text).strip(); - self.Owner = str(owner).strip(); - self.logbooks = logbooks + self.Text = str(text).strip() + self.Owner = str(owner).strip() + + if logbooks is None and _conf.has_option('DEFAULT', 'logbooks'): + self.logbooks = [Logbook(n) for n in _conf.get('DEFAULT', 'logbooks').split(',')] + else: + self.logbooks = logbooks if tags is not None: self.tags = tags @@ -101,8 +107,8 @@ def __init__(self, name, owner=None): Create a logbook >> Logbook('commissioning', 'controls') ''' - self.__Name = str(name).strip(); - self.__Owner = str(owner).strip(); + self.__Name = str(name).strip() + self.__Owner = str(owner).strip() def getName(self): return self.__Name diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index fc169d4..db12d37 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -1,2 +1,2 @@ -from OlogDataTypes import * -from OlogClient import * \ No newline at end of file +from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment +from OlogClient import OlogClient diff --git a/pyOlog/_conf.py b/pyOlog/_conf.py index 202dd19..e09c15e 100644 --- a/pyOlog/_conf.py +++ b/pyOlog/_conf.py @@ -10,16 +10,23 @@ url=http://localhost:8000/Olog """ +import os.path +import logging + +logger = logging.getLogger(__name__) + +defaults = {'url' : 'http://localhost:8181/Olog'} +conf_files = ['/etc/pyOlog.conf', + os.path.expanduser('~/pyOlog.conf'), + os.path.expanduser('~/.pyOlog.conf'), + 'pyOlog.conf'] + def __loadConfig(): - import os.path import ConfigParser - dflt={'url':'http://localhost:8000/Olog'} - cf=ConfigParser.SafeConfigParser(defaults=dflt) - cf.read([ - '/etc/pyOlog.conf', - os.path.expanduser('~/pyOlog.conf'), - 'pyOlog.conf' - ]) + cf=ConfigParser.SafeConfigParser(defaults=defaults) + files = cf.read(conf_files) + for f in files: + logger.info("Read config file %s", f) return cf -_conf=__loadConfig() \ No newline at end of file +_conf=__loadConfig() diff --git a/scripts/olog.py b/scripts/olog.py index 0c3888f..d6771b5 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -5,7 +5,6 @@ import argparse import subprocess -from ConfigParser import SafeConfigParser from getpass import getpass, getuser @@ -43,10 +42,6 @@ """ -class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, - argparse.RawDescriptionHelpFormatter): - pass - def get_option(cfg, base, opt): """Check if option base/opt is in config cfg""" if cfg.has_option(base, opt): @@ -68,41 +63,18 @@ def get_screenshot(root = False, itype = 'png'): def olog(): """Command line utility for making Olog entries""" - # Get Defaults from Config File - - cfg = SafeConfigParser() - files = ['/etc/olog.conf', - os.path.join(os.getenv('HOME'),'.olog.conf')] - files = cfg.read(files) - - default_url = get_option(cfg, 'olog', 'url') - - default_logbooks = get_option(cfg, 'olog', 'logbooks') - if default_logbooks is not None: - default_logbooks = default_logbooks.split(',') - - default_username = get_option(cfg, 'olog', 'username') - if default_username is None: - default_username = getuser() - - default_passwd = get_option(cfg, 'olog', 'password') - - default_tags = get_option(cfg, 'olog', 'tags') - if default_tags is not None: - default_tags = default_tags.split(',') - # Parse Command Line Options parser = argparse.ArgumentParser(epilog = description, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-l', '--logbooks', dest = 'logbooks', help = "Logbook Name(s)", nargs = '*', - default = default_logbooks) + default = None) parser.add_argument('-t', '--tags', dest = 'tags', nargs = '*', help = "OLog Tag Name(s)", - default = default_tags) + default = None) parser.add_argument('-u', '--user', dest = 'user', - default = default_username, + default = None, help = "Username for Olog Access") parser.add_argument('-f', '--file', dest = 'text', type=argparse.FileType('r'), @@ -110,12 +82,13 @@ def olog(): help = "Filename of log entry text.") parser.add_argument('--url', dest = 'url', help = "Base URL for Olog Access", - default = default_url) + default = None) parser.add_argument('-a', '--attach', dest = 'attach', nargs = '*', help = "filename of attachments") parser.add_argument('-p', '--passwd', dest = 'passwd', - help = "Password for logging entry") + help = "Password for logging entry", + default = None) group = parser.add_mutually_exclusive_group() group.add_argument('-s','--screenshot', dest = 'screenshot', help = 'Take screenshot of whole screen', @@ -133,20 +106,10 @@ def olog(): args = parser.parse_args() - # Check for - - if args.url is None: - parser.error('The URL must be specified') - if args.logbooks is None: - parser.error('At least one logbook must be specified') - if args.user is None: - parser.error('You must specify a username') - - if args.verbose: - for f in files: - print("Reading config from {}".format(f)) - - logbooks = [Logbook(n) for n in args.logbooks] + if args.logbooks: + logbooks = [Logbook(n) for n in args.logbooks] + else: + logbooks = None if args.tags is not None: tags = [Tag(n) for n in args.tags] else: @@ -185,24 +148,11 @@ def olog(): log_entry = LogEntry(text, args.user, logbooks, tags = tags, attachments = attachments) + print(log_entry) - # Now get the password - - passwd = None - if args.passwd is None: - if default_passwd is None: - if have_keyring: - passwd = keyring.get_password('olog', args.user) - if passwd is None: - passwd = getpass('Olog Password for {}:'.format(args.user)) - else: - passwd = default_passwd - else: - passwd = args.passwd - # Now do the log entry - client = OlogClient(args.url, args.user, passwd) + client = OlogClient(args.url, args.user, args.passwd) client.log(log_entry) def main(): diff --git a/setup.py b/setup.py index 4f9a2d3..7147863 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ author_email='shroffk@bnl.gov', packages=['pyOlog'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], - scripts=['scripts/olog.py', 'scripts/ologgrab'], + scripts=['scripts/olog.py'], entry_points = { 'console_scripts': [ 'olog = olog:main'] From 11931571c34a43bd76b8783ea8cc74797dd3766f Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 20:59:25 -0500 Subject: [PATCH 06/79] Checkin with new version. Major changes to structure --- pyOlog/OlogClient.py | 57 +++++---------------- pyOlog/OlogDataTypes.py | 33 ++++++++---- pyOlog/_conf.py | 32 ------------ pyOlog/api.py | 0 pyOlog/api/__init__.py | 1 + pyOlog/api/session.py | 16 ++++++ pyOlog/api/simple.py | 109 ++++++++++++++++++++++++++++++++++++++++ pyOlog/conf.py | 58 +++++++++++++++++++++ pyOlog/ipy.py | 7 +++ pyOlog/utils.py | 14 ++++++ scripts/olog.py | 63 ++++------------------- setup.py | 2 +- 12 files changed, 253 insertions(+), 139 deletions(-) delete mode 100644 pyOlog/_conf.py delete mode 100644 pyOlog/api.py create mode 100644 pyOlog/api/__init__.py create mode 100644 pyOlog/api/session.py create mode 100644 pyOlog/api/simple.py create mode 100644 pyOlog/conf.py create mode 100644 pyOlog/utils.py diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index f169c7c..1368076 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -25,6 +25,8 @@ from json import JSONEncoder, JSONDecoder from urllib import urlencode +import urllib3 +urllib3.disable_warnings() from urllib3.poolmanager import PoolManager from collections import OrderedDict @@ -33,15 +35,7 @@ import ssl from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment -from _conf import _conf - -try: - import keyring -except ImportError: - have_keyring = False -else: - have_keyring = True - +from conf import _conf class OlogClient(object): ''' @@ -54,65 +48,40 @@ class OlogClient(object): __logbooksResource = '/resources/logbooks' __attachmentResource = '/resources/attachments' - def __init__(self, url=None, username=None, password=None, interactive = True): + def __init__(self, url=None, username=None, password=None): ''' Initialize OlogClient and configure session :param url: The base URL of the Olog glassfish server. :param username: The username for authentication. :param password: The password for authentication. - :param interactive: If true then if no password is found, ask for it on th - console If :param username: is None, then the username will be read from the config file. If no :param username: is avaliable then the session is opened without authentication. - - If :param password: is None then the password will be read from the config file - if this is not set, then if the keyring package is avaliable it will be read - from the gnome keyring. Failing that, if interactive is true, it will be asked - for on the command line. ''' - self.__url = self.__getDefaultConfig('url', url) - self.__username = self.__getDefaultConfig('username', username) - self.__password = self.__getDefaultConfig('password', password) + self.__url = _conf.getValue('url', url) + self.__username = _conf.getValue('username', username) + self.__password = _conf.getValue('password', password) logger.info("Using base URL %s", self.__url) - if self.__username and not self.__password: - # Try to get password from keyring - if have_keyring: - logger.info("Checking keyring for username %s", self.__username) - self.__password = keyring.get_password('olog', self.__username) - if self.__password: - logger.info("Password obtained from keyring.") - else: - logger.info("No password in keyring.") - else: - logger.info("No keyring avaliable") - # If this did not work (no passwd or no keyring) - if self.__password is None and interactive: - self.__password = getpass('Olog Password for {}:'.format(self.__username)) if self.__username and self.__password: + # If we have a valid username and password, setup authentication + logger.info("Using username %s for authentication.", self.__username) self.__auth = auth.HTTPBasicAuth(self.__username, self.__password) else: + + # Don't use authentication logger.info("No authentiation configured.") self.__auth = None self.__session = requests.Session() self.__session.mount('https://', Ssl3HttpAdapter()) - self.__session.get(self.__url + self.__tagsResource, verify=False, headers=self.__jsonheader).raise_for_status() - - def __getDefaultConfig(self, arg, value): - ''' - If Value is None, this will try to find the value in one of the configuration files - ''' - if value == None and _conf.has_option('DEFAULT', arg): - return _conf.get('DEFAULT', arg) - else: - return value + self.__session.get(self.__url + self.__tagsResource, + verify=False, headers=self.__jsonheader).raise_for_status() def log(self, logEntry): ''' diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index 901d217..f38aa91 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -10,7 +10,7 @@ import os import mimetypes -from _conf import _conf +from conf import _conf class LogEntry(object): ''' @@ -18,7 +18,9 @@ class LogEntry(object): It can optionally be associated with one or more logbooks and contain one or more tags, properties and attachments ''' - def __init__(self, text, owner, logbooks, tags=None, attachments=None, properties=None, id=None, createTime=None, modifyTime=None): + def __init__(self, text, owner = None, logbooks = None, + tags=None, attachments=None, properties=None, id=None, + createTime=None, modifyTime=None): ''' Constructor for log Entry Simple LogEntry @@ -28,22 +30,33 @@ def __init__(self, text, owner, logbooks, tags=None, attachments=None, propertie >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')], tags=[Tag('TimingSystem')] - properties=[Property('Ticket', attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}] + properties=[Property('Ticket', + attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}] attachments=[Attachment(open('databrowser.plt'))] ) ''' self.Text = str(text).strip() - self.Owner = str(owner).strip() - if logbooks is None and _conf.has_option('DEFAULT', 'logbooks'): - self.logbooks = [Logbook(n) for n in _conf.get('DEFAULT', 'logbooks').split(',')] + self.Owner = _conf.getValue('username', owner) + if self.Owner is None: + raise ValueError("You must specify an owner (hint: check config file)") + + if logbooks is None: + logbooks = _conf.getValue('logbooks') + if logbooks is None: + raise ValueError("You must specify a logbook (hint: check config file)") + self.logbooks = [Logbook(n) for n in logbooks.split(',')] else: self.logbooks = logbooks - if tags is not None: - self.tags = tags + if tags is None: + tags = _conf.getValue('tags') + if tags is not None: + self.tags = [Tag(n) for n in tags.split(',')] + else: + self.tags = [] else: - self.tags = [] + self.tags = tags if attachments is not None: self.attachments = attachments @@ -123,7 +136,7 @@ def __cmp__(self, *arg, **kwargs): class Tag(object): ''' - A Tag consists of a unique name, it is used to tag logEntries to enable querying and organizing log Entries + A Tag consists of a unique name, it is used to tag logEntries""" ''' def __init__(self, name, state="Active"): diff --git a/pyOlog/_conf.py b/pyOlog/_conf.py deleted file mode 100644 index e09c15e..0000000 --- a/pyOlog/_conf.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Internal module - -Used to read the pyOlog.conf file - -example file -cat ~/pyOlog.conf -[DEFAULT] -url=http://localhost:8000/Olog -""" - -import os.path -import logging - -logger = logging.getLogger(__name__) - -defaults = {'url' : 'http://localhost:8181/Olog'} -conf_files = ['/etc/pyOlog.conf', - os.path.expanduser('~/pyOlog.conf'), - os.path.expanduser('~/.pyOlog.conf'), - 'pyOlog.conf'] - -def __loadConfig(): - import ConfigParser - cf=ConfigParser.SafeConfigParser(defaults=defaults) - files = cf.read(conf_files) - for f in files: - logger.info("Read config file %s", f) - return cf - -_conf=__loadConfig() diff --git a/pyOlog/api.py b/pyOlog/api.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyOlog/api/__init__.py b/pyOlog/api/__init__.py new file mode 100644 index 0000000..f1994de --- /dev/null +++ b/pyOlog/api/__init__.py @@ -0,0 +1 @@ +from simple import SimpleOlogClient diff --git a/pyOlog/api/session.py b/pyOlog/api/session.py new file mode 100644 index 0000000..52cbcb1 --- /dev/null +++ b/pyOlog/api/session.py @@ -0,0 +1,16 @@ +__author__ = 'swilkins' +from ..OlogClient import OlogClient + +import keyring +import getpass + +def init_session(): + """Initiate a session and do password caching using keyring""" + username = getpass.getuser() + password = keyring.get_password('olog', username) + if password is None: + password = getpass.getpass("Olog Password (username = {}) :".format(username)) + client = OlogClient(username = username, password = password) + return client + +session = init_session() diff --git a/pyOlog/api/simple.py b/pyOlog/api/simple.py new file mode 100644 index 0000000..2f44e74 --- /dev/null +++ b/pyOlog/api/simple.py @@ -0,0 +1,109 @@ +__author__ = "swilkins" +""" +A simple API to the Olog client in python +""" + +import os +from tempfile import NamedTemporaryFile +from subprocess import call + +import getpass +import keyring + +from ..OlogClient import OlogClient +from ..OlogDataTypes import LogEntry, Logbook, Tag, Attachment + +class SimpleOlogClient(object): + def __init__(self, url = None, username = None, password = None): + """Initiate a session and do password caching using keyring""" + if username is None: + username = getpass.getuser() + if password is None: + password = keyring.get_password('olog', username) + if password is None: + password = getpass.getpass("Olog Password (username = {}) :".format(username)) + + if username and not password: + raise Exception("Unable to obtain password and authentication requested.") + self.session = OlogClient(username = username, password = password) + + def getTags(self): + """Return a list of tag names in the Olog""" + return [t.getName() for t in self.session.listTags()] + + def getLogbooks(self): + """Return a list of tag names in the Olog""" + return [l.getName() for l in self.session.listLogbooks()] + + def savefig(self, **kwargs): + """Save a matplotlib figure to the logbook""" + import matplotlib.pyplot as plt + import StringIO + + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', **kwargs) + imgdata.seek(0) + + a = Attachment(imgdata, 'plot.png') + + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'] += [a] + else: + kwargs['attachments'] = [kwargs['attachments'], a] + + self.log(attachments = a, **kwargs) + + def log(self, text = None, logbooks = None, tags = None, properties = None, + attachments = None, verify = True): + """ + Create olog entry. + + :param str text: String of the olog entry to make. + :param logbooks: Logbooks to make entry into. + :type logbooks: None, List or string + :param tags:Tags to apply to logbook entry. + :type tags: None, List or string + + """ + + if logbooks: + if not isinstance(logbooks, list): + logbooks = [logbooks] + if tags: + if not isinstance(tags, list): + tags = [tags] + if attachments: + if not isinstance(attachments, list): + attachments = [attachments] + + if logbooks: + if verify: + if not any([x in logbooks for x in self.getLogbooks()]): + raise ValueError("Invalid Logbook name (not in Olog)") + logbooks = [Logbook(n) for n in logbooks] + + if tags: + if verify: + if not any([x in tags for x in self.getTags()]): + raise ValueError("Invalid Tag (not in Olog)") + tags = [Tag(n) for n in tags] + + if not text: + with NamedTemporaryFile(suffix='.tmp') as tempfile: + editor = os.environ.get('EDITOR', 'vim') + call([editor, tempfile.name]) + text = tempfile.read() + + toattach = [] + if attachments: + for a in attachments: + if isinstance(a, Attachment): + toattach.append(a) + else: + toattach.append(Attachment(open(a))) + + log = LogEntry(text, logbooks = logbooks, + tags = tags, attachments = toattach) + self.session.log(log) + diff --git a/pyOlog/conf.py b/pyOlog/conf.py new file mode 100644 index 0000000..61e114a --- /dev/null +++ b/pyOlog/conf.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +""" +Configuration module used to set defaults for pyOlog to connect to the Olog. + +Default locations are searched for a config file. An example file is listed below: + +[DEFAULT] +url=http://localhost:8000/Olog +username=swilkins +logbooks=Commissioning +tags=pyOlog +""" + +import os +import os.path +import logging + +logger = logging.getLogger(__name__) + +class Config(object): + defaults = {'url' : 'http://localhost:8181/Olog', + 'username' : os.getlogin()} + conf_files = ['/etc/pyOlog.conf', + os.path.expanduser('~/pyOlog.conf'), + os.path.expanduser('~/.pyOlog.conf'), + 'pyOlog.conf'] + heading = 'DEFAULT' + def __init__(self): + """Initialise config object""" + import ConfigParser + self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) + files = self.cf.read(self.conf_files) + for f in files: + logger.info("Read config file %s", f) + + def getValue(self, arg, value = None): + ''' + Get a default from the config file. + + :param arg: Parameter to return + :param value: Value to check for. + + This method will return the default value from the config. If + :param value: is not None then this will always return :param value:. + If :param value: is None then the config is searched for an entry + :param arg:. If no config is avaliable then None is returned. + + :returns: Config value or None. + ''' + if value is None: + if self.cf.has_option(self.heading, arg): + return self.cf.get(self.heading, arg) + else: + return None + else: + return value + +_conf = Config() diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 8b13789..5f2d4a4 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1 +1,8 @@ +from pyOlog.api import SimpleOlogClient +olog_client = SimpleOlogClient() + +def load_ipython_extension(ipython): + push_vars = {'olog' : olog_client.log, + 'savefig_olog' : olog_client.savefig} + ipython.push(push_vars) diff --git a/pyOlog/utils.py b/pyOlog/utils.py new file mode 100644 index 0000000..44acd63 --- /dev/null +++ b/pyOlog/utils.py @@ -0,0 +1,14 @@ + +import subprocess + +def get_screenshot(root = False, itype = 'png'): + """Open ImageMagick and get screngrab as png.""" + if root: + opts = '-window root' + else: + opts = '' + image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), + shell = True, + stdout = subprocess.PIPE) + return image.communicate()[0] + diff --git a/scripts/olog.py b/scripts/olog.py index d6771b5..dac96e4 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -4,18 +4,10 @@ import os, sys import argparse -import subprocess -from getpass import getpass, getuser - -from pyOlog import LogEntry, Logbook, Tag, Attachment, OlogClient - -try: - import keyring -except ImportError: - have_keyring = False -else: - have_keyring = True +from pyOlog import Logbook, Tag, Attachment, OlogClient +from pyOlog.api import SimpleOlogClient +from pyOlog.utils import get_screenshot description = """\ Command line utility for making OLog entries. @@ -42,24 +34,6 @@ """ -def get_option(cfg, base, opt): - """Check if option base/opt is in config cfg""" - if cfg.has_option(base, opt): - return cfg.get(base, opt) - else: - return None - -def get_screenshot(root = False, itype = 'png'): - """Open ImageMagick and get screngrab as png.""" - if root: - opts = '-window root' - else: - opts = '' - image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), - shell = True, - stdout = subprocess.PIPE) - return image.communicate()[0] - def olog(): """Command line utility for making Olog entries""" @@ -73,7 +47,7 @@ def olog(): parser.add_argument('-t', '--tags', dest = 'tags', nargs = '*', help = "OLog Tag Name(s)", default = None) - parser.add_argument('-u', '--user', dest = 'user', + parser.add_argument('-u', '--user', dest = 'username', default = None, help = "Username for Olog Access") parser.add_argument('-f', '--file', dest = 'text', @@ -107,11 +81,11 @@ def olog(): args = parser.parse_args() if args.logbooks: - logbooks = [Logbook(n) for n in args.logbooks] + logbooks = [Logbook(n) for n in args.logbooks.split(',')] else: logbooks = None if args.tags is not None: - tags = [Tag(n) for n in args.tags] + tags = [Tag(n) for n in args.tags.split(',')] else: tags = None @@ -132,28 +106,13 @@ def olog(): else: attachments.append(screenshot) - # Get the text for the log entry - if args.text is not None: - with args.text as file: - text = file.read() - else: - if not args.quiet: - print("Type log entry below (Enter -END- to end):", - file = sys.stderr) - sentinel = '-END-' - text = '\n'.join(iter(raw_input, sentinel)) - # First create the log entry - log_entry = LogEntry(text, args.user, logbooks, - tags = tags, - attachments = attachments) - print(log_entry) - - # Now do the log entry - - client = OlogClient(args.url, args.user, args.passwd) - client.log(log_entry) + c = SimpleOlogClient(args.url, args.username, args.passwd) + c.log(args.text, + logbooks = logbooks, + tags = tags, + attachments = attachments) def main(): try: diff --git a/setup.py b/setup.py index 7147863..2bb784e 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup(name='pyOlog', - version='0.1.0', + version='0.2.0', description='Python Olog Client Lib', author='Kunal Shroff', author_email='shroffk@bnl.gov', From 741eeea71d951e3ebeff99c25b74c4ba32db7021 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 21:19:14 -0500 Subject: [PATCH 07/79] Added "magic" for ipython --- pyOlog/api/simple.py | 21 ++++++++++++++++++--- pyOlog/ipy.py | 13 ++++++++++++- pyOlog/utils.py | 5 +++-- scripts/olog.py | 9 +++------ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/pyOlog/api/simple.py b/pyOlog/api/simple.py index 2f44e74..a1ecc23 100644 --- a/pyOlog/api/simple.py +++ b/pyOlog/api/simple.py @@ -10,6 +10,7 @@ import getpass import keyring +from ..utils import get_screenshot from ..OlogClient import OlogClient from ..OlogDataTypes import LogEntry, Logbook, Tag, Attachment @@ -35,7 +36,19 @@ def getLogbooks(self): """Return a list of tag names in the Olog""" return [l.getName() for l in self.session.listLogbooks()] - def savefig(self, **kwargs): + def screenshot(self, *args, **kwargs): + """Make a screenshot of an area and add a log entry""" + sha = get_screenshot() + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'].append(sha) + else: + kwargs['attachments'] = [kwargs['attachments'], sha] + else: + kwargs['attachments'] = [sha] + self.log(*args, **kwargs) + + def savefig(self, *args, **kwargs): """Save a matplotlib figure to the logbook""" import matplotlib.pyplot as plt import StringIO @@ -51,8 +64,10 @@ def savefig(self, **kwargs): kwargs['attachments'] += [a] else: kwargs['attachments'] = [kwargs['attachments'], a] - - self.log(attachments = a, **kwargs) + else: + kwargs['attachments'] = [a] + + self.log(*args, **kwargs) def log(self, text = None, logbooks = None, tags = None, properties = None, attachments = None, verify = True): diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 5f2d4a4..920c0ae 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1,8 +1,19 @@ +from IPython.core.magic import (register_line_magic, register_cell_magic, + register_line_cell_magic) + from pyOlog.api import SimpleOlogClient + olog_client = SimpleOlogClient() +@register_line_magic +def logit(line): + olog_client.log() + def load_ipython_extension(ipython): push_vars = {'olog' : olog_client.log, - 'savefig_olog' : olog_client.savefig} + 'olog_savefig' : olog_client.savefig, + 'olog_grab' : olog_client.screenshot} ipython.push(push_vars) + +del logit diff --git a/pyOlog/utils.py b/pyOlog/utils.py index 44acd63..25bf28f 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -1,4 +1,4 @@ - +from OlogDataTypes import Attachment import subprocess def get_screenshot(root = False, itype = 'png'): @@ -10,5 +10,6 @@ def get_screenshot(root = False, itype = 'png'): image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), shell = True, stdout = subprocess.PIPE) - return image.communicate()[0] + img = image.communicate()[0] + return Attachment(img, 'screenshot.' + itype) diff --git a/scripts/olog.py b/scripts/olog.py index dac96e4..45678c0 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -92,7 +92,7 @@ def olog(): if args.attach is not None: attachments = [Attachment(open(a)) for a in args.attach.split(',')] else: - attachments = None + attachments = [] # Grab Screenshot @@ -100,11 +100,8 @@ def olog(): if not args.quiet and args.grab: print("Select area of screen to add to log entry.", file = sys.stderr) - screenshot = Attachment(get_screenshot(args.screenshot), 'screenshot.png') - if attachments is None: - attachments = [screenshot] - else: - attachments.append(screenshot) + screenshot = get_screenshot(args.screenshot) + attachments.append(screenshot) # First create the log entry From da2a0cb0a83efbb8c6cae2636c4d94439ddadc3e Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 28 Nov 2014 21:19:54 -0500 Subject: [PATCH 08/79] Added *.swo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 62b45be..6ec3e4f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ pyOlog.egg-info /target/ *.pyc *.swp +*.swo build dist From 6f7f00cfb92792a961adb1583e5e2e4ea7131671 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 06:43:08 -0500 Subject: [PATCH 09/79] DOC : Added documentation --- .gitignore | 1 + doc/Makefile | 153 +++++++++++++++++++++++++++++ doc/api.rst | 9 ++ doc/client.rst | 6 ++ doc/conf.py | 242 ++++++++++++++++++++++++++++++++++++++++++++++ doc/datatypes.rst | 6 ++ doc/index.rst | 24 +++++ doc/simple.rst | 6 ++ 8 files changed, 447 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/api.rst create mode 100644 doc/client.rst create mode 100644 doc/conf.py create mode 100644 doc/datatypes.rst create mode 100644 doc/index.rst create mode 100644 doc/simple.rst diff --git a/.gitignore b/.gitignore index 6ec3e4f..872a414 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pyOlog.egg-info *.swo build dist +doc/_* diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..d3a98e8 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pyOlog.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pyOlog.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/pyOlog" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pyOlog" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/api.rst b/doc/api.rst new file mode 100644 index 0000000..23030a3 --- /dev/null +++ b/doc/api.rst @@ -0,0 +1,9 @@ +API +=== + +Contents: + +.. toctree:: + :maxdepth: 2 + + simple diff --git a/doc/client.rst b/doc/client.rst new file mode 100644 index 0000000..5890071 --- /dev/null +++ b/doc/client.rst @@ -0,0 +1,6 @@ +====================== + :mod:`Client` Module +====================== + +.. automodule:: pyOlog.OlogClient + :members: diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000..5ea98b3 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# +# pyOlog documentation build configuration file, created by +# sphinx-quickstart on Sat Nov 29 06:14:28 2014. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('../')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.mathjax'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'pyOlog' +copyright = u'2014, Kunal Schroff, Stuart Wilkins' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.2' +# The full version, including alpha/beta/rc tags. +release = '0.2.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'agogo' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'pyOlogdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'pyOlog.tex', u'pyOlog Documentation', + u'Kunal Schroff, Stuart Wilkins', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'pyolog', u'pyOlog Documentation', + [u'Kunal Schroff, Stuart Wilkins'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'pyOlog', u'pyOlog Documentation', + u'Kunal Schroff, Stuart Wilkins', 'pyOlog', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' diff --git a/doc/datatypes.rst b/doc/datatypes.rst new file mode 100644 index 0000000..ebc609c --- /dev/null +++ b/doc/datatypes.rst @@ -0,0 +1,6 @@ +========================= + :mod:`Data Types` Module +========================= + +.. automodule:: pyOlog.OlogDataTypes + :members: diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000..aefe5db --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,24 @@ +.. pyOlog documentation master file, created by + sphinx-quickstart on Sat Nov 29 06:14:28 2014. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to pyOlog's documentation! +================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + api + client + datatypes + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/simple.rst b/doc/simple.rst new file mode 100644 index 0000000..51281ca --- /dev/null +++ b/doc/simple.rst @@ -0,0 +1,6 @@ +====================== + :mod:`simple` Module +====================== + +.. automodule:: pyOlog.api + :members: From f5d709a965ec5d755fa975deb375394198ee8b9b Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 06:51:46 -0500 Subject: [PATCH 10/79] Moved simple API to root of module --- pyOlog/{api/simple.py => SimpleOlogClient.py} | 0 pyOlog/__init__.py | 1 + 2 files changed, 1 insertion(+) rename pyOlog/{api/simple.py => SimpleOlogClient.py} (100%) diff --git a/pyOlog/api/simple.py b/pyOlog/SimpleOlogClient.py similarity index 100% rename from pyOlog/api/simple.py rename to pyOlog/SimpleOlogClient.py diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index db12d37..d120ef9 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -1,2 +1,3 @@ from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from OlogClient import OlogClient +from SimpleClient import SimpleOlogClient From 24f57670e40f3700f0877d1fb7f4f62e3582693c Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 06:52:24 -0500 Subject: [PATCH 11/79] API : Updated to new API --- pyOlog/ipy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 920c0ae..926bc5c 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1,7 +1,7 @@ from IPython.core.magic import (register_line_magic, register_cell_magic, register_line_cell_magic) -from pyOlog.api import SimpleOlogClient +from pyOlog import SimpleOlogClient olog_client = SimpleOlogClient() @@ -10,10 +10,14 @@ def logit(line): olog_client.log() +@register_line_magic +def grabit(line): + olog_client.screenshot() + def load_ipython_extension(ipython): push_vars = {'olog' : olog_client.log, 'olog_savefig' : olog_client.savefig, 'olog_grab' : olog_client.screenshot} ipython.push(push_vars) -del logit +del logit, grabit From 93167a1595ead1d51f31fed6979b812e2275c845 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 07:17:59 -0500 Subject: [PATCH 12/79] API : Changed to SimpleOlogClient --- pyOlog/SimpleOlogClient.py | 6 +++--- pyOlog/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index a1ecc23..e7402c5 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -10,9 +10,9 @@ import getpass import keyring -from ..utils import get_screenshot -from ..OlogClient import OlogClient -from ..OlogDataTypes import LogEntry, Logbook, Tag, Attachment +from .utils import get_screenshot +from .OlogClient import OlogClient +from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment class SimpleOlogClient(object): def __init__(self, url = None, username = None, password = None): diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index d120ef9..a8fdcf4 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -1,3 +1,3 @@ from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from OlogClient import OlogClient -from SimpleClient import SimpleOlogClient +from SimpleOlogClient import SimpleOlogClient From 41f0dfc135a267e737c8aff4ac2e67693c10ed60 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 07:19:05 -0500 Subject: [PATCH 13/79] API : Added OlogHander (to use with python logging) --- pyOlog/OlogHandler.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pyOlog/OlogHandler.py diff --git a/pyOlog/OlogHandler.py b/pyOlog/OlogHandler.py new file mode 100644 index 0000000..75ded6d --- /dev/null +++ b/pyOlog/OlogHandler.py @@ -0,0 +1,14 @@ +import logging +from SimpleOlogClient import SimpleOlogClient + +class OlogHandler(logging.Handler): + def __init__(self, logbooks = None, tags = None): + logging.Handler.__init__(self) + self.session = SimpleOlogClient() + self.logbooks = logbooks + self.tags = tags + def emit(self, record): + if hasattr(record, message): + self.session.log(record.message, logbooks = logbooks, tags = tags) + else: + self.session.log(record.msg, logbooks = logbooks, tags = tags) From a1672e1bce1defe9c94de235a905a5ea0ed1a769 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 07:19:59 -0500 Subject: [PATCH 14/79] Added example for python logging --- tests/logger.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/logger.py diff --git a/tests/logger.py b/tests/logger.py new file mode 100644 index 0000000..fb06ca7 --- /dev/null +++ b/tests/logger.py @@ -0,0 +1,20 @@ +import logging +from pyOlog.ologhandler import OlogHandler + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +olog = OlogHandler() +olog.setLevel(logging.DEBUG) + +logger.addHandler(olog) + +def main(): + logger.debug('Debug message') + logger.info('Info Message') + logger.warn('Warn Message') + logger.error('Error Message') + logger.critical('Critical Message') + +if __name__ == "__main__": + main() From b71a26c2ec6d1b4cab60d6b761b564cafc7e8cf1 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 07:38:08 -0500 Subject: [PATCH 15/79] MNT : Removed default logging --- pyOlog/OlogClient.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 1368076..7942744 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -7,14 +7,9 @@ @author: shroffk ''' import logging, sys -fmt = logging.Formatter("%(asctime)-15s [%(name)5s:%(levelname)s] %(message)s") logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) -handler = logging.StreamHandler(sys.stdout) -handler.setFormatter(fmt) -logger.addHandler(handler) - from getpass import getpass import requests From 7def13efc0890bc43d1f8a037357c4292d93a098 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 07:38:53 -0500 Subject: [PATCH 16/79] Updated logger to use getMessage() --- pyOlog/OlogHandler.py | 8 ++++---- tests/logger.py | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyOlog/OlogHandler.py b/pyOlog/OlogHandler.py index 75ded6d..95d91c0 100644 --- a/pyOlog/OlogHandler.py +++ b/pyOlog/OlogHandler.py @@ -8,7 +8,7 @@ def __init__(self, logbooks = None, tags = None): self.logbooks = logbooks self.tags = tags def emit(self, record): - if hasattr(record, message): - self.session.log(record.message, logbooks = logbooks, tags = tags) - else: - self.session.log(record.msg, logbooks = logbooks, tags = tags) + # ToDo add log level to olog + self.session.log(record.getMessage(), + logbooks = self.logbooks, + tags = self.tags) diff --git a/tests/logger.py b/tests/logger.py index fb06ca7..b3b65c3 100644 --- a/tests/logger.py +++ b/tests/logger.py @@ -1,13 +1,20 @@ import logging -from pyOlog.ologhandler import OlogHandler +from pyOlog.OlogHandler import OlogHandler logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + olog = OlogHandler() olog.setLevel(logging.DEBUG) +olog.setFormatter(formatter) + +ch = logging.StreamHandler() +ch.setLevel(logging.DEBUG) logger.addHandler(olog) +logger.addHandler(ch) def main(): logger.debug('Debug message') From e32436828d82dbda91f8f976a83a5d632150b6e3 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 08:03:13 -0500 Subject: [PATCH 17/79] Fixed formatting of log message --- pyOlog/OlogHandler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyOlog/OlogHandler.py b/pyOlog/OlogHandler.py index 95d91c0..eda2d19 100644 --- a/pyOlog/OlogHandler.py +++ b/pyOlog/OlogHandler.py @@ -9,6 +9,10 @@ def __init__(self, logbooks = None, tags = None): self.tags = tags def emit(self, record): # ToDo add log level to olog - self.session.log(record.getMessage(), - logbooks = self.logbooks, - tags = self.tags) + try: + msg = self.format(record) + self.session.log(msg, + logbooks = self.logbooks, + tags = self.tags) + except: + self.handleError(record) From 2f9ecdc6acae9b75e09cf1291442d599715a33b9 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 09:14:13 -0500 Subject: [PATCH 18/79] Moved utility to open editor to utils --- pyOlog/SimpleOlogClient.py | 11 ++--------- pyOlog/utils.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index e7402c5..1b75e1e 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -3,14 +3,10 @@ A simple API to the Olog client in python """ -import os -from tempfile import NamedTemporaryFile -from subprocess import call - import getpass import keyring -from .utils import get_screenshot +from .utils import get_screenshot, get_text_from_editor from .OlogClient import OlogClient from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment @@ -105,10 +101,7 @@ def log(self, text = None, logbooks = None, tags = None, properties = None, tags = [Tag(n) for n in tags] if not text: - with NamedTemporaryFile(suffix='.tmp') as tempfile: - editor = os.environ.get('EDITOR', 'vim') - call([editor, tempfile.name]) - text = tempfile.read() + text = get_text_from_editor() toattach = [] if attachments: diff --git a/pyOlog/utils.py b/pyOlog/utils.py index 25bf28f..6c9f919 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -1,5 +1,8 @@ -from OlogDataTypes import Attachment +import os import subprocess +import tempfile + +from OlogDataTypes import Attachment def get_screenshot(root = False, itype = 'png'): """Open ImageMagick and get screngrab as png.""" @@ -13,3 +16,11 @@ def get_screenshot(root = False, itype = 'png'): img = image.communicate()[0] return Attachment(img, 'screenshot.' + itype) + +def get_text_from_editor(): + """Open text editor and return text""" + with tempfile.NamedTemporaryFile(suffix='.tmp') as f: + editor = os.environ.get('EDITOR', 'vim') + subprocess.call([editor, f.name]) + text = f.read() + return text From a013f968671b2404c77596da08c021b815d8f7a4 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 09:14:29 -0500 Subject: [PATCH 19/79] Added magic to capture command output and add to log --- pyOlog/ipy.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 926bc5c..174ce87 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1,8 +1,11 @@ from IPython.core.magic import (register_line_magic, register_cell_magic, - register_line_cell_magic) + register_line_cell_magic, Magics, magics_class, + line_magic, cell_magic) -from pyOlog import SimpleOlogClient +from IPython.utils.io import capture_output +from IPython.display import display +from pyOlog import SimpleOlogClient olog_client = SimpleOlogClient() @@ -14,10 +17,20 @@ def logit(line): def grabit(line): olog_client.screenshot() +@magics_class +class OlogMagics(Magics): + @line_magic + def logcell(self, line): + with capture_output() as c: + self.shell.run_cell(line) + c.show() + msg = "STDOUT\n======\n\n" + c.stdout + "\n\nSTDERR\n======\n\n" + c.stderr + olog_client.log(msg) + def load_ipython_extension(ipython): push_vars = {'olog' : olog_client.log, 'olog_savefig' : olog_client.savefig, 'olog_grab' : olog_client.screenshot} ipython.push(push_vars) - + ipython.register_magics(OlogMagics) del logit, grabit From b40ce99f94cf1a716f69d5d9eff18276528d8ac2 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 29 Nov 2014 21:29:56 -0500 Subject: [PATCH 20/79] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac0dcab --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +pyOlog +====== + +Python client library for Olog From 7c875ad910b37ce426951640cb5a1ecdf6141686 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 06:20:41 -0500 Subject: [PATCH 21/79] Fixed script to correctly use tags and logbooks with SimpleParser --- scripts/olog.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/scripts/olog.py b/scripts/olog.py index 45678c0..6cfb64a 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -7,7 +7,7 @@ from pyOlog import Logbook, Tag, Attachment, OlogClient from pyOlog.api import SimpleOlogClient -from pyOlog.utils import get_screenshot +from pyOlog.utils import get_screenshot, get_text_from_editor description = """\ Command line utility for making OLog entries. @@ -22,14 +22,20 @@ text file can be specified with the '--file' option. Multiple Tags and Logbooks can be specified after the option on the -command line separated by spaces. +command line separated by spaces. For example: + + %(prog)s -t "RF Area" "Bumps" + +Wil add the tags 'RF Area' and 'Bumps' Note : A password is requested on the command line unless the option -'-p' is supplied with a valid password. +'-p' is supplied with a valid password, the password is in the config +file or it can be obtained from the keyring. Optionally commands will take default from a config file located -in the users home directory ~/.olog.cfg This can contain the base -url for the Olog and also the default logbook to use. +in the users home directory ~/.pyOlog.conf This can contain the base +url for the Olog and also the default logbook to use. Administrators +can use the /etc/pyOlog.conf file to specify system wide config. """ @@ -80,15 +86,6 @@ def olog(): args = parser.parse_args() - if args.logbooks: - logbooks = [Logbook(n) for n in args.logbooks.split(',')] - else: - logbooks = None - if args.tags is not None: - tags = [Tag(n) for n in args.tags.split(',')] - else: - tags = None - if args.attach is not None: attachments = [Attachment(open(a)) for a in args.attach.split(',')] else: @@ -105,10 +102,15 @@ def olog(): # First create the log entry + if args.text is None: + text = get_text_from_editor() + else: + text = args.text + c = SimpleOlogClient(args.url, args.username, args.passwd) - c.log(args.text, - logbooks = logbooks, - tags = tags, + c.log(text, + logbooks = args.logbooks, + tags = args.tags, attachments = attachments) def main(): From 02801d2fe8e3b8792f68ae707d6f8f6baab97f48 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 06:21:16 -0500 Subject: [PATCH 22/79] Added message to get_text_from_editor --- pyOlog/utils.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/pyOlog/utils.py b/pyOlog/utils.py index 6c9f919..da389f8 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -4,6 +4,14 @@ from OlogDataTypes import Attachment +text_message = ''' +# +# Please enter the log message using the editor. Lines beginning +# with '#' will be ignored, and an empty message aborts the log +# message from being logged. +# +''' + def get_screenshot(root = False, itype = 'png'): """Open ImageMagick and get screngrab as png.""" if root: @@ -17,10 +25,41 @@ def get_screenshot(root = False, itype = 'png'): return Attachment(img, 'screenshot.' + itype) -def get_text_from_editor(): +def get_text_from_editor(additional_text = None): """Open text editor and return text""" with tempfile.NamedTemporaryFile(suffix='.tmp') as f: + # Write out the file and flush + message = text_message + if not additional_text: + message += '' + else: + message += additional_text + f.write(message) + f.flush() + + # Now open editor to edit file editor = os.environ.get('EDITOR', 'vim') subprocess.call([editor, f.name]) + + # Read file back in + f.seek(0) text = f.read() + + # Strip off any lines that start with whitespace and a '#' + lines = [n for n in text.splitlines() if not n.lstrip().startswith('#')] + text = ''.join(lines) return text + +def get_pyplot_fig(self, *args, **kwargs): + """Save a matplotlib figure as an Attachment""" + import matplotlib.pyplot as plt + import StringIO + + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', **kwargs) + imgdata.seek(0) + + a = Attachment(imgdata, 'plot.png') + + return a + From afa9ece68856e2f76c7283fee145374cc0ab4aa1 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 06:26:05 -0500 Subject: [PATCH 23/79] Added save_pyplot_figure --- pyOlog/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pyOlog/utils.py b/pyOlog/utils.py index da389f8..a60cb8f 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -12,6 +12,19 @@ # ''' +def save_pyplot_figure(**kwargs): + """Save a matplotlib figure to an Olog Attachment Object""" + import matplotlib.pyplot as plt + import StringIO + + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', **kwargs) + imgdata.seek(0) + + a = Attachment(imgdata, 'plot.png') + + return a + def get_screenshot(root = False, itype = 'png'): """Open ImageMagick and get screngrab as png.""" if root: From 7dde871d7b23572113bab357d4262dde41a31d5c Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 07:27:18 -0500 Subject: [PATCH 24/79] Added prepend and postpend messages --- pyOlog/utils.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyOlog/utils.py b/pyOlog/utils.py index a60cb8f..a0d5920 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -38,15 +38,20 @@ def get_screenshot(root = False, itype = 'png'): return Attachment(img, 'screenshot.' + itype) -def get_text_from_editor(additional_text = None): +def get_text_from_editor(prepend = None, postpend = None): """Open text editor and return text""" with tempfile.NamedTemporaryFile(suffix='.tmp') as f: # Write out the file and flush - message = text_message - if not additional_text: - message += '' + if prepend: + message = prepend + message += '\n' else: - message += additional_text + message = '' + + message += text_message + + if postpend: + message += postpend f.write(message) f.flush() From 970d1feda75621370a4a90e7a7f5b6eba31a6914 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 07:27:34 -0500 Subject: [PATCH 25/79] Rebuilt ipy module with magics and helper function --- pyOlog/ipy.py | 116 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 101 insertions(+), 15 deletions(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 174ce87..2967917 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1,36 +1,122 @@ -from IPython.core.magic import (register_line_magic, register_cell_magic, - register_line_cell_magic, Magics, magics_class, - line_magic, cell_magic) +from __future__ import print_function + +from IPython.core.magic import Magics, magics_class, line_magic, cell_magic from IPython.utils.io import capture_output from IPython.display import display from pyOlog import SimpleOlogClient +from pyOlog.utils import save_pyplot_figure, get_screenshot, get_text_from_editor olog_client = SimpleOlogClient() -@register_line_magic -def logit(line): - olog_client.log() +def olog(msg = None, logbooks = None, tags = None, + attachments = None, **kwargs): + """Make a log entry to the Olog + + :param msg: Message for log entry. + If None use and editor to get message. + :param logbooks: Logbooks to add message to. + :type logbooks: String or List of Strings. + :param tags: Tags to tag the log entry with. + :type tags: String or List of Strings. + :param attachments: List of attachments to add to log entry. + :type attachments: Attchment objects + """ + if not msg: + msg = get_text_from_editor() + olog_client.log(msg, logbooks = logbooks, tags = tags, + attachments = attachments) + return + +def olog_savefig(**kwargs): + """Save a pyplot figure and place it in tho Olog + + The **kwargs are all passed onto the :func savefig: function + and then onto the :func olog" function + + :returns: None + """ + fig = save_pyplot_figure(**kwargs) + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'].append(fig) + else: + kwargs['attachments'] = [kwargs['attatchments'], fig] + else: + kwargs['attachments'] = fig + + olog(**kwargs) + return + +def olog_grab(root = False, **kwargs): + """Grab a screenshot and place it in tho Olog + + :param root" If True, the entire screen is grabbed else select + an area as a rubber band. -@register_line_magic -def grabit(line): - olog_client.screenshot() + The **kwargs are all passed onto the :func olog: function + + :returns: None + """ + if not root: + print("Select area of screen to grab .........") + a = get_screenshot(root) + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'].append(a) + else: + kwargs['attachments'] = [kwargs['attatchments'], a] + else: + kwargs['attachments'] = a + + olog(**kwargs) + return @magics_class class OlogMagics(Magics): + msg_store = '' + + @line_magic + def log_add(self, line): + with capture_output() as c: + self.shell.run_cell(line) + c.show() + self.msg_store += c.stdout + self.msg_store += '\n' + + @line_magic + def log_end(self, line): + text = get_text_from_editor(prepend = self.msg_store) + olog_client.log(text) + self.msg_store = '' + + @line_magic + def log_clear(self, line): + self.msg_store = '' + @line_magic - def logcell(self, line): + def log_line(self, line): with capture_output() as c: self.shell.run_cell(line) c.show() - msg = "STDOUT\n======\n\n" + c.stdout + "\n\nSTDERR\n======\n\n" + c.stderr + msg = c.stdout olog_client.log(msg) + @line_magic + def logit(self, line): + if line.strip() == '': + olog_client.log() + else: + olog_cleint.log(msg = line.strip()) + + @line_magic + def grabit(self, line): + olog_grab() + def load_ipython_extension(ipython): - push_vars = {'olog' : olog_client.log, - 'olog_savefig' : olog_client.savefig, - 'olog_grab' : olog_client.screenshot} + push_vars = {'olog' : olog, + 'olog_savefig' : olog_savefig, + 'olog_grab' : olog_grab} ipython.push(push_vars) ipython.register_magics(OlogMagics) -del logit, grabit From 470d2a2cc3d223ac23e79ad0bc0a9fa3eb521d3a Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 07:34:37 -0500 Subject: [PATCH 26/79] DOC : Added docstrings to magic functions --- pyOlog/ipy.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 2967917..f65058a 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -79,6 +79,7 @@ class OlogMagics(Magics): @line_magic def log_add(self, line): + """Run the line and capture the output for the Olog""" with capture_output() as c: self.shell.run_cell(line) c.show() @@ -87,16 +88,19 @@ def log_add(self, line): @line_magic def log_end(self, line): + """Store the captured lines in the Olog""" text = get_text_from_editor(prepend = self.msg_store) olog_client.log(text) self.msg_store = '' @line_magic def log_clear(self, line): + """Clear the store of captured lines""" self.msg_store = '' @line_magic def log_line(self, line): + """Run the line and add the output to the Olog""" with capture_output() as c: self.shell.run_cell(line) c.show() @@ -105,6 +109,7 @@ def log_line(self, line): @line_magic def logit(self, line): + """Add a log entry to the Olog""" if line.strip() == '': olog_client.log() else: @@ -112,6 +117,7 @@ def logit(self, line): @line_magic def grabit(self, line): + """Grab a screenshot and add it to the Olog""" olog_grab() def load_ipython_extension(ipython): From 81308852a799321881e3c1f9c512009a0340d317 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 30 Nov 2014 07:44:06 -0500 Subject: [PATCH 27/79] Added thumbnail image to savefig along with PDF copy to Olog --- pyOlog/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyOlog/utils.py b/pyOlog/utils.py index a0d5920..0e9e23a 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -18,10 +18,17 @@ def save_pyplot_figure(**kwargs): import StringIO imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', **kwargs) + plt.savefig(imgdata, format = 'pdf', **kwargs) imgdata.seek(0) - a = Attachment(imgdata, 'plot.png') + a = [Attachment(imgdata, 'plot.pdf')] + + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', dpi = 50, + **kwargs) + imgdata.seek(0) + + a.append(Attachment(imgdata, 'thumbnail.png')) return a From 7845bcd680b642159d76b58ec3e6f666ae27cd7a Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Thu, 4 Dec 2014 18:26:53 -0500 Subject: [PATCH 28/79] Fixed some bugs --- pyOlog/OlogClient.py | 1 - pyOlog/SimpleOlogClient.py | 33 --------------------------------- pyOlog/ipy.py | 5 +++-- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 7942744..3a20fea 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -21,7 +21,6 @@ from urllib import urlencode import urllib3 -urllib3.disable_warnings() from urllib3.poolmanager import PoolManager from collections import OrderedDict diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 1b75e1e..5f4c1bf 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -32,39 +32,6 @@ def getLogbooks(self): """Return a list of tag names in the Olog""" return [l.getName() for l in self.session.listLogbooks()] - def screenshot(self, *args, **kwargs): - """Make a screenshot of an area and add a log entry""" - sha = get_screenshot() - if 'attachments' in kwargs: - if isinstance(kwargs['attachments'], list): - kwargs['attachments'].append(sha) - else: - kwargs['attachments'] = [kwargs['attachments'], sha] - else: - kwargs['attachments'] = [sha] - self.log(*args, **kwargs) - - def savefig(self, *args, **kwargs): - """Save a matplotlib figure to the logbook""" - import matplotlib.pyplot as plt - import StringIO - - imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', **kwargs) - imgdata.seek(0) - - a = Attachment(imgdata, 'plot.png') - - if 'attachments' in kwargs: - if isinstance(kwargs['attachments'], list): - kwargs['attachments'] += [a] - else: - kwargs['attachments'] = [kwargs['attachments'], a] - else: - kwargs['attachments'] = [a] - - self.log(*args, **kwargs) - def log(self, text = None, logbooks = None, tags = None, properties = None, attachments = None, verify = True): """ diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index f65058a..337cc83 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -113,7 +113,7 @@ def logit(self, line): if line.strip() == '': olog_client.log() else: - olog_cleint.log(msg = line.strip()) + olog_client.log(msg = line.strip()) @line_magic def grabit(self, line): @@ -123,6 +123,7 @@ def grabit(self, line): def load_ipython_extension(ipython): push_vars = {'olog' : olog, 'olog_savefig' : olog_savefig, - 'olog_grab' : olog_grab} + 'olog_grab' : olog_grab, + 'olog_client' : olog_client} ipython.push(push_vars) ipython.register_magics(OlogMagics) From ee734adf184c5e4f3a6a44c8d0ef0e94391f7530 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Thu, 11 Dec 2014 17:14:52 -0500 Subject: [PATCH 29/79] Bug Fix --- pyOlog/ipy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 337cc83..f5c464d 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -113,7 +113,7 @@ def logit(self, line): if line.strip() == '': olog_client.log() else: - olog_client.log(msg = line.strip()) + olog_client.log(line.strip()) @line_magic def grabit(self, line): From e50fc82551270661ed17bcb6a4d6cc15f93375d0 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 12 Dec 2014 19:54:39 -0500 Subject: [PATCH 30/79] Fixed ipython magics to correctly deal with output --- pyOlog/ipy.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index f5c464d..581c9d2 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -1,6 +1,6 @@ from __future__ import print_function -from IPython.core.magic import Magics, magics_class, line_magic, cell_magic +from IPython.core.magic import Magics, magics_class, line_magic, cell_magic from IPython.utils.io import capture_output from IPython.display import display @@ -10,18 +10,18 @@ olog_client = SimpleOlogClient() -def olog(msg = None, logbooks = None, tags = None, +def olog(msg = None, logbooks = None, tags = None, attachments = None, **kwargs): """Make a log entry to the Olog - :param msg: Message for log entry. + :param msg: Message for log entry. If None use and editor to get message. :param logbooks: Logbooks to add message to. :type logbooks: String or List of Strings. :param tags: Tags to tag the log entry with. :type tags: String or List of Strings. :param attachments: List of attachments to add to log entry. - :type attachments: Attchment objects + :type attachments: Attchment objects """ if not msg: msg = get_text_from_editor() @@ -31,12 +31,12 @@ def olog(msg = None, logbooks = None, tags = None, def olog_savefig(**kwargs): """Save a pyplot figure and place it in tho Olog - + The **kwargs are all passed onto the :func savefig: function and then onto the :func olog" function - + :returns: None - """ + """ fig = save_pyplot_figure(**kwargs) if 'attachments' in kwargs: if isinstance(kwargs['attachments'], list): @@ -47,18 +47,18 @@ def olog_savefig(**kwargs): kwargs['attachments'] = fig olog(**kwargs) - return + return def olog_grab(root = False, **kwargs): """Grab a screenshot and place it in tho Olog - + :param root" If True, the entire screen is grabbed else select an area as a rubber band. The **kwargs are all passed onto the :func olog: function - + :returns: None - """ + """ if not root: print("Select area of screen to grab .........") a = get_screenshot(root) @@ -71,7 +71,7 @@ def olog_grab(root = False, **kwargs): kwargs['attachments'] = a olog(**kwargs) - return + return @magics_class class OlogMagics(Magics): @@ -80,6 +80,8 @@ class OlogMagics(Magics): @line_magic def log_add(self, line): """Run the line and capture the output for the Olog""" + self.msg_store += ">>>{}\n".format(line) + self.msg_store += "\n" with capture_output() as c: self.shell.run_cell(line) c.show() @@ -89,8 +91,8 @@ def log_add(self, line): @line_magic def log_end(self, line): """Store the captured lines in the Olog""" - text = get_text_from_editor(prepend = self.msg_store) - olog_client.log(text) + #text = get_text_from_editor(prepend = self.msg_store) + olog_client.log(self.msg_store) self.msg_store = '' @line_magic @@ -101,10 +103,12 @@ def log_clear(self, line): @line_magic def log_line(self, line): """Run the line and add the output to the Olog""" + msg = ">>>{}\n".format(line) + msg += "\n" with capture_output() as c: self.shell.run_cell(line) c.show() - msg = c.stdout + msg += c.stdout olog_client.log(msg) @line_magic @@ -125,5 +129,5 @@ def load_ipython_extension(ipython): 'olog_savefig' : olog_savefig, 'olog_grab' : olog_grab, 'olog_client' : olog_client} - ipython.push(push_vars) + ipython.push(push_vars) ipython.register_magics(OlogMagics) From 92c3d62db8523ee39b6f2940bd526fd580ba001b Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 12 Dec 2014 19:59:02 -0500 Subject: [PATCH 31/79] Added ropeproject --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 872a414..5b9b27c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pyOlog.egg-info build dist doc/_* +.ropeproject From e2848522ee7aba0d82d859eb0d581519600b4c55 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 12 Dec 2014 20:22:12 -0500 Subject: [PATCH 32/79] Fixed bug when spawning editor for log entry --- pyOlog/ipy.py | 4 ++-- pyOlog/utils.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyOlog/ipy.py b/pyOlog/ipy.py index 581c9d2..d9bc4c8 100644 --- a/pyOlog/ipy.py +++ b/pyOlog/ipy.py @@ -91,8 +91,8 @@ def log_add(self, line): @line_magic def log_end(self, line): """Store the captured lines in the Olog""" - #text = get_text_from_editor(prepend = self.msg_store) - olog_client.log(self.msg_store) + text = get_text_from_editor(prepend = self.msg_store) + olog_client.log(text) self.msg_store = '' @line_magic diff --git a/pyOlog/utils.py b/pyOlog/utils.py index 0e9e23a..7e3d941 100644 --- a/pyOlog/utils.py +++ b/pyOlog/utils.py @@ -16,7 +16,7 @@ def save_pyplot_figure(**kwargs): """Save a matplotlib figure to an Olog Attachment Object""" import matplotlib.pyplot as plt import StringIO - + imgdata = StringIO.StringIO() plt.savefig(imgdata, format = 'pdf', **kwargs) imgdata.seek(0) @@ -39,7 +39,7 @@ def get_screenshot(root = False, itype = 'png'): else: opts = '' image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), - shell = True, + shell = True, stdout = subprocess.PIPE) img = image.communicate()[0] @@ -49,11 +49,13 @@ def get_text_from_editor(prepend = None, postpend = None): """Open text editor and return text""" with tempfile.NamedTemporaryFile(suffix='.tmp') as f: # Write out the file and flush + + message = '' + if prepend: - message = prepend + message += '\n\n' + message += prepend message += '\n' - else: - message = '' message += text_message @@ -72,7 +74,7 @@ def get_text_from_editor(prepend = None, postpend = None): # Strip off any lines that start with whitespace and a '#' lines = [n for n in text.splitlines() if not n.lstrip().startswith('#')] - text = ''.join(lines) + text = '\n'.join(lines) return text def get_pyplot_fig(self, *args, **kwargs): From 37f71cb02daa3ed7ac9c6489e562f75a576a4b8f Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 13 Dec 2014 18:54:30 -0500 Subject: [PATCH 33/79] Fixed build of scripts. Added password default in config file --- pyOlog/OlogHandler.py | 2 +- pyOlog/SimpleOlogClient.py | 27 ++++++++++++++++++++------- scripts/olog.py | 12 ++++++------ scripts/ologgrab | 7 ------- setup.py | 4 ++-- 5 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 scripts/ologgrab diff --git a/pyOlog/OlogHandler.py b/pyOlog/OlogHandler.py index eda2d19..c7e944b 100644 --- a/pyOlog/OlogHandler.py +++ b/pyOlog/OlogHandler.py @@ -12,7 +12,7 @@ def emit(self, record): try: msg = self.format(record) self.session.log(msg, - logbooks = self.logbooks, + logbooks = self.logbooks, tags = self.tags) except: self.handleError(record) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 5f4c1bf..d8a5201 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -6,24 +6,37 @@ import getpass import keyring -from .utils import get_screenshot, get_text_from_editor +from .utils import get_text_from_editor from .OlogClient import OlogClient from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment +from .conf import _conf + class SimpleOlogClient(object): def __init__(self, url = None, username = None, password = None): """Initiate a session and do password caching using keyring""" + + # First check config file for defaults + + if username is None: - username = getpass.getuser() - if password is None: - password = keyring.get_password('olog', username) + if _conf.getValue('username'): + username = _conf.getValue('username') + else: + username = getpass.getuser() + if password is None: - password = getpass.getpass("Olog Password (username = {}) :".format(username)) + if _conf.getValue('password'): + password = _conf.getValue('password') + if password is None: + password = keyring.get_password('olog', username) + if password is None: + password = getpass.getpass("Olog Password (username = {}) :".format(username)) if username and not password: raise Exception("Unable to obtain password and authentication requested.") self.session = OlogClient(username = username, password = password) - + def getTags(self): """Return a list of tag names in the Olog""" return [t.getName() for t in self.session.listTags()] @@ -68,7 +81,7 @@ def log(self, text = None, logbooks = None, tags = None, properties = None, tags = [Tag(n) for n in tags] if not text: - text = get_text_from_editor() + text = get_text_from_editor() toattach = [] if attachments: diff --git a/scripts/olog.py b/scripts/olog.py index 6cfb64a..9fc0286 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -6,7 +6,7 @@ import argparse from pyOlog import Logbook, Tag, Attachment, OlogClient -from pyOlog.api import SimpleOlogClient +from pyOlog import SimpleOlogClient from pyOlog.utils import get_screenshot, get_text_from_editor description = """\ @@ -18,8 +18,8 @@ This makes a log entry into the 'Operations' log tagged with the tag 'Data' from the account of 'swilkins' with an image 'image.png attached to the log entry. The log text is taken from stdin and can -either be entered on the command line or piped in. Alternatively a -text file can be specified with the '--file' option. +either be entered on the command line or piped in. Alternatively a +text file can be specified with the '--file' option. Multiple Tags and Logbooks can be specified after the option on the command line separated by spaces. For example: @@ -71,7 +71,7 @@ def olog(): default = None) group = parser.add_mutually_exclusive_group() group.add_argument('-s','--screenshot', dest = 'screenshot', - help = 'Take screenshot of whole screen', + help = 'Take screenshot of whole screen', default = False, action = 'store_true') group.add_argument('-g', '--grap', dest = 'grab', @@ -91,11 +91,11 @@ def olog(): else: attachments = [] - # Grab Screenshot + # Grab Screenshot if args.screenshot or args.grab: if not args.quiet and args.grab: - print("Select area of screen to add to log entry.", + print("Select area of screen to add to log entry.", file = sys.stderr) screenshot = get_screenshot(args.screenshot) attachments.append(screenshot) diff --git a/scripts/ologgrab b/scripts/ologgrab deleted file mode 100644 index e4ea907..0000000 --- a/scripts/ologgrab +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -tmpfile=`mktemp`.png -echo "Select portion of the screen using the mouse." -import $tmpfile -echo "Done." -olog -a $tmpfile $* -rm -rf $tmpfile diff --git a/setup.py b/setup.py index 2bb784e..f9f9c5f 100644 --- a/setup.py +++ b/setup.py @@ -20,9 +20,9 @@ author_email='shroffk@bnl.gov', packages=['pyOlog'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], - scripts=['scripts/olog.py'], + #scripts=['scripts/olog.py'], entry_points = { 'console_scripts': [ - 'olog = olog:main'] + 'olog = pyOlog.olog:main'] } ) From 8ff5377f62e81dabba0ed7f90128df1579a0e5a8 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 13 Dec 2014 18:55:09 -0500 Subject: [PATCH 34/79] Added olog script --- pyOlog/olog.py | 124 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 pyOlog/olog.py diff --git a/pyOlog/olog.py b/pyOlog/olog.py new file mode 100644 index 0000000..9fc0286 --- /dev/null +++ b/pyOlog/olog.py @@ -0,0 +1,124 @@ +#!/usr/bin/python +from __future__ import print_function + +import os, sys + +import argparse + +from pyOlog import Logbook, Tag, Attachment, OlogClient +from pyOlog import SimpleOlogClient +from pyOlog.utils import get_screenshot, get_text_from_editor + +description = """\ +Command line utility for making OLog entries. + +Example: + %(prog)s -l Operations -t Data -u swilkins -a ./image.png + +This makes a log entry into the 'Operations' log tagged with the +tag 'Data' from the account of 'swilkins' with an image 'image.png +attached to the log entry. The log text is taken from stdin and can +either be entered on the command line or piped in. Alternatively a +text file can be specified with the '--file' option. + +Multiple Tags and Logbooks can be specified after the option on the +command line separated by spaces. For example: + + %(prog)s -t "RF Area" "Bumps" + +Wil add the tags 'RF Area' and 'Bumps' + +Note : A password is requested on the command line unless the option +'-p' is supplied with a valid password, the password is in the config +file or it can be obtained from the keyring. + +Optionally commands will take default from a config file located +in the users home directory ~/.pyOlog.conf This can contain the base +url for the Olog and also the default logbook to use. Administrators +can use the /etc/pyOlog.conf file to specify system wide config. + + +""" + +def olog(): + """Command line utility for making Olog entries""" + + # Parse Command Line Options + + parser = argparse.ArgumentParser(epilog = description, + formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument('-l', '--logbooks', dest = 'logbooks', + help = "Logbook Name(s)", nargs = '*', + default = None) + parser.add_argument('-t', '--tags', dest = 'tags', + nargs = '*', help = "OLog Tag Name(s)", + default = None) + parser.add_argument('-u', '--user', dest = 'username', + default = None, + help = "Username for Olog Access") + parser.add_argument('-f', '--file', dest = 'text', + type=argparse.FileType('r'), + default=None, + help = "Filename of log entry text.") + parser.add_argument('--url', dest = 'url', + help = "Base URL for Olog Access", + default = None) + parser.add_argument('-a', '--attach', dest = 'attach', + nargs = '*', + help = "filename of attachments") + parser.add_argument('-p', '--passwd', dest = 'passwd', + help = "Password for logging entry", + default = None) + group = parser.add_mutually_exclusive_group() + group.add_argument('-s','--screenshot', dest = 'screenshot', + help = 'Take screenshot of whole screen', + default = False, + action = 'store_true') + group.add_argument('-g', '--grap', dest = 'grab', + help = 'Grab area of screen and add as attatchment.', + default = False, + action = 'store_true') + group = parser.add_mutually_exclusive_group() + group.add_argument('-v', action = 'store_true', dest = 'verbose', + help = "Verbose output", default = False) + group.add_argument('-q', action = 'store_true', dest = 'quiet', + help = "Suppress all output", default = False) + + args = parser.parse_args() + + if args.attach is not None: + attachments = [Attachment(open(a)) for a in args.attach.split(',')] + else: + attachments = [] + + # Grab Screenshot + + if args.screenshot or args.grab: + if not args.quiet and args.grab: + print("Select area of screen to add to log entry.", + file = sys.stderr) + screenshot = get_screenshot(args.screenshot) + attachments.append(screenshot) + + # First create the log entry + + if args.text is None: + text = get_text_from_editor() + else: + text = args.text + + c = SimpleOlogClient(args.url, args.username, args.passwd) + c.log(text, + logbooks = args.logbooks, + tags = args.tags, + attachments = attachments) + +def main(): + try: + olog() + except KeyboardInterrupt: + print('\nAborted.\n') + sys.exit() + +if __name__ == '__main__': + main() From b423ce2b15202df60229a1c94934c56b5efd5d10 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 20 Dec 2014 12:59:01 -0500 Subject: [PATCH 35/79] Updated for conda recipies --- conda-recipie/meta.yaml | 4 +- pyOlog/OlogClient.py | 103 ++++++++++++++++++++-------------------- pyOlog/conf.py | 10 ++-- 3 files changed, 58 insertions(+), 59 deletions(-) diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml index ada4ad3..b046547 100644 --- a/conda-recipie/meta.yaml +++ b/conda-recipie/meta.yaml @@ -1,7 +1,7 @@ package: name: pyOlog - version: "0.1.0" + version: "0.2.0" source: git_url: https://github.com/NSLS-II-CSX/pyOlog.git @@ -14,7 +14,7 @@ requirements: - python - setuptools - requests - + - urllib3 run: - python diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 3a20fea..1642a4b 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -26,7 +26,7 @@ from collections import OrderedDict import tempfile -import ssl +import ssl from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from conf import _conf @@ -36,7 +36,7 @@ class OlogClient(object): classdocs ''' __jsonheader = {'content-type':'application/json', 'accept':'application/json'} - __logsResource = '/resources/logs' + __logsResource = '/resources/logs' __propertiesResource = '/resources/properties' __tagsResource = '/resources/tags' __logbooksResource = '/resources/logbooks' @@ -49,21 +49,20 @@ def __init__(self, url=None, username=None, password=None): :param url: The base URL of the Olog glassfish server. :param username: The username for authentication. :param password: The password for authentication. - + If :param username: is None, then the username will be read from the config file. If no :param username: is avaliable then the session is opened without - authentication. + authentication. ''' - self.__url = _conf.getValue('url', url) self.__username = _conf.getValue('username', username) self.__password = _conf.getValue('password', password) - + logger.info("Using base URL %s", self.__url) if self.__username and self.__password: # If we have a valid username and password, setup authentication - + logger.info("Using username %s for authentication.", self.__username) self.__auth = auth.HTTPBasicAuth(self.__username, self.__password) else: @@ -71,12 +70,12 @@ def __init__(self, url=None, username=None, password=None): # Don't use authentication logger.info("No authentiation configured.") self.__auth = None - + self.__session = requests.Session() self.__session.mount('https://', Ssl3HttpAdapter()) - self.__session.get(self.__url + self.__tagsResource, + self.__session.get(self.__url + self.__tagsResource, verify=False, headers=self.__jsonheader).raise_for_status() - + def log(self, logEntry): ''' Create a log entry @@ -99,9 +98,9 @@ def log(self, logEntry): files={'file': attachment.getFilePost()} ) resp.raise_for_status() - - - + + + def createLogbook(self, logbook): ''' Create a Logbook @@ -113,8 +112,8 @@ def createLogbook(self, logbook): verify=False, headers=self.__jsonheader, auth=self.__auth).raise_for_status() - - + + def createTag(self, tag): ''' Create a Tag @@ -127,7 +126,7 @@ def createTag(self, tag): verify=False, headers=self.__jsonheader, auth=self.__auth).raise_for_status() - + def createProperty(self, property): ''' Create a Property @@ -141,27 +140,27 @@ def createProperty(self, property): verify=False, headers=self.__jsonheader, auth=self.__auth).raise_for_status() - + def find(self, **kwds): ''' Search for logEntries based on one or many search criteria >> find(search='*Timing*') find logentries with the text Timing in the description - + >> find(tag='magnets') find log entries with the a tag named 'magnets' - + >> find(logbook='controls') find log entries in the logbook named 'controls' - + >> find(property='context') find log entires with property named 'context' - + >> find(start=str(time.time() - 3600) find the log entries made in the last hour >> find(start=123243434, end=123244434) find all the log entries made between the epoc times 123243434 and 123244434 - + Searching using multiple criteria >>find(logbook='contorls', tag='magnets') find all the log entries in logbook 'controls' AND with tag named 'magnets' @@ -175,10 +174,10 @@ def find(self, **kwds): ) resp.raise_for_status() logs = [] - for jsonLogEntry in resp.json(): + for jsonLogEntry in resp.json(): logs.append(LogEntryDecoder().dictToLogEntry(jsonLogEntry)) return logs - + def listAttachments(self, logEntryId): ''' Search for attachments on a logentry @@ -201,8 +200,8 @@ def listAttachments(self, logEntryId): testFile.name = fileName testFile.write(f.content) attachments.append(Attachment(file=testFile)) - return attachments - + return attachments + def listTags(self): ''' List all tags in the Olog. @@ -216,7 +215,7 @@ def listTags(self): for jsonTag in resp.json().pop('tag'): tags.append(TagDecoder().dictToTag(jsonTag)) return tags - + def listLogbooks(self): ''' List all logbooks in the Olog. @@ -230,7 +229,7 @@ def listLogbooks(self): for jsonLogbook in resp.json().pop('logbook'): logbooks.append(LogbookDecoder().dictToLogbook(jsonLogbook)) return logbooks - + def listProperties(self): ''' List all Properties and their attributes in the Olog. @@ -244,8 +243,8 @@ def listProperties(self): for jsonProperty in resp.json().pop('property'): properties.append(PropertyDecoder().dictToProperty(jsonProperty)) return properties - - + + def delete(self, **kwds): ''' Method to delete a logEntry, logbook, property, tag. @@ -259,14 +258,14 @@ def delete(self, **kwds): delete(logEntryId = int) >>> delete(logEntryId=1234) - + delete(logbookName = String) >>> delete(logbookName = 'logbookName') - + delete(tagName = String) >>> delete(tagName = 'myTag') # tagName = tag name of the tag to be deleted (it will be removed from all logEntries) - + delete(propertyName = String) >>> delete(propertyName = 'position') # propertyName = property name of property to be deleted (it will be removed from all logEntries) @@ -275,8 +274,8 @@ def delete(self, **kwds): self.__handleSingleDeleteParameter(**kwds) else: raise Exception, 'incorrect usage: Delete a single Logbook/tag/property' - - + + def __handleSingleDeleteParameter(self, **kwds): if 'logbookName' in kwds: self.__session.delete(self.__url + self.__logbooksResource + '/' + kwds['logbookName'].strip(), @@ -290,7 +289,7 @@ def __handleSingleDeleteParameter(self, **kwds): headers=self.__jsonheader, auth=self.__auth).raise_for_status() pass - elif 'propertyName' in kwds: + elif 'propertyName' in kwds: self.__session.delete(self.__url + self.__propertiesResource + '/' + kwds['propertyName'].strip(), data=PropertyEncoder().encode(Property(kwds['propertyName'].strip(), attributes={})), verify=False, @@ -307,7 +306,7 @@ def __handleSingleDeleteParameter(self, **kwds): raise Exception, ' unkown key, use logEntryId, logbookName, tagName or propertyName' class PropertyEncoder(JSONEncoder): - + def default(self, obj): if isinstance(obj, Property): test = {} @@ -320,52 +319,52 @@ def default(self, obj): return json.JSONEncoder.default(self, obj) class PropertyDecoder(JSONDecoder): - + def __init__(self): json.JSONDecoder.__init__(self, object_hook=self.dictToProperty) - + def dictToProperty(self, d): if d: return Property(name=d.pop('name'), attributes=d.pop('attributes')) - + class LogbookEncoder(JSONEncoder): - + def default(self, obj): if isinstance(obj, Logbook): return {"name":obj.getName(), "owner":obj.getOwner()} return json.JSONEncoder.default(self, obj) class LogbookDecoder(JSONDecoder): - + def __init__(self): json.JSONDecoder.__init__(self, object_hook=self.dictToLogbook) - + def dictToLogbook(self, d): if d: return Logbook(name=d.pop('name'), owner=d.pop('owner')) else: return None - + class TagEncoder(JSONEncoder): - + def default(self, obj): if isinstance(obj, Tag): return {"state": obj.getState(), "name": obj.getName()} return json.JSONEncoder.default(self, obj) - + class TagDecoder(JSONDecoder): - + def __init__(self): json.JSONDecoder.__init__(self, object_hook=self.dictToTag) - + def dictToTag(self, d): if d: return Tag(name=d.pop('name'), state=d.pop('state')) else: return None - + class LogEntryEncoder(JSONEncoder): - + def default(self, obj): if isinstance(obj, LogEntry): logbooks = [] @@ -386,10 +385,10 @@ def default(self, obj): return json.JSONEncoder.default(self, obj) class LogEntryDecoder(JSONDecoder): - + def __init__(self): json.JSONDecoder.__init__(self, object_hook=self.dictToLogEntry) - + def dictToLogEntry(self, d): if d: return LogEntry(text=d.pop('description'), diff --git a/pyOlog/conf.py b/pyOlog/conf.py index 61e114a..762a85f 100644 --- a/pyOlog/conf.py +++ b/pyOlog/conf.py @@ -19,7 +19,7 @@ class Config(object): defaults = {'url' : 'http://localhost:8181/Olog', - 'username' : os.getlogin()} + 'username' : os.environ['USER']} conf_files = ['/etc/pyOlog.conf', os.path.expanduser('~/pyOlog.conf'), os.path.expanduser('~/.pyOlog.conf'), @@ -30,7 +30,7 @@ def __init__(self): import ConfigParser self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) files = self.cf.read(self.conf_files) - for f in files: + for f in files: logger.info("Read config file %s", f) def getValue(self, arg, value = None): @@ -41,9 +41,9 @@ def getValue(self, arg, value = None): :param value: Value to check for. This method will return the default value from the config. If - :param value: is not None then this will always return :param value:. + :param value: is not None then this will always return :param value:. If :param value: is None then the config is searched for an entry - :param arg:. If no config is avaliable then None is returned. + :param arg:. If no config is avaliable then None is returned. :returns: Config value or None. ''' @@ -54,5 +54,5 @@ def getValue(self, arg, value = None): return None else: return value - + _conf = Config() From 55115709a40600d15f0670ce163fd79441a45f45 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 10:14:33 -0500 Subject: [PATCH 36/79] Started re-factor of modules to conform to PEP8 --- conda-recipie/meta.yaml | 8 +- pyOlog/OlogClient.py | 249 ++++++++++++++++++++++--------------- pyOlog/SimpleOlogClient.py | 167 ++++++++++++------------- 3 files changed, 233 insertions(+), 191 deletions(-) diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml index b046547..b6be3db 100644 --- a/conda-recipie/meta.yaml +++ b/conda-recipie/meta.yaml @@ -1,6 +1,6 @@ package: - name: pyOlog + name: pyolog version: "0.2.0" source: @@ -13,10 +13,12 @@ requirements: build: - python - setuptools - - requests - - urllib3 run: - python + - setuptools + - requests + - keyring + - urllib3 test: imports: diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 1642a4b..6f880ef 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -6,10 +6,20 @@ @author: shroffk ''' -import logging, sys +import logging +import string + logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) +KEYRING_NAME = 'olog' +try: + import keyring +except ImportError: + have_keyring = False +else: + have_keyring = True + from getpass import getpass import requests @@ -20,7 +30,6 @@ from json import JSONEncoder, JSONDecoder from urllib import urlencode -import urllib3 from urllib3.poolmanager import PoolManager from collections import OrderedDict @@ -31,18 +40,20 @@ from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from conf import _conf + class OlogClient(object): ''' classdocs ''' - __jsonheader = {'content-type':'application/json', 'accept':'application/json'} + __jsonheader = {'content-type': 'application/json', + 'accept': 'application/json'} __logsResource = '/resources/logs' __propertiesResource = '/resources/properties' __tagsResource = '/resources/tags' __logbooksResource = '/resources/logbooks' __attachmentResource = '/resources/attachments' - def __init__(self, url=None, username=None, password=None): + def __init__(self, url=None, username=None, password=None, ask=True): ''' Initialize OlogClient and configure session @@ -50,21 +61,36 @@ def __init__(self, url=None, username=None, password=None): :param username: The username for authentication. :param password: The password for authentication. - If :param username: is None, then the username will be read from the config - file. If no :param username: is avaliable then the session is opened without - authentication. + If :param username: is None, then the username will be read + from the config file. If no :param username: is avaliable then + the session is opened without authentication. + + If :param ask: is True, then the olog will try using both + the keyring module and askpass to get a password. + ''' - self.__url = _conf.getValue('url', url) - self.__username = _conf.getValue('username', username) - self.__password = _conf.getValue('password', password) + self.__url = _conf.getValue('url', url) + username = _conf.getValue('username', username) + password = _conf.getValue('password', password) + + if username and not password and ask: + # try methods for a password + if have_keyring: + password = keyring.get_password(KEYRING_NAME, username) + + # If it is not in the keyring, or we don't have that module + if not password: + password = getpass.getpass("Olog Password (username = {}):" + .format(username)) logger.info("Using base URL %s", self.__url) - if self.__username and self.__password: + if username and password: # If we have a valid username and password, setup authentication - logger.info("Using username %s for authentication.", self.__username) - self.__auth = auth.HTTPBasicAuth(self.__username, self.__password) + logger.info("Using username %s for authentication.", + username) + self.__auth = auth.HTTPBasicAuth(username, password) else: # Don't use authentication @@ -74,7 +100,8 @@ def __init__(self, url=None, username=None, password=None): self.__session = requests.Session() self.__session.mount('https://', Ssl3HttpAdapter()) self.__session.get(self.__url + self.__tagsResource, - verify=False, headers=self.__jsonheader).raise_for_status() + verify=False, + headers=self.__jsonheader).raise_for_status() def log(self, logEntry): ''' @@ -83,36 +110,34 @@ def log(self, logEntry): :param logEntry: An instance of LogEntry to add to the Olog ''' + logEntry = ''.join(c for c in logEntry if c in string.printable) resp = self.__session.post(self.__url + self.__logsResource, - data=LogEntryEncoder().encode(logEntry), - verify=False, - headers=self.__jsonheader, - auth=self.__auth) + data=LogEntryEncoder().encode(logEntry), + verify=False, + headers=self.__jsonheader, + auth=self.__auth) resp.raise_for_status() id = LogEntryDecoder().dictToLogEntry(resp.json()[0]).getId() '''Attachments''' for attachment in logEntry.getAttachments(): - resp = self.__session.post(self.__url + self.__attachmentResource +'/'+ str(id), - verify=False, - auth=self.__auth, - files={'file': attachment.getFilePost()} - ) + url = "{0}{1}/{2}".format(self.__url, self.__attachmentResource, + str(id)) + resp = self.__session.post(url, verify=False, auth=self.__auth, + files={'file': attachment.getFilePost()}) resp.raise_for_status() - - def createLogbook(self, logbook): ''' Create a Logbook :param logbook: An instance of Logbook to create in the Olog. ''' - self.__session.put(self.__url + self.__logbooksResource + '/' + logbook.getName(), - data=LogbookEncoder().encode(logbook), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() - + url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + logbook.getName()) + self.__session.put(url, data=LogbookEncoder().encode(logbook), + verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() def createTag(self, tag): ''' @@ -120,12 +145,12 @@ def createTag(self, tag): :param tag: An instance of Tag to create in the Olog. ''' - url = self.__url + self.__tagsResource + '/' + tag.getName() - self.__session.put(url, - data=TagEncoder().encode(tag), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__tagsResource, + tag.getName()) + self.__session.put(url, data=TagEncoder().encode(tag), + verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() def createProperty(self, property): ''' @@ -133,13 +158,13 @@ def createProperty(self, property): :param property: An instance of Property to create in the Olog. ''' - url = self.__url + self.__propertiesResource + '/' + property.getName() - p = PropertyEncoder().encode(property) - self.__session.put(url, - data=PropertyEncoder().encode(property), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__propertiesResource, + property.getName()) + # p = PropertyEncoder().encode(property) + self.__session.put(url, data=PropertyEncoder().encode(property), + verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() def find(self, **kwds): ''' @@ -159,19 +184,23 @@ def find(self, **kwds): >> find(start=str(time.time() - 3600) find the log entries made in the last hour >> find(start=123243434, end=123244434) - find all the log entries made between the epoc times 123243434 and 123244434 + find all the log entries made between the epoc times 123243434 + and 123244434 Searching using multiple criteria >>find(logbook='contorls', tag='magnets') - find all the log entries in logbook 'controls' AND with tag named 'magnets' + find all the log entries in logbook 'controls' AND with tag + named 'magnets' ''' - #search = '*' + text + '*' - query_string = self.__url + self.__logsResource + '?' + urlencode(OrderedDict(kwds)) + # search = '*' + text + '*' + query_string = "{0}{1}?{2}".format(self.__url, + self.__logsResource, + urlencode(OrderedDict(kwds))) resp = self.__session.get(query_string, - verify=False, - headers=self.__jsonheader, - auth=self.__auth - ) + verify=False, + headers=self.__jsonheader, + auth=self.__auth + ) resp.raise_for_status() logs = [] for jsonLogEntry in resp.json(): @@ -184,18 +213,17 @@ def listAttachments(self, logEntryId): :param logEntryId: The ID of the log entry to list the attachments. ''' - resp = self.__session.get(self.__url+self.__attachmentResource+'/'+str(logEntryId), - verify=False, - headers=self.__jsonheader) + url = "{0}{1}/{2}".format(self.__url, self.__attachmentResource, + str(logEntryId)) + resp = self.__session.get(url, verify=False, + headers=self.__jsonheader) resp.raise_for_status() attachments = [] for jsonAttachment in resp.json().pop('attachment'): fileName = jsonAttachment.pop('fileName') - f = self.__session.get(self.__url+ - self.__attachmentResource+'/'+ - str(logEntryId)+'/'+ - fileName, - verify=False) + url = "{0}{1}/{2}/{3}".format(self.__url, self.__attachmentResource, + str(logEntryId), fileName) + f = self.__session.get(url, verify=False) testFile = tempfile.NamedTemporaryFile(delete=False) testFile.name = fileName testFile.write(f.content) @@ -207,9 +235,9 @@ def listTags(self): List all tags in the Olog. ''' resp = self.__session.get(self.__url + self.__tagsResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) + verify=False, + headers=self.__jsonheader, + auth=self.__auth) resp.raise_for_status() tags = [] for jsonTag in resp.json().pop('tag'): @@ -221,9 +249,9 @@ def listLogbooks(self): List all logbooks in the Olog. ''' resp = self.__session.get(self.__url + self.__logbooksResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) + verify=False, + headers=self.__jsonheader, + auth=self.__auth) resp.raise_for_status() logbooks = [] for jsonLogbook in resp.json().pop('logbook'): @@ -235,16 +263,15 @@ def listProperties(self): List all Properties and their attributes in the Olog. ''' resp = self.__session.get(self.__url + self.__propertiesResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) + verify=False, + headers=self.__jsonheader, + auth=self.__auth) resp.raise_for_status() properties = [] for jsonProperty in resp.json().pop('property'): properties.append(PropertyDecoder().dictToProperty(jsonProperty)) return properties - def delete(self, **kwds): ''' Method to delete a logEntry, logbook, property, tag. @@ -264,46 +291,53 @@ def delete(self, **kwds): delete(tagName = String) >>> delete(tagName = 'myTag') - # tagName = tag name of the tag to be deleted (it will be removed from all logEntries) + # tagName = tag name of the tag to be deleted + (it will be removed from all logEntries) delete(propertyName = String) >>> delete(propertyName = 'position') - # propertyName = property name of property to be deleted (it will be removed from all logEntries) + # propertyName = property name of property to be deleted + (it will be removed from all logEntries) ''' if len(kwds) == 1: self.__handleSingleDeleteParameter(**kwds) else: - raise Exception, 'incorrect usage: Delete a single Logbook/tag/property' - + raise ValueError('Can only delete a single Logbook/tag/property') def __handleSingleDeleteParameter(self, **kwds): if 'logbookName' in kwds: - self.__session.delete(self.__url + self.__logbooksResource + '/' + kwds['logbookName'].strip(), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + kwds['logbookName'].strip()) + self.__session.delete(url, verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() pass elif 'tagName' in kwds: - self.__session.delete(self.__url + self.__tagsResource + '/' + kwds['tagName'].strip(), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + kwds['tagName'].strip()) + self.__session.delete(url, verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() pass elif 'propertyName' in kwds: - self.__session.delete(self.__url + self.__propertiesResource + '/' + kwds['propertyName'].strip(), - data=PropertyEncoder().encode(Property(kwds['propertyName'].strip(), attributes={})), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + kwds['propertyName'].strip()) + data = PropertyEncoder().encode(Property( + kwds['propertyName'].strip())) + self.__session.delete(url, data=data, verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() pass elif 'logEntryId' in kwds: - self.__session.delete(self.__url + self.__logsResource + '/' + str(kwds['logEntryId']).strip(), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + kwds['logEntryId'].strip()) + self.__session.delete(url, verify=False, + headers=self.__jsonheader, + auth=self.__auth).raise_for_status() pass else: - raise Exception, ' unkown key, use logEntryId, logbookName, tagName or propertyName' + raise ValueError('Unknown Key') + class PropertyEncoder(JSONEncoder): @@ -318,6 +352,7 @@ def default(self, obj): return prop return json.JSONEncoder.default(self, obj) + class PropertyDecoder(JSONDecoder): def __init__(self): @@ -327,13 +362,15 @@ def dictToProperty(self, d): if d: return Property(name=d.pop('name'), attributes=d.pop('attributes')) + class LogbookEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Logbook): - return {"name":obj.getName(), "owner":obj.getOwner()} + return {"name": obj.getName(), "owner": obj.getOwner()} return json.JSONEncoder.default(self, obj) + class LogbookDecoder(JSONDecoder): def __init__(self): @@ -345,6 +382,7 @@ def dictToLogbook(self, d): else: return None + class TagEncoder(JSONEncoder): def default(self, obj): @@ -352,6 +390,7 @@ def default(self, obj): return {"state": obj.getState(), "name": obj.getName()} return json.JSONEncoder.default(self, obj) + class TagDecoder(JSONDecoder): def __init__(self): @@ -363,6 +402,7 @@ def dictToTag(self, d): else: return None + class LogEntryEncoder(JSONEncoder): def default(self, obj): @@ -376,14 +416,13 @@ def default(self, obj): properties = [] for property in obj.getProperties(): properties.append(PropertyEncoder().default(property)) - return [{"description":obj.getText(), - "owner":obj.getOwner(), - "level":"Info", - "logbooks":logbooks, - "tags":tags, - "properties":properties}] + return [{"description": obj.getText(), + "owner": obj.getOwner(), "level": "Info", + "logbooks": logbooks, "tags": tags, + "properties": properties}] return json.JSONEncoder.default(self, obj) + class LogEntryDecoder(JSONDecoder): def __init__(self): @@ -391,11 +430,17 @@ def __init__(self): def dictToLogEntry(self, d): if d: + logbooks = [LogbookDecoder().dictToLogbook(logbook) + for logbook in d.pop('logbooks')] + + tags = [TagDecoder().dictToTag(tag) for tag in d.pop('tags')] + + properties = [PropertyDecoder().dictToProperty(property) + for property in d.pop('properties')] return LogEntry(text=d.pop('description'), owner=d.pop('owner'), - logbooks=[LogbookDecoder().dictToLogbook(logbook) for logbook in d.pop('logbooks')], - tags=[TagDecoder().dictToTag(tag) for tag in d.pop('tags')], - properties=[PropertyDecoder().dictToProperty(property) for property in d.pop('properties')], + logbooks=logbooks, tags=tags, + properties=properties, id=d.pop('id'), createTime=d.pop('createdDate'), modifyTime=d.pop('modifiedDate')) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index d8a5201..c4bd799 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -3,95 +3,90 @@ A simple API to the Olog client in python """ -import getpass -import keyring - from .utils import get_text_from_editor from .OlogClient import OlogClient from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment -from .conf import _conf class SimpleOlogClient(object): - def __init__(self, url = None, username = None, password = None): - """Initiate a session and do password caching using keyring""" - - # First check config file for defaults - - - if username is None: - if _conf.getValue('username'): - username = _conf.getValue('username') - else: - username = getpass.getuser() - - if password is None: - if _conf.getValue('password'): - password = _conf.getValue('password') - if password is None: - password = keyring.get_password('olog', username) - if password is None: - password = getpass.getpass("Olog Password (username = {}) :".format(username)) - - if username and not password: - raise Exception("Unable to obtain password and authentication requested.") - self.session = OlogClient(username = username, password = password) - - def getTags(self): - """Return a list of tag names in the Olog""" - return [t.getName() for t in self.session.listTags()] - - def getLogbooks(self): - """Return a list of tag names in the Olog""" - return [l.getName() for l in self.session.listLogbooks()] - - def log(self, text = None, logbooks = None, tags = None, properties = None, - attachments = None, verify = True): - """ - Create olog entry. - - :param str text: String of the olog entry to make. - :param logbooks: Logbooks to make entry into. - :type logbooks: None, List or string - :param tags:Tags to apply to logbook entry. - :type tags: None, List or string - - """ - - if logbooks: - if not isinstance(logbooks, list): - logbooks = [logbooks] - if tags: - if not isinstance(tags, list): - tags = [tags] - if attachments: - if not isinstance(attachments, list): - attachments = [attachments] - - if logbooks: - if verify: - if not any([x in logbooks for x in self.getLogbooks()]): - raise ValueError("Invalid Logbook name (not in Olog)") - logbooks = [Logbook(n) for n in logbooks] - - if tags: - if verify: - if not any([x in tags for x in self.getTags()]): - raise ValueError("Invalid Tag (not in Olog)") - tags = [Tag(n) for n in tags] - - if not text: - text = get_text_from_editor() - - toattach = [] - if attachments: - for a in attachments: - if isinstance(a, Attachment): - toattach.append(a) - else: - toattach.append(Attachment(open(a))) - - log = LogEntry(text, logbooks = logbooks, - tags = tags, attachments = toattach) - self.session.log(log) - + def __init__(self, *args, **kwargs): + """Initiate a session and do password caching using keyring""" + + # First check config file for defaults + + # if username is None: + # if _conf.getValue('username'): + # username = _conf.getValue('username') + # else: + # username = getpass.getuser() + + # if password is None: + # if _conf.getValue('password'): + # password = _conf.getValue('password') + # if password is None: + # password = keyring.get_password('olog', username) + # if password is None: + # password = getpass.getpass("Olog Password (username = {}) :" + # .format(username)) + + # if username and not password: + # raise Exception("Unable to obtain authentication.") + self.session = OlogClient(*args, **kwargs) + + def getTags(self): + """Return a list of tag names in the Olog""" + return [t.getName() for t in self.session.listTags()] + + def getLogbooks(self): + """Return a list of tag names in the Olog""" + return [l.getName() for l in self.session.listLogbooks()] + + def log(self, text=None, logbooks=None, tags=None, properties=None, + attachments=None, verify=True): + """ + Create olog entry. + + :param str text: String of the olog entry to make. + :param logbooks: Logbooks to make entry into. + :type logbooks: None, List or string + :param tags:Tags to apply to logbook entry. + :type tags: None, List or string + + """ + + if logbooks: + if not isinstance(logbooks, list): + logbooks = [logbooks] + if tags: + if not isinstance(tags, list): + tags = [tags] + if attachments: + if not isinstance(attachments, list): + attachments = [attachments] + + if logbooks: + if verify: + if not any([x in logbooks for x in self.getLogbooks()]): + raise ValueError("Invalid Logbook name (not in Olog)") + logbooks = [Logbook(n) for n in logbooks] + + if tags: + if verify: + if not any([x in tags for x in self.getTags()]): + raise ValueError("Invalid Tag (not in Olog)") + tags = [Tag(n) for n in tags] + + if not text: + text = get_text_from_editor() + + toattach = [] + if attachments: + for a in attachments: + if isinstance(a, Attachment): + toattach.append(a) + else: + toattach.append(Attachment(open(a))) + + log = LogEntry(text, logbooks=logbooks, + tags=tags, attachments=toattach) + self.session.log(log) From 7ee5002a3b041f08995138c5c07a17896cf1b3ca Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 10:15:19 -0500 Subject: [PATCH 37/79] Added bck files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5b9b27c..c9ace11 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build dist doc/_* .ropeproject +*.bak From 4105685292465701dc8c8903bc872d8afd8b0bd5 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 13:05:46 -0500 Subject: [PATCH 38/79] Fixed logging and cleaned up imports --- conda-recipie/meta.yaml | 3 +- pyOlog/OlogClient.py | 239 +++++++++++++++++++--------------------- pyOlog/OlogDataTypes.py | 94 ++++++++-------- pyOlog/__init__.py | 13 +++ pyOlog/conf.py | 78 ++++++------- 5 files changed, 219 insertions(+), 208 deletions(-) diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml index b6be3db..a419081 100644 --- a/conda-recipie/meta.yaml +++ b/conda-recipie/meta.yaml @@ -5,9 +5,10 @@ package: source: git_url: https://github.com/NSLS-II-CSX/pyOlog.git + git_tag: refactor build: - number: 0 + number: 2 requirements: build: diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 6f880ef..30f910e 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -7,35 +7,27 @@ @author: shroffk ''' import logging -import string logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) KEYRING_NAME = 'olog' try: - import keyring + from keyring import get_password except ImportError: have_keyring = False + logger.warning("No keyring module found") else: have_keyring = True from getpass import getpass import requests -from requests.adapters import HTTPAdapter -from requests import auth -import json from json import JSONEncoder, JSONDecoder - from urllib import urlencode -from urllib3.poolmanager import PoolManager - from collections import OrderedDict import tempfile -import ssl from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from conf import _conf @@ -45,13 +37,13 @@ class OlogClient(object): ''' classdocs ''' - __jsonheader = {'content-type': 'application/json', - 'accept': 'application/json'} - __logsResource = '/resources/logs' - __propertiesResource = '/resources/properties' - __tagsResource = '/resources/tags' - __logbooksResource = '/resources/logbooks' - __attachmentResource = '/resources/attachments' + json_header = {'content-type': 'application/json', + 'accept': 'application/json'} + logs_resource = '/resources/logs' + properties_resource = '/resources/properties' + tags_resource = '/resources/tags' + logbooks_resource = '/resources/logbooks' + attachments_resource = '/resources/attachments' def __init__(self, url=None, username=None, password=None, ask=True): ''' @@ -69,62 +61,89 @@ def __init__(self, url=None, username=None, password=None, ask=True): the keyring module and askpass to get a password. ''' - self.__url = _conf.getValue('url', url) + self._url = _conf.getValue('url', url) + self.verify = False username = _conf.getValue('username', username) password = _conf.getValue('password', password) if username and not password and ask: # try methods for a password if have_keyring: - password = keyring.get_password(KEYRING_NAME, username) + password = get_password(KEYRING_NAME, username) # If it is not in the keyring, or we don't have that module if not password: - password = getpass.getpass("Olog Password (username = {}):" - .format(username)) + logger.info("Password not found in keyring") + password = getpass("Olog Password (username = {}):" + .format(username)) - logger.info("Using base URL %s", self.__url) + logger.info("Using base URL %s", self._url) if username and password: # If we have a valid username and password, setup authentication logger.info("Using username %s for authentication.", username) - self.__auth = auth.HTTPBasicAuth(username, password) + self._auth = requests.auth.HTTPBasicAuth(username, password) else: # Don't use authentication logger.info("No authentiation configured.") - self.__auth = None + self._auth = None + + self._session = requests.Session() + self._get("{0}{1}".format(self._url, self.tags_resource)) + + def _get(self, url, **kwargs): + """Do an http GET request""" + resp = self._session.get(url, verify=self.verify, + headers=self.json_header, + **kwargs) + resp.raise_for_status() + return resp + + def _put(self, url, **kwargs): + """Do an http put request""" + resp = self._session.put(url, verify=self.verify, + headers=self.json_header, + auth=self._auth, + **kwargs) + resp.raise_for_status() + return resp + + def _post(self, url, **kwargs): + """Do an http post request""" + resp = self._session.post(url, verify=self.verify, + headers=self.json_header, + auth=self._auth, **kwargs) + resp.raise_for_status() + return resp - self.__session = requests.Session() - self.__session.mount('https://', Ssl3HttpAdapter()) - self.__session.get(self.__url + self.__tagsResource, - verify=False, - headers=self.__jsonheader).raise_for_status() + def _delete(self, url, **kwargs): + """Do an http delete request""" + resp = self._session.delete(url, verify=self.verify, + headers=self.json_header, + auth=self._auth, **kwargs) + resp.raise_for_status() + return resp - def log(self, logEntry): + def log(self, log_entry): ''' Create a log entry - :param logEntry: An instance of LogEntry to add to the Olog + :param log_entry: An instance of LogEntry to add to the Olog ''' - logEntry = ''.join(c for c in logEntry if c in string.printable) - resp = self.__session.post(self.__url + self.__logsResource, - data=LogEntryEncoder().encode(logEntry), - verify=False, - headers=self.__jsonheader, - auth=self.__auth) - resp.raise_for_status() + resp = self._post(self._url + self.logs_resource, + data=LogEntryEncoder().encode(log_entry)) id = LogEntryDecoder().dictToLogEntry(resp.json()[0]).getId() - '''Attachments''' - for attachment in logEntry.getAttachments(): - url = "{0}{1}/{2}".format(self.__url, self.__attachmentResource, + + # Handle attachments + + for attachment in log_entry.getAttachments(): + url = "{0}{1}/{2}".format(self._url, self.attachments_resource, str(id)) - resp = self.__session.post(url, verify=False, auth=self.__auth, - files={'file': attachment.getFilePost()}) - resp.raise_for_status() + resp = self._post(url, files={'file': attachment.getFilePost()}) def createLogbook(self, logbook): ''' @@ -132,12 +151,9 @@ def createLogbook(self, logbook): :param logbook: An instance of Logbook to create in the Olog. ''' - url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, logbook.getName()) - self.__session.put(url, data=LogbookEncoder().encode(logbook), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + self._put(url, data=LogbookEncoder().encode(logbook)) def createTag(self, tag): ''' @@ -145,12 +161,9 @@ def createTag(self, tag): :param tag: An instance of Tag to create in the Olog. ''' - url = "{0}{1}/{2}".format(self.__url, self.__tagsResource, + url = "{0}{1}/{2}".format(self._url, self.tags_resource, tag.getName()) - self.__session.put(url, data=TagEncoder().encode(tag), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + self._put(url, data=TagEncoder().encode(tag)) def createProperty(self, property): ''' @@ -158,13 +171,10 @@ def createProperty(self, property): :param property: An instance of Property to create in the Olog. ''' - url = "{0}{1}/{2}".format(self.__url, self.__propertiesResource, + url = "{0}{1}/{2}".format(self._url, self.properties_resource, property.getName()) # p = PropertyEncoder().encode(property) - self.__session.put(url, data=PropertyEncoder().encode(property), - verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() + self._put(url, data=PropertyEncoder().encode(property)) def find(self, **kwds): ''' @@ -193,18 +203,15 @@ def find(self, **kwds): named 'magnets' ''' # search = '*' + text + '*' - query_string = "{0}{1}?{2}".format(self.__url, - self.__logsResource, + query_string = "{0}{1}?{2}".format(self._url, + self.logs_resource, urlencode(OrderedDict(kwds))) - resp = self.__session.get(query_string, - verify=False, - headers=self.__jsonheader, - auth=self.__auth - ) - resp.raise_for_status() + resp = self._get(query_string) + logs = [] for jsonLogEntry in resp.json(): logs.append(LogEntryDecoder().dictToLogEntry(jsonLogEntry)) + return logs def listAttachments(self, logEntryId): @@ -213,17 +220,16 @@ def listAttachments(self, logEntryId): :param logEntryId: The ID of the log entry to list the attachments. ''' - url = "{0}{1}/{2}".format(self.__url, self.__attachmentResource, + url = "{0}{1}/{2}".format(self._url, self.attachments_resource, str(logEntryId)) - resp = self.__session.get(url, verify=False, - headers=self.__jsonheader) - resp.raise_for_status() + resp = self._get(url) + attachments = [] for jsonAttachment in resp.json().pop('attachment'): fileName = jsonAttachment.pop('fileName') - url = "{0}{1}/{2}/{3}".format(self.__url, self.__attachmentResource, + url = "{0}{1}/{2}/{3}".format(self._url, self.attachments_resource, str(logEntryId), fileName) - f = self.__session.get(url, verify=False) + f = self._get(url) testFile = tempfile.NamedTemporaryFile(delete=False) testFile.name = fileName testFile.write(f.content) @@ -234,11 +240,8 @@ def listTags(self): ''' List all tags in the Olog. ''' - resp = self.__session.get(self.__url + self.__tagsResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) - resp.raise_for_status() + resp = self._get(self._url + self.tags_resource) + tags = [] for jsonTag in resp.json().pop('tag'): tags.append(TagDecoder().dictToTag(jsonTag)) @@ -248,11 +251,8 @@ def listLogbooks(self): ''' List all logbooks in the Olog. ''' - resp = self.__session.get(self.__url + self.__logbooksResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) - resp.raise_for_status() + resp = self._get(self._url + self.logbooks_resource) + logbooks = [] for jsonLogbook in resp.json().pop('logbook'): logbooks.append(LogbookDecoder().dictToLogbook(jsonLogbook)) @@ -262,11 +262,8 @@ def listProperties(self): ''' List all Properties and their attributes in the Olog. ''' - resp = self.__session.get(self.__url + self.__propertiesResource, - verify=False, - headers=self.__jsonheader, - auth=self.__auth) - resp.raise_for_status() + resp = self._get(self._url + self.properties_resource) + properties = [] for jsonProperty in resp.json().pop('property'): properties.append(PropertyDecoder().dictToProperty(jsonProperty)) @@ -306,35 +303,27 @@ def delete(self, **kwds): def __handleSingleDeleteParameter(self, **kwds): if 'logbookName' in kwds: - url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, kwds['logbookName'].strip()) - self.__session.delete(url, verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() - pass + self._delete(url) + elif 'tagName' in kwds: - url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, kwds['tagName'].strip()) - self.__session.delete(url, verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() - pass + self._delete(url) + elif 'propertyName' in kwds: - url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, kwds['propertyName'].strip()) data = PropertyEncoder().encode(Property( kwds['propertyName'].strip())) - self.__session.delete(url, data=data, verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() - pass + self._delete(url, data=data) + elif 'logEntryId' in kwds: - url = "{0}{1}/{2}".format(self.__url, self.__logbooksResource, + url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, kwds['logEntryId'].strip()) - self.__session.delete(url, verify=False, - headers=self.__jsonheader, - auth=self.__auth).raise_for_status() - pass + self._delete(url) + else: raise ValueError('Unknown Key') @@ -350,13 +339,13 @@ def default(self, obj): prop["name"] = obj.getName() prop["attributes"] = test return prop - return json.JSONEncoder.default(self, obj) + return JSONEncoder.default(self, obj) class PropertyDecoder(JSONDecoder): def __init__(self): - json.JSONDecoder.__init__(self, object_hook=self.dictToProperty) + JSONDecoder.__init__(self, object_hook=self.dictToProperty) def dictToProperty(self, d): if d: @@ -368,13 +357,13 @@ class LogbookEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Logbook): return {"name": obj.getName(), "owner": obj.getOwner()} - return json.JSONEncoder.default(self, obj) + return JSONEncoder.default(self, obj) class LogbookDecoder(JSONDecoder): def __init__(self): - json.JSONDecoder.__init__(self, object_hook=self.dictToLogbook) + JSONDecoder.__init__(self, object_hook=self.dictToLogbook) def dictToLogbook(self, d): if d: @@ -388,13 +377,13 @@ class TagEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Tag): return {"state": obj.getState(), "name": obj.getName()} - return json.JSONEncoder.default(self, obj) + return JSONEncoder.default(self, obj) class TagDecoder(JSONDecoder): def __init__(self): - json.JSONDecoder.__init__(self, object_hook=self.dictToTag) + JSONDecoder.__init__(self, object_hook=self.dictToTag) def dictToTag(self, d): if d: @@ -420,13 +409,13 @@ def default(self, obj): "owner": obj.getOwner(), "level": "Info", "logbooks": logbooks, "tags": tags, "properties": properties}] - return json.JSONEncoder.default(self, obj) + return JSONEncoder.default(self, obj) class LogEntryDecoder(JSONDecoder): def __init__(self): - json.JSONDecoder.__init__(self, object_hook=self.dictToLogEntry) + JSONDecoder.__init__(self, object_hook=self.dictToLogEntry) def dictToLogEntry(self, d): if d: @@ -448,11 +437,13 @@ def dictToLogEntry(self, d): return None -class Ssl3HttpAdapter(HTTPAdapter): - """"Transport adapter" that allows us to use SSLv3.""" - - def init_poolmanager(self, connections, maxsize, block=False): - self.poolmanager = PoolManager(num_pools=connections, - maxsize=maxsize, - block=block, - ssl_version=ssl.PROTOCOL_SSLv3) +# class Ssl3HttpAdapter(HTTPAdapter): +# """"Transport adapter" that allows us to use SSLv3.""" +# +# def init_poolmanager(self, connections, maxsize, block=False): +# self.poolmanager = PoolManager(num_pools=connections, +# maxsize=maxsize, +# block=block, +# # ssl_version=ssl.PROTOCOL_SSLv3, +# cert_reqs='CERT_REQUIRED', +# ca_certs=certifi.where()) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index f38aa91..8929592 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -9,6 +9,7 @@ import os import mimetypes +import string from conf import _conf @@ -18,23 +19,24 @@ class LogEntry(object): It can optionally be associated with one or more logbooks and contain one or more tags, properties and attachments ''' - def __init__(self, text, owner = None, logbooks = None, + def __init__(self, text, owner = None, logbooks = None, tags=None, attachments=None, properties=None, id=None, createTime=None, modifyTime=None): ''' Constructor for log Entry Simple LogEntry >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')]) - + Comprehensive logEntry - >> LogEntry('test log entry', 'controls', + >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')], tags=[Tag('TimingSystem')] - properties=[Property('Ticket', + properties=[Property('Ticket', attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}] attachments=[Attachment(open('databrowser.plt'))] ) ''' + text = ''.join(c for c in text if c in string.printable) self.Text = str(text).strip() self.Owner = _conf.getValue('username', owner) @@ -71,46 +73,46 @@ def __init__(self, text, owner = None, logbooks = None, self.__id = id self.__createTime = createTime self.__modifytime = modifyTime - + def getId(self): return self.__id - + def getCreateTime(self): return self.__createTime - + def getModifyTime(self): return self.__modifytime - + def getText(self): return self.Text - + def getOwner(self): return self.Owner - + def getLogbooks(self): return self.logbooks - + def getTags(self): return self.tags - + def getAttachments(self): return self.attachments - + def getProperties(self): return self.properties - - def __cmp__(self, *arg, **kwargs): + + def __cmp__(self, *arg, **kwargs): if arg[0] == None: - return 1 + return 1 if self.__id: return cmp((self.__id),(arg[0].__id)) else: raise Exception, 'Invalid LogEntry: id cannot be None' - - + + class Logbook(object): ''' - A Logbook consist of an unique name and an owner, + A Logbook consist of an unique name and an owner, logentries can be added to a logbook so long as the user either the owner or a member of the owner group ''' @@ -122,18 +124,18 @@ def __init__(self, name, owner=None): ''' self.__Name = str(name).strip() self.__Owner = str(owner).strip() - + def getName(self): return self.__Name - + def getOwner(self): return self.__Owner - - def __cmp__(self, *arg, **kwargs): + + def __cmp__(self, *arg, **kwargs): if arg[0] == None: - return 1 + return 1 return cmp((self.__Name, self.__Owner), (arg[0].__Name, arg[0].__Owner)) - + class Tag(object): ''' A Tag consists of a unique name, it is used to tag logEntries""" @@ -146,29 +148,29 @@ def __init__(self, name, state="Active"): ''' self.__Name = str(name).strip() self.__State = str(state).strip() - + def getName(self): return self.__Name - + def getState(self): return self.__State - - def __cmp__(self, *arg, **kwargs): + + def __cmp__(self, *arg, **kwargs): if arg[0] == None: - return 1 + return 1 return cmp((self.__Name, self.__State), (arg[0].__Name, arg[0].__State)) - + class Attachment(object): ''' A Attachment, a file associated with the log entry - TODO this is not thread safe + TODO this is not thread safe ''' - + def __init__(self, file, filename = None): ''' - Create Attachment + Create Attachment - file can either be a file object or a string. For a + file can either be a file object or a string. For a string, the filename must be specified. >> Attachment(file=open('/home/usr/databrowser.plt') @@ -180,7 +182,7 @@ def __init__(self, file, filename = None): def getFile(self): return self.__file def getFilePost(self): - if self.__filename is None: + if self.__filename is None: basename = os.path.basename(self.__file.name) else: basename = os.path.basename(self.__filename) @@ -191,9 +193,9 @@ def getFilePost(self): class Property(object): ''' - A property consists of a unique name and a set of attributes consisting of key value pairs + A property consists of a unique name and a set of attributes consisting of key value pairs ''' - + def __init__(self, name, attributes=None): ''' Create a property with a unique name and attributes @@ -202,21 +204,21 @@ def __init__(self, name, attributes=None): ''' self.__Name = str(name).strip() self.Attributes = attributes - + def getName(self): return self.__Name - + def getAttributes(self): return self.Attributes; - + def getAttributeNames(self): return self.Attributes.keys() - + def getAttributeValue(self, attributeName): return self.Attributes.get(attributeName) - - def __cmp__(self, *arg, **kwargs): + + def __cmp__(self, *arg, **kwargs): if arg[0] == None: - return 1 + return 1 return cmp((self.__Name, set(self.Attributes)), (arg[0].__Name, set(arg[0].Attributes))) - + diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index a8fdcf4..77de5c8 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -1,3 +1,16 @@ +import logging +import sys +logger = logging.getLogger("pyOlog") +logger.setLevel(logging.DEBUG) + +handler = logging.StreamHandler(sys.stderr) +handler.setLevel(logging.DEBUG) + +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +handler.setFormatter(formatter) + +logger.addHandler(handler) + from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment from OlogClient import OlogClient from SimpleOlogClient import SimpleOlogClient diff --git a/pyOlog/conf.py b/pyOlog/conf.py index 762a85f..149ce24 100644 --- a/pyOlog/conf.py +++ b/pyOlog/conf.py @@ -2,7 +2,8 @@ """ Configuration module used to set defaults for pyOlog to connect to the Olog. -Default locations are searched for a config file. An example file is listed below: +Default locations are searched for a config file. +An example file is listed below: [DEFAULT] url=http://localhost:8000/Olog @@ -17,42 +18,45 @@ logger = logging.getLogger(__name__) + class Config(object): - defaults = {'url' : 'http://localhost:8181/Olog', - 'username' : os.environ['USER']} - conf_files = ['/etc/pyOlog.conf', - os.path.expanduser('~/pyOlog.conf'), - os.path.expanduser('~/.pyOlog.conf'), - 'pyOlog.conf'] - heading = 'DEFAULT' - def __init__(self): - """Initialise config object""" - import ConfigParser - self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) - files = self.cf.read(self.conf_files) - for f in files: - logger.info("Read config file %s", f) - - def getValue(self, arg, value = None): - ''' - Get a default from the config file. - - :param arg: Parameter to return - :param value: Value to check for. - - This method will return the default value from the config. If - :param value: is not None then this will always return :param value:. - If :param value: is None then the config is searched for an entry - :param arg:. If no config is avaliable then None is returned. - - :returns: Config value or None. - ''' - if value is None: - if self.cf.has_option(self.heading, arg): - return self.cf.get(self.heading, arg) - else: - return None - else: - return value + defaults = {'url': 'http://localhost:8181/Olog', + 'username': os.environ['USER']} + conf_files = ['/etc/pyOlog.conf', + os.path.expanduser('~/pyOlog.conf'), + os.path.expanduser('~/.pyOlog.conf'), + os.path.expanduser('~/.pyologrc'), + 'pyOlog.conf'] + + def __init__(self, conf='DEFAULT'): + """Initialise config object""" + self.heading = conf + import ConfigParser + self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) + files = self.cf.read(self.conf_files) + for f in files: + logger.info("Read config file %s", f) + + def getValue(self, arg, value=None): + ''' + Get a default from the config file. + + :param arg: Parameter to return + :param value: Value to check for. + + This method will return the default value from the config. If + :param value: is not None then this will always return :param value:. + If :param value: is None then the config is searched for an entry + :param arg:. If no config is avaliable then None is returned. + + :returns: Config value or None. + ''' + if value is None: + if self.cf.has_option(self.heading, arg): + return self.cf.get(self.heading, arg) + else: + return None + else: + return value _conf = Config() From 01c21d9c101538615db14a4b5a3bdcaee922e3b4 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 15:19:47 -0500 Subject: [PATCH 39/79] Reformatted as per PEP8. Added docstrings --- pyOlog/OlogHandler.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/pyOlog/OlogHandler.py b/pyOlog/OlogHandler.py index c7e944b..3ba65d6 100644 --- a/pyOlog/OlogHandler.py +++ b/pyOlog/OlogHandler.py @@ -1,18 +1,25 @@ import logging from SimpleOlogClient import SimpleOlogClient + class OlogHandler(logging.Handler): - def __init__(self, logbooks = None, tags = None): - logging.Handler.__init__(self) - self.session = SimpleOlogClient() - self.logbooks = logbooks - self.tags = tags - def emit(self, record): - # ToDo add log level to olog - try: - msg = self.format(record) - self.session.log(msg, - logbooks = self.logbooks, - tags = self.tags) - except: - self.handleError(record) + + def __init__(self, logbooks=None, tags=None): + """Initialize the ologhandler + + :param logbooks: list of strings of logbooks to add messages to + :param tags: list of strings of tags to add to all messages + """ + super(OlogHandler, self).__init__() + self.session = SimpleOlogClient() + self.logbooks = logbooks + self.tags = tags + + def emit(self, record): + try: + msg = self.format(record) + self.session.log(msg, + logbooks=self.logbooks, + tags=self.tags) + except: + self.handleError(record) From 0b8f89739276e495d6bddd7e18cd635b3cc8b121 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 15:46:02 -0500 Subject: [PATCH 40/79] Added auth to session --- README | 0 conda-recipie/meta.yaml | 1 - pyOlog/OlogClient.py | 9 ++++++++- 3 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml index a419081..365e2e6 100644 --- a/conda-recipie/meta.yaml +++ b/conda-recipie/meta.yaml @@ -19,7 +19,6 @@ requirements: - setuptools - requests - keyring - - urllib3 test: imports: diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 30f910e..52fef5a 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -23,6 +23,12 @@ import requests +# +# Disable warning for non verified HTTPS requests +# +from requests.packages import urllib3 +urllib3.disable_warnings() + from json import JSONEncoder, JSONDecoder from urllib import urlencode from collections import OrderedDict @@ -92,11 +98,12 @@ def __init__(self, url=None, username=None, password=None, ask=True): self._auth = None self._session = requests.Session() - self._get("{0}{1}".format(self._url, self.tags_resource)) + self._session.auth = self._auth def _get(self, url, **kwargs): """Do an http GET request""" resp = self._session.get(url, verify=self.verify, + auth=self._auth, headers=self.json_header, **kwargs) resp.raise_for_status() From 7b0e13689136d0a44f6f4093c71a3d2754901b65 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 16:26:40 -0500 Subject: [PATCH 41/79] Refactored stings for URLs --- pyOlog/OlogClient.py | 77 ++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 52fef5a..76a9d4e 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -99,38 +99,30 @@ def __init__(self, url=None, username=None, password=None, ask=True): self._session = requests.Session() self._session.auth = self._auth + self._session.headers.update(self.json_header) + self._session.verify = self.verify def _get(self, url, **kwargs): """Do an http GET request""" - resp = self._session.get(url, verify=self.verify, - auth=self._auth, - headers=self.json_header, - **kwargs) + resp = self._session.get(self._url + url, **kwargs) resp.raise_for_status() return resp def _put(self, url, **kwargs): """Do an http put request""" - resp = self._session.put(url, verify=self.verify, - headers=self.json_header, - auth=self._auth, - **kwargs) + resp = self._session.put(self._url + url, **kwargs) resp.raise_for_status() return resp def _post(self, url, **kwargs): """Do an http post request""" - resp = self._session.post(url, verify=self.verify, - headers=self.json_header, - auth=self._auth, **kwargs) + resp = self._session.post(self._url + url, **kwargs) resp.raise_for_status() return resp def _delete(self, url, **kwargs): """Do an http delete request""" - resp = self._session.delete(url, verify=self.verify, - headers=self.json_header, - auth=self._auth, **kwargs) + resp = self._session.delete(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -141,15 +133,14 @@ def log(self, log_entry): :param log_entry: An instance of LogEntry to add to the Olog ''' - resp = self._post(self._url + self.logs_resource, + resp = self._post(self.logs_resource, data=LogEntryEncoder().encode(log_entry)) id = LogEntryDecoder().dictToLogEntry(resp.json()[0]).getId() # Handle attachments for attachment in log_entry.getAttachments(): - url = "{0}{1}/{2}".format(self._url, self.attachments_resource, - str(id)) + url = "/".join((self.attachments_resource, str(id))) resp = self._post(url, files={'file': attachment.getFilePost()}) def createLogbook(self, logbook): @@ -158,8 +149,7 @@ def createLogbook(self, logbook): :param logbook: An instance of Logbook to create in the Olog. ''' - url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, - logbook.getName()) + url = "/".join((self.logbooks_resource, logbook.getName())) self._put(url, data=LogbookEncoder().encode(logbook)) def createTag(self, tag): @@ -168,8 +158,7 @@ def createTag(self, tag): :param tag: An instance of Tag to create in the Olog. ''' - url = "{0}{1}/{2}".format(self._url, self.tags_resource, - tag.getName()) + url = "/".join((self.tags_resource, tag.getName())) self._put(url, data=TagEncoder().encode(tag)) def createProperty(self, property): @@ -178,10 +167,9 @@ def createProperty(self, property): :param property: An instance of Property to create in the Olog. ''' - url = "{0}{1}/{2}".format(self._url, self.properties_resource, - property.getName()) - # p = PropertyEncoder().encode(property) - self._put(url, data=PropertyEncoder().encode(property)) + url = "/".join((self.properties_resource, property.getName())) + p = PropertyEncoder().encode(property) + self._put(url, data=p) def find(self, **kwds): ''' @@ -210,9 +198,8 @@ def find(self, **kwds): named 'magnets' ''' # search = '*' + text + '*' - query_string = "{0}{1}?{2}".format(self._url, - self.logs_resource, - urlencode(OrderedDict(kwds))) + query_string = "?".join((self.logs_resource, + urlencode(OrderedDict(kwds)))) resp = self._get(query_string) logs = [] @@ -227,27 +214,27 @@ def listAttachments(self, logEntryId): :param logEntryId: The ID of the log entry to list the attachments. ''' - url = "{0}{1}/{2}".format(self._url, self.attachments_resource, - str(logEntryId)) + url = "/".join((self.attachments_resource, str(logEntryId))) resp = self._get(url) attachments = [] for jsonAttachment in resp.json().pop('attachment'): - fileName = jsonAttachment.pop('fileName') - url = "{0}{1}/{2}/{3}".format(self._url, self.attachments_resource, - str(logEntryId), fileName) + filename = jsonAttachment.pop('filename') + url = "/".join((self.attachments_resource, str(logEntryId), + filename)) f = self._get(url) testFile = tempfile.NamedTemporaryFile(delete=False) - testFile.name = fileName + testFile.name = filename testFile.write(f.content) attachments.append(Attachment(file=testFile)) + return attachments def listTags(self): ''' List all tags in the Olog. ''' - resp = self._get(self._url + self.tags_resource) + resp = self._get(self.tags_resource) tags = [] for jsonTag in resp.json().pop('tag'): @@ -258,7 +245,7 @@ def listLogbooks(self): ''' List all logbooks in the Olog. ''' - resp = self._get(self._url + self.logbooks_resource) + resp = self._get(self.logbooks_resource) logbooks = [] for jsonLogbook in resp.json().pop('logbook'): @@ -269,7 +256,7 @@ def listProperties(self): ''' List all Properties and their attributes in the Olog. ''' - resp = self._get(self._url + self.properties_resource) + resp = self._get(self.properties_resource) properties = [] for jsonProperty in resp.json().pop('property'): @@ -310,25 +297,25 @@ def delete(self, **kwds): def __handleSingleDeleteParameter(self, **kwds): if 'logbookName' in kwds: - url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, - kwds['logbookName'].strip()) + url = "/".join((self.logbooks_resource, + kwds['logbookName'].strip())) self._delete(url) elif 'tagName' in kwds: - url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, - kwds['tagName'].strip()) + url = "/".join((self.logbooks_resource, + kwds['tagName'].strip())) self._delete(url) elif 'propertyName' in kwds: - url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, - kwds['propertyName'].strip()) + url = "/".join((self.logbooks_resource, + kwds['propertyName'].strip())) data = PropertyEncoder().encode(Property( kwds['propertyName'].strip())) self._delete(url, data=data) elif 'logEntryId' in kwds: - url = "{0}{1}/{2}".format(self._url, self.logbooks_resource, - kwds['logEntryId'].strip()) + url = "/".join((self.logbooks_resource, + kwds['logEntryId'].strip())) self._delete(url) else: From 1168a3737ed72c2a7e71db02ec8d707e7d8efcd9 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 17:00:22 -0500 Subject: [PATCH 42/79] With separate auth --- pyOlog/OlogClient.py | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 76a9d4e..e6b6655 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -21,14 +21,19 @@ from getpass import getpass +import ssl import requests +from requests.packages import urllib3 +from requests.adapters import HTTPAdapter + # # Disable warning for non verified HTTPS requests # -from requests.packages import urllib3 urllib3.disable_warnings() +from requests.packages.urllib3.poolmanager import PoolManager + from json import JSONEncoder, JSONDecoder from urllib import urlencode from collections import OrderedDict @@ -98,31 +103,40 @@ def __init__(self, url=None, username=None, password=None, ask=True): self._auth = None self._session = requests.Session() - self._session.auth = self._auth + self._session.mount('https://', ssl3_http_adapter()) + # self._session.auth = _auth self._session.headers.update(self.json_header) self._session.verify = self.verify def _get(self, url, **kwargs): """Do an http GET request""" - resp = self._session.get(self._url + url, **kwargs) + print self._url + url + resp = self._session.get(self._url + url, auth=self._auth, + **kwargs) resp.raise_for_status() return resp def _put(self, url, **kwargs): """Do an http put request""" - resp = self._session.put(self._url + url, **kwargs) + print self._url + url + resp = self._session.put(self._url + url, auth=self._auth, + **kwargs) resp.raise_for_status() return resp def _post(self, url, **kwargs): """Do an http post request""" - resp = self._session.post(self._url + url, **kwargs) + print self._url + url + resp = self._session.post(self._url + url, auth=self._auth, + **kwargs) resp.raise_for_status() return resp def _delete(self, url, **kwargs): """Do an http delete request""" - resp = self._session.delete(self._url + url, **kwargs) + print self._url + url + resp = self._session.delete(self._url + url, auth=self._auth, + **kwargs) resp.raise_for_status() return resp @@ -431,13 +445,11 @@ def dictToLogEntry(self, d): return None -# class Ssl3HttpAdapter(HTTPAdapter): -# """"Transport adapter" that allows us to use SSLv3.""" -# -# def init_poolmanager(self, connections, maxsize, block=False): -# self.poolmanager = PoolManager(num_pools=connections, -# maxsize=maxsize, -# block=block, -# # ssl_version=ssl.PROTOCOL_SSLv3, -# cert_reqs='CERT_REQUIRED', -# ca_certs=certifi.where()) +class ssl3_http_adapter(HTTPAdapter): + """"Transport adapter" that allows us to use SSLv3.""" + + def init_poolmanager(self, connections, maxsize, block=False): + self.poolmanager = PoolManager(num_pools=connections, + maxsize=maxsize, + block=block, + ssl_version=ssl.PROTOCOL_SSLv3) From dcc347c5bf4ffe2736ae1db7853842db2bf668eb Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 20:47:04 -0500 Subject: [PATCH 43/79] Refactored to meet PEP8 --- pyOlog/OlogDataTypes.py | 108 ++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index 8929592..8bf3187 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -13,26 +13,29 @@ from conf import _conf + class LogEntry(object): ''' - A LogEntry consists of some Text description, an owner and an associated logbook - It can optionally be associated with one or more logbooks and contain one or more tags, properties and attachments + A LogEntry consists of some Text description, an owner and an + associated logbook It can optionally be associated with one or more + logbooks and contain one or more tags, properties and attachments ''' - - def __init__(self, text, owner = None, logbooks = None, + def __init__(self, text, owner=None, logbooks=None, tags=None, attachments=None, properties=None, id=None, createTime=None, modifyTime=None): ''' Constructor for log Entry Simple LogEntry - >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')]) + >> LogEntry('test log entry', 'controls', + logbooks=[Logbook('commissioning', owner='controls')]) Comprehensive logEntry >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')], tags=[Tag('TimingSystem')] properties=[Property('Ticket', - attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}] + attributes={'Id':'1234', + 'URL':'http://trac.nsls2.bnl.gov/trac/1234'}] attachments=[Attachment(open('databrowser.plt'))] ) ''' @@ -41,47 +44,48 @@ def __init__(self, text, owner = None, logbooks = None, self.Owner = _conf.getValue('username', owner) if self.Owner is None: - raise ValueError("You must specify an owner (hint: check config file)") + raise ValueError("You must specify an owner") if logbooks is None: - logbooks = _conf.getValue('logbooks') - if logbooks is None: - raise ValueError("You must specify a logbook (hint: check config file)") - self.logbooks = [Logbook(n) for n in logbooks.split(',')] + logbooks = _conf.getValue('logbooks') + if logbooks is None: + raise ValueError("You must specify a logbook") + + self.logbooks = [Logbook(n) for n in logbooks.split(',')] else: - self.logbooks = logbooks + self.logbooks = logbooks if tags is None: - tags = _conf.getValue('tags') - if tags is not None: - self.tags = [Tag(n) for n in tags.split(',')] - else: - self.tags = [] + tags = _conf.getValue('tags') + if tags is not None: + self.tags = [Tag(n) for n in tags.split(',')] + else: + self.tags = [] else: - self.tags = tags + self.tags = tags if attachments is not None: - self.attachments = attachments + self.attachments = attachments else: - self.attachments = [] + self.attachments = [] if properties is not None: - self.properties = properties + self.properties = properties else: - self.properties = [] + self.properties = [] - self.__id = id - self.__createTime = createTime - self.__modifytime = modifyTime + self._id = id + self._create_time = createTime + self._modify_time = modifyTime def getId(self): - return self.__id + return self._id def getCreateTime(self): - return self.__createTime + return self._create_time def getModifyTime(self): - return self.__modifytime + return self._modify_time def getText(self): return self.Text @@ -102,12 +106,12 @@ def getProperties(self): return self.properties def __cmp__(self, *arg, **kwargs): - if arg[0] == None: + if arg[0] is None: return 1 - if self.__id: - return cmp((self.__id),(arg[0].__id)) + if self._id: + return cmp((self._id), (arg[0].__id)) else: - raise Exception, 'Invalid LogEntry: id cannot be None' + raise ValueError('Invalid LogEntry: id cannot be None') class Logbook(object): @@ -132,10 +136,11 @@ def getOwner(self): return self.__Owner def __cmp__(self, *arg, **kwargs): - if arg[0] == None: + if arg[0] is None: return 1 return cmp((self.__Name, self.__Owner), (arg[0].__Name, arg[0].__Owner)) + class Tag(object): ''' A Tag consists of a unique name, it is used to tag logEntries""" @@ -156,17 +161,18 @@ def getState(self): return self.__State def __cmp__(self, *arg, **kwargs): - if arg[0] == None: + if arg[0] is None: return 1 return cmp((self.__Name, self.__State), (arg[0].__Name, arg[0].__State)) + class Attachment(object): ''' A Attachment, a file associated with the log entry TODO this is not thread safe ''' - def __init__(self, file, filename = None): + def __init__(self, file, filename=None): ''' Create Attachment @@ -177,30 +183,36 @@ def __init__(self, file, filename = None): >> Attachment(file=open('test.jpg','rb') >> Attachment(file=string, filename = 'mydata.png') ''' - self.__file=file - self.__filename=filename + self.__file = file + self.__filename = filename + def getFile(self): return self.__file + def getFilePost(self): if self.__filename is None: - basename = os.path.basename(self.__file.name) + basename = os.path.basename(self.__file.name) else: - basename = os.path.basename(self.__filename) + basename = os.path.basename(self.__filename) mtype = mimetypes.guess_type(basename)[0] if mtype is None: - mtype = 'application/octet-stream' - return (basename, self.__file, mtype) + mtype = 'application/octet-stream' + return (basename, self.__file, mtype) + class Property(object): ''' - A property consists of a unique name and a set of attributes consisting of key value pairs + A property consists of a unique name and a set of attributes + consisting of key value pairs ''' def __init__(self, name, attributes=None): ''' Create a property with a unique name and attributes - >> Property('Ticket', attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'} - >> Property('Scan', attributes={'Number':'run-1234', 'script':'scan_20130117.py'} + >> Property('Ticket', attributes={'Id':'1234', + 'URL':'http://trac.nsls2.bnl.gov/trac/1234'} + >> Property('Scan', attributes={'Number':'run-1234', + 'script':'scan_20130117.py'} ''' self.__Name = str(name).strip() self.Attributes = attributes @@ -209,7 +221,7 @@ def getName(self): return self.__Name def getAttributes(self): - return self.Attributes; + return self.Attributes def getAttributeNames(self): return self.Attributes.keys() @@ -218,7 +230,7 @@ def getAttributeValue(self, attributeName): return self.Attributes.get(attributeName) def __cmp__(self, *arg, **kwargs): - if arg[0] == None: + if arg[0] is None: return 1 - return cmp((self.__Name, set(self.Attributes)), (arg[0].__Name, set(arg[0].Attributes))) - + return cmp((self.__Name, set(self.Attributes)), + (arg[0].__Name, set(arg[0].Attributes))) From 9294c7fd976ba4824bbb198dda50406e4cba76db Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 20:47:35 -0500 Subject: [PATCH 44/79] Refactored to use more efficient use of requests --- pyOlog/OlogClient.py | 55 ++++++-------------- pyOlog/SimpleOlogClient.py | 101 +++++++++++++++++++++++++++---------- 2 files changed, 88 insertions(+), 68 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index e6b6655..8f8a7a7 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -21,21 +21,15 @@ from getpass import getpass -import ssl import requests -from requests.packages import urllib3 -from requests.adapters import HTTPAdapter - # # Disable warning for non verified HTTPS requests # +from requests.packages import urllib3 urllib3.disable_warnings() -from requests.packages.urllib3.poolmanager import PoolManager - from json import JSONEncoder, JSONDecoder -from urllib import urlencode from collections import OrderedDict import tempfile @@ -92,51 +86,45 @@ def __init__(self, url=None, username=None, password=None, ask=True): if username and password: # If we have a valid username and password, setup authentication - logger.info("Using username %s for authentication.", username) - self._auth = requests.auth.HTTPBasicAuth(username, password) + _auth = (username, password) else: # Don't use authentication logger.info("No authentiation configured.") - self._auth = None + _auth = None self._session = requests.Session() - self._session.mount('https://', ssl3_http_adapter()) - # self._session.auth = _auth + self._session.auth = _auth self._session.headers.update(self.json_header) self._session.verify = self.verify def _get(self, url, **kwargs): """Do an http GET request""" print self._url + url - resp = self._session.get(self._url + url, auth=self._auth, - **kwargs) + resp = self._session.get(self._url + url, **kwargs) resp.raise_for_status() return resp def _put(self, url, **kwargs): """Do an http put request""" print self._url + url - resp = self._session.put(self._url + url, auth=self._auth, - **kwargs) + resp = self._session.put(self._url + url, **kwargs) resp.raise_for_status() return resp def _post(self, url, **kwargs): """Do an http post request""" print self._url + url - resp = self._session.post(self._url + url, auth=self._auth, - **kwargs) + resp = self._session.post(self._url + url, **kwargs) resp.raise_for_status() return resp def _delete(self, url, **kwargs): """Do an http delete request""" print self._url + url - resp = self._session.delete(self._url + url, auth=self._auth, - **kwargs) + resp = self._session.delete(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -211,30 +199,27 @@ def find(self, **kwds): find all the log entries in logbook 'controls' AND with tag named 'magnets' ''' - # search = '*' + text + '*' - query_string = "?".join((self.logs_resource, - urlencode(OrderedDict(kwds)))) - resp = self._get(query_string) + resp = self._get(self.logs_resource, params=OrderedDict(kwds)) logs = [] - for jsonLogEntry in resp.json(): - logs.append(LogEntryDecoder().dictToLogEntry(jsonLogEntry)) + for json_log_entry in resp.json(): + logs.append(LogEntryDecoder().dictToLogEntry(json_log_entry)) return logs - def listAttachments(self, logEntryId): + def listAttachments(self, log_entry_id): ''' Search for attachments on a logentry - :param logEntryId: The ID of the log entry to list the attachments. + :param log_entry_id: The ID of the log entry to list the attachments. ''' - url = "/".join((self.attachments_resource, str(logEntryId))) + url = "/".join((self.attachments_resource, str(log_entry_id))) resp = self._get(url) attachments = [] for jsonAttachment in resp.json().pop('attachment'): filename = jsonAttachment.pop('filename') - url = "/".join((self.attachments_resource, str(logEntryId), + url = "/".join((self.attachments_resource, str(log_entry_id), filename)) f = self._get(url) testFile = tempfile.NamedTemporaryFile(delete=False) @@ -443,13 +428,3 @@ def dictToLogEntry(self, d): modifyTime=d.pop('modifiedDate')) else: return None - - -class ssl3_http_adapter(HTTPAdapter): - """"Transport adapter" that allows us to use SSLv3.""" - - def init_poolmanager(self, connections, maxsize, block=False): - self.poolmanager = PoolManager(num_pools=connections, - maxsize=maxsize, - block=block, - ssl_version=ssl.PROTOCOL_SSLv3) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index c4bd799..328a840 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -8,39 +8,84 @@ from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment +def logentry_to_dict(log): + rtn = dict() + + lid = log.getId() + if not lid: + return rtn + + rtn['id'] = lid + + def update(name, value): + if value: + try: + iter(value) + except TypeError: + pass + else: + if any(isinstance(x, (Logbook, Tag)) for x in value): + value = [v.getName() for v in value] + else: + value = value + rtn[name] = value + + update('create_time', log.getCreateTime()) + update('modify_time', log.getModifyTime()) + update('text', log.getText()) + update('owner', log.getOwner()) + update('logbooks', log.getLogbooks()) + update('tags', log.getTags()) + update('attachments', log.getAttachments()) + update('properties', log.getProperties()) + + return rtn + + class SimpleOlogClient(object): def __init__(self, *args, **kwargs): - """Initiate a session and do password caching using keyring""" - - # First check config file for defaults - - # if username is None: - # if _conf.getValue('username'): - # username = _conf.getValue('username') - # else: - # username = getpass.getuser() - - # if password is None: - # if _conf.getValue('password'): - # password = _conf.getValue('password') - # if password is None: - # password = keyring.get_password('olog', username) - # if password is None: - # password = getpass.getpass("Olog Password (username = {}) :" - # .format(username)) - - # if username and not password: - # raise Exception("Unable to obtain authentication.") + """Initiate a session """ self.session = OlogClient(*args, **kwargs) - def getTags(self): + def get_tags(self): """Return a list of tag names in the Olog""" return [t.getName() for t in self.session.listTags()] - def getLogbooks(self): - """Return a list of tag names in the Olog""" + def get_logbooks(self): + """Return a list of logbooks names in the Olog""" return [l.getName() for l in self.session.listLogbooks()] + def find(self, **kwargs): + """Find log entries which match kwargs + + Search for logEntries based on one or many search criteria + >> find(search='*Timing*') + find logentries with the text Timing in the description + + >> find(tag='magnets') + find log entries with the a tag named 'magnets' + + >> find(logbook='controls') + find log entries in the logbook named 'controls' + + >> find(property='context') + find log entires with property named 'context' + + >> find(start=str(time.time() - 3600) + find the log entries made in the last hour + >> find(start=123243434, end=123244434) + find all the log entries made between the epoc times 123243434 + and 123244434 + + Searching using multiple criteria + >>find(logbook='contorls', tag='magnets') + find all the log entries in logbook 'controls' AND with tag + named 'magnets' + """ + + results = self.session.find(**kwargs) + return [logentry_to_dict(result) for result in results] + def log(self, text=None, logbooks=None, tags=None, properties=None, attachments=None, verify=True): """ @@ -66,14 +111,14 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, if logbooks: if verify: - if not any([x in logbooks for x in self.getLogbooks()]): - raise ValueError("Invalid Logbook name (not in Olog)") + if not any([x in logbooks for x in self.get_logbooks()]): + raise ValueError("Logbook does not exits in Olog") logbooks = [Logbook(n) for n in logbooks] if tags: if verify: - if not any([x in tags for x in self.getTags()]): - raise ValueError("Invalid Tag (not in Olog)") + if not any([x in tags for x in self.get_tags()]): + raise ValueError("Tag does not exits in Olog") tags = [Tag(n) for n in tags] if not text: From 1107ccc0a02eac3798fffb3e6cfd016651ceb606 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 20:53:33 -0500 Subject: [PATCH 45/79] Refactored to remove __ vaiable names --- pyOlog/OlogDataTypes.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index 8bf3187..5de6b87 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -126,19 +126,19 @@ def __init__(self, name, owner=None): Create a logbook >> Logbook('commissioning', 'controls') ''' - self.__Name = str(name).strip() - self.__Owner = str(owner).strip() + self._name = str(name).strip() + self._owner = str(owner).strip() def getName(self): - return self.__Name + return self._name def getOwner(self): - return self.__Owner + return self._owner def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self.__Name, self.__Owner), (arg[0].__Name, arg[0].__Owner)) + return cmp((self._name, self._owner), (arg[0].__Name, arg[0].__Owner)) class Tag(object): @@ -151,19 +151,19 @@ def __init__(self, name, state="Active"): Create a Tag object >> Tag('TimingSystem') ''' - self.__Name = str(name).strip() - self.__State = str(state).strip() + self._name = str(name).strip() + self._state = str(state).strip() def getName(self): - return self.__Name + return self._name def getState(self): - return self.__State + return self._state def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self.__Name, self.__State), (arg[0].__Name, arg[0].__State)) + return cmp((self._name, self._state), (arg[0].__Name, arg[0].__State)) class Attachment(object): @@ -183,21 +183,21 @@ def __init__(self, file, filename=None): >> Attachment(file=open('test.jpg','rb') >> Attachment(file=string, filename = 'mydata.png') ''' - self.__file = file - self.__filename = filename + self._file = file + self._filename = filename def getFile(self): - return self.__file + return self._file def getFilePost(self): - if self.__filename is None: - basename = os.path.basename(self.__file.name) + if self._filename is None: + basename = os.path.basename(self._file.name) else: - basename = os.path.basename(self.__filename) + basename = os.path.basename(self._filename) mtype = mimetypes.guess_type(basename)[0] if mtype is None: mtype = 'application/octet-stream' - return (basename, self.__file, mtype) + return (basename, self._file, mtype) class Property(object): @@ -214,11 +214,11 @@ def __init__(self, name, attributes=None): >> Property('Scan', attributes={'Number':'run-1234', 'script':'scan_20130117.py'} ''' - self.__Name = str(name).strip() + self._name = str(name).strip() self.Attributes = attributes def getName(self): - return self.__Name + return self._name def getAttributes(self): return self.Attributes @@ -232,5 +232,5 @@ def getAttributeValue(self, attributeName): def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self.__Name, set(self.Attributes)), + return cmp((self._name, set(self.Attributes)), (arg[0].__Name, set(arg[0].Attributes))) From ba70f78f3c1c805a2a77a944ee446012d6ad9857 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 21:07:24 -0500 Subject: [PATCH 46/79] Fixed download of attachments to not use temp files --- pyOlog/OlogClient.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 8f8a7a7..b923827 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -22,11 +22,8 @@ from getpass import getpass import requests - -# -# Disable warning for non verified HTTPS requests -# from requests.packages import urllib3 +# Disable warning for non verified HTTPS requests urllib3.disable_warnings() from json import JSONEncoder, JSONDecoder @@ -222,10 +219,7 @@ def listAttachments(self, log_entry_id): url = "/".join((self.attachments_resource, str(log_entry_id), filename)) f = self._get(url) - testFile = tempfile.NamedTemporaryFile(delete=False) - testFile.name = filename - testFile.write(f.content) - attachments.append(Attachment(file=testFile)) + attachments.append(Attachment(file=f.content, filename=filename)) return attachments From a142222c6affc371fcd614c257d4be2aaf225a42 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 21:32:43 -0500 Subject: [PATCH 47/79] Refactored to comply to PEP8 --- scripts/olog.py | 159 ++++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 79 deletions(-) diff --git a/scripts/olog.py b/scripts/olog.py index 9fc0286..ecc79c9 100644 --- a/scripts/olog.py +++ b/scripts/olog.py @@ -1,11 +1,11 @@ #!/usr/bin/python from __future__ import print_function -import os, sys +import sys import argparse -from pyOlog import Logbook, Tag, Attachment, OlogClient +from pyOlog import Attachment from pyOlog import SimpleOlogClient from pyOlog.utils import get_screenshot, get_text_from_editor @@ -40,85 +40,86 @@ """ + def olog(): - """Command line utility for making Olog entries""" - - # Parse Command Line Options - - parser = argparse.ArgumentParser(epilog = description, - formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument('-l', '--logbooks', dest = 'logbooks', - help = "Logbook Name(s)", nargs = '*', - default = None) - parser.add_argument('-t', '--tags', dest = 'tags', - nargs = '*', help = "OLog Tag Name(s)", - default = None) - parser.add_argument('-u', '--user', dest = 'username', - default = None, - help = "Username for Olog Access") - parser.add_argument('-f', '--file', dest = 'text', - type=argparse.FileType('r'), - default=None, - help = "Filename of log entry text.") - parser.add_argument('--url', dest = 'url', - help = "Base URL for Olog Access", - default = None) - parser.add_argument('-a', '--attach', dest = 'attach', - nargs = '*', - help = "filename of attachments") - parser.add_argument('-p', '--passwd', dest = 'passwd', - help = "Password for logging entry", - default = None) - group = parser.add_mutually_exclusive_group() - group.add_argument('-s','--screenshot', dest = 'screenshot', - help = 'Take screenshot of whole screen', - default = False, - action = 'store_true') - group.add_argument('-g', '--grap', dest = 'grab', - help = 'Grab area of screen and add as attatchment.', - default = False, - action = 'store_true') - group = parser.add_mutually_exclusive_group() - group.add_argument('-v', action = 'store_true', dest = 'verbose', - help = "Verbose output", default = False) - group.add_argument('-q', action = 'store_true', dest = 'quiet', - help = "Suppress all output", default = False) - - args = parser.parse_args() - - if args.attach is not None: - attachments = [Attachment(open(a)) for a in args.attach.split(',')] - else: - attachments = [] - - # Grab Screenshot - - if args.screenshot or args.grab: - if not args.quiet and args.grab: - print("Select area of screen to add to log entry.", - file = sys.stderr) - screenshot = get_screenshot(args.screenshot) - attachments.append(screenshot) - - # First create the log entry - - if args.text is None: - text = get_text_from_editor() - else: - text = args.text - - c = SimpleOlogClient(args.url, args.username, args.passwd) - c.log(text, - logbooks = args.logbooks, - tags = args.tags, - attachments = attachments) + """Command line utility for making Olog entries""" + + # Parse Command Line Options + + fclass = argparse.RawDescriptionHelpFormatter + parser = argparse.ArgumentParser(epilog=description, formatter_class=fclass) + parser.add_argument('-l', '--logbooks', dest='logbooks', + help="Logbook Name(s)", nargs='*', + default=None) + parser.add_argument('-t', '--tags', dest='tags', + nargs='*', help="OLog Tag Name(s)", + default=None) + parser.add_argument('-u', '--user', dest='username', + default=None, + help="Username for Olog Access") + parser.add_argument('-f', '--file', dest='text', + type=argparse.FileType('r'), + default=None, + help="Filename of log entry text.") + parser.add_argument('--url', dest='url', + help="Base URL for Olog Access", + default=None) + parser.add_argument('-a', '--attach', dest='attach', + nargs='*', + help="filename of attachments") + parser.add_argument('-p', '--passwd', dest='passwd', + help="Password for logging entry", + default=None) + group = parser.add_mutually_exclusive_group() + group.add_argument('-s', '--screenshot', dest='screenshot', + help='Take screenshot of whole screen', + default=False, + action='store_true') + group.add_argument('-g', '--grap', dest='grab', + help='Grab area of screen and add as attatchment.', + default=False, + action='store_true') + group = parser.add_mutually_exclusive_group() + group.add_argument('-v', action='store_true', dest='verbose', + help="Verbose output", default=False) + group.add_argument('-q', action='store_true', dest='quiet', + help="Suppress all output", default=False) + + args = parser.parse_args() + + if args.attach is not None: + attachments = [Attachment(open(a)) for a in args.attach.split(',')] + else: + attachments = [] + + # Grab Screenshot + + if args.screenshot or args.grab: + if not args.quiet and args.grab: + print("Select area of screen to add to log entry.", + file=sys.stderr) + screenshot = get_screenshot(args.screenshot) + attachments.append(screenshot) + + # First create the log entry + + if args.text is None: + text = get_text_from_editor() + else: + text = args.text + + c = SimpleOlogClient(args.url, args.username, args.passwd) + c.log(text, logbooks=args.logbooks, tags=args.tags, + attachments=attachments) + def main(): - try: - olog() - except KeyboardInterrupt: - print('\nAborted.\n') - sys.exit() + try: + olog() + except KeyboardInterrupt: + print('\nAborted.\n') + sys.exit() if __name__ == '__main__': - main() + + main() From ef71800a49e783e810bf6b98b3f173a72f6446ed Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 21:37:27 -0500 Subject: [PATCH 48/79] Moved scripts into module, refactored setup.py --- scripts/olog.py | 125 ------------------------------------------------ 1 file changed, 125 deletions(-) delete mode 100644 scripts/olog.py diff --git a/scripts/olog.py b/scripts/olog.py deleted file mode 100644 index ecc79c9..0000000 --- a/scripts/olog.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python -from __future__ import print_function - -import sys - -import argparse - -from pyOlog import Attachment -from pyOlog import SimpleOlogClient -from pyOlog.utils import get_screenshot, get_text_from_editor - -description = """\ -Command line utility for making OLog entries. - -Example: - %(prog)s -l Operations -t Data -u swilkins -a ./image.png - -This makes a log entry into the 'Operations' log tagged with the -tag 'Data' from the account of 'swilkins' with an image 'image.png -attached to the log entry. The log text is taken from stdin and can -either be entered on the command line or piped in. Alternatively a -text file can be specified with the '--file' option. - -Multiple Tags and Logbooks can be specified after the option on the -command line separated by spaces. For example: - - %(prog)s -t "RF Area" "Bumps" - -Wil add the tags 'RF Area' and 'Bumps' - -Note : A password is requested on the command line unless the option -'-p' is supplied with a valid password, the password is in the config -file or it can be obtained from the keyring. - -Optionally commands will take default from a config file located -in the users home directory ~/.pyOlog.conf This can contain the base -url for the Olog and also the default logbook to use. Administrators -can use the /etc/pyOlog.conf file to specify system wide config. - - -""" - - -def olog(): - """Command line utility for making Olog entries""" - - # Parse Command Line Options - - fclass = argparse.RawDescriptionHelpFormatter - parser = argparse.ArgumentParser(epilog=description, formatter_class=fclass) - parser.add_argument('-l', '--logbooks', dest='logbooks', - help="Logbook Name(s)", nargs='*', - default=None) - parser.add_argument('-t', '--tags', dest='tags', - nargs='*', help="OLog Tag Name(s)", - default=None) - parser.add_argument('-u', '--user', dest='username', - default=None, - help="Username for Olog Access") - parser.add_argument('-f', '--file', dest='text', - type=argparse.FileType('r'), - default=None, - help="Filename of log entry text.") - parser.add_argument('--url', dest='url', - help="Base URL for Olog Access", - default=None) - parser.add_argument('-a', '--attach', dest='attach', - nargs='*', - help="filename of attachments") - parser.add_argument('-p', '--passwd', dest='passwd', - help="Password for logging entry", - default=None) - group = parser.add_mutually_exclusive_group() - group.add_argument('-s', '--screenshot', dest='screenshot', - help='Take screenshot of whole screen', - default=False, - action='store_true') - group.add_argument('-g', '--grap', dest='grab', - help='Grab area of screen and add as attatchment.', - default=False, - action='store_true') - group = parser.add_mutually_exclusive_group() - group.add_argument('-v', action='store_true', dest='verbose', - help="Verbose output", default=False) - group.add_argument('-q', action='store_true', dest='quiet', - help="Suppress all output", default=False) - - args = parser.parse_args() - - if args.attach is not None: - attachments = [Attachment(open(a)) for a in args.attach.split(',')] - else: - attachments = [] - - # Grab Screenshot - - if args.screenshot or args.grab: - if not args.quiet and args.grab: - print("Select area of screen to add to log entry.", - file=sys.stderr) - screenshot = get_screenshot(args.screenshot) - attachments.append(screenshot) - - # First create the log entry - - if args.text is None: - text = get_text_from_editor() - else: - text = args.text - - c = SimpleOlogClient(args.url, args.username, args.passwd) - c.log(text, logbooks=args.logbooks, tags=args.tags, - attachments=attachments) - - -def main(): - try: - olog() - except KeyboardInterrupt: - print('\nAborted.\n') - sys.exit() - -if __name__ == '__main__': - - main() From 13bec90c236bfa40db2ec372b8c8d868c2f4bd90 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 22:24:18 -0500 Subject: [PATCH 49/79] Refactored scripts and cleanded up setup.py --- pyOlog/olog.py | 159 +++++++++++++++++++++++++------------------------ setup.py | 17 ++---- 2 files changed, 85 insertions(+), 91 deletions(-) diff --git a/pyOlog/olog.py b/pyOlog/olog.py index 9fc0286..ecc79c9 100644 --- a/pyOlog/olog.py +++ b/pyOlog/olog.py @@ -1,11 +1,11 @@ #!/usr/bin/python from __future__ import print_function -import os, sys +import sys import argparse -from pyOlog import Logbook, Tag, Attachment, OlogClient +from pyOlog import Attachment from pyOlog import SimpleOlogClient from pyOlog.utils import get_screenshot, get_text_from_editor @@ -40,85 +40,86 @@ """ + def olog(): - """Command line utility for making Olog entries""" - - # Parse Command Line Options - - parser = argparse.ArgumentParser(epilog = description, - formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument('-l', '--logbooks', dest = 'logbooks', - help = "Logbook Name(s)", nargs = '*', - default = None) - parser.add_argument('-t', '--tags', dest = 'tags', - nargs = '*', help = "OLog Tag Name(s)", - default = None) - parser.add_argument('-u', '--user', dest = 'username', - default = None, - help = "Username for Olog Access") - parser.add_argument('-f', '--file', dest = 'text', - type=argparse.FileType('r'), - default=None, - help = "Filename of log entry text.") - parser.add_argument('--url', dest = 'url', - help = "Base URL for Olog Access", - default = None) - parser.add_argument('-a', '--attach', dest = 'attach', - nargs = '*', - help = "filename of attachments") - parser.add_argument('-p', '--passwd', dest = 'passwd', - help = "Password for logging entry", - default = None) - group = parser.add_mutually_exclusive_group() - group.add_argument('-s','--screenshot', dest = 'screenshot', - help = 'Take screenshot of whole screen', - default = False, - action = 'store_true') - group.add_argument('-g', '--grap', dest = 'grab', - help = 'Grab area of screen and add as attatchment.', - default = False, - action = 'store_true') - group = parser.add_mutually_exclusive_group() - group.add_argument('-v', action = 'store_true', dest = 'verbose', - help = "Verbose output", default = False) - group.add_argument('-q', action = 'store_true', dest = 'quiet', - help = "Suppress all output", default = False) - - args = parser.parse_args() - - if args.attach is not None: - attachments = [Attachment(open(a)) for a in args.attach.split(',')] - else: - attachments = [] - - # Grab Screenshot - - if args.screenshot or args.grab: - if not args.quiet and args.grab: - print("Select area of screen to add to log entry.", - file = sys.stderr) - screenshot = get_screenshot(args.screenshot) - attachments.append(screenshot) - - # First create the log entry - - if args.text is None: - text = get_text_from_editor() - else: - text = args.text - - c = SimpleOlogClient(args.url, args.username, args.passwd) - c.log(text, - logbooks = args.logbooks, - tags = args.tags, - attachments = attachments) + """Command line utility for making Olog entries""" + + # Parse Command Line Options + + fclass = argparse.RawDescriptionHelpFormatter + parser = argparse.ArgumentParser(epilog=description, formatter_class=fclass) + parser.add_argument('-l', '--logbooks', dest='logbooks', + help="Logbook Name(s)", nargs='*', + default=None) + parser.add_argument('-t', '--tags', dest='tags', + nargs='*', help="OLog Tag Name(s)", + default=None) + parser.add_argument('-u', '--user', dest='username', + default=None, + help="Username for Olog Access") + parser.add_argument('-f', '--file', dest='text', + type=argparse.FileType('r'), + default=None, + help="Filename of log entry text.") + parser.add_argument('--url', dest='url', + help="Base URL for Olog Access", + default=None) + parser.add_argument('-a', '--attach', dest='attach', + nargs='*', + help="filename of attachments") + parser.add_argument('-p', '--passwd', dest='passwd', + help="Password for logging entry", + default=None) + group = parser.add_mutually_exclusive_group() + group.add_argument('-s', '--screenshot', dest='screenshot', + help='Take screenshot of whole screen', + default=False, + action='store_true') + group.add_argument('-g', '--grap', dest='grab', + help='Grab area of screen and add as attatchment.', + default=False, + action='store_true') + group = parser.add_mutually_exclusive_group() + group.add_argument('-v', action='store_true', dest='verbose', + help="Verbose output", default=False) + group.add_argument('-q', action='store_true', dest='quiet', + help="Suppress all output", default=False) + + args = parser.parse_args() + + if args.attach is not None: + attachments = [Attachment(open(a)) for a in args.attach.split(',')] + else: + attachments = [] + + # Grab Screenshot + + if args.screenshot or args.grab: + if not args.quiet and args.grab: + print("Select area of screen to add to log entry.", + file=sys.stderr) + screenshot = get_screenshot(args.screenshot) + attachments.append(screenshot) + + # First create the log entry + + if args.text is None: + text = get_text_from_editor() + else: + text = args.text + + c = SimpleOlogClient(args.url, args.username, args.passwd) + c.log(text, logbooks=args.logbooks, tags=args.tags, + attachments=attachments) + def main(): - try: - olog() - except KeyboardInterrupt: - print('\nAborted.\n') - sys.exit() + try: + olog() + except KeyboardInterrupt: + print('\nAborted.\n') + sys.exit() if __name__ == '__main__': - main() + + main() diff --git a/setup.py b/setup.py index f9f9c5f..bde79d8 100644 --- a/setup.py +++ b/setup.py @@ -7,22 +7,15 @@ @author: shroffk ''' -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - +from setuptools import setup setup(name='pyOlog', - version='0.2.0', + version='0.3.0', description='Python Olog Client Lib', author='Kunal Shroff', author_email='shroffk@bnl.gov', packages=['pyOlog'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], - #scripts=['scripts/olog.py'], - entry_points = { - 'console_scripts': [ - 'olog = pyOlog.olog:main'] - } - ) + entry_points={'console_scripts': [ + 'olog = pyOlog.olog:main']} + ) From ef02c951ed4253fd877d33076da91e4b83fa3d30 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Wed, 24 Dec 2014 22:27:21 -0500 Subject: [PATCH 50/79] Updated to version 0.3.0 --- conda-recipie/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda-recipie/meta.yaml b/conda-recipie/meta.yaml index 365e2e6..2b2c1e1 100644 --- a/conda-recipie/meta.yaml +++ b/conda-recipie/meta.yaml @@ -1,7 +1,7 @@ package: name: pyolog - version: "0.2.0" + version: "0.3.0" source: git_url: https://github.com/NSLS-II-CSX/pyOlog.git @@ -26,5 +26,5 @@ test: about: home: http://olog.github.io/ - license: BSD + license: MIT summary: Python client for the OLog From e63f28b6a86e37445deb3a988e7d1d9b1a053078 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 11:21:11 -0500 Subject: [PATCH 51/79] Restructured --- pyOlog/api/__init__.py | 1 - pyOlog/api/session.py | 16 ---------------- pyOlog/cli/__init__.py | 0 pyOlog/{ => cli}/ipy.py | 0 pyOlog/{ => cli}/olog.py | 0 pyOlog/{ => cli}/utils.py | 0 pyOlog/gui/__init__.py | 0 7 files changed, 17 deletions(-) delete mode 100644 pyOlog/api/__init__.py delete mode 100644 pyOlog/api/session.py create mode 100644 pyOlog/cli/__init__.py rename pyOlog/{ => cli}/ipy.py (100%) rename pyOlog/{ => cli}/olog.py (100%) rename pyOlog/{ => cli}/utils.py (100%) create mode 100644 pyOlog/gui/__init__.py diff --git a/pyOlog/api/__init__.py b/pyOlog/api/__init__.py deleted file mode 100644 index f1994de..0000000 --- a/pyOlog/api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from simple import SimpleOlogClient diff --git a/pyOlog/api/session.py b/pyOlog/api/session.py deleted file mode 100644 index 52cbcb1..0000000 --- a/pyOlog/api/session.py +++ /dev/null @@ -1,16 +0,0 @@ -__author__ = 'swilkins' -from ..OlogClient import OlogClient - -import keyring -import getpass - -def init_session(): - """Initiate a session and do password caching using keyring""" - username = getpass.getuser() - password = keyring.get_password('olog', username) - if password is None: - password = getpass.getpass("Olog Password (username = {}) :".format(username)) - client = OlogClient(username = username, password = password) - return client - -session = init_session() diff --git a/pyOlog/cli/__init__.py b/pyOlog/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyOlog/ipy.py b/pyOlog/cli/ipy.py similarity index 100% rename from pyOlog/ipy.py rename to pyOlog/cli/ipy.py diff --git a/pyOlog/olog.py b/pyOlog/cli/olog.py similarity index 100% rename from pyOlog/olog.py rename to pyOlog/cli/olog.py diff --git a/pyOlog/utils.py b/pyOlog/cli/utils.py similarity index 100% rename from pyOlog/utils.py rename to pyOlog/cli/utils.py diff --git a/pyOlog/gui/__init__.py b/pyOlog/gui/__init__.py new file mode 100644 index 0000000..e69de29 From c5db139bbeca8f0b3d82e139decad3afb825ac6c Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:15:38 -0500 Subject: [PATCH 52/79] Added gui application --- pyOlog/gui/main.py | 26 +++++++++ pyOlog/gui/scribble.py | 120 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 pyOlog/gui/main.py create mode 100644 pyOlog/gui/scribble.py diff --git a/pyOlog/gui/main.py b/pyOlog/gui/main.py new file mode 100644 index 0000000..9338352 --- /dev/null +++ b/pyOlog/gui/main.py @@ -0,0 +1,26 @@ +import sys +from PyQt4 import QtGui +from scribble import ScribbleArea + + +class MainWindow(QtGui.QMainWindow): + def __init__(self, parent=None): + QtGui.QMainWindow.__init__(self, parent) + self.scribble_area = ScribbleArea() + self.setCentralWidget(self.scribble_area) + self.initUI() + + def initUI(self): + self.setGeometry(100, 100, 1030, 800) + self.setWindowTitle("Olog Gui Client") + + +def main(): + app = QtGui.QApplication(sys.argv) + main = MainWindow() + main.show() + + sys.exit(app.exec_()) + +if __name__ == "__main__": + main() diff --git a/pyOlog/gui/scribble.py b/pyOlog/gui/scribble.py new file mode 100644 index 0000000..9ce2eda --- /dev/null +++ b/pyOlog/gui/scribble.py @@ -0,0 +1,120 @@ +from PyQt4 import QtCore, QtGui + + +class ScribbleArea(QtGui.QWidget): + def __init__(self, parent=None): + super(ScribbleArea, self).__init__(parent) + + self.setAttribute(QtCore.Qt.WA_StaticContents) + self.modified = False + self.scribbling = False + self.myPenWidth = 1 + self.myPenColor = QtCore.Qt.blue + self.image = QtGui.QImage() + self.lastPoint = QtCore.QPoint() + + def openImage(self, fileName): + loadedImage = QtGui.QImage() + if not loadedImage.load(fileName): + return False + + newSize = loadedImage.size().expandedTo(self.size()) + self.resizeImage(loadedImage, newSize) + self.image = loadedImage + self.modified = False + self.update() + return True + + def saveImage(self, fileName, fileFormat): + visibleImage = self.image + self.resizeImage(visibleImage, self.size()) + + if visibleImage.save(fileName, fileFormat): + self.modified = False + return True + else: + return False + + def setPenColor(self, newColor): + self.myPenColor = newColor + + def setPenWidth(self, newWidth): + self.myPenWidth = newWidth + + def clearImage(self): + self.image.fill(QtGui.qRgb(255, 255, 255)) + self.modified = True + self.update() + + def mousePressEvent(self, event): + if event.button() == QtCore.Qt.LeftButton: + self.lastPoint = event.pos() + self.scribbling = True + + def mouseMoveEvent(self, event): + if (event.buttons() & QtCore.Qt.LeftButton) and self.scribbling: + self.drawLineTo(event.pos()) + + def mouseReleaseEvent(self, event): + if event.button() == QtCore.Qt.LeftButton and self.scribbling: + self.drawLineTo(event.pos()) + self.scribbling = False + + def paintEvent(self, event): + painter = QtGui.QPainter(self) + painter.drawImage(QtCore.QPoint(0, 0), self.image) + + def resizeEvent(self, event): + if (self.width() > self.image.width()) or \ + (self.height() > self.image.height()): + newWidth = max(self.width() + 128, self.image.width()) + newHeight = max(self.height() + 128, self.image.height()) + self.resizeImage(self.image, QtCore.QSize(newWidth, newHeight)) + self.update() + + super(ScribbleArea, self).resizeEvent(event) + + def drawLineTo(self, endPoint): + painter = QtGui.QPainter(self.image) + painter.setPen(QtGui.QPen(self.myPenColor, self.myPenWidth, + QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, + QtCore.Qt.RoundJoin)) + painter.drawLine(self.lastPoint, endPoint) + self.modified = True + + rad = self.myPenWidth / 2 + 2 + self.update(QtCore.QRect(self.lastPoint, endPoint) + .normalized().adjusted(-rad, -rad, +rad, +rad)) + self.lastPoint = QtCore.QPoint(endPoint) + + def resizeImage(self, image, newSize): + if image.size() == newSize: + return + + newImage = QtGui.QImage(newSize, QtGui.QImage.Format_RGB32) + newImage.fill(QtGui.qRgb(255, 255, 255)) + painter = QtGui.QPainter(newImage) + painter.drawImage(QtCore.QPoint(0, 0), image) + self.image = newImage + + def print_(self): + printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution) + + printDialog = QtGui.QPrintDialog(printer, self) + if printDialog.exec_() == QtGui.QDialog.Accepted: + painter = QtGui.QPainter(printer) + rect = painter.viewport() + size = self.image.size() + size.scale(rect.size(), QtCore.Qt.KeepAspectRatio) + painter.setViewport(rect.x(), rect.y(), size.width(), size.height()) + painter.setWindow(self.image.rect()) + painter.drawImage(0, 0, self.image) + + def isModified(self): + return self.modified + + def penColor(self): + return self.myPenColor + + def penWidth(self): + return self.myPenWidth From 07f088a2eaaee80deefc95d8c9f82b89ddc56c7f Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:38:12 -0500 Subject: [PATCH 53/79] Refactored to use relative imports --- pyOlog/SimpleOlogClient.py | 4 ---- pyOlog/cli/__init__.py | 1 + pyOlog/cli/olog.py | 6 +++--- pyOlog/cli/utils.py | 2 +- pyOlog/gui/__init__.py | 1 + setup.py | 4 +++- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 328a840..60c5c33 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -3,7 +3,6 @@ A simple API to the Olog client in python """ -from .utils import get_text_from_editor from .OlogClient import OlogClient from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment @@ -121,9 +120,6 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, raise ValueError("Tag does not exits in Olog") tags = [Tag(n) for n in tags] - if not text: - text = get_text_from_editor() - toattach = [] if attachments: for a in attachments: diff --git a/pyOlog/cli/__init__.py b/pyOlog/cli/__init__.py index e69de29..aea6572 100644 --- a/pyOlog/cli/__init__.py +++ b/pyOlog/cli/__init__.py @@ -0,0 +1 @@ +from .olog import main diff --git a/pyOlog/cli/olog.py b/pyOlog/cli/olog.py index ecc79c9..2297cf6 100644 --- a/pyOlog/cli/olog.py +++ b/pyOlog/cli/olog.py @@ -5,9 +5,9 @@ import argparse -from pyOlog import Attachment -from pyOlog import SimpleOlogClient -from pyOlog.utils import get_screenshot, get_text_from_editor +from .. import Attachment +from .. import SimpleOlogClient +from .utils import get_screenshot, get_text_from_editor description = """\ Command line utility for making OLog entries. diff --git a/pyOlog/cli/utils.py b/pyOlog/cli/utils.py index 7e3d941..209396f 100644 --- a/pyOlog/cli/utils.py +++ b/pyOlog/cli/utils.py @@ -2,7 +2,7 @@ import subprocess import tempfile -from OlogDataTypes import Attachment +from .. import Attachment text_message = ''' # diff --git a/pyOlog/gui/__init__.py b/pyOlog/gui/__init__.py index e69de29..c28a133 100644 --- a/pyOlog/gui/__init__.py +++ b/pyOlog/gui/__init__.py @@ -0,0 +1 @@ +from .main import main diff --git a/setup.py b/setup.py index bde79d8..211985c 100644 --- a/setup.py +++ b/setup.py @@ -17,5 +17,7 @@ packages=['pyOlog'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], entry_points={'console_scripts': [ - 'olog = pyOlog.olog:main']} + 'olog = pyOlog.cli:main'], + 'gui_scripts': [ + 'ologgui = pyOlog.gui:main']} ) From c1ac89055fa7a6b37d4381355416e22d7d3f7682 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:38:40 -0500 Subject: [PATCH 54/79] Reindented --- pyOlog/cli/utils.py | 111 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/pyOlog/cli/utils.py b/pyOlog/cli/utils.py index 209396f..5208989 100644 --- a/pyOlog/cli/utils.py +++ b/pyOlog/cli/utils.py @@ -13,80 +13,79 @@ ''' def save_pyplot_figure(**kwargs): - """Save a matplotlib figure to an Olog Attachment Object""" - import matplotlib.pyplot as plt - import StringIO + """Save a matplotlib figure to an Olog Attachment Object""" + import matplotlib.pyplot as plt + import StringIO - imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'pdf', **kwargs) - imgdata.seek(0) + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'pdf', **kwargs) + imgdata.seek(0) - a = [Attachment(imgdata, 'plot.pdf')] + a = [Attachment(imgdata, 'plot.pdf')] - imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', dpi = 50, - **kwargs) - imgdata.seek(0) + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', dpi = 50, + **kwargs) + imgdata.seek(0) - a.append(Attachment(imgdata, 'thumbnail.png')) + a.append(Attachment(imgdata, 'thumbnail.png')) - return a + return a def get_screenshot(root = False, itype = 'png'): - """Open ImageMagick and get screngrab as png.""" - if root: - opts = '-window root' - else: - opts = '' - image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), - shell = True, - stdout = subprocess.PIPE) - img = image.communicate()[0] - - return Attachment(img, 'screenshot.' + itype) + """Open ImageMagick and get screngrab as png.""" + if root: + opts = '-window root' + else: + opts = '' + image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), + shell = True, + stdout = subprocess.PIPE) + img = image.communicate()[0] + + return Attachment(img, 'screenshot.' + itype) def get_text_from_editor(prepend = None, postpend = None): - """Open text editor and return text""" - with tempfile.NamedTemporaryFile(suffix='.tmp') as f: - # Write out the file and flush + """Open text editor and return text""" + with tempfile.NamedTemporaryFile(suffix='.tmp') as f: + # Write out the file and flush - message = '' + message = '' - if prepend: - message += '\n\n' - message += prepend - message += '\n' + if prepend: + message += '\n\n' + message += prepend + message += '\n' - message += text_message + message += text_message - if postpend: - message += postpend - f.write(message) - f.flush() + if postpend: + message += postpend + f.write(message) + f.flush() - # Now open editor to edit file - editor = os.environ.get('EDITOR', 'vim') - subprocess.call([editor, f.name]) + # Now open editor to edit file + editor = os.environ.get('EDITOR', 'vim') + subprocess.call([editor, f.name]) - # Read file back in - f.seek(0) - text = f.read() + # Read file back in + f.seek(0) + text = f.read() - # Strip off any lines that start with whitespace and a '#' - lines = [n for n in text.splitlines() if not n.lstrip().startswith('#')] - text = '\n'.join(lines) - return text + # Strip off any lines that start with whitespace and a '#' + lines = [n for n in text.splitlines() if not n.lstrip().startswith('#')] + text = '\n'.join(lines) + return text def get_pyplot_fig(self, *args, **kwargs): - """Save a matplotlib figure as an Attachment""" - import matplotlib.pyplot as plt - import StringIO + """Save a matplotlib figure as an Attachment""" + import matplotlib.pyplot as plt + import StringIO - imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', **kwargs) - imgdata.seek(0) + imgdata = StringIO.StringIO() + plt.savefig(imgdata, format = 'png', **kwargs) + imgdata.seek(0) - a = Attachment(imgdata, 'plot.png') - - return a + a = Attachment(imgdata, 'plot.png') + return a From 25a292ecc6dcaf8b8aea8527e9d5ed329efffbd7 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:40:25 -0500 Subject: [PATCH 55/79] reformeatted as per PEP8 --- pyOlog/cli/utils.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pyOlog/cli/utils.py b/pyOlog/cli/utils.py index 5208989..34093ac 100644 --- a/pyOlog/cli/utils.py +++ b/pyOlog/cli/utils.py @@ -12,19 +12,20 @@ # ''' + def save_pyplot_figure(**kwargs): """Save a matplotlib figure to an Olog Attachment Object""" import matplotlib.pyplot as plt import StringIO imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'pdf', **kwargs) + plt.savefig(imgdata, format='pdf', **kwargs) imgdata.seek(0) a = [Attachment(imgdata, 'plot.pdf')] imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', dpi = 50, + plt.savefig(imgdata, format='png', dpi=50, **kwargs) imgdata.seek(0) @@ -32,20 +33,22 @@ def save_pyplot_figure(**kwargs): return a -def get_screenshot(root = False, itype = 'png'): + +def get_screenshot(root=False, itype='png'): """Open ImageMagick and get screngrab as png.""" if root: opts = '-window root' else: opts = '' - image = subprocess.Popen('import {0} {1}:-'.format(opts,itype), - shell = True, - stdout = subprocess.PIPE) + image = subprocess.Popen('import {0} {1}:-'.format(opts, itype), + shell=True, + stdout=subprocess.PIPE) img = image.communicate()[0] return Attachment(img, 'screenshot.' + itype) -def get_text_from_editor(prepend = None, postpend = None): + +def get_text_from_editor(prepend=None, postpend=None): """Open text editor and return text""" with tempfile.NamedTemporaryFile(suffix='.tmp') as f: # Write out the file and flush @@ -77,13 +80,14 @@ def get_text_from_editor(prepend = None, postpend = None): text = '\n'.join(lines) return text + def get_pyplot_fig(self, *args, **kwargs): """Save a matplotlib figure as an Attachment""" import matplotlib.pyplot as plt import StringIO imgdata = StringIO.StringIO() - plt.savefig(imgdata, format = 'png', **kwargs) + plt.savefig(imgdata, format='png', **kwargs) imgdata.seek(0) a = Attachment(imgdata, 'plot.png') From 12375db9da74b731ec263a3d04555f6968b9890e Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:46:45 -0500 Subject: [PATCH 56/79] Moved tests out of modules --- {pyOlog/test => test}/Desert.jpg | Bin {pyOlog/test => test}/OlogClientTest.py | 0 {pyOlog/test => test}/OlogDataTypeTest.py | 0 {pyOlog/test => test}/__init__.py | 0 {pyOlog/test => test}/debug.log | 0 {tests => test}/logger.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {pyOlog/test => test}/Desert.jpg (100%) rename {pyOlog/test => test}/OlogClientTest.py (100%) rename {pyOlog/test => test}/OlogDataTypeTest.py (100%) rename {pyOlog/test => test}/__init__.py (100%) rename {pyOlog/test => test}/debug.log (100%) rename {tests => test}/logger.py (100%) diff --git a/pyOlog/test/Desert.jpg b/test/Desert.jpg similarity index 100% rename from pyOlog/test/Desert.jpg rename to test/Desert.jpg diff --git a/pyOlog/test/OlogClientTest.py b/test/OlogClientTest.py similarity index 100% rename from pyOlog/test/OlogClientTest.py rename to test/OlogClientTest.py diff --git a/pyOlog/test/OlogDataTypeTest.py b/test/OlogDataTypeTest.py similarity index 100% rename from pyOlog/test/OlogDataTypeTest.py rename to test/OlogDataTypeTest.py diff --git a/pyOlog/test/__init__.py b/test/__init__.py similarity index 100% rename from pyOlog/test/__init__.py rename to test/__init__.py diff --git a/pyOlog/test/debug.log b/test/debug.log similarity index 100% rename from pyOlog/test/debug.log rename to test/debug.log diff --git a/tests/logger.py b/test/logger.py similarity index 100% rename from tests/logger.py rename to test/logger.py From da3a8289cc714feb55860cf5cc00029a215e665c Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 13:48:07 -0500 Subject: [PATCH 57/79] Cleaned up tests --- test/__init__.py | 0 test/debug.log | 1782 ---------------------------------------------- 2 files changed, 1782 deletions(-) delete mode 100644 test/__init__.py delete mode 100644 test/debug.log diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/debug.log b/test/debug.log deleted file mode 100644 index cfac441..0000000 --- a/test/debug.log +++ /dev/null @@ -1,1782 +0,0 @@ -[0121/104002:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104006:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104106:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104308:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104308:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/104308:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/105223:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0121/105223:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133030:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133033:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133034:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133034:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133040:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133041:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133146:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133146:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133146:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133153:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133153:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133257:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133257:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133312:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133312:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133322:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133343:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133343:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133428:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133431:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133431:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133437:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133437:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133500:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133500:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133505:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133505:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133506:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133506:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133507:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133507:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133509:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133510:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133510:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133512:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133512:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133515:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133515:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133517:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133517:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133522:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133522:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133538:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133538:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133544:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133544:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133556:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133620:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133620:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133620:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133621:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133713:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133713:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133719:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133719:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133732:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133740:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133812:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133812:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133821:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133821:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133821:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133949:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133949:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133949:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133954:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/133954:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134004:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134004:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134005:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134005:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134011:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134011:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134056:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134056:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134056:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134103:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134103:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134230:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134230:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134233:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134233:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134237:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134237:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134517:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134517:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134528:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134620:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134620:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134636:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134641:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134641:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134645:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134645:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134645:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134645:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134646:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134652:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134652:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134710:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134710:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134714:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134714:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134714:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134717:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134717:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134725:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134725:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134734:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134735:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134740:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134740:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134743:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134743:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134749:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134749:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134752:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134754:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134754:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134757:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134757:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134802:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134802:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134809:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134809:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134812:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134812:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134813:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134818:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134823:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134824:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134833:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134835:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134835:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134835:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134852:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134852:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134858:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134858:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134903:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134903:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134937:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134937:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134946:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134946:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134949:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/134949:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135003:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135024:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135024:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135040:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135040:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135041:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135053:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135053:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135106:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135106:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135113:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135113:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135113:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135113:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135116:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135116:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135121:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135121:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135129:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135129:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135133:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135133:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135139:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135139:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135151:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135157:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135157:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135158:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135158:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135159:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135159:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135204:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135204:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135236:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135241:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135242:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135242:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135251:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135251:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135252:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135253:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135253:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135255:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135255:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135316:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135347:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135347:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135349:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135349:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135352:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135352:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135401:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135403:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135403:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135407:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135407:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135410:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135410:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135410:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135410:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135422:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135422:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135422:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135422:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135423:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135423:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135429:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135429:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135431:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135439:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135442:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135442:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135444:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135449:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135449:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135449:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135450:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135450:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135450:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135521:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135521:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135524:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135532:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135532:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135534:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135534:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135534:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135534:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135536:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135536:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135542:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135542:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135630:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135630:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135630:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135641:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135641:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135648:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135648:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135651:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135651:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135654:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135654:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135657:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135702:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135702:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135702:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135705:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135705:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135721:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135723:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135723:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135735:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135759:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135759:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135801:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135801:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135808:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135808:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135808:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135808:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135809:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135809:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135825:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135825:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135826:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135826:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135842:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135842:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135843:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135843:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135857:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135857:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135913:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135913:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135917:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135917:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135917:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135919:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135919:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135925:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135925:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135925:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135926:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135929:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135931:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135931:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135934:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135934:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135934:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135941:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135941:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135942:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135942:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135947:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135947:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135955:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135955:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135959:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135959:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135959:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/135959:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140004:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140004:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140005:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140005:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140024:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140026:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140026:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140032:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140032:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140041:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140041:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140043:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140048:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140048:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140108:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140108:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140112:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140112:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140118:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140122:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140122:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140122:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140122:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140122:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140130:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140130:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140130:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140130:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140153:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140153:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140153:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140154:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140154:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140209:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140209:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140209:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140211:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140223:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140223:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140225:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140227:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140227:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140231:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140231:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140244:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140244:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140253:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140253:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140253:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140255:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140255:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140303:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140303:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140303:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140303:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140303:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140304:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140304:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140307:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140308:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140308:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140311:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140311:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140311:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140312:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140312:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140314:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140314:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140314:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140314:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140316:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140316:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140323:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140323:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140324:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140324:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140324:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140324:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140326:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140326:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140326:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140326:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140326:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140333:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140333:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140333:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140334:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140337:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140339:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140339:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140339:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140341:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140346:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140346:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140346:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140346:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140346:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140347:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140347:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140348:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140348:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140348:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140351:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140354:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140354:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140354:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140357:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140409:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140409:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140409:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140409:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140412:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140412:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140428:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140428:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140442:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140505:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140505:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140513:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140513:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140835:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140840:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140840:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140846:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140846:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140846:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140846:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140854:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140905:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140905:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140905:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140909:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140909:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140930:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140930:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140934:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/140934:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141016:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141017:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141017:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141017:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141031:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141031:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141035:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141036:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141036:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141050:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141050:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141051:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141051:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141051:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141051:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141107:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141109:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141109:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141126:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141126:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141126:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141128:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141128:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141131:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141131:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141233:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141526:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141526:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141529:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141532:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141532:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141606:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141611:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141612:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141614:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141614:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141614:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141614:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141616:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141616:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141618:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141618:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141623:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141624:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141644:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141649:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141649:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141651:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141651:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141651:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141655:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141655:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141658:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141658:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141701:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141701:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141707:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141707:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141712:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141712:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141712:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141743:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141743:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141744:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141744:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141745:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141746:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141749:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141750:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141750:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141752:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141752:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141752:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141752:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141804:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141816:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141816:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141816:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141837:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141837:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141838:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141838:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141841:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141841:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141848:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141848:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141848:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141848:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141901:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141901:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141902:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141902:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141906:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141906:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141907:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141913:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141913:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141915:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141915:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141915:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141915:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141918:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141918:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141923:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141927:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141927:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141932:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141932:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141932:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141936:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141936:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/141944:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142057:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142057:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142100:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142101:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142101:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142110:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142110:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142111:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142117:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142117:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142144:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142144:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142144:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142144:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142152:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142152:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142157:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142157:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142158:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142158:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142210:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142210:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142213:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142213:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142241:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142241:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142246:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142247:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142247:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142248:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142248:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142254:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142300:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142301:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142301:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142301:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142301:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142306:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142306:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142318:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142319:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142319:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142321:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142327:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142327:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142329:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142340:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142340:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142342:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142342:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142345:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142345:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142418:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142420:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142420:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142420:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142425:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142425:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142426:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142432:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142436:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142436:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142438:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142438:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142439:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142439:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142440:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142440:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142442:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142442:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142453:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142453:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142453:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142453:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142453:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142454:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142457:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142457:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142459:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142503:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142503:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142503:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142503:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142503:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142506:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142506:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142506:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142507:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142507:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142507:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142508:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142508:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142514:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142553:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142553:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142554:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142554:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142559:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142559:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142601:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142601:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142602:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142602:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142603:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142603:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0122/142603:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083844:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083856:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083858:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083858:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083901:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083901:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083910:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083910:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083922:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0124/083928:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/151543:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/151551:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/151551:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152458:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152504:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - -[0125/152504:ERROR:message_queue.cc(496)] Failed to send boolean response to client handle : The pipe is being closed. - From dccc83f6c94716cf6207623990c04962433dbb60 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Fri, 26 Dec 2014 14:21:38 -0500 Subject: [PATCH 58/79] Removed str() methods and used format() instead --- pyOlog/OlogClient.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index b923827..299b8d3 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -29,10 +29,8 @@ from json import JSONEncoder, JSONDecoder from collections import OrderedDict -import tempfile - -from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment -from conf import _conf +from .OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment +from .conf import _conf class OlogClient(object): @@ -139,7 +137,7 @@ def log(self, log_entry): # Handle attachments for attachment in log_entry.getAttachments(): - url = "/".join((self.attachments_resource, str(id))) + url = "{0}/{1}".format(self.attachments_resource, id) resp = self._post(url, files={'file': attachment.getFilePost()}) def createLogbook(self, logbook): @@ -185,7 +183,7 @@ def find(self, **kwds): >> find(property='context') find log entires with property named 'context' - >> find(start=str(time.time() - 3600) + >> find(start=time.time() - 3600) find the log entries made in the last hour >> find(start=123243434, end=123244434) find all the log entries made between the epoc times 123243434 @@ -210,14 +208,14 @@ def listAttachments(self, log_entry_id): :param log_entry_id: The ID of the log entry to list the attachments. ''' - url = "/".join((self.attachments_resource, str(log_entry_id))) + url = "{0}/{1}".format(self.attachments_resource, log_entry_id) resp = self._get(url) attachments = [] for jsonAttachment in resp.json().pop('attachment'): filename = jsonAttachment.pop('filename') - url = "/".join((self.attachments_resource, str(log_entry_id), - filename)) + url = "{0}/{1}/{2}".format(self.attachments_resource, log_entry_id, + filename) f = self._get(url) attachments.append(Attachment(file=f.content, filename=filename)) @@ -321,7 +319,7 @@ def default(self, obj): if isinstance(obj, Property): test = {} for key in obj.getAttributes(): - test[str(key)] = str(obj.getAttributeValue(key)) + test[str(key)] = '{}'.format(obj.getAttributeValue(key)) prop = OrderedDict() prop["name"] = obj.getName() prop["attributes"] = test From a5b0ea786bba7c1fc26843cec76770dbbb5c3e79 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sat, 27 Dec 2014 10:57:07 -0500 Subject: [PATCH 59/79] Refactor of types removing setters / getters --- pyOlog/OlogClient.py | 27 ++-- pyOlog/OlogDataTypes.py | 263 ++++++++++++++++++++----------------- pyOlog/SimpleOlogClient.py | 36 ++++- pyOlog/conf.py | 25 +++- pyOlog/gui/main.py | 8 +- 5 files changed, 211 insertions(+), 148 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 299b8d3..e7a3392 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -12,9 +12,9 @@ KEYRING_NAME = 'olog' try: - from keyring import get_password + import keyring except ImportError: - have_keyring = False + keyring = None logger.warning("No keyring module found") else: have_keyring = True @@ -61,15 +61,15 @@ def __init__(self, url=None, username=None, password=None, ask=True): the keyring module and askpass to get a password. ''' - self._url = _conf.getValue('url', url) + self._url = _conf.get_value('url', url) self.verify = False - username = _conf.getValue('username', username) - password = _conf.getValue('password', password) + username = _conf.get_username(username) + password = _conf.get_value('password', password) if username and not password and ask: # try methods for a password - if have_keyring: - password = get_password(KEYRING_NAME, username) + if keyring: + password = keyring.get_password(KEYRING_NAME, username) # If it is not in the keyring, or we don't have that module if not password: @@ -314,31 +314,30 @@ def __handleSingleDeleteParameter(self, **kwds): class PropertyEncoder(JSONEncoder): - def default(self, obj): if isinstance(obj, Property): test = {} for key in obj.getAttributes(): test[str(key)] = '{}'.format(obj.getAttributeValue(key)) prop = OrderedDict() - prop["name"] = obj.getName() + prop["name"] = obj.name prop["attributes"] = test return prop return JSONEncoder.default(self, obj) class PropertyDecoder(JSONDecoder): - def __init__(self): JSONDecoder.__init__(self, object_hook=self.dictToProperty) def dictToProperty(self, d): if d: - return Property(name=d.pop('name'), attributes=d.pop('attributes')) + return Property(name=d.pop('name'), + attributes=d.pop('attributes'), + ) class LogbookEncoder(JSONEncoder): - def default(self, obj): if isinstance(obj, Logbook): return {"name": obj.getName(), "owner": obj.getOwner()} @@ -346,7 +345,6 @@ def default(self, obj): class LogbookDecoder(JSONDecoder): - def __init__(self): JSONDecoder.__init__(self, object_hook=self.dictToLogbook) @@ -358,7 +356,6 @@ def dictToLogbook(self, d): class TagEncoder(JSONEncoder): - def default(self, obj): if isinstance(obj, Tag): return {"state": obj.getState(), "name": obj.getName()} @@ -366,7 +363,6 @@ def default(self, obj): class TagDecoder(JSONDecoder): - def __init__(self): JSONDecoder.__init__(self, object_hook=self.dictToTag) @@ -398,7 +394,6 @@ def default(self, obj): class LogEntryDecoder(JSONDecoder): - def __init__(self): JSONDecoder.__init__(self, object_hook=self.dictToLogEntry) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index 5de6b87..cacf366 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -1,11 +1,11 @@ -''' +""" Copyright (c) 2010 Brookhaven National Laboratory All rights reserved. Use is subject to license terms and conditions. Created on Jan 10, 2013 @author: shroffk -''' +""" import os import mimetypes @@ -15,16 +15,24 @@ class LogEntry(object): - ''' - A LogEntry consists of some Text description, an owner and an + """A LogEntry consists of some Text description, an owner and an associated logbook It can optionally be associated with one or more logbooks and contain one or more tags, properties and attachments - ''' - def __init__(self, text, owner=None, logbooks=None, - tags=None, attachments=None, properties=None, id=None, - createTime=None, modifyTime=None): - ''' - Constructor for log Entry + """ + def __init__(self, text=None, owner=None, logbooks=None, + tags=None, attachments=None, properties=None, + id=None, create_time=None, modify_time=None): + """ Constructor for log Entry + + :param text: Text of log entry + :type text: string + :param owner: Owner of log entry + :type owner: string + :param logbooks: Logbooks to add entry to + :type logbooks: string, list of strings, Logbook object. + :param tags: Tags to add to log entries + :type tags: string, list of strings, Tag object. + Simple LogEntry >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')]) @@ -38,16 +46,16 @@ def __init__(self, text, owner=None, logbooks=None, 'URL':'http://trac.nsls2.bnl.gov/trac/1234'}] attachments=[Attachment(open('databrowser.plt'))] ) - ''' + """ text = ''.join(c for c in text if c in string.printable) - self.Text = str(text).strip() + self.text = text.strip() + self.owner = _conf.get_value('username', owner) - self.Owner = _conf.getValue('username', owner) - if self.Owner is None: + if self.owner is None: raise ValueError("You must specify an owner") if logbooks is None: - logbooks = _conf.getValue('logbooks') + logbooks = _conf.get_value('logbooks') if logbooks is None: raise ValueError("You must specify a logbook") @@ -56,7 +64,7 @@ def __init__(self, text, owner=None, logbooks=None, self.logbooks = logbooks if tags is None: - tags = _conf.getValue('tags') + tags = _conf.get_value('tags') if tags is not None: self.tags = [Tag(n) for n in tags.split(',')] else: @@ -74,163 +82,172 @@ def __init__(self, text, owner=None, logbooks=None, else: self.properties = [] - self._id = id - self._create_time = createTime - self._modify_time = modifyTime - - def getId(self): - return self._id - - def getCreateTime(self): - return self._create_time - - def getModifyTime(self): - return self._modify_time - - def getText(self): - return self.Text - - def getOwner(self): - return self.Owner - - def getLogbooks(self): - return self.logbooks - - def getTags(self): - return self.tags - - def getAttachments(self): - return self.attachments - - def getProperties(self): - return self.properties + self.id = id + self.create_time = create_time + self.modify_time = modify_time def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 if self._id: - return cmp((self._id), (arg[0].__id)) + return cmp((self.id), (arg[0].id)) else: raise ValueError('Invalid LogEntry: id cannot be None') class Logbook(object): - ''' - A Logbook consist of an unique name and an owner, + """ A Logbook consist of an unique name and an owner, logentries can be added to a logbook so long as the user either the owner or a member of the owner group - ''' + """ - def __init__(self, name, owner=None): - ''' - Create a logbook - >> Logbook('commissioning', 'controls') - ''' - self._name = str(name).strip() - self._owner = str(owner).strip() + def __init__(self, name, owner=None, active=True): + """ Create logbook object + + :param name: Name of logbook + :type name: string + :param owner: Owner of logbook + :type owner: string + :param active: State of logbook + :type active: bool - def getName(self): - return self._name + If the owner is not specified then the default is read from the + config file. - def getOwner(self): - return self._owner + + For example: + >> Logbook('commissioning', 'controls') + """ + self.name = '{}'.format(name).strip() + self.owner = _conf.get_owner(owner) + self.active = active def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self._name, self._owner), (arg[0].__Name, arg[0].__Owner)) + return cmp((self.name, self.owner), (arg[0].name, arg[0].owner)) class Tag(object): - ''' - A Tag consists of a unique name, it is used to tag logEntries""" - ''' + """ A Tag consists of a unique name, it is used to tag log entries + """ + + def __init__(self, name, active=True): + """ + :param name: Name of tag + :type name: string + :param active: The tags active state + :type active: bool - def __init__(self, name, state="Active"): - ''' - Create a Tag object + For example: >> Tag('TimingSystem') - ''' - self._name = str(name).strip() - self._state = str(state).strip() + """ + self.name = "{}".format(name).strip() + if active: + self.state = 'Active' + else: + self.state = 'Inactive' - def getName(self): - return self._name + @property + def active(self): + if self.state == 'Active': + return True + else: + return False - def getState(self): - return self._state + @active.setter + def active(self, value): + if value: + self.state = 'Active' + else: + self.state = 'Inactive' def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self._name, self._state), (arg[0].__Name, arg[0].__State)) + return cmp((self.name, self.state), (arg[0].name, arg[0].state)) class Attachment(object): - ''' - A Attachment, a file associated with the log entry - TODO this is not thread safe - ''' + """ A class representation of an Olog Attachment. An Attachment, is + a file associated with the log entry. This object contains filename and + mime-type information about the attachment. + """ + default_mime_type = 'application/octet-stream' - def __init__(self, file, filename=None): - ''' - Create Attachment + def __init__(self, file, filename=None, mime_type=None): + """ Create Attachment - file can either be a file object or a string. For a - string, the filename must be specified. + :param file: File object or data + :type file: String, or file object + :param filename: Filename of attatchment + :type filename: String + :param mime_type: Mime-type of attachment + :type mime_type: String + + For example: >> Attachment(file=open('/home/usr/databrowser.plt') >> Attachment(file=open('test.jpg','rb') - >> Attachment(file=string, filename = 'mydata.png') - ''' - self._file = file - self._filename = filename + >> Attachment(file=string, filename='mydata.png') + """ + self.file = file + self.filename = filename + self.mime_type = mime_type + + def get_file_post(self): + """Get tuple for makeing http post of attachment - def getFile(self): - return self._file + :returns: Tuple of filename, file object and mimetype + :rtype: tuple + """ - def getFilePost(self): - if self._filename is None: - basename = os.path.basename(self._file.name) + if self.filename is None: + basename = os.path.basename(self.file.name) else: - basename = os.path.basename(self._filename) - mtype = mimetypes.guess_type(basename)[0] - if mtype is None: - mtype = 'application/octet-stream' - return (basename, self._file, mtype) + basename = os.path.basename(self.filename) + if self.mime_type is None: + mtype = mimetypes.guess_type(basename)[0] + if mtype is None: + mtype = self.default_mime_type -class Property(object): - ''' - A property consists of a unique name and a set of attributes - consisting of key value pairs - ''' + return (basename, self.file, mtype) + +class Property(object): + """ A class representation of an Olog property. A property consists of + a unique name and a set of attributes consisting of key value pairs. + The ket value pairs are represented as a dictionary. + """ def __init__(self, name, attributes=None): - ''' - Create a property with a unique name and attributes - >> Property('Ticket', attributes={'Id':'1234', - 'URL':'http://trac.nsls2.bnl.gov/trac/1234'} - >> Property('Scan', attributes={'Number':'run-1234', - 'script':'scan_20130117.py'} - ''' - self._name = str(name).strip() - self.Attributes = attributes + """ Create a property with a unique name and attributes + + :param name: Name of property + :type name: string + :param attributes: Attributes of the property as a dict + :type attributes: dictionary - def getName(self): - return self._name + For example: - def getAttributes(self): - return self.Attributes + >>> Property('Ticket', attributes={'Id':'1234', + 'URL':'http://trac.nsls2.bnl.gov/trac/1234'} + >>> Property('Scan', attributes={'Number':'run-1234', + 'script':'scan_20130117.py'} + """ + self.name = name + self.attributes = attributes - def getAttributeNames(self): - return self.Attributes.keys() + @property + def attribute_names(self): + return self.attributes.keys() - def getAttributeValue(self, attributeName): - return self.Attributes.get(attributeName) + @property + def attribute_value(self, attribute_name): + return self.attributes.get(attribute_name) def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 - return cmp((self._name, set(self.Attributes)), - (arg[0].__Name, set(arg[0].Attributes))) + return cmp((self.name, set(self.attributes)), + (arg[0].name, set(arg[0].attributes))) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 60c5c33..c02190f 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -4,7 +4,7 @@ """ from .OlogClient import OlogClient -from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment +from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment, Property def logentry_to_dict(log): @@ -46,14 +46,44 @@ def __init__(self, *args, **kwargs): """Initiate a session """ self.session = OlogClient(*args, **kwargs) - def get_tags(self): + @property + def tags(self): """Return a list of tag names in the Olog""" return [t.getName() for t in self.session.listTags()] - def get_logbooks(self): + @property + def logbooks(self): """Return a list of logbooks names in the Olog""" return [l.getName() for l in self.session.listLogbooks()] + def create_logbook(self, logbook, owner=None): + """Create a logbook + + :param logbook: Name of logbook to create + :param owner: Owner of logbook (defaults to default from config file) + """ + logbook = Logbook(logbook, owner) + self.session.createLogbook(logbook) + + def create_tag(self, tag, active=True): + """Create a tag + + :param tag: Name of tag to create + :param active: State of tag + """ + + tag = Tag(tag, active) + self.session.createTag(tag) + + def create_property(self, property, keys): + """Create a property + + :param property: Name of property + :param keys: Name of keys associated with the property. + """ + property = Property(property, keys) + self.session.createProperty(property) + def find(self, **kwargs): """Find log entries which match kwargs diff --git a/pyOlog/conf.py b/pyOlog/conf.py index 149ce24..88f0622 100644 --- a/pyOlog/conf.py +++ b/pyOlog/conf.py @@ -15,6 +15,7 @@ import os import os.path import logging +import getpass logger = logging.getLogger(__name__) @@ -31,13 +32,15 @@ class Config(object): def __init__(self, conf='DEFAULT'): """Initialise config object""" self.heading = conf + import ConfigParser self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) files = self.cf.read(self.conf_files) + for f in files: logger.info("Read config file %s", f) - def getValue(self, arg, value=None): + def get_value(self, arg, value=None): ''' Get a default from the config file. @@ -59,4 +62,24 @@ def getValue(self, arg, value=None): else: return value + def get_username(self, value=None): + """Get the username to be used""" + if value is None: + if self.cf.has_option(self.heading, 'username'): + return self.cf.get(self.heading, 'username') + else: + return getpass.getuser() + else: + return value + + def get_owner(self, value=None): + """Get the owner for tags, logbooks and properties to be used""" + if value is None: + if self.cf.has_option(self.heading, 'default owner'): + return self.cf.get(self.heading, 'default owner') + else: + return self.get_username() + else: + return value + _conf = Config() diff --git a/pyOlog/gui/main.py b/pyOlog/gui/main.py index 9338352..412dd4c 100644 --- a/pyOlog/gui/main.py +++ b/pyOlog/gui/main.py @@ -7,11 +7,9 @@ class MainWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.scribble_area = ScribbleArea() - self.setCentralWidget(self.scribble_area) - self.initUI() - - def initUI(self): - self.setGeometry(100, 100, 1030, 800) + self.text_area = QtGui.QTextEdit(self) + self.setCentralWidget(self.text_area) + self.setGeometry(20, 20, 1030, 800) self.setWindowTitle("Olog Gui Client") From 298ae81fd2c221c30ea002890d5ce5524ff46a14 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 28 Dec 2014 10:42:32 -0500 Subject: [PATCH 60/79] refactored to remove getters --- pyOlog/OlogClient.py | 27 ++++++++++++--------------- pyOlog/OlogDataTypes.py | 28 ++++++++++++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index e7a3392..032563b 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -34,9 +34,6 @@ class OlogClient(object): - ''' - classdocs - ''' json_header = {'content-type': 'application/json', 'accept': 'application/json'} logs_resource = '/resources/logs' @@ -317,8 +314,8 @@ class PropertyEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Property): test = {} - for key in obj.getAttributes(): - test[str(key)] = '{}'.format(obj.getAttributeValue(key)) + for key in obj.attributes: + test[str(key)] = '{}'.format(obj.attribute_value(key)) prop = OrderedDict() prop["name"] = obj.name prop["attributes"] = test @@ -340,7 +337,7 @@ def dictToProperty(self, d): class LogbookEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Logbook): - return {"name": obj.getName(), "owner": obj.getOwner()} + return {"name": obj.name, "owner": obj.owner} return JSONEncoder.default(self, obj) @@ -358,7 +355,7 @@ def dictToLogbook(self, d): class TagEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Tag): - return {"state": obj.getState(), "name": obj.getName()} + return {"state": obj.state, "name": obj.name} return JSONEncoder.default(self, obj) @@ -374,20 +371,19 @@ def dictToTag(self, d): class LogEntryEncoder(JSONEncoder): - def default(self, obj): if isinstance(obj, LogEntry): logbooks = [] - for logbook in obj.getLogbooks(): + for logbook in obj.logbooks: logbooks.append(LogbookEncoder().default(logbook)) tags = [] - for tag in obj.getTags(): + for tag in obj.tags: tags.append(TagEncoder().default(tag)) properties = [] - for property in obj.getProperties(): + for property in obj.properties: properties.append(PropertyEncoder().default(property)) - return [{"description": obj.getText(), - "owner": obj.getOwner(), "level": "Info", + return [{"description": obj.text, + "owner": obj.owner, "level": "Info", "logbooks": logbooks, "tags": tags, "properties": properties}] return JSONEncoder.default(self, obj) @@ -406,12 +402,13 @@ def dictToLogEntry(self, d): properties = [PropertyDecoder().dictToProperty(property) for property in d.pop('properties')] + return LogEntry(text=d.pop('description'), owner=d.pop('owner'), logbooks=logbooks, tags=tags, properties=properties, id=d.pop('id'), - createTime=d.pop('createdDate'), - modifyTime=d.pop('modifiedDate')) + create_time=d.pop('createdDate'), + modify_time=d.pop('modifiedDate')) else: return None diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index cacf366..1a2836f 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -32,20 +32,28 @@ def __init__(self, text=None, owner=None, logbooks=None, :type logbooks: string, list of strings, Logbook object. :param tags: Tags to add to log entries :type tags: string, list of strings, Tag object. + :param attachments: attachments to add to the log entry + :type attachments: list of attachment objects + :param properties: properties to add to the log entry + :type properties: list of properties objects + :param id: numerical id of log entry + :type id: integer + + Example: Simple LogEntry - >> LogEntry('test log entry', 'controls', - logbooks=[Logbook('commissioning', owner='controls')]) + >>> LogEntry('test log entry', 'controls', + logbooks=[Logbook('commissioning', owner='controls')]) Comprehensive logEntry - >> LogEntry('test log entry', 'controls', - logbooks=[Logbook('commissioning', owner='controls')], - tags=[Tag('TimingSystem')] - properties=[Property('Ticket', - attributes={'Id':'1234', - 'URL':'http://trac.nsls2.bnl.gov/trac/1234'}] - attachments=[Attachment(open('databrowser.plt'))] - ) + >>> LogEntry('test log entry', 'controls', + logbooks=[Logbook('commissioning', owner='controls')], + tags=[Tag('TimingSystem')] + properties=[Property('Ticket', + attributes={'Id':'1234', + 'URL':'http://trac.nsls2.bnl.gov/trac/1234'}] + attachments=[Attachment(open('databrowser.plt'))] + ) """ text = ''.join(c for c in text if c in string.printable) self.text = text.strip() From b264e6c53d5ec52e99ada13bec7944295df426da Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 28 Dec 2014 12:35:58 -0500 Subject: [PATCH 61/79] Fixed property addition to only use keys --- pyOlog/OlogClient.py | 34 ++++++++++++++++++-------------- pyOlog/OlogDataTypes.py | 4 ---- pyOlog/SimpleOlogClient.py | 40 +++++++++++++++++++++++--------------- 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 032563b..a14db9f 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -94,28 +94,28 @@ def __init__(self, url=None, username=None, password=None, ask=True): def _get(self, url, **kwargs): """Do an http GET request""" - print self._url + url + logger.debug("HTTP GET to %s", self._url + url) resp = self._session.get(self._url + url, **kwargs) resp.raise_for_status() return resp def _put(self, url, **kwargs): """Do an http put request""" - print self._url + url + logger.debug("HTTP PUT to %s", self._url + url) resp = self._session.put(self._url + url, **kwargs) resp.raise_for_status() return resp def _post(self, url, **kwargs): """Do an http post request""" - print self._url + url + logger.debug("HTTP POST to %s", self._url + url) resp = self._session.post(self._url + url, **kwargs) resp.raise_for_status() return resp def _delete(self, url, **kwargs): """Do an http delete request""" - print self._url + url + logger.debug("HTTP DELETE to %s", self._url + url) resp = self._session.delete(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -129,13 +129,15 @@ def log(self, log_entry): ''' resp = self._post(self.logs_resource, data=LogEntryEncoder().encode(log_entry)) - id = LogEntryDecoder().dictToLogEntry(resp.json()[0]).getId() + id = LogEntryDecoder().dictToLogEntry(resp.json()[0]).id # Handle attachments - for attachment in log_entry.getAttachments(): + for attachment in log_entry.attachments: url = "{0}/{1}".format(self.attachments_resource, id) - resp = self._post(url, files={'file': attachment.getFilePost()}) + resp = self._post(url, files={'file': attachment.get_file_post()}) + + return id def createLogbook(self, logbook): ''' @@ -143,7 +145,7 @@ def createLogbook(self, logbook): :param logbook: An instance of Logbook to create in the Olog. ''' - url = "/".join((self.logbooks_resource, logbook.getName())) + url = "/".join((self.logbooks_resource, logbook.name)) self._put(url, data=LogbookEncoder().encode(logbook)) def createTag(self, tag): @@ -152,7 +154,7 @@ def createTag(self, tag): :param tag: An instance of Tag to create in the Olog. ''' - url = "/".join((self.tags_resource, tag.getName())) + url = "/".join((self.tags_resource, tag.name)) self._put(url, data=TagEncoder().encode(tag)) def createProperty(self, property): @@ -161,7 +163,7 @@ def createProperty(self, property): :param property: An instance of Property to create in the Olog. ''' - url = "/".join((self.properties_resource, property.getName())) + url = "/".join((self.properties_resource, property.name)) p = PropertyEncoder().encode(property) self._put(url, data=p) @@ -313,12 +315,12 @@ def __handleSingleDeleteParameter(self, **kwds): class PropertyEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Property): - test = {} - for key in obj.attributes: - test[str(key)] = '{}'.format(obj.attribute_value(key)) + attributes = dict() + for key, value in obj.attributes.iteritems(): + attributes[str(key)] = value prop = OrderedDict() prop["name"] = obj.name - prop["attributes"] = test + prop["attributes"] = attributes return prop return JSONEncoder.default(self, obj) @@ -365,7 +367,9 @@ def __init__(self): def dictToTag(self, d): if d: - return Tag(name=d.pop('name'), state=d.pop('state')) + t = Tag(name=d.pop('name')) + t.state = d.pop('state') + return t else: return None diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index 1a2836f..f68a5e4 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -250,10 +250,6 @@ def __init__(self, name, attributes=None): def attribute_names(self): return self.attributes.keys() - @property - def attribute_value(self, attribute_name): - return self.attributes.get(attribute_name) - def __cmp__(self, *arg, **kwargs): if arg[0] is None: return 1 diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index c02190f..a57d18e 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -10,7 +10,7 @@ def logentry_to_dict(log): rtn = dict() - lid = log.getId() + lid = log.id if not lid: return rtn @@ -24,19 +24,19 @@ def update(name, value): pass else: if any(isinstance(x, (Logbook, Tag)) for x in value): - value = [v.getName() for v in value] + value = [v.name for v in value] else: value = value rtn[name] = value - update('create_time', log.getCreateTime()) - update('modify_time', log.getModifyTime()) - update('text', log.getText()) - update('owner', log.getOwner()) - update('logbooks', log.getLogbooks()) - update('tags', log.getTags()) - update('attachments', log.getAttachments()) - update('properties', log.getProperties()) + update('create_time', log.create_time) + update('modify_time', log.modify_time) + update('text', log.text) + update('owner', log.owner) + update('logbooks', log.logbooks) + update('tags', log.tags) + update('attachments', log.attachments) + update('properties', log.properties) return rtn @@ -49,12 +49,18 @@ def __init__(self, *args, **kwargs): @property def tags(self): """Return a list of tag names in the Olog""" - return [t.getName() for t in self.session.listTags()] + return [t.name for t in self.session.listTags()] @property def logbooks(self): """Return a list of logbooks names in the Olog""" - return [l.getName() for l in self.session.listLogbooks()] + return [l.name for l in self.session.listLogbooks()] + + @property + def properties(self): + """Return a list of logbooks names in the Olog""" + return [(l.name, l.attribute_names) + for l in self.session.listProperties()] def create_logbook(self, logbook, owner=None): """Create a logbook @@ -81,7 +87,9 @@ def create_property(self, property, keys): :param property: Name of property :param keys: Name of keys associated with the property. """ - property = Property(property, keys) + keys_dict = dict() + [keys_dict.update({k: ''}) for k in keys] + property = Property(property, keys_dict) self.session.createProperty(property) def find(self, **kwargs): @@ -140,13 +148,13 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, if logbooks: if verify: - if not any([x in logbooks for x in self.get_logbooks()]): + if not any([x in logbooks for x in self.logbooks]): raise ValueError("Logbook does not exits in Olog") logbooks = [Logbook(n) for n in logbooks] if tags: if verify: - if not any([x in tags for x in self.get_tags()]): + if not any([x in tags for x in self.tags]): raise ValueError("Tag does not exits in Olog") tags = [Tag(n) for n in tags] @@ -160,4 +168,4 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, log = LogEntry(text, logbooks=logbooks, tags=tags, attachments=toattach) - self.session.log(log) + return self.session.log(log) From f8f5265480ce8a9b3d2aebbfd8b78164475de656 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 28 Dec 2014 13:03:35 -0500 Subject: [PATCH 62/79] Removed more camelcase --- pyOlog/OlogClient.py | 8 ++++---- pyOlog/SimpleOlogClient.py | 26 +++++++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index a14db9f..75b0f5c 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -201,7 +201,7 @@ def find(self, **kwds): return logs - def listAttachments(self, log_entry_id): + def list_attachments(self, log_entry_id): ''' Search for attachments on a logentry @@ -220,7 +220,7 @@ def listAttachments(self, log_entry_id): return attachments - def listTags(self): + def list_tags(self): ''' List all tags in the Olog. ''' @@ -231,7 +231,7 @@ def listTags(self): tags.append(TagDecoder().dictToTag(jsonTag)) return tags - def listLogbooks(self): + def list_logbooks(self): ''' List all logbooks in the Olog. ''' @@ -242,7 +242,7 @@ def listLogbooks(self): logbooks.append(LogbookDecoder().dictToLogbook(jsonLogbook)) return logbooks - def listProperties(self): + def list_properties(self): ''' List all Properties and their attributes in the Olog. ''' diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index a57d18e..7393a38 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -49,18 +49,18 @@ def __init__(self, *args, **kwargs): @property def tags(self): """Return a list of tag names in the Olog""" - return [t.name for t in self.session.listTags()] + return [t.name for t in self.session.list_tags()] @property def logbooks(self): """Return a list of logbooks names in the Olog""" - return [l.name for l in self.session.listLogbooks()] + return [l.name for l in self.session.list_logbooks()] @property def properties(self): - """Return a list of logbooks names in the Olog""" + """Return a list of propertys in the Olog""" return [(l.name, l.attribute_names) - for l in self.session.listProperties()] + for l in self.session.list_properties()] def create_logbook(self, logbook, owner=None): """Create a logbook @@ -137,13 +137,13 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, """ if logbooks: - if not isinstance(logbooks, list): + if isinstance(logbooks, basestring): logbooks = [logbooks] if tags: - if not isinstance(tags, list): + if isinstance(tags, basestring): tags = [tags] if attachments: - if not isinstance(attachments, list): + if isinstance(attachments, (Attachment, file)): attachments = [attachments] if logbooks: @@ -158,14 +158,22 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, raise ValueError("Tag does not exits in Olog") tags = [Tag(n) for n in tags] + if properties: + properties = [Property(a, b) for a, b in properties] + toattach = [] if attachments: for a in attachments: if isinstance(a, Attachment): toattach.append(a) + elif isinstance(a, file): + toattach.append(Attachment(a)) else: - toattach.append(Attachment(open(a))) + raise ValueError("Attachments must be file objects or \ + Olog Attachment objects") log = LogEntry(text, logbooks=logbooks, - tags=tags, attachments=toattach) + tags=tags, properties=properties, + attachments=toattach) + return self.session.log(log) From 8077aa14c6251acf0eb19bb997c4069361b989a0 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 28 Dec 2014 13:14:30 -0500 Subject: [PATCH 63/79] Refactored as per PEP8 --- pyOlog/cli/ipy.py | 220 +++++++++++++++++++++++----------------------- 1 file changed, 112 insertions(+), 108 deletions(-) diff --git a/pyOlog/cli/ipy.py b/pyOlog/cli/ipy.py index d9bc4c8..2f7e901 100644 --- a/pyOlog/cli/ipy.py +++ b/pyOlog/cli/ipy.py @@ -1,133 +1,137 @@ from __future__ import print_function -from IPython.core.magic import Magics, magics_class, line_magic, cell_magic +from IPython.core.magic import Magics, magics_class, line_magic from IPython.utils.io import capture_output -from IPython.display import display -from pyOlog import SimpleOlogClient -from pyOlog.utils import save_pyplot_figure, get_screenshot, get_text_from_editor +from .. import SimpleOlogClient +from .utils import save_pyplot_figure, get_screenshot, get_text_from_editor olog_client = SimpleOlogClient() -def olog(msg = None, logbooks = None, tags = None, - attachments = None, **kwargs): - """Make a log entry to the Olog - - :param msg: Message for log entry. - If None use and editor to get message. - :param logbooks: Logbooks to add message to. - :type logbooks: String or List of Strings. - :param tags: Tags to tag the log entry with. - :type tags: String or List of Strings. - :param attachments: List of attachments to add to log entry. - :type attachments: Attchment objects - """ - if not msg: - msg = get_text_from_editor() - olog_client.log(msg, logbooks = logbooks, tags = tags, - attachments = attachments) - return -def olog_savefig(**kwargs): - """Save a pyplot figure and place it in tho Olog +def olog(msg=None, logbooks=None, tags=None, + attachments=None, **kwargs): + """Make a log entry to the Olog + + :param msg: Message for log entry. + If None use and editor to get message. + :param logbooks: Logbooks to add message to. + :type logbooks: String or List of Strings. + :param tags: Tags to tag the log entry with. + :type tags: String or List of Strings. + :param attachments: List of attachments to add to log entry. + :type attachments: Attchment objects + """ + if not msg: + msg = get_text_from_editor() + olog_client.log(msg, logbooks=logbooks, tags=tags, + attachments=attachments) + return - The **kwargs are all passed onto the :func savefig: function - and then onto the :func olog" function - :returns: None - """ - fig = save_pyplot_figure(**kwargs) - if 'attachments' in kwargs: - if isinstance(kwargs['attachments'], list): - kwargs['attachments'].append(fig) +def olog_savefig(**kwargs): + """Save a pyplot figure and place it in tho Olog + + The **kwargs are all passed onto the :func savefig: function + and then onto the :func olog" function + + :returns: None + """ + fig = save_pyplot_figure(**kwargs) + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'].append(fig) + else: + kwargs['attachments'] = [kwargs['attatchments'], fig] else: - kwargs['attachments'] = [kwargs['attatchments'], fig] - else: - kwargs['attachments'] = fig + kwargs['attachments'] = fig - olog(**kwargs) - return + olog(**kwargs) + return -def olog_grab(root = False, **kwargs): - """Grab a screenshot and place it in tho Olog - :param root" If True, the entire screen is grabbed else select - an area as a rubber band. +def olog_grab(root=False, **kwargs): + """Grab a screenshot and place it in tho Olog - The **kwargs are all passed onto the :func olog: function + :param root" If True, the entire screen is grabbed else select + an area as a rubber band. - :returns: None - """ - if not root: - print("Select area of screen to grab .........") - a = get_screenshot(root) - if 'attachments' in kwargs: - if isinstance(kwargs['attachments'], list): - kwargs['attachments'].append(a) + The **kwargs are all passed onto the :func olog: function + + :returns: None + """ + if not root: + print("Select area of screen to grab .........") + a = get_screenshot(root) + if 'attachments' in kwargs: + if isinstance(kwargs['attachments'], list): + kwargs['attachments'].append(a) + else: + kwargs['attachments'] = [kwargs['attatchments'], a] else: - kwargs['attachments'] = [kwargs['attatchments'], a] - else: - kwargs['attachments'] = a + kwargs['attachments'] = a + + olog(**kwargs) + return - olog(**kwargs) - return @magics_class class OlogMagics(Magics): - msg_store = '' - - @line_magic - def log_add(self, line): - """Run the line and capture the output for the Olog""" - self.msg_store += ">>>{}\n".format(line) - self.msg_store += "\n" - with capture_output() as c: - self.shell.run_cell(line) - c.show() - self.msg_store += c.stdout - self.msg_store += '\n' - - @line_magic - def log_end(self, line): - """Store the captured lines in the Olog""" - text = get_text_from_editor(prepend = self.msg_store) - olog_client.log(text) - self.msg_store = '' - - @line_magic - def log_clear(self, line): - """Clear the store of captured lines""" - self.msg_store = '' - - @line_magic - def log_line(self, line): - """Run the line and add the output to the Olog""" - msg = ">>>{}\n".format(line) - msg += "\n" - with capture_output() as c: - self.shell.run_cell(line) - c.show() - msg += c.stdout - olog_client.log(msg) - - @line_magic - def logit(self, line): - """Add a log entry to the Olog""" - if line.strip() == '': - olog_client.log() - else: - olog_client.log(line.strip()) + msg_store = '' + + @line_magic + def log_add(self, line): + """Run the line and capture the output for the Olog""" + self.msg_store += ">>>{}\n".format(line) + self.msg_store += "\n" + with capture_output() as c: + self.shell.run_cell(line) + c.show() + self.msg_store += c.stdout + self.msg_store += '\n' + + @line_magic + def log_end(self, line): + """Store the captured lines in the Olog""" + text = get_text_from_editor(prepend=self.msg_store) + olog_client.log(text) + self.msg_store = '' + + @line_magic + def log_clear(self, line): + """Clear the store of captured lines""" + self.msg_store = '' + + @line_magic + def log_line(self, line): + """Run the line and add the output to the Olog""" + msg = ">>>{}\n".format(line) + msg += "\n" + with capture_output() as c: + self.shell.run_cell(line) + c.show() + msg += c.stdout + olog_client.log(msg) + + @line_magic + def logit(self, line): + """Add a log entry to the Olog""" + if line.strip() == '': + olog_client.log() + else: + olog_client.log(line.strip()) + + @line_magic + def grabit(self, line): + """Grab a screenshot and add it to the Olog""" + olog_grab() - @line_magic - def grabit(self, line): - """Grab a screenshot and add it to the Olog""" - olog_grab() def load_ipython_extension(ipython): - push_vars = {'olog' : olog, - 'olog_savefig' : olog_savefig, - 'olog_grab' : olog_grab, - 'olog_client' : olog_client} - ipython.push(push_vars) - ipython.register_magics(OlogMagics) + push_vars = {'olog': olog, + 'olog_savefig': olog_savefig, + 'olog_grab': olog_grab, + 'olog_client': olog_client} + ipython.push(push_vars) + ipython.register_magics(OlogMagics) From b1ea1a8f1c4da5e044b317f519826670bf7810e8 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Sun, 28 Dec 2014 13:14:57 -0500 Subject: [PATCH 64/79] Removed doxy stuff --- Doxyfile | 1630 ------------------------------------------------------ pom.xml | 76 --- 2 files changed, 1706 deletions(-) delete mode 100644 Doxyfile delete mode 100644 pom.xml diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 7c8d3fd..0000000 --- a/Doxyfile +++ /dev/null @@ -1,1630 +0,0 @@ -# Doxyfile 1.7.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "Python Olog Client Library" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = "2.2.4-SNAPSHOT" - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = "./target/site" - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = "./pyOlog" - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = *.py - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = "./pyOlog/test" - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans.ttf - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 2bb9336..0000000 --- a/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - 4.0.0 - - olog - edu.msu.nscl.olog - ../../ - 2.2.9-SNAPSHOT - - pyOlog - http://olog.github.com/ - - pyOlog - Olog - - - scm:git:ssh://git@github.com/${github.projectOwner}/${github.projectName}.git - scm:git:github - ssh://git@github.com/${github.projectOwner}/${github.projectName}.git - HEAD - - - jira - http://java.net/jira/browse/OLOG/component/14887 - - - Jenkins - https://openepics.ci.cloudbees.com/view/Olog/ - - - - - org.apache.maven.plugins - maven-release-plugin - 2.4 - - true - - - - - - - - org.apache.maven.plugins - maven-changes-plugin - 2.7.1 - - Fix Version,Priority,Type,Summary,Assignee,Key,Status,Resolution - Fix Version,Priority,Key DESC - pyOlog - - - - - jira-report - - - - - - com.soebes.maven.plugins.dmg - doxygen-maven-plugin - 1.0.1 - - Python Olog Client Library - ./pyOlog - *.py - yes - ./pyOlog/test - html - - - - - - From c9ee8d96f97066d4c9503e4fe0077bb62b5dd7d9 Mon Sep 17 00:00:00 2001 From: Stuart Wilkins Date: Mon, 19 Jan 2015 16:57:37 -0500 Subject: [PATCH 65/79] Removed Std Log --- pyOlog/__init__.py | 4 ++-- pyOlog/cli/ipy.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index 77de5c8..3b6f0b4 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -1,10 +1,10 @@ import logging import sys logger = logging.getLogger("pyOlog") -logger.setLevel(logging.DEBUG) +logger.setLevel(logging.CRITICAL) handler = logging.StreamHandler(sys.stderr) -handler.setLevel(logging.DEBUG) +handler.setLevel(logging.CRITICAL) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) diff --git a/pyOlog/cli/ipy.py b/pyOlog/cli/ipy.py index 2f7e901..9ba7743 100644 --- a/pyOlog/cli/ipy.py +++ b/pyOlog/cli/ipy.py @@ -1,7 +1,6 @@ from __future__ import print_function from IPython.core.magic import Magics, magics_class, line_magic - from IPython.utils.io import capture_output from .. import SimpleOlogClient @@ -110,7 +109,9 @@ def log_line(self, line): msg += "\n" with capture_output() as c: self.shell.run_cell(line) + c.show() + msg += c.stdout olog_client.log(msg) From f4b1101ad848887c5a94e51e498461b722d86b8c Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Sat, 24 Jan 2015 18:18:48 -0500 Subject: [PATCH 66/79] Fixed attachment and completed doc strings --- pyOlog/OlogClient.py | 12 +- pyOlog/OlogDataTypes.py | 1 - pyOlog/SimpleOlogClient.py | 248 +++++++++++++++++++++++++++++-------- 3 files changed, 204 insertions(+), 57 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 75b0f5c..5726bf4 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -89,12 +89,13 @@ def __init__(self, url=None, username=None, password=None, ask=True): self._session = requests.Session() self._session.auth = _auth - self._session.headers.update(self.json_header) + # self._session.headers.update(self.json_header) self._session.verify = self.verify def _get(self, url, **kwargs): """Do an http GET request""" logger.debug("HTTP GET to %s", self._url + url) + kwargs.update({'headers': self.json_header}) resp = self._session.get(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -102,13 +103,16 @@ def _get(self, url, **kwargs): def _put(self, url, **kwargs): """Do an http put request""" logger.debug("HTTP PUT to %s", self._url + url) + kwargs.update({'headers': self.json_header}) resp = self._session.put(self._url + url, **kwargs) resp.raise_for_status() return resp - def _post(self, url, **kwargs): + def _post(self, url, json=True, **kwargs): """Do an http post request""" logger.debug("HTTP POST to %s", self._url + url) + if json: + kwargs.update({'headers': self.json_header}) resp = self._session.post(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -116,6 +120,7 @@ def _post(self, url, **kwargs): def _delete(self, url, **kwargs): """Do an http delete request""" logger.debug("HTTP DELETE to %s", self._url + url) + kwargs.update({'headers': self.json_header}) resp = self._session.delete(self._url + url, **kwargs) resp.raise_for_status() return resp @@ -135,7 +140,8 @@ def log(self, log_entry): for attachment in log_entry.attachments: url = "{0}/{1}".format(self.attachments_resource, id) - resp = self._post(url, files={'file': attachment.get_file_post()}) + resp = self._post(url, json=False, + files={'file': attachment.get_file_post()}) return id diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index f68a5e4..fb21e4f 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -219,7 +219,6 @@ def get_file_post(self): mtype = mimetypes.guess_type(basename)[0] if mtype is None: mtype = self.default_mime_type - return (basename, self.file, mtype) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 7393a38..a883c7c 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -25,6 +25,10 @@ def update(name, value): else: if any(isinstance(x, (Logbook, Tag)) for x in value): value = [v.name for v in value] + if any(isinstance(x, Property) for x in value): + value = {p.name: {n: p.attributes[n] + for n in p.attribute_names} + for p in value} else: value = value rtn[name] = value @@ -42,40 +46,105 @@ def update(name, value): class SimpleOlogClient(object): + """ + Client interface to Olog + + This class can be used as a simple interface to the Olog + for creating and searching for log entries. + + """ + def __init__(self, *args, **kwargs): - """Initiate a session """ + """Initiate a session + + Initiate a session to communicate with the Olog server. the `args` + and `kwargs` are passed onto the `OlogClient` as the initialization + parameters. + + See Also + -------- + + OlogClient : Client interface to the Olog + + """ self.session = OlogClient(*args, **kwargs) @property def tags(self): - """Return a list of tag names in the Olog""" + """Return a list of tags + + Returns a list of the tag names associated with the Olog + instance. + + Returns + ------- + + list + Tag names as string + """ return [t.name for t in self.session.list_tags()] @property def logbooks(self): - """Return a list of logbooks names in the Olog""" + """Return logbook names + + Returns a list of logbook names associated with the + Olog instance. + + Returns + ------- + + list + Logbook names as string + """ return [l.name for l in self.session.list_logbooks()] @property def properties(self): - """Return a list of propertys in the Olog""" - return [(l.name, l.attribute_names) - for l in self.session.list_properties()] + """Return property names + + Returns a list of the property names associated with the Olog + instance. + + Returns + ------- + + dict + dictionary with keys as property names and attributes as + a list of the properties attributes + + """ + return {l.name: l.attribute_names + for l in self.session.list_properties()} def create_logbook(self, logbook, owner=None): """Create a logbook - :param logbook: Name of logbook to create - :param owner: Owner of logbook (defaults to default from config file) + Create a logbook in the current Olog instance. + + Parameters + ---------- + logbook : string + Name of logbook to create + owner : string, optional + Owner of logbook (defaults to default from config file) + """ logbook = Logbook(logbook, owner) - self.session.createLogbook(logbook) + return self.session.createLogbook(logbook) def create_tag(self, tag, active=True): """Create a tag - :param tag: Name of tag to create - :param active: State of tag + Create a tag in the current olog instance. + + Parameters + ---------- + tag : string + Name of tag to create + active : bool, optional + State of the tag + """ tag = Tag(tag, active) @@ -84,8 +153,16 @@ def create_tag(self, tag, active=True): def create_property(self, property, keys): """Create a property - :param property: Name of property - :param keys: Name of keys associated with the property. + Create a property in the current olog instance. + + Parameters + ---------- + + property : string + Name of property to create + keys : list of strings + Keys of the peoperty + """ keys_dict = dict() [keys_dict.update({k: ''}) for k in keys] @@ -93,49 +170,96 @@ def create_property(self, property, keys): self.session.createProperty(property) def find(self, **kwargs): - """Find log entries which match kwargs - - Search for logEntries based on one or many search criteria - >> find(search='*Timing*') - find logentries with the text Timing in the description + """Find log entries + + Find (search) for log entries based on keyword arguments. + + Parameters + ---------- + id : int + Search for logbook with ID id. + search : string + Search logbook text for string. + tag : string + Find log entries with tags matching tag. + logbook : string + Find log entries in logbooks logbook. + property : string + Find log entries with a property matching property. + start : float + Find log entries created after time start. Time should be a + float of the number of seconds since the unix Epoch. + stop : float + Find log entries created before time stop. Time should be a + float of the number of seconds since the unix Epoch. + + Returns + ------- + dictionary + Dictionary of logbook entries matching seach criteria. + + Examples + -------- + Search for the log entry with an ID 100 + + >>>soc = SimpleOlogClient() + >>>result = soc.find(id=100) + + Search for log entries with the log entry matching "Timing" which + were created in the last hour with a tag matchin "magnets" + + >>>soc = SimpleOlogClient() + >>>result = soc..find(string='*Timing*', tag='magnets', + start = time.time() - 3600) - >> find(tag='magnets') - find log entries with the a tag named 'magnets' - - >> find(logbook='controls') - find log entries in the logbook named 'controls' - - >> find(property='context') - find log entires with property named 'context' - - >> find(start=str(time.time() - 3600) - find the log entries made in the last hour - >> find(start=123243434, end=123244434) - find all the log entries made between the epoc times 123243434 - and 123244434 - - Searching using multiple criteria - >>find(logbook='contorls', tag='magnets') - find all the log entries in logbook 'controls' AND with tag - named 'magnets' """ results = self.session.find(**kwargs) return [logentry_to_dict(result) for result in results] def log(self, text=None, logbooks=None, tags=None, properties=None, - attachments=None, verify=True): - """ - Create olog entry. - - :param str text: String of the olog entry to make. - :param logbooks: Logbooks to make entry into. - :type logbooks: None, List or string - :param tags:Tags to apply to logbook entry. - :type tags: None, List or string + attachments=None, verify=True, ensure=False): + """ Create log entry. + + Create a single log entry in the Olog instance. + + Parameters + ---------- + text : string + The body of the log entry. + logbooks : string or list of strings + The logbooks which to add the log entry to. + tags : string or list of strings + The tags to add to the log entry. + properties : dict of property dicts + The properties to add to the log entry + attachments : list of file like objects + The attachments to add to the log entry + verify : bool + Check that properties, tags and logbooks are in the Olog + instance. + ensure : bool + If a property, tag or logbook is not in the Olog then + create the property, tag or logbook before making the log + entry. Seting ensure to True will set verify to False. + + Raises + ------ + + ValueError + If the property, tag or logbook does not exist and ensure is + True. + + Returns + ------- + int + The id of the log entry created. """ + if ensure: + verify = False + if logbooks: if isinstance(logbooks, basestring): logbooks = [logbooks] @@ -147,19 +271,37 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, attachments = [attachments] if logbooks: - if verify: - if not any([x in logbooks for x in self.logbooks]): - raise ValueError("Logbook does not exits in Olog") + for x in logbooks: + if x not in self.logbooks: + if ensure: + self.create_logbook(x) + if verify: + raise ValueError("Logbook {} does not exist in Olog" + .format(x)) + logbooks = [Logbook(n) for n in logbooks] if tags: - if verify: - if not any([x in tags for x in self.tags]): - raise ValueError("Tag does not exits in Olog") + for x in tags: + if x not in self.tags: + if ensure: + self.create_tag(x) + if verify: + raise ValueError("Tag {} does not exist in Olog" + .format(x)) + tags = [Tag(n) for n in tags] if properties: - properties = [Property(a, b) for a, b in properties] + for x, y in properties.iteritems(): + if x not in self.properties: + if ensure: + self.create_property(x, y.keys()) + if verify: + raise ValueError("Property {} does not exist in Olog". + format(x)) + + properties = [Property(a, b) for a, b in properties.iteritems()] toattach = [] if attachments: From 1b2f6527bcfc7d0e3ff2ac7dd06735be13ca514a Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 29 Dec 2014 09:05:18 -0500 Subject: [PATCH 67/79] MNT : Ensure `have_keyring` is always defined --- pyOlog/OlogClient.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 5726bf4..2340ea6 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -16,6 +16,7 @@ except ImportError: keyring = None logger.warning("No keyring module found") + have_keyring = False else: have_keyring = True From 70a6de70e8c442ea92d5d023eac744fde97a5105 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 4 Feb 2015 17:22:34 -0500 Subject: [PATCH 68/79] MNT : python3 compatibility changes --- pyOlog/OlogClient.py | 1 + pyOlog/OlogDataTypes.py | 2 +- pyOlog/__init__.py | 6 +++--- pyOlog/conf.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 2340ea6..4b18c37 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -6,6 +6,7 @@ @author: shroffk ''' +from __future__ import (print_function, absolute_import) import logging logger = logging.getLogger(__name__) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index fb21e4f..02f6bbb 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -11,7 +11,7 @@ import mimetypes import string -from conf import _conf +from .conf import _conf class LogEntry(object): diff --git a/pyOlog/__init__.py b/pyOlog/__init__.py index 3b6f0b4..6a156d8 100644 --- a/pyOlog/__init__.py +++ b/pyOlog/__init__.py @@ -11,6 +11,6 @@ logger.addHandler(handler) -from OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment -from OlogClient import OlogClient -from SimpleOlogClient import SimpleOlogClient +from .OlogDataTypes import LogEntry, Logbook, Tag, Property, Attachment +from .OlogClient import OlogClient +from .SimpleOlogClient import SimpleOlogClient diff --git a/pyOlog/conf.py b/pyOlog/conf.py index 88f0622..21b269e 100644 --- a/pyOlog/conf.py +++ b/pyOlog/conf.py @@ -33,8 +33,8 @@ def __init__(self, conf='DEFAULT'): """Initialise config object""" self.heading = conf - import ConfigParser - self.cf = ConfigParser.SafeConfigParser(defaults=self.defaults) + from six.moves import configparser + self.cf = configparser.SafeConfigParser(defaults=self.defaults) files = self.cf.read(self.conf_files) for f in files: From f4f1b7013bbafbb736f13d9cf64b567a6846042f Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Thu, 5 Feb 2015 07:25:10 -0500 Subject: [PATCH 69/79] Fixed docstrings --- pyOlog/SimpleOlogClient.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index a883c7c..9c62b85 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -200,17 +200,18 @@ def find(self, **kwargs): Examples -------- - Search for the log entry with an ID 100 + Search for the log entry with an ID 100:: >>>soc = SimpleOlogClient() >>>result = soc.find(id=100) Search for log entries with the log entry matching "Timing" which - were created in the last hour with a tag matchin "magnets" + were created in the last hour with a tag matchin "magnets":: >>>soc = SimpleOlogClient() - >>>result = soc..find(string='*Timing*', tag='magnets', - start = time.time() - 3600) + >>>result = soc.find(string='*Timing*', tag='magnets', + start = time.time() - 3600) + """ From 3304fdcfd4723b57ff000e8929f8153370e9d645 Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Thu, 5 Feb 2015 07:25:26 -0500 Subject: [PATCH 70/79] Fixed bug where None for text field was unallowed --- pyOlog/OlogDataTypes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyOlog/OlogDataTypes.py b/pyOlog/OlogDataTypes.py index fb21e4f..702633d 100644 --- a/pyOlog/OlogDataTypes.py +++ b/pyOlog/OlogDataTypes.py @@ -55,7 +55,10 @@ def __init__(self, text=None, owner=None, logbooks=None, attachments=[Attachment(open('databrowser.plt'))] ) """ - text = ''.join(c for c in text if c in string.printable) + if text is not None: + text = ''.join(c for c in text if c in string.printable) + else: + text = '' self.text = text.strip() self.owner = _conf.get_value('username', owner) From e73e63d6f12bb49e5291c3c97a0464a471fe14da Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Sun, 8 Feb 2015 09:26:25 -0500 Subject: [PATCH 71/79] BUG : Fixed None on log message --- pyOlog/cli/ipy.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyOlog/cli/ipy.py b/pyOlog/cli/ipy.py index 9ba7743..f7e2f40 100644 --- a/pyOlog/cli/ipy.py +++ b/pyOlog/cli/ipy.py @@ -9,7 +9,7 @@ olog_client = SimpleOlogClient() -def olog(msg=None, logbooks=None, tags=None, +def olog(msg=None, edit=False, logbooks=None, tags=None, attachments=None, **kwargs): """Make a log entry to the Olog @@ -94,7 +94,7 @@ def log_add(self, line): def log_end(self, line): """Store the captured lines in the Olog""" text = get_text_from_editor(prepend=self.msg_store) - olog_client.log(text) + olog(text) self.msg_store = '' @line_magic @@ -113,15 +113,15 @@ def log_line(self, line): c.show() msg += c.stdout - olog_client.log(msg) + olog(msg) @line_magic def logit(self, line): """Add a log entry to the Olog""" if line.strip() == '': - olog_client.log() + olog() else: - olog_client.log(line.strip()) + olog(line.strip()) @line_magic def grabit(self, line): @@ -134,5 +134,6 @@ def load_ipython_extension(ipython): 'olog_savefig': olog_savefig, 'olog_grab': olog_grab, 'olog_client': olog_client} + ipython.push(push_vars) ipython.register_magics(OlogMagics) From a2f29440ef9c1db38740fbfaa593ae6c9bf3a93a Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Sun, 8 Feb 2015 11:39:43 -0500 Subject: [PATCH 72/79] Fixed setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 211985c..ca23773 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ description='Python Olog Client Lib', author='Kunal Shroff', author_email='shroffk@bnl.gov', - packages=['pyOlog'], + packages=['pyOlog', 'pyOlog.cli'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], entry_points={'console_scripts': [ 'olog = pyOlog.cli:main'], From cfd6b2abb30b3de2362054d3290807c0b06b69ad Mon Sep 17 00:00:00 2001 From: "Stuart B. Wilkins" Date: Sun, 8 Feb 2015 11:39:43 -0500 Subject: [PATCH 73/79] Fixed setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 211985c..ca23773 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ description='Python Olog Client Lib', author='Kunal Shroff', author_email='shroffk@bnl.gov', - packages=['pyOlog'], + packages=['pyOlog', 'pyOlog.cli'], requires=['requests (>=2.0.0)', 'urllib3 (>=1.7.1)'], entry_points={'console_scripts': [ 'olog = pyOlog.cli:main'], From be199dc14caea5b8b736a60a3dd0aaba8812643a Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 10 Jun 2015 13:05:22 -0400 Subject: [PATCH 74/79] MNT: more py3k compatibility fixes --- pyOlog/SimpleOlogClient.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 9c62b85..7ac4b22 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -1,8 +1,11 @@ +from __future__ import (print_function, absolute_import) __author__ = "swilkins" """ A simple API to the Olog client in python """ +import io +import six from .OlogClient import OlogClient from .OlogDataTypes import LogEntry, Logbook, Tag, Attachment, Property @@ -262,13 +265,13 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, verify = False if logbooks: - if isinstance(logbooks, basestring): + if isinstance(logbooks, six.string_types): logbooks = [logbooks] if tags: - if isinstance(tags, basestring): + if isinstance(tags, six.string_types): tags = [tags] if attachments: - if isinstance(attachments, (Attachment, file)): + if isinstance(attachments, (Attachment, io.IOBase)): attachments = [attachments] if logbooks: @@ -309,7 +312,7 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, for a in attachments: if isinstance(a, Attachment): toattach.append(a) - elif isinstance(a, file): + elif isinstance(a, io.IOBase): toattach.append(Attachment(a)) else: raise ValueError("Attachments must be file objects or \ From e7f5e7b1c0765564ce7c9b92b276d501dae9f231 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 10 Jun 2015 13:24:28 -0400 Subject: [PATCH 75/79] MNT: use items Not worrying about py2k performance. --- pyOlog/SimpleOlogClient.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyOlog/SimpleOlogClient.py b/pyOlog/SimpleOlogClient.py index 7ac4b22..3f4b347 100644 --- a/pyOlog/SimpleOlogClient.py +++ b/pyOlog/SimpleOlogClient.py @@ -297,7 +297,7 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, tags = [Tag(n) for n in tags] if properties: - for x, y in properties.iteritems(): + for x, y in properties.items(): if x not in self.properties: if ensure: self.create_property(x, y.keys()) @@ -305,7 +305,7 @@ def log(self, text=None, logbooks=None, tags=None, properties=None, raise ValueError("Property {} does not exist in Olog". format(x)) - properties = [Property(a, b) for a, b in properties.iteritems()] + properties = [Property(a, b) for a, b in properties.items()] toattach = [] if attachments: From 0f9a6b6761b342e1581be241db2bd2036e6d74db Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 10 Jun 2015 13:27:39 -0400 Subject: [PATCH 76/79] MNT: yet more py3k --- pyOlog/OlogClient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyOlog/OlogClient.py b/pyOlog/OlogClient.py index 4b18c37..8e4165f 100644 --- a/pyOlog/OlogClient.py +++ b/pyOlog/OlogClient.py @@ -324,7 +324,7 @@ class PropertyEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Property): attributes = dict() - for key, value in obj.attributes.iteritems(): + for key, value in obj.attributes.items(): attributes[str(key)] = value prop = OrderedDict() prop["name"] = obj.name From b70dd2109b30e7dbbaa4d4135bf2b6a3c79f47f3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 10 Jun 2015 13:51:22 -0400 Subject: [PATCH 77/79] MNT: yet py3k Open a text file, not as binary file --- pyOlog/cli/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyOlog/cli/utils.py b/pyOlog/cli/utils.py index 34093ac..28d6a0d 100644 --- a/pyOlog/cli/utils.py +++ b/pyOlog/cli/utils.py @@ -50,7 +50,7 @@ def get_screenshot(root=False, itype='png'): def get_text_from_editor(prepend=None, postpend=None): """Open text editor and return text""" - with tempfile.NamedTemporaryFile(suffix='.tmp') as f: + with tempfile.NamedTemporaryFile(suffix='.tmp', mode='w+t') as f: # Write out the file and flush message = '' From 338f1a5565d2c72f668eb541d0d61dda3b1436fc Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 31 Jan 2016 12:02:21 -0500 Subject: [PATCH 78/79] FIX: handle ctrl-c during grabit --- pyOlog/cli/ipy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyOlog/cli/ipy.py b/pyOlog/cli/ipy.py index f7e2f40..1eea5c0 100644 --- a/pyOlog/cli/ipy.py +++ b/pyOlog/cli/ipy.py @@ -62,7 +62,12 @@ def olog_grab(root=False, **kwargs): """ if not root: print("Select area of screen to grab .........") - a = get_screenshot(root) + try: + a = get_screenshot(root) + except KeyboardInterrupt: + print("Canceled, not entry created") + return + if 'attachments' in kwargs: if isinstance(kwargs['attachments'], list): kwargs['attachments'].append(a) From 721fff1dde25701724f3b8fdf5e72381758756cc Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 31 Jan 2016 12:12:06 -0500 Subject: [PATCH 79/79] TYPO: fix warning message --- pyOlog/cli/ipy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyOlog/cli/ipy.py b/pyOlog/cli/ipy.py index 1eea5c0..fe01b8f 100644 --- a/pyOlog/cli/ipy.py +++ b/pyOlog/cli/ipy.py @@ -65,7 +65,7 @@ def olog_grab(root=False, **kwargs): try: a = get_screenshot(root) except KeyboardInterrupt: - print("Canceled, not entry created") + print("Canceled, no entry created") return if 'attachments' in kwargs: