Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 3
0
	def get_auth_callback(self):
		"""gives back the auth callback:
			The actual function is called out of the ownCloudSync object."""
		def auth_wrapper(prompt, buffer, bufferLength, echo, verify, userData):
			return self.authCallback(prompt, buffer, bufferLength, echo, verify, userData)
		if not self.auth_callback:
			self.auth_callback = csynclib.csync_auth_callback(auth_wrapper)
		return self.auth_callback
Exemplo n.º 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.'
		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
Exemplo n.º 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