Skip to content

Commit

Permalink
add 3.1.2 for release
Browse files Browse the repository at this point in the history
bug fix for obj (ftp)
  • Loading branch information
mythmgn committed Dec 10, 2019
1 parent a679584 commit 7ca74cd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
44 changes: 43 additions & 1 deletion cup/storage/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def rmdir(self, path, recursive=True):
}
"""

@abc.abstractmethod
def rename(self, frompath, topath):
"""rename from path to path"""


class AFSObjectSystem(ObjectInterface):
"""
Expand Down Expand Up @@ -221,6 +225,10 @@ def mkdir(self, path):
def rmdir(self, path):
"""rmdir of a path"""

def rename(self, frompath, topath):
"""rename"""
raise err.NotImplementedYet('AFSObjectSystem.rename')


# pylint: disable=R0902
# need to have so many
Expand Down Expand Up @@ -476,6 +484,10 @@ def delete_bucket(self, bucket_name, forcely=False):
ret['msg'] = str(error)
return ret

def rename(self, frompath, topath):
"""rename"""
raise err.NotImplementedYet('AFSObjectSystem.rename')


class FTPObjectSystem(ObjectInterface):
"""
Expand Down Expand Up @@ -511,7 +523,7 @@ def __init__(self, config):
self._host = self._uri.split(':')[1][2:]
self._port = ftplib.FTP_PORT
if len(self._uri.split(':')[2]) > 0:
self.port = int(self._uri.split(':')[2])
self._port = int(self._uri.split(':')[2])
self._ftp_con.connect(self._host, self._port, self._dufault_timeout)
self._ftp_con.login(self._user, self._passwd)
self._last_optime = time.time()
Expand Down Expand Up @@ -755,6 +767,21 @@ def _call_back(arg):
self._ftp_con.cwd(cwd)
return False

def rename(self, frompath, topath):
"""rename frompath to path"""
ret = {
'returncode': 0,
'msg': 'success'
}
try:
self._ftp_con.rename(frompath, topath)
except Exception as error:
ret['returncode'] = -1
ret['msg'] = 'failed to rename from {0} to {1}'.format(
frompath, topath
)
return ret


class LocalObjectSystem(ObjectInterface):
"""local object system"""
Expand Down Expand Up @@ -868,4 +895,19 @@ def rmdir(self, path, recursive=True):
ret['msg'] = 'failed to rmdir, err:{0}'.format(error)
return ret

def rename(self, frompath, topath):
"""rename from path to path"""
ret = {
'returncode': 0,
'msg': 'success'
}
try:
os.rename(frompath, topath)
except IOError as error:
ret['returncode'] = -1
ret['msg'] = 'failed to rename {0} to {1}'.format(
frompath, topath
)
return ret

# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent
2 changes: 1 addition & 1 deletion cup/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]


VERSION = '3.1.0'
VERSION = '3.1.2'
AUTHOR = 'CUP-DEV Team'

# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
print(traceback.print_exc())
exit(-1)

with open('README.md', 'r',encoding='utf-8') as fh:
with open('README.md', 'r', encoding='utf-8') as fh:
LONG_DESCRIPTION = fh.read()

# Guannan add windows platform support on 2014/11/4 20:04
Expand Down

0 comments on commit 7ca74cd

Please sign in to comment.