Пример #1
0
	def sync(self):
		r = csynclib.csync_create(self.ctx, self.cfg['src'], self.cfg['url'])
		if r != 0:
			error(self.ctx,'csync_create', r)
		csynclib.csync_set_log_callback(self.ctx, csynclib.csync_log_callback(log))
		acb = csynclib.csync_auth_callback(authCallback)
		if DEBUG:
			print 'authCallback setup'
		csynclib.csync_set_auth_callback(self.ctx, acb)

		r = csynclib.csync_init(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_init', r)
		if DEBUG:
			print 'Initialization done.'
		#csynclib.csync_set_log_verbosity(self.ctx, ctypes.c_int(11))
		r = csynclib.csync_update(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_update', r)
		if DEBUG:
			print 'Update done.'
		r = csynclib.csync_reconcile(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_reconcile', r)
		if DEBUG:
			print 'Reconcile done.'
		r = csynclib.csync_propagate(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_propogate', r)
		if DEBUG:
			print 'Propogate finished, destroying.'
		r = csynclib.csync_destroy(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_destroy', r)
		return
Пример #2
0
    def sync(self):
        r = csynclib.csync_create(self.ctx, self.cfg['src'], self.cfg['url'])
        if r != 0:
            error(self.ctx, 'csync_create', r)
        csynclib.csync_set_log_callback(self.ctx,
                                        csynclib.csync_log_callback(log))
        acb = csynclib.csync_auth_callback(authCallback)
        if DEBUG:
            print 'authCallback setup'
        csynclib.csync_set_auth_callback(self.ctx, acb)

        r = csynclib.csync_init(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_init', r)
        if DEBUG:
            print 'Initialization done.'
        if self.cfg.has_key('usedownloadlimit') or self.cfg.has_key(
                'useuploadlimit'):
            if csynclib.csync_version(CSYNC_VERSION_INT(0, 81, 0)) is None:
                print 'Bandwidth throttling requires ocsync version >= 0.81.0, ignoring limits'
            else:
                if self.cfg.has_key('usedownloadlimit') and self.cfg[
                        'usedownloadlimit'] and self.cfg.has_key(
                            'downloadlimit'):
                    dlimit = ctypes.c_int(
                        int(self.cfg['downloadlimit']) * 1000)
                    if DEBUG:
                        print 'Download limit: ', dlimit.value
                    csynclib.csync_set_module_property(
                        self.ctx, 'bandwidth_limit_download',
                        ctypes.pointer(dlimit))
                if self.cfg.has_key('useuploadlimit') and self.cfg[
                        'useuploadlimit'] and self.cfg.has_key('uploadlimit'):
                    ulimit = ctypes.c_int(int(self.cfg['uploadlimit']) * 1000)
                    if DEBUG:
                        print 'Upload limit: ', ulimit.value
                    csynclib.csync_set_module_property(
                        self.ctx, 'bandwidth_limit_upload',
                        ctypes.pointer(ulimit))
        #csynclib.csync_set_log_verbosity(self.ctx, ctypes.c_int(11))
        r = csynclib.csync_update(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_update', r)
        if DEBUG:
            print 'Update done.'
        r = csynclib.csync_reconcile(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_reconcile', r)
        if DEBUG:
            print 'Reconcile done.'
        r = csynclib.csync_propagate(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_propogate', r)
        if DEBUG:
            print 'Propogate finished, destroying.'
        r = csynclib.csync_destroy(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_destroy', r)
        return
Пример #3
0
	def sync(self):
		r = csynclib.csync_create(self.ctx, self.cfg['src'], self.cfg['url'])
		if r != 0:
			error(self.ctx,'csync_create', r)
		csynclib.csync_set_log_callback(self.ctx, csynclib.csync_log_callback(log))
		acb = csynclib.csync_auth_callback(authCallback)
		if DEBUG:
			print 'authCallback setup'
		csynclib.csync_set_auth_callback(self.ctx, acb)

		r = csynclib.csync_init(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_init', r)
		if DEBUG:
			print 'Initialization done.'
		if self.cfg.has_key('usedownloadlimit') or self.cfg.has_key('useuploadlimit'):
			if csynclib.csync_version(CSYNC_VERSION_INT(0,81,0)) is None:
				print 'Bandwidth throttling requires ocsync version >= 0.81.0, ignoring limits'
			else:
				if self.cfg.has_key('usedownloadlimit') and self.cfg['usedownloadlimit'] and self.cfg.has_key('downloadlimit'):
					dlimit = ctypes.c_int(int(self.cfg['downloadlimit']) * 1000)
					if DEBUG:
						print 'Download limit: ', dlimit.value
					csynclib.csync_set_module_property(self.ctx, 'bandwidth_limit_download', ctypes.pointer(dlimit))
				if self.cfg.has_key('useuploadlimit') and self.cfg['useuploadlimit'] and self.cfg.has_key('uploadlimit'):
					ulimit = ctypes.c_int(int(self.cfg['uploadlimit']) * 1000)
					if DEBUG:
						print 'Upload limit: ', ulimit.value
					csynclib.csync_set_module_property(self.ctx,'bandwidth_limit_upload',ctypes.pointer(ulimit))
		#csynclib.csync_set_log_verbosity(self.ctx, ctypes.c_int(11))
		r = csynclib.csync_update(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_update', r)
		if DEBUG:
			print 'Update done.'
		r = csynclib.csync_reconcile(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_reconcile', r)
		if DEBUG:
			print 'Reconcile done.'
		r = csynclib.csync_propagate(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_propogate', r)
		if DEBUG:
			print 'Propogate finished, destroying.'
		r = csynclib.csync_destroy(self.ctx)
		if r != 0:
			error(self.ctx, 'csync_destroy', r)
		return
Пример #4
0
	def sync(self):
		r = csynclib.csync_create(self.ctx, self.cfg['src'], self.cfg['url'])
		if r != 0:
			self.error('csync_create', r)
		
		csynclib.csync_set_log_callback(self.ctx, self.get_log_callback())
		csynclib.csync_set_log_verbosity(self.ctx, self.cfg['verbosity_ocsync'])

		self.logger.debug('authCallback setup')
		csynclib.csync_set_auth_callback(self.ctx, self.get_auth_callback())

		if self.cfg['progress']:
			csynclib.csync_set_progress_callback(self.ctx, self.get_progress_callback())
		
		r = csynclib.csync_init(self.ctx)
		if r != 0:
			self.error('csync_init', r)
		self.logger.debug('Initialization done.')
		if (self.cfg.has_key('downloadlimit') and self.cfg['downloadlimit']) or \
			(self.cfg.has_key('uploadlimit') and self.cfg['uploadlimit']):
			if csynclib.csync_version(CSYNC_VERSION_INT(0,81,0)) is None:
				self.logger.warning('Bandwidth throttling requires ocsync version >= 0.81.0, ignoring limits')
			else:
				if self.cfg.has_key('downloadlimit') and self.cfg['downloadlimit']:
					dlimit = ctypes.c_int(int(self.cfg['downloadlimit']) * 1000)
					self.logger.debug('Download limit: %i', dlimit.value)
					csynclib.csync_set_module_property(self.ctx, 'bandwidth_limit_download', ctypes.pointer(dlimit))
				if self.cfg.has_key('uploadlimit') and self.cfg['uploadlimit']:
					ulimit = ctypes.c_int(int(self.cfg['uploadlimit']) * 1000)
					self.logger.debug('Upload limit: %i', ulimit.value)
					csynclib.csync_set_module_property(self.ctx,'bandwidth_limit_upload',ctypes.pointer(ulimit))
		r = csynclib.csync_update(self.ctx)
		if r != 0:
			self.error('csync_update', r)
		self.logger.debug('Update done.')
		r = csynclib.csync_reconcile(self.ctx)
		if r != 0:
			self.error('csync_reconcile', r)
		self.logger.debug('Reconcile done.')
		r = csynclib.csync_propagate(self.ctx)
		if r != 0:
			self.error('csync_propogate', r)
		self.logger.debug('Propogate finished, destroying.')
		r = csynclib.csync_destroy(self.ctx)
		if r != 0:
			self.error('csync_destroy', r)
Пример #5
0
    def sync(self):
        r = csynclib.csync_create(self.ctx, self.cfg['src'], self.cfg['url'])
        if r != 0:
            error(self.ctx, 'csync_create', r)
        csynclib.csync_set_log_callback(self.ctx,
                                        csynclib.csync_log_callback(log))
        acb = csynclib.csync_auth_callback(authCallback)
        if DEBUG:
            print 'authCallback setup'
        csynclib.csync_set_auth_callback(self.ctx, acb)

        r = csynclib.csync_init(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_init', r)
        if DEBUG:
            print 'Initialization done.'
        #csynclib.csync_set_log_verbosity(self.ctx, ctypes.c_int(11))
        r = csynclib.csync_update(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_update', r)
        if DEBUG:
            print 'Update done.'
        r = csynclib.csync_reconcile(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_reconcile', r)
        if DEBUG:
            print 'Reconcile done.'
        r = csynclib.csync_propagate(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_propogate', r)
        if DEBUG:
            print 'Propogate finished, destroying.'
        r = csynclib.csync_destroy(self.ctx)
        if r != 0:
            error(self.ctx, 'csync_destroy', r)
        return