Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
fb8b800f
Commit
fb8b800f
authored
Oct 09, 2014
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传
parent
67b0cd55
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
views.py
webroot/AutoSa/AutoSa/views.py
+13
-0
upFile.html
webroot/AutoSa/templates/upFile.html
+1
-1
No files found.
webroot/AutoSa/AutoSa/views.py
View file @
fb8b800f
...
@@ -17,6 +17,7 @@ import ldap.modlist as modlist
...
@@ -17,6 +17,7 @@ import ldap.modlist as modlist
import
crypt
import
crypt
import
hashlib
import
hashlib
from
UserManage.forms
import
UserAddForm
,
GroupAddForm
from
UserManage.forms
import
UserAddForm
,
GroupAddForm
import
paramiko
base_dir
=
"/opt/jumpserver/"
base_dir
=
"/opt/jumpserver/"
...
@@ -900,7 +901,19 @@ def upFile(request):
...
@@ -900,7 +901,19 @@ def upFile(request):
for
chunk
in
upload_file
.
chunks
():
for
chunk
in
upload_file
.
chunks
():
f
.
write
(
chunk
)
f
.
write
(
chunk
)
f
.
close
()
f
.
close
()
asset
=
Assets
.
objects
.
get
(
ip
=
host
,
None
)
if
asset
:
port
=
asset
.
port
jm
=
PyCrypt
(
key
)
user
=
User
.
objects
.
get
(
username
)
t
=
paramiko
.
Transport
(
host
,
port
)
t
.
connect
(
username
=
username
,
password
=
jm
.
decrypt
(
user
.
password
))
sftp
=
paramiko
.
SFTPClient
.
from_transport
(
t
)
sftp
.
put
(
filename
,
path
)
return
HttpResponse
(
'save
%
s Ok, size
%
s'
%
(
upload_file
.
name
,
upload_file
.
size
))
return
HttpResponse
(
'save
%
s Ok, size
%
s'
%
(
upload_file
.
name
,
upload_file
.
size
))
else
:
return
render_to_response
(
'info.html'
,
{
'error'
:
u"上传失败"
})
return
render_to_response
(
'upFile.html'
,
return
render_to_response
(
'upFile.html'
,
{
'username'
:
username
},
{
'username'
:
username
},
...
...
webroot/AutoSa/templates/upFile.html
View file @
fb8b800f
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"file"
class=
"col-sm-2 control-label"
>
上传目录
<span
style=
"color: red"
>
*
</span></label>
<label
for=
"file"
class=
"col-sm-2 control-label"
>
选择文件
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"file"
class=
"form-control"
id=
"file"
name=
"file"
placeholder=
"点击添加"
>
<input
type=
"file"
class=
"form-control"
id=
"file"
name=
"file"
placeholder=
"点击添加"
>
</div>
</div>
...
...
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