Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ftp module import and small changes #1

Merged
merged 8 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- A deletefile method to the fs_local class (#1).
- Dependency ftputil to the project settings (#1).

### Fixed

- Broken import in ftp filesystem module (#1).
- The intorods.filesys.sync.sync method uses `<fs>.mkdir(path, parents=True)`,
added `parents` kwarg to mkdir for all filesystem classes (#1).

## [0.0.7] - 2023-06-07

### Added

- Migrated internal RIVM version to github.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [

dependencies = [
"cryptography",
"ftputil",
"paramiko",
"python-irodsclient",
"pyyaml",
Expand Down
2 changes: 1 addition & 1 deletion src/intorods/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__VERSION__ = "0.0.7"
__VERSION__ = "0.0.8"
2 changes: 1 addition & 1 deletion src/intorods/filesys/fs_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def getfolder(self, path):
return self.getfile(path)

@abstractmethod
def mkdir(self, path):
def mkdir(self, path, parents=False):
pass

def createfile(self, path):
Expand Down
4 changes: 2 additions & 2 deletions src/intorods/filesys/fs_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import stat
import ftputil
from filesys.fs_base import factory, fsobject_base, fs_base
from intorods.filesys.fs_base import factory, fsobject_base, fs_base
import os
from datetime import datetime

Expand Down Expand Up @@ -100,7 +100,7 @@ def ls(self, path):
pass
return result

def mkdir(self, path):
def mkdir(self, path, parents=False):
exit(1)

def open(self, path, mode):
Expand Down
2 changes: 1 addition & 1 deletion src/intorods/filesys/fs_irods.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def mkdir(self, path, parents=False):
if parents:
parentdir, dir = os.path.split(path)
if not self.folderexists(parentdir):
self.mkdir(parentdir, True)
self.mkdir(parentdir, parents=True)
self.irods_session.collections.create(path)
return folder_irods(self, path)

Expand Down
10 changes: 8 additions & 2 deletions src/intorods/filesys/fs_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ def lsfilenames(self, path):
result = [f.name for f in os.scandir(path) if not f.is_dir()]
return result

def mkdir(self, path):
os.mkdir(path)
def mkdir(self, path, parents=False):
if parents:
os.makedirs(path)
else:
os.mkdir(path)

def open(self, path, mode):
return open(path, mode)

def deletefile(self, path):
os.remove(path)


factory.register('local', fs_local.factory, '')
2 changes: 1 addition & 1 deletion src/intorods/filesys/fs_scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def ls(self, path):
result.append(fileobject)
return result

def mkdir(self, path):
def mkdir(self, path, parents=False):
exit(1)

def open(self, path, mode):
Expand Down
2 changes: 1 addition & 1 deletion src/intorods/filesys/fs_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def ls(self, path):
def lsfilenames(self, path):
return self.sftp.listdir(path)

def mkdir(self, path):
def mkdir(self, path, parents=False):
exit(1)

def open(self, path, mode):
Expand Down
8 changes: 7 additions & 1 deletion src/intorods/filesys/fs_smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import logging
import socket
import tempfile
import os

from smb.SMBConnection import SMBConnection
from smb import smb_constants
from intorods.filesys.fs_base import factory, fsobject_base, fs_base
Expand Down Expand Up @@ -152,7 +154,11 @@ def lsfilenames(self, path):
result.append(entry.filename)
return result

def mkdir(self, path):
def mkdir(self, path, parents=False):
if parents:
parentdir, dir = os.path.split(path)
if not self.folderexists(parentdir):
self.mkdir(parentdir, parents=True)
self.smb_conn.createDirectory(self.share, uxtowin(path))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this adhere to the parents parameter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be simple, I copied the implementation of the irods fs. It uses the folderexists method of the respective fs class. Note: this method uses self.exists(path) for the smb fs, but this exists method does not seem to be implemented.


# TODO
Expand Down