Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
83fcd17c
authored
Jan 30, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://giccero.cloud.ik.bme.hu/cloud
parents
949ba8a0
4216ec58
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
16 deletions
+51
-16
cloud/urls.py
+1
-0
miscellaneous/store-server/CloudStore.py
+31
-16
store/api.py
+12
-0
store/views.py
+7
-0
No files found.
cloud/urls.py
View file @
83fcd17c
...
@@ -25,4 +25,5 @@ urlpatterns = patterns('',
...
@@ -25,4 +25,5 @@ urlpatterns = patterns('',
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
url
(
r'^fwapi/$'
,
'firewall.views.firewall_api'
,
name
=
'firewall_api'
),
url
(
r'^fwapi/$'
,
'firewall.views.firewall_api'
,
name
=
'firewall_api'
),
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
)
)
miscellaneous/store-server/CloudStore.py
View file @
83fcd17c
...
@@ -168,6 +168,17 @@ def cmd_remove(request, neptun, home_path):
...
@@ -168,6 +168,17 @@ def cmd_remove(request, neptun, home_path):
return
return
COMMANDS
[
'REMOVE'
]
=
cmd_remove
COMMANDS
[
'REMOVE'
]
=
cmd_remove
def
cmd_toplist
(
request
,
neptun
,
home_path
):
d
=
[]
try
:
top_dir
=
os
.
path
.
normpath
(
os
.
path
.
join
(
home_path
,
"../.top"
))
d
=
[
file_dict
(
os
.
readlink
(
os
.
path
.
join
(
top_dir
,
f
)),
home_path
)
for
f
in
os
.
listdir
(
top_dir
)]
except
:
pass
return
json
.
dumps
(
sorted
(
d
,
key
=
lambda
f
:
f
[
'MTIME'
]))
COMMANDS
[
'TOPLIST'
]
=
cmd_toplist
@route
(
'/set/<neptun>'
,
method
=
'POST'
)
@route
(
'/set/<neptun>'
,
method
=
'POST'
)
def
set_keys
(
neptun
):
def
set_keys
(
neptun
):
key_list
=
[]
key_list
=
[]
...
@@ -247,13 +258,14 @@ def upload(hash_num):
...
@@ -247,13 +258,14 @@ def upload(hash_num):
# TODO setuid subcommand
# TODO setuid subcommand
# Check if file exist (root can overwrite anything not safe)
# Check if file exist (root can overwrite anything not safe)
f
=
open
(
up_path
,
'wb'
)
f
=
open
(
up_path
,
'wb'
)
datalength
=
0
for
chunk
in
fbuffer
(
file_data
.
file
):
f
.
write
(
chunk
)
datalength
+=
len
(
chunk
)
f
.
close
()
os
.
chown
(
up_path
,
getpwnam
(
username
)
.
pw_uid
,
getpwnam
(
username
)
.
pw_gid
)
os
.
chown
(
up_path
,
getpwnam
(
username
)
.
pw_uid
,
getpwnam
(
username
)
.
pw_gid
)
os
.
chmod
(
up_path
,
0644
)
os
.
chmod
(
up_path
,
0644
)
f
.
close
()
with
open
(
up_path
,
'wb'
)
as
f
:
datalength
=
0
for
chunk
in
fbuffer
(
file_data
.
file
):
f
.
write
(
chunk
)
datalength
+=
len
(
chunk
)
return
'Upload finished: '
+
file_name
+
' - '
+
str
(
datalength
)
+
' Byte'
return
'Upload finished: '
+
file_name
+
' - '
+
str
(
datalength
)
+
' Byte'
...
@@ -304,18 +316,21 @@ def list_directory(home, path):
...
@@ -304,18 +316,21 @@ def list_directory(home, path):
return
json
.
dumps
((
os
.
path
.
basename
(
path
),
'F'
,
os
.
path
.
getsize
(
path
),
os
.
path
.
getmtime
(
path
)))
return
json
.
dumps
((
os
.
path
.
basename
(
path
),
'F'
,
os
.
path
.
getsize
(
path
),
os
.
path
.
getmtime
(
path
)))
# List directory and return list
# List directory and return list
else
:
else
:
tuplelist
=
[]
filelist
=
os
.
listdir
(
path
)
filelist
=
os
.
listdir
(
path
)
# Add type support
dictlist
=
[
file_dict
(
os
.
path
.
join
(
path
,
f
),
home
)
for
f
in
filelist
]
for
item
in
filelist
:
return
json
.
dumps
(
dictlist
)
static_route
=
path
+
"/"
+
item
if
os
.
path
.
isdir
(
static_route
):
def
file_dict
(
path
,
home
):
is_dir
=
'D'
basename
=
os
.
path
.
basename
(
path
.
rstrip
(
'/'
))
else
:
if
os
.
path
.
isdir
(
path
):
is_dir
=
'F'
is_dir
=
'D'
element
=
{
'NAME'
:
item
,
'TYPE'
:
is_dir
,
'SIZE'
:
os
.
path
.
getsize
(
static_route
)
/
1024
,
'MTIME'
:
os
.
path
.
getmtime
(
static_route
)
}
else
:
tuplelist
.
append
(
element
)
is_dir
=
'F'
return
json
.
dumps
(
tuplelist
)
return
{
'NAME'
:
basename
,
'TYPE'
:
is_dir
,
'SIZE'
:
os
.
path
.
getsize
(
path
)
/
1024
,
'MTIME'
:
os
.
path
.
getmtime
(
path
),
'DIR'
:
os
.
path
.
relpath
(
os
.
path
.
dirname
(
path
),
home
)}
def
getQuotaStatus
(
neptun
):
def
getQuotaStatus
(
neptun
):
output
=
subprocess
.
check_output
([
ROOT_BIN_FOLDER
+
'/'
+
USER_MANAGER
,
'status'
,
neptun
],
stderr
=
subprocess
.
STDOUT
)
output
=
subprocess
.
check_output
([
ROOT_BIN_FOLDER
+
'/'
+
USER_MANAGER
,
'status'
,
neptun
],
stderr
=
subprocess
.
STDOUT
)
...
...
store/api.py
View file @
83fcd17c
...
@@ -76,6 +76,18 @@ class StoreApi:
...
@@ -76,6 +76,18 @@ class StoreApi:
else
:
else
:
raise
Http404
raise
Http404
@staticmethod
@staticmethod
def
toplist
(
neptun
):
url
=
settings
[
'store_url'
]
+
'/'
+
neptun
payload
=
json
.
dumps
({
'CMD'
:
'TOPLIST'
})
r
=
StoreApi
.
post_request
(
url
,
payload
)
if
r
.
status_code
==
requests
.
codes
.
ok
:
tupplelist
=
json
.
loads
(
r
.
content
)
for
item
in
tupplelist
:
item
[
'MTIME'
]
=
time
.
ctime
(
item
[
'MTIME'
])
return
tupplelist
else
:
raise
Http404
@staticmethod
def
requestdownload
(
neptun
,
path
):
def
requestdownload
(
neptun
,
path
):
url
=
settings
[
'store_url'
]
+
'/'
+
neptun
url
=
settings
[
'store_url'
]
+
'/'
+
neptun
payload
=
json
.
dumps
({
'CMD'
:
'DOWNLOAD'
,
'PATH'
:
path
})
payload
=
json
.
dumps
({
'CMD'
:
'DOWNLOAD'
,
'PATH'
:
path
})
...
...
store/views.py
View file @
83fcd17c
...
@@ -66,6 +66,13 @@ def index(request):
...
@@ -66,6 +66,13 @@ def index(request):
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
@login_required
def
toplist
(
request
):
user
=
request
.
user
.
username
path
=
backpath
=
'/'
file_list
=
StoreApi
.
toplist
(
user
)
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
def
logout
(
request
):
def
logout
(
request
):
auth
.
logout
(
request
)
auth
.
logout
(
request
)
return
redirect
(
'/'
)
return
redirect
(
'/'
)
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