Exemple #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
Exemple #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
Exemple #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
Exemple #4
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
Exemple #5
0
	def get_log_callback(self):
		def log_wrapper(ctx, verbosity, function, buffer, userdata):
			return self.log(verbosity, function, buffer, userdata)
		if not self.log_callback:
			self.log_callback = csynclib.csync_log_callback(log_wrapper)
		return self.log_callback