Example #1
0
def test_bad_values_fail():
    for i, s in [(4, "target_path = /wasdfkshdf"),
                 (6, "inbox_path = /dfsdfhljfwe/wefsdfh")]:
        new_lines = copy.copy(conf_lines)
        new_lines[i] = s
        h = cStringIO.StringIO('\n'.join(new_lines))
        with pytest.raises(ValueError):
            config.read_configuration(h)
Example #2
0
def test_bad_values_fail():
    for i,s in [(4,"target_path = /wasdfkshdf"),
                (6,"inbox_path = /dfsdfhljfwe/wefsdfh")]:
        new_lines = copy.copy(conf_lines)
        new_lines[i] = s
        h = cStringIO.StringIO('\n'.join(new_lines))
        with pytest.raises(ValueError):
            config.read_configuration(h)
Example #3
0
    def action(self):
        omit_blast = self.omit_blast
        with open(self.config_path) as h:
            config = cf.read_configuration(h)
        monitor_path = config['target_path']
        syslog.syslog(syslog.LOG_NOTICE, "sequencereportd monitoring %s for runs to process." % monitor_path)
        class Handler(pyinotify.ProcessEvent):
            def process_IN_UNMOUNT(self, event):
                syslog.syslog(syslog.LOG_NOTICE, "Backing filesystem of %s was unmounted. Exiting." % \
                                  (event.path,))
                exit(0)
            def process_default(self, event):
                syslog.syslog(syslog.LOG_NOTICE, "Event on %s in monitored share." % (event.pathname,))
                if event.name != 'workup.json' and \
                        not event.name.endswith('.ab1'):
                    syslog.syslog(syslog.LOG_NOTICE, "Ignoring event on %s." % (event.pathname,))
                    return

                wrote, result = try_report(event.path, omit_blast)
                if not wrote:
                    syslog.syslog(syslog.LOG_NOTICE, "No action in %s: %s" % \
                                      (event.path,result))
                else:
                    syslog.syslog(syslog.LOG_NOTICE, "Wrote report in %s." % (result,))
        wm = pyinotify.WatchManager()
        notifier = pyinotify.Notifier(wm, Handler())
        wm.add_watch(monitor_path,
                     pyinotify.IN_CREATE |
                     pyinotify.IN_DELETE |
                     pyinotify.IN_MOVED_TO |
                     pyinotify.IN_ATTRIB | 
                     pyinotify.IN_MODIFY,
                     rec=True)
        notifier.loop()
Example #4
0
 def action(self):
     with open(self.config_path) as h:
         config = cf.read_configuration(h)
     monitor_path = config['target_path']
     syslog.syslog(syslog.LOG_NOTICE, "dailysummaryd monitoring %s for reports to summarize." % monitor_path)
     class Handler(pyinotify.ProcessEvent):
         def process_IN_UNMOUNT(self, event):
             syslog.syslog(syslog.LOG_NOTICE, "Backing filesystem of %s was unmounted. Exiting." % \
                               (event.path,))
             exit(0)
         def process_default(self, event):
             syslog.syslog(syslog.LOG_NOTICE, "Event on %s in monitored share." % (event.pathname,))
             if not event.name.endswith('report.html'):
                 syslog.syslog(syslog.LOG_NOTICE, "Ignoring event on %s." % (event.pathname,))
                 return
             wrote, result = summarize(os.path.dirname(event.path))
             if not wrote:
                 syslog.syslog(syslog.LOG_NOTICE, "No action in %s: %s" % \
                                   (event.path,result))
             else:
                 syslog.syslog(syslog.LOG_NOTICE, "Wrote summary in %s." % (result,))
     wm = pyinotify.WatchManager()
     notifier = pyinotify.Notifier(wm, Handler())
     wm.add_watch(monitor_path,
                  pyinotify.IN_CREATE |
                  pyinotify.IN_DELETE |
                  pyinotify.IN_MOVED_TO |
                  pyinotify.IN_ATTRIB | 
                  pyinotify.IN_MODIFY,
                  rec=True)
     notifier.loop()
Example #5
0
def test_good_config_works():
    good_config = cStringIO.StringIO('\n'.join(conf_lines))
    assert config.read_configuration(good_config) == \
        {'target_path': '/var',
         'inbox_path': '/usr/bin',
         'db_port': 5432, 'db_name': 'mdx',
         'db_server': 'localhost', 'db_username': '******',
         'db_credentials': 'data/dbcredential', 'db_password': '******'}
Example #6
0
def test_good_config_works():
    good_config = cStringIO.StringIO('\n'.join(conf_lines))
    assert config.read_configuration(good_config) == \
        {'target_path': '/var',
         'inbox_path': '/usr/bin', 
         'db_port': 5432, 'db_name': 'mdx', 
         'db_server': 'localhost', 'db_username': '******', 
         'db_credentials': 'data/dbcredential', 'db_password': '******'}
Example #7
0
 def action(self):
     with open(self.config_path) as h:
         config = cf.read_configuration(h)
     db = oursql.connect(host=config['db_server'],
                         user=config['db_username'],
                         passwd=config['db_password'],
                         db=config['db_name'],
                         port=config['db_port'])
 
     syslog.syslog(syslog.LOG_NOTICE, "Placed monitoring %s for incoming files." % (config['inbox_path'],))
 
     class Handler(pyinotify.ProcessEvent):
         def process_IN_UNMOUNT(self, event):
             syslog.syslog(syslog.LOG_NOTICE, "Backing filesystem of %s was unmounted. Exiting." % event.path)
             exit(0)
         def process_default(self, event):
             syslog.syslog(syslog.LOG_NOTICE, "File %s created...processing." % (event.pathname,))
             seqlab.place.placewrapper(db, event.pathname, config['target_path'])
 
     wm = pyinotify.WatchManager()
     notifier = pyinotify.Notifier(wm, Handler())
     wm.add_watch(config['inbox_path'], pyinotify.IN_CREATE, rec=True)
     notifier.loop()