def handle(self, *args, **options):
        """ execute sync command """
        # store verbosity level in instance attribute for later use
        self.verbosity = int(options.get('verbosity'))
        # blank line
        self.stdout.write('\r\n')
        # retrieve layers
        layers = self.retrieve_layers(*args, **options)

        if len(layers) < 1:
            self.stdout.write('no layers to process\n\r')
            return
        else:
            self.verbose('going to process %d layers...' % len(layers))

        # loop over
        for layer in layers:
            # retrieve interop class if available
            try:
                synchronizer_path = layer.external.synchronizer_path
            except (ObjectDoesNotExist, AttributeError):
                self.stdout.write('External Layer %s does not have a synchronizer class specified\n\r' % layer.name)
                continue

            # if no synchronizer_path jump to next layer
            if synchronizer_path == 'None':
                self.stdout.write('External Layer %s does not have a synchronizer class specified\n\r' % layer.name)
                continue

            if layer.external.config is None:
                self.stdout.write('Layer %s does not have a config yet\n\r' % layer.name)
                continue

            # retrieve class
            synchronizer = import_by_path(synchronizer_path)
            self.stdout.write('imported module %s\r\n' % synchronizer.__name__)

            # try running
            try:
                instance = synchronizer(layer, verbosity=self.verbosity)
                self.stdout.write('Processing layer "%s"\r\n' % layer.slug)
                messages = instance.sync()
            except ImproperlyConfigured as e:
                self.stdout.write('Validation error: %s\r\n' % e)
                continue
            except Exception as e:
                self.stdout.write('Got Exception: %s\r\n' % e)
                exception(e)
                continue

            for message in messages:
                self.stdout.write('%s\n\r' % message)

        self.stdout.write('\r\n')
def handle ( self , * args , ** options ) : self . verbosity = int ( options . get ( 'verbosity' ) ) self . stdout . write ( '\r\n' ) layers = self . retrieve_layers ( * args , ** options ) if len ( layers ) < 1 : self . stdout . write ( 'no layers to process\n\r' ) return else : self . verbose ( 'going to process %d layers...' % len ( layers ) ) for layer in layers : try : synchronizer_path = layer . external . synchronizer_path except ( ObjectDoesNotExist , AttributeError ) : self . stdout . write ( 'External Layer %s does not have a synchronizer class specified\n\r' % layer . name ) continue if synchronizer_path == 'None' : self . stdout . write ( 'External Layer %s does not have a synchronizer class specified\n\r' % layer . name ) continue if layer . external . config is None : self . stdout . write ( 'Layer %s does not have a config yet\n\r' % layer . name ) continue synchronizer = import_by_path ( synchronizer_path ) self . stdout . write ( 'imported module %s\r\n' % synchronizer . __name__ ) try : instance = synchronizer ( layer , verbosity = self . verbosity ) self . stdout . write ( 'Processing layer "%s"\r\n' % layer . slug ) messages = instance . sync ( ) except ImproperlyConfigured as e : self . stdout . write ( 'Validation error: %s\r\n' % e ) continue except Exception as e : self . stdout . write ( 'Got Exception: %s\r\n' % e ) exception ( e ) continue for message in messages : self . stdout . write ( '%s\n\r' % message ) self . stdout . write ( '\r\n' )
execute sync command