def tearDownZope(self, app): handle = DAVFS(WEBDAV_URL, credentials=dict(username=WEBDAV_USERNAME, password=WEBDAV_PASSWORD)) if handle.exists(self.testing_directory): handle.removedir(self.testing_directory, recursive=True, force=True) z2.uninstallProduct(app, 'xmldirector.plonecore')
def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir): from fs.contrib.davfs import DAVFS url = fs_path if '://' not in url: url = 'http://' + url scheme, url = url.split('://', 1) username, password, url = _parse_credentials(url) credentials = None if username or password: credentials = {} if username: credentials['username'] = username if password: credentials['password'] = password url = '%s://%s' % (scheme, url) fs = DAVFS(url, credentials=credentials) return fs, ''
def __init__(self, root, dav_url, dav_user=None, dav_pw=None): super(DavFsDataStore, self).__init__(root) parsed = urlparse(dav_url) self.dav_user = dav_user or parsed.username self.dav_pw = dav_pw or parsed.password self.dav_url = parsed.geturl() self.dav_fs = DAVFS(url=self.dav_url, credentials={'username': self.dav_user, 'password': self.dav_pw})
def webdav_handle(self, subpath=None): """ Return WebDAV handle to root of configured connector object including configured webdav_subpath. """ registry = getUtility(IRegistry) settings = registry.forInterface(IWebdavSettings) adapted = IConnector(self) url = adapted.webdav_url or settings.webdav_url if adapted.webdav_subpath: url += '/{}'.format(adapted.webdav_subpath) if subpath: url += '/{}'.format(urllib.quote(subpath)) # system-wide credentials username = settings.webdav_username password = settings.webdav_password # local credentials override the system credentials if adapted.webdav_username and adapted.webdav_password: username = adapted.webdav_username password = adapted.webdav_password try: return DAVFS(url, credentials=dict(username=username, password=password)) except Exception as e: e.url = url raise e
def webdav_handle(self): """ Return WebDAV handle """ registry = getUtility(IRegistry) settings = registry.forInterface(IWebdavSettings) root_url = settings.webdav_url username = settings.webdav_username password = settings.webdav_password if settings.webdav_dexterity_subpath: url = '{}/{}'.format(root_url, settings.webdav_dexterity_subpath) else: url = root_url try: return DAVFS(url, credentials=dict(username=username, password=password)) except fs.errors.ResourceNotFoundError: root_handle = DAVFS(root_url, credentials=dict(username=username, password=password)) root_handle.makedir(settings.webdav_dexterity_subpath, True, True) return DAVFS(url, credentials=dict(username=username, password=password))
#super(httplib.HTTPSConnection, self).__init__(host, port, key_file, cert_file, strict, timeout, source_address, context) httplib.HTTPSConnection.__init__(self, host, port, key_file, cert_file, strict, timeout, source_address, context) # http://stackoverflow.com/questions/5319430/how-do-i-have-python-httplib-accept-untrusted-certs credentials = { 'username':os.environ['OC_USER'], 'password':os.environ['OC_PASS'] } connection_classes = { "http": httplib.HTTPConnection, "https": UnsecureHTTPSConnection, } dvfs = DAVFS("https://quamis.go.ro/owncloud/remote.php/webdav/", credentials=credentials, connection_classes=connection_classes ) #print dvfs.getinfo("/") #print dvfs.listdir("/de lasat acasa/") #print dvfs.listdir("/GoogleDrive/") # http://docs.pyfilesystem.org/en/latest/interface.html #dirs = dvfs.ilistdirinfo("/") #for d in dirs: # print d t1 = time.time() files = [] for (ocd, ocf) in dvfs.walk("/de lasat acasa/"): for f in ocf: