def on_modified(self, event):
        '''
        Listens for modifications of the given log file and executes QC workflow on the newly copied file.
        @param event: is triggered on any file modification within the directory monitored
        '''
        # Only watch for changes on file 'robocopy'
        event_file = event.__dict__['_src_path']
        if not 'robocopy' in event_file:
            return

        self.service.log("{0} New robocopy event".format(self.get_time()))

        # Actually process the robocopy log file and any new RAW files, which will take some time
        qc_pipeline(self.indir, self.outdir, event_file)
        # Call function again in case new file(s) were copied during the run.
        # It will return without running if now new files are ready for processing
        qc_pipeline(self.indir, self.outdir, event_file)

        self.service.log("{0} Monitoring for new RAW files..".format(self.get_time()))
if __name__ == "__main__":
    # Program can be called with 'install' as only argument which triggers a service installation
    if sys.argv[1] == 'install':
        instart(QCMonitorService, 'ctmm-qc', 'ctmm_qc-monitor')
    else:
        # Create and parse command line arguments
        parser = ArgumentParser(description='QC-workflow monitor for MS data using NIST metrics')
        parser.add_argument('indir', type=str,
                            help='Input folder containing (Thermo) RAW files outputted by a mass-spectrometer')
        parser.add_argument('outdir', type=str, help='Folder in which output (report) PDF files will be written')
        # If no copylog folder is supplied, the QC pipeline will be ran a single time on the indir
        # directory and will process all non-processed RAW files within this folder. After processing
        # the process will stop
        parser.add_argument('copylogdir', type=str, help=('(Optional) Directory containing logfile (local) that'
                                                          ' Robocopy uses to write status messages (should be named:'
                                                          ' "robocopy.*". If missing, the QC tool will process all'
                                                          ' RAW files in the given indir and uses the QC'
                                                          ' log file for tracking already processed files'), 
                            nargs='?')

        #Extract arguments
        args = parser.parse_args()

        # If no copylogdir is given, process all files in indir
        if args.copylogdir == None:
            qc_pipeline(args.indir, args.outdir, None)
        else:
            # Create new monitor checking for changes in the given robocopy logfile
            monitor = QCMonitor(args.indir, args.outdir, args.copylogdir)
            monitor.start()
        '''
        Sets paths to input / output directories etc.
        @param indir: directory to monitor for file changes
        @param outdir: directory to store output (passed to QC tool)
        '''
        self.indir = indir
        self.outdir = outdir
        print "Monitoring:  \nInput Dir:   {0}\nOutput Dir:  {1}".format(self.indir, self.outdir)

if __name__ == "__main__":
    # Program can be called with 'install' as only argument which triggers a service installation
    # Create and parse command line arguments
    parser = ArgumentParser(description='QC-workflow monitor for MS data using NIST metrics')
    parser.add_argument('indir', type=str,
                        help='Input folder containing (Thermo) RAW files outputted by a mass-spectrometer')
    parser.add_argument('outdir', type=str, help='Folder in which temporary folders and files will be created')
    # If no copylog folder is supplied, the QC pipeline will be ran a single time on the indir
    # directory and will process all non-processed RAW files within this folder. After processing
    # the process will stop

    #Extract arguments
    args = parser.parse_args()
    try:
        while True:
            status = qc_pipeline(args.indir, args.outdir)
            if status == False:
                print"Finished QC processing of existing files from {0}.\n reinvoking QC pipeline after 1 minute.".format(args.indir)
                sleep(60)
    except KeyboardInterrupt:
        print "Shutdown requested...exiting"
        sys.exit(0)