Unverified Commit 5f8d1227 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #115 from jumpserver/dev

Dev
parents 83eb5d1b 4f53020d
......@@ -111,7 +111,9 @@ class ElFinderConnector:
func()
except Exception as e:
self.response['error'] = '%s' % e
logger.error("Error occur ------------------------------")
logger.exception(e)
logger.error("Error end ------------------------------")
def get_request_data(self):
data_source = {}
......
......@@ -88,7 +88,6 @@ class SFTPVolume(BaseVolume):
def list(self, target, name_only=False):
""" Returns a list of files/directories in the target directory. """
path = self._path(target)
print("List {} {}".format(target, path))
with self.lock:
return self._list(path)
......@@ -96,7 +95,6 @@ class SFTPVolume(BaseVolume):
""" Get the sub directory of directory
"""
path = self._path(target)
print("Tree {} {}".format(target, path))
with self.lock:
infos = self._list(path)
tree = list(filter(lambda x: x['mime'] == 'directory', infos))
......@@ -107,7 +105,6 @@ class SFTPVolume(BaseVolume):
获取目录的父目录, 如果deep为0,则直到根
"""
path = self._path(target).rstrip(self.path_sep)
print("Parents {} {}".format(target, path))
with self.lock:
return self._parents(path, depth=depth)
......@@ -173,7 +170,6 @@ class SFTPVolume(BaseVolume):
remote_path = self._remote_path(path)
try:
data = self.sftp.lstat(remote_path)
print(data)
exist = True
except FileNotFoundError:
exist = False
......@@ -188,7 +184,6 @@ class SFTPVolume(BaseVolume):
def paste(self, targets, dest, cut):
""" Moves/copies target files/directories from source to dest. """
print("Paste {} {} {}".format(targets, dest, cut))
dest_parent_path = self._path(dest)
added = []
removed = []
......@@ -198,14 +193,12 @@ class SFTPVolume(BaseVolume):
dest_path = self._join(dest_parent_path, self._base_name(src_path))
if self.is_dir(src_path):
raise OSError("Copy folder unsupported now")
print("Paste {} to => {}".format(src_path, dest_parent_path))
if self.is_exist(dest_path):
print("Exist {}".format(dest_path))
continue
src_remote_path = self._remote_path(src_path)
dest_remote_path = self._remote_path(dest_path)
f = self.sftp.open(src_remote_path, mode='r')
try:
f = self.sftp.open(src_remote_path, mode='r')
attr = self.sftp.putfo(f, dest_remote_path)
if cut:
removed.append(self.remove(target))
......
......@@ -422,7 +422,7 @@
'minsLeft' : '剩余 $1 分钟', // from v2.1.17 added 13.11.2016
'openAsEncoding' : '使用所选编码重新打开', // from v2.1.19 added 2.12.2016
'saveAsEncoding' : '使用所选编码保存', // from v2.1.19 added 2.12.2016
'selectFolder' : '选择目录', // from v2.1.20 added 13.12.2016
'selectFolder' : '选择目录(暂不支持)', // from v2.1.20 added 13.12.2016
'firstLetterSearch': '首字母搜索', // from v2.1.23 added 24.3.2017
'presets' : '预置', // from v2.1.25 added 26.5.2017
'tooManyToTrash' : '项目太多,不能移动到回收站.', // from v2.1.25 added 9.6.2017
......
......@@ -332,7 +332,6 @@ class BaseServer:
return self._cmd_parser.parse_output(self.output_data)
def _parse_input(self):
print("Parse input: {}".format(self.input_data))
if not self.input_data:
return
return self._cmd_parser.parse_input(self.input_data)
......
......@@ -45,7 +45,7 @@ def convert_error(func):
class SFTPServer(paramiko.SFTPServerInterface):
root = 'home' # Home or /tmp or other path, must exist on all server
root = '/tmp' # Home or /tmp or other path, must exist on all server
def __init__(self, server, **kwargs):
"""
......@@ -73,6 +73,8 @@ class SFTPServer(paramiko.SFTPServerInterface):
self.server.connection.user
)
for asset in assets:
if asset.protocol != 'ssh':
continue
value = {}
key = asset.hostname
if asset.org_id:
......@@ -96,7 +98,6 @@ class SFTPServer(paramiko.SFTPServerInterface):
active_channels = [c for c in trans._channels.values() if not c.closed]
if not active_channels:
print("CLose transport")
trans.close()
if proxy:
proxy.close()
......@@ -414,6 +415,9 @@ class InternalSFTPClient(SFTPServer):
attr = super().lstat.__wrapped__(self, path)
return attr
def rmdir(self, path):
return super().rmdir.__wrapped__(self, path)
def get_channel(self):
return FakeChannel.new()
......@@ -422,7 +426,13 @@ class InternalSFTPClient(SFTPServer):
def putfo(self, f, path, callback=None, confirm=True):
client, rpath = self.get_sftp_client_rpath(path)
return client.putfo(f, rpath, callback=callback, confirm=confirm)
success = False
try:
attr = client.putfo(f, rpath, callback=callback, confirm=confirm)
success = True
return attr
finally:
self.create_ftp_log(path, 'Upload', success)
def close(self):
return self.session_ended()
......@@ -13,6 +13,10 @@ import argparse
import time
import signal
dirs = ('logs', 'keys')
for d in dirs:
os.makedirs(d, exist_ok=True)
from coco import Coco
try:
......@@ -21,9 +25,6 @@ except ImportError:
print("Please prepare config file `cp conf_example.py conf.py`")
sys.exit(1)
dirs = ('logs', 'keys')
for d in dirs:
os.makedirs(d, exist_ok=True)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DAEMON = False
......@@ -119,7 +120,7 @@ if __name__ == '__main__':
description="""
coco service control tools;
Example: \r\n
Example: \r\n
%(prog)s start -d;
"""
......
......@@ -18,7 +18,7 @@ idna==2.6
itsdangerous==0.24
Jinja2==2.10
jmespath==0.9.3
jms-storage==0.0.18
jms-storage==0.0.19
jumpserver-python-sdk==0.0.50
MarkupSafe==1.0
oss2==2.4.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment