Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
e0bbd459
Commit
e0bbd459
authored
Aug 01, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 解决sftp的问题
parent
9711195f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
sftp.py
coco/sftp.py
+9
-2
No files found.
coco/sftp.py
View file @
e0bbd459
...
...
@@ -51,10 +51,16 @@ class SFTPServer(paramiko.SFTPServerInterface):
return
self
.
_sftp
[
host
][
'sftp'
]
def
get_perm_hosts
(
self
):
hosts
=
{}
assets
=
app_service
.
get_user_assets
(
self
.
server
.
request
.
user
)
return
{
asset
.
hostname
:
asset
for
asset
in
assets
}
for
asset
in
assets
:
key
=
asset
.
hostname
if
asset
.
org_id
:
key
=
"{}.{}"
.
format
(
asset
.
hostname
,
asset
.
org_name
)
hosts
[
key
]
=
asset
return
hosts
def
parse_path
(
self
,
path
):
data
=
path
.
lstrip
(
'/'
)
.
split
(
'/'
)
...
...
@@ -89,11 +95,12 @@ class SFTPServer(paramiko.SFTPServerInterface):
def
create_ftp_log
(
self
,
path
,
operate
,
is_success
=
True
,
filename
=
None
):
host
,
su
,
rpath
=
self
.
parse_path
(
path
)
asset
=
self
.
hosts
.
get
(
host
)
date_start
=
datetime
.
utcnow
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
+
" +0000"
,
data
=
{
"user"
:
self
.
server
.
request
.
user
.
username
,
"asset"
:
host
,
"org_id"
:
self
.
server
.
asset
.
org_id
,
"org_id"
:
asset
.
org_id
,
"system_user"
:
su
,
"remote_addr"
:
self
.
server
.
request
.
addr
[
0
],
"operate"
:
operate
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment