def process_IN_MODIFY(self, event):
        """
        This class is the default execution for all events
        """
        date = datetime.today()
        message = date.__str__() + ' : ' +  'Alteracao no diretorio %s' % event.pathname
        print >> sys.stderr, message

        # Create datadaemon instance
        d = datadaemon.datadaemon()

        # Setup files list
        d.files = []
        d.files.append('file://' + event.pathname)
        #for file in event.pathname:
            # Add URL formatting
        #    d.files.append('file://' + event.pathname)

        # Run storage
        try:
            d.run()

            # Remove object as it's no longer necessary
            del d
        except:
            date = datetime.today()
            message = date.__str__() + ' : files storage error' + traceback.format_exc()
            print >> sys.stderr, message

            # Remove object as it's no longer necessary
            del d
示例#2
0
    def execute(self):
        """
        Run datadaemon
        """
        if not self.options.file_url:
            log.error('You have to supply URL for this option')
            return

        # You have to supply files full path
        d = datadaemon.datadaemon()

        # Have to supply file in URL format
        d.file_url = self.options.file_url

        # Execute it
        d.run()
    def setUp(self):
        """
        Create test necessary objects, opens database connections,
        find files, etc.
        """
        test_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/test-zip/document.zip')

        # Copy it to tmp so we don't lose the file
        tmp_file = '/tmp/pareceres_zips.zip'
        shutil.copy2(test_file, tmp_file)

        # Add URL formatting to tile
        self.url_file = 'file://%s' % tmp_file

        class TestES(es.ESIntegration):
            # Overload ckanclient loading
            def load_ckanclient(self):
                """
                Load test instance
                """
                # Load ckanclient Test instance
                client_test.setup_class()

                return client_test.c

        # Setup ESIntegration test data
        self.es_instance = TestES()

        # Teste indice
        self.es_instance.indice = 'lbdf-teste'

        # Index and mappings create
        #response = self.es_instance.indice_create()
        self.es_instance.types_create()

        # Document in object
        test_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static/document.data')
        f = open(test_file, 'r')
        self.document = pickle.load(f)
        f.close()

        # Datadaemon instance
        self.d_instance = datadaemon.datadaemon()
        self.d_instance.es_instance.indice = 'lbdf-teste'

        # Dataset list from Ckan
        self.dataset_list = client_test.package_register_get()