Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
7ac5bef1
Commit
7ac5bef1
authored
Sep 10, 2012
by
Sofia Papagiannaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code formatting to conform to the PEP 8 style guide
parent
65f9b8fd
Changes
59
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
59 changed files
with
2987 additions
and
2519 deletions
+2987
-2519
other/migrate.py
other/migrate.py
+14
-12
snf-pithos-app/distribute_setup.py
snf-pithos-app/distribute_setup.py
+25
-13
snf-pithos-app/pithos/api/delegate.py
snf-pithos-app/pithos/api/delegate.py
+12
-10
snf-pithos-app/pithos/api/dispatch.py
snf-pithos-app/pithos/api/dispatch.py
+22
-15
snf-pithos-app/pithos/api/faults.py
snf-pithos-app/pithos/api/faults.py
+19
-5
snf-pithos-app/pithos/api/functions.py
snf-pithos-app/pithos/api/functions.py
+321
-242
snf-pithos-app/pithos/api/management/commands/storagequota.py
...pithos-app/pithos/api/management/commands/storagequota.py
+14
-13
snf-pithos-app/pithos/api/public.py
snf-pithos-app/pithos/api/public.py
+42
-33
snf-pithos-app/pithos/api/settings.py
snf-pithos-app/pithos/api/settings.py
+15
-8
snf-pithos-app/pithos/api/short_url.py
snf-pithos-app/pithos/api/short_url.py
+34
-18
snf-pithos-app/pithos/api/templatetags/get_type.py
snf-pithos-app/pithos/api/templatetags/get_type.py
+8
-7
snf-pithos-app/pithos/api/urls.py
snf-pithos-app/pithos/api/urls.py
+22
-16
snf-pithos-app/pithos/api/util.py
snf-pithos-app/pithos/api/util.py
+207
-137
snf-pithos-app/setup.py
snf-pithos-app/setup.py
+45
-43
snf-pithos-backend/distribute_setup.py
snf-pithos-backend/distribute_setup.py
+25
-13
snf-pithos-backend/pithos/backends/__init__.py
snf-pithos-backend/pithos/backends/__init__.py
+1
-1
snf-pithos-backend/pithos/backends/base.py
snf-pithos-backend/pithos/backends/base.py
+210
-201
snf-pithos-backend/pithos/backends/filter.py
snf-pithos-backend/pithos/backends/filter.py
+8
-7
snf-pithos-backend/pithos/backends/lib/hashfiler/__init__.py
snf-pithos-backend/pithos/backends/lib/hashfiler/__init__.py
+5
-6
snf-pithos-backend/pithos/backends/lib/hashfiler/blocker.py
snf-pithos-backend/pithos/backends/lib/hashfiler/blocker.py
+13
-12
snf-pithos-backend/pithos/backends/lib/hashfiler/context_file.py
...hos-backend/pithos/backends/lib/hashfiler/context_file.py
+7
-8
snf-pithos-backend/pithos/backends/lib/hashfiler/mapper.py
snf-pithos-backend/pithos/backends/lib/hashfiler/mapper.py
+8
-8
snf-pithos-backend/pithos/backends/lib/hashfiler/store.py
snf-pithos-backend/pithos/backends/lib/hashfiler/store.py
+16
-16
snf-pithos-backend/pithos/backends/lib/rabbitmq/__init__.py
snf-pithos-backend/pithos/backends/lib/rabbitmq/__init__.py
+5
-6
snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py
snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py
+10
-9
snf-pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py
...pithos-backend/pithos/backends/lib/sqlalchemy/__init__.py
+5
-6
snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/env.py
...hos-backend/pithos/backends/lib/sqlalchemy/alembic/env.py
+8
-7
snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/230f8ce9c90f_alter_nodes_add_colu.py
...emy/alembic/versions/230f8ce9c90f_alter_nodes_add_colu.py
+18
-15
snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/3dd56e750a3_fix_latest_version.py
...lchemy/alembic/versions/3dd56e750a3_fix_latest_version.py
+16
-14
snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/8320b1c62d9_create_index_nodes_p.py
...hemy/alembic/versions/8320b1c62d9_create_index_nodes_p.py
+2
-0
snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbworker.py
...pithos-backend/pithos/backends/lib/sqlalchemy/dbworker.py
+7
-7
snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py
...ithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py
+16
-13
snf-pithos-backend/pithos/backends/lib/sqlalchemy/groups.py
snf-pithos-backend/pithos/backends/lib/sqlalchemy/groups.py
+47
-45
snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py
snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py
+203
-186
snf-pithos-backend/pithos/backends/lib/sqlalchemy/permissions.py
...hos-backend/pithos/backends/lib/sqlalchemy/permissions.py
+35
-34
snf-pithos-backend/pithos/backends/lib/sqlalchemy/public.py
snf-pithos-backend/pithos/backends/lib/sqlalchemy/public.py
+19
-15
snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py
...ithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py
+42
-39
snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py
snf-pithos-backend/pithos/backends/lib/sqlite/__init__.py
+5
-6
snf-pithos-backend/pithos/backends/lib/sqlite/dbworker.py
snf-pithos-backend/pithos/backends/lib/sqlite/dbworker.py
+7
-7
snf-pithos-backend/pithos/backends/lib/sqlite/dbwrapper.py
snf-pithos-backend/pithos/backends/lib/sqlite/dbwrapper.py
+10
-10
snf-pithos-backend/pithos/backends/lib/sqlite/groups.py
snf-pithos-backend/pithos/backends/lib/sqlite/groups.py
+27
-27
snf-pithos-backend/pithos/backends/lib/sqlite/node.py
snf-pithos-backend/pithos/backends/lib/sqlite/node.py
+219
-206
snf-pithos-backend/pithos/backends/lib/sqlite/permissions.py
snf-pithos-backend/pithos/backends/lib/sqlite/permissions.py
+26
-26
snf-pithos-backend/pithos/backends/lib/sqlite/public.py
snf-pithos-backend/pithos/backends/lib/sqlite/public.py
+13
-13
snf-pithos-backend/pithos/backends/lib/sqlite/xfeatures.py
snf-pithos-backend/pithos/backends/lib/sqlite/xfeatures.py
+32
-32
snf-pithos-backend/pithos/backends/migrate.py
snf-pithos-backend/pithos/backends/migrate.py
+6
-9
snf-pithos-backend/pithos/backends/modular.py
snf-pithos-backend/pithos/backends/modular.py
+354
-263
snf-pithos-backend/setup.py
snf-pithos-backend/setup.py
+35
-33
snf-pithos-tools/distribute_setup.py
snf-pithos-tools/distribute_setup.py
+25
-13
snf-pithos-tools/pithos/tools/dispatcher.py
snf-pithos-tools/pithos/tools/dispatcher.py
+15
-11
snf-pithos-tools/pithos/tools/fs.py
snf-pithos-tools/pithos/tools/fs.py
+59
-69
snf-pithos-tools/pithos/tools/lib/client.py
snf-pithos-tools/pithos/tools/lib/client.py
+234
-222
snf-pithos-tools/pithos/tools/lib/fuse.py
snf-pithos-tools/pithos/tools/lib/fuse.py
+117
-98
snf-pithos-tools/pithos/tools/lib/hashmap.py
snf-pithos-tools/pithos/tools/lib/hashmap.py
+13
-11
snf-pithos-tools/pithos/tools/lib/transfer.py
snf-pithos-tools/pithos/tools/lib/transfer.py
+22
-19
snf-pithos-tools/pithos/tools/lib/util.py
snf-pithos-tools/pithos/tools/lib/util.py
+8
-5
snf-pithos-tools/pithos/tools/sh.py
snf-pithos-tools/pithos/tools/sh.py
+142
-110
snf-pithos-tools/pithos/tools/sync.py
snf-pithos-tools/pithos/tools/sync.py
+49
-49
snf-pithos-tools/setup.py
snf-pithos-tools/setup.py
+43
-40
No files found.
other/migrate.py
View file @
7ac5bef1
...
...
@@ -41,6 +41,7 @@ from django.conf import settings
from
pithos.backends.modular
import
ModularBackend
class
Migration
(
object
):
def
__init__
(
self
,
db
):
self
.
engine
=
create_engine
(
db
)
...
...
@@ -54,12 +55,13 @@ class Migration(object):
def
execute
(
self
):
pass
class
Cache
():
def
__init__
(
self
,
db
):
self
.
engine
=
create_engine
(
db
)
metadata
=
MetaData
(
self
.
engine
)
columns
=
[]
columns
=
[]
columns
.
append
(
Column
(
'path'
,
String
(
2048
),
primary_key
=
True
))
columns
.
append
(
Column
(
'hash'
,
String
(
255
)))
self
.
files
=
Table
(
'files'
,
metadata
,
*
columns
)
...
...
@@ -69,7 +71,7 @@ class Cache():
def
put
(
self
,
path
,
hash
):
# Insert or replace.
s
=
self
.
files
.
delete
().
where
(
self
.
files
.
c
.
path
==
path
)
s
=
self
.
files
.
delete
().
where
(
self
.
files
.
c
.
path
==
path
)
r
=
self
.
conn
.
execute
(
s
)
r
.
close
()
s
=
self
.
files
.
insert
()
...
...
snf-pithos-app/distribute_setup.py
View file @
7ac5bef1
...
...
@@ -144,7 +144,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
except
ImportError
:
return
_do_download
(
version
,
download_base
,
to_dir
,
download_delay
)
try
:
pkg_resources
.
require
(
"distribute>="
+
version
)
pkg_resources
.
require
(
"distribute>="
+
version
)
return
except
pkg_resources
.
VersionConflict
:
e
=
sys
.
exc_info
()[
1
]
...
...
@@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
if
not
no_fake
:
_create_fake_setuptools_pkg_info
(
to_dir
)
def
download_setuptools
(
version
=
DEFAULT_VERSION
,
download_base
=
DEFAULT_URL
,
to_dir
=
os
.
curdir
,
delay
=
15
):
"""Download distribute from a specified location and return its filename
...
...
@@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
dst
.
close
()
return
os
.
path
.
realpath
(
saveto
)
def
_no_sandbox
(
function
):
def
__no_sandbox
(
*
args
,
**
kw
):
try
:
...
...
@@ -227,6 +229,7 @@ def _no_sandbox(function):
return
__no_sandbox
def
_patch_file
(
path
,
content
):
"""Will backup the file then patch it"""
existing_content
=
open
(
path
).
read
()
...
...
@@ -245,15 +248,18 @@ def _patch_file(path, content):
_patch_file
=
_no_sandbox
(
_patch_file
)
def
_same_content
(
path
,
content
):
return
open
(
path
).
read
()
==
content
def
_rename_path
(
path
):
new_name
=
path
+
'.OLD.%s'
%
time
.
time
()
log
.
warn
(
'Renaming %s into %s'
,
path
,
new_name
)
os
.
rename
(
path
,
new_name
)
return
new_name
def
_remove_flat_installation
(
placeholder
):
if
not
os
.
path
.
isdir
(
placeholder
):
log
.
warn
(
'Unkown installation at %s'
,
placeholder
)
...
...
@@ -289,11 +295,13 @@ def _remove_flat_installation(placeholder):
_remove_flat_installation
=
_no_sandbox
(
_remove_flat_installation
)
def
_after_install
(
dist
):
log
.
warn
(
'After install bootstrap.'
)
placeholder
=
dist
.
get_command_obj
(
'install'
).
install_purelib
_create_fake_setuptools_pkg_info
(
placeholder
)
def
_create_fake_setuptools_pkg_info
(
placeholder
):
if
not
placeholder
or
not
os
.
path
.
exists
(
placeholder
):
log
.
warn
(
'Could not find the install location'
)
...
...
@@ -321,7 +329,9 @@ def _create_fake_setuptools_pkg_info(placeholder):
finally
:
f
.
close
()
_create_fake_setuptools_pkg_info
=
_no_sandbox
(
_create_fake_setuptools_pkg_info
)
_create_fake_setuptools_pkg_info
=
_no_sandbox
(
_create_fake_setuptools_pkg_info
)
def
_patch_egg_dir
(
path
):
# let's check if it's already patched
...
...
@@ -343,6 +353,7 @@ def _patch_egg_dir(path):
_patch_egg_dir
=
_no_sandbox
(
_patch_egg_dir
)
def
_before_install
():
log
.
warn
(
'Before install bootstrap.'
)
_fake_setuptools
()
...
...
@@ -351,7 +362,7 @@ def _before_install():
def
_under_prefix
(
location
):
if
'install'
not
in
sys
.
argv
:
return
True
args
=
sys
.
argv
[
sys
.
argv
.
index
(
'install'
)
+
1
:]
args
=
sys
.
argv
[
sys
.
argv
.
index
(
'install'
)
+
1
:]
for
index
,
arg
in
enumerate
(
args
):
for
option
in
(
'--root'
,
'--prefix'
):
if
arg
.
startswith
(
'%s='
%
option
):
...
...
@@ -359,7 +370,7 @@ def _under_prefix(location):
return
location
.
startswith
(
top_dir
)
elif
arg
==
option
:
if
len
(
args
)
>
index
:
top_dir
=
args
[
index
+
1
]
top_dir
=
args
[
index
+
1
]
return
location
.
startswith
(
top_dir
)
if
arg
==
'--user'
and
USER_SITE
is
not
None
:
return
location
.
startswith
(
USER_SITE
)
...
...
@@ -380,7 +391,8 @@ def _fake_setuptools():
replacement
=
False
))
except
TypeError
:
# old distribute API
setuptools_dist
=
ws
.
find
(
pkg_resources
.
Requirement
.
parse
(
'setuptools'
))
setuptools_dist
=
ws
.
find
(
pkg_resources
.
Requirement
.
parse
(
'setuptools'
))
if
setuptools_dist
is
None
:
log
.
warn
(
'No setuptools distribution found'
)
...
...
snf-pithos-app/pithos/api/delegate.py
View file @
7ac5bef1
...
...
@@ -46,6 +46,7 @@ from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS, SERVIC
logger
=
logging
.
getLogger
(
__name__
)
def
delegate_to_login_service
(
request
):
url
=
AUTHENTICATION_URL
users
=
AUTHENTICATION_USERS
...
...
@@ -61,6 +62,7 @@ def delegate_to_login_service(request):
uri
=
proto
+
p
.
netloc
+
'/login?'
+
urlencode
(
params
)
return
HttpResponseRedirect
(
uri
)
@
csrf_exempt
def
delegate_to_feedback_service
(
request
):
url
=
AUTHENTICATION_URL
...
...
@@ -75,7 +77,7 @@ def delegate_to_feedback_service(request):
proto
=
'http://'
uri
=
proto
+
p
.
netloc
+
'/im/service/api/v2.0/feedback'
headers
=
{
'X-Auth-Token'
:
SERVICE_TOKEN
}
headers
=
{
'X-Auth-Token'
:
SERVICE_TOKEN
}
values
=
dict
([(
k
,
v
)
for
k
,
v
in
request
.
POST
.
items
()])
data
=
urllib
.
urlencode
(
values
)
req
=
urllib2
.
Request
(
uri
,
data
,
headers
)
...
...
snf-pithos-app/pithos/api/dispatch.py
View file @
7ac5bef1
...
...
@@ -14,6 +14,7 @@ from astakos.im.settings import DEFAULT_FROM_EMAIL
import
socket
from
smtplib
import
SMTPException
def
update_md5
(
m
):
if
m
[
'resource'
]
!=
'object'
or
m
[
'details'
][
'action'
]
!=
'object update'
:
return
...
...
@@ -33,17 +34,21 @@ def update_md5(m):
version
=
m
[
'details'
][
'version'
]
meta
=
None
try
:
meta
=
backend
.
get_object_meta
(
account
,
account
,
container
,
name
,
'pithos'
,
version
)
meta
=
backend
.
get_object_meta
(
account
,
account
,
container
,
name
,
'pithos'
,
version
)
if
meta
[
'checksum'
]
==
''
:
size
,
hashmap
=
backend
.
get_object_hashmap
(
account
,
account
,
container
,
name
,
version
)
size
,
hashmap
=
backend
.
get_object_hashmap
(
account
,
account
,
container
,
name
,
version
)
checksum
=
hashmap_md5
(
backend
,
hashmap
,
size
)
backend
.
update_object_checksum
(
account
,
account
,
container
,
name
,
version
,
checksum
)
backend
.
update_object_checksum
(
account
,
account
,
container
,
name
,
version
,
checksum
)
print
'INFO: Updated checksum for path "%s"'
%
(
path
,)
except
Exception
,
e
:
print
'WARNING: Can not update checksum for path "%s" (%s)'
%
(
path
,
e
)
backend
.
close
()
def
send_sharing_notification
(
m
):
if
m
[
'resource'
]
!=
'sharing'
:
return
...
...
@@ -56,9 +61,11 @@ def send_sharing_notification(m):
subject
=
'Invitation to a Pithos+ shared object'
from_email
=
DEFAULT_FROM_EMAIL
recipient_list
=
members
message
=
'User %s has invited you to a Pithos+ shared object. You can view it under "Shared to me" at "%s".'
%
(
user
,
path
)
message
=
'User %s has invited you to a Pithos+ shared object. You can view it under "Shared to me" at "%s".'
%
(
user
,
path
)
try
:
send_mail
(
subject
,
message
,
from_email
,
recipient_list
)
print
'INFO: Sharing notification sent for path "%s" to %s'
%
(
path
,
','
.
join
(
recipient_list
))
print
'INFO: Sharing notification sent for path "%s" to %s'
%
(
path
,
','
.
join
(
recipient_list
))
except
(
SMTPException
,
socket
.
error
)
as
e
:
print
'WARNING: Can not update send email for sharing "%s" (%s)'
%
(
path
,
e
)
print
'WARNING: Can not update send email for sharing "%s" (%s)'
%
(
path
,
e
)
snf-pithos-app/pithos/api/faults.py
View file @
7ac5bef1
...
...
@@ -31,6 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
def
camelCase
(
s
):
return
s
[
0
].
lower
()
+
s
[
1
:]
...
...
@@ -42,41 +43,54 @@ class Fault(Exception):
self
.
details
=
details
self
.
name
=
name
or
camelCase
(
self
.
__class__
.
__name__
)
class
NotModified
(
Fault
):
code
=
304
class
BadRequest
(
Fault
):
code
=
400
class
Unauthorized
(
Fault
):
code
=
401
class
Forbidden
(
Fault
):
code
=
403
class
ItemNotFound
(
Fault
):
code
=
404
class
Conflict
(
Fault
):
code
=
409
class
LengthRequired
(
Fault
):
code
=
411
class
PreconditionFailed
(
Fault
):
code
=
412
class
RequestEntityTooLarge
(
Fault
):
code
=
413
class
RangeNotSatisfiable
(
Fault
):
code
=
416
class
UnprocessableEntity
(
Fault
):
code
=
422
class
InternalServerError
(
Fault
):
code
=
500
class
NotImplemented
(
Fault
):
code
=
501
snf-pithos-app/pithos/api/functions.py
View file @
7ac5bef1
This diff is collapsed.
Click to expand it.
snf-pithos-app/pithos/api/management/commands/storagequota.py
View file @
7ac5bef1
...
...
@@ -78,5 +78,6 @@ class Command(BaseCommand):
if
quota
is
not
None
:
backend
.
update_account_policy
(
user
,
user
,
{
'quota'
:
quota
})
else
:
self
.
stdout
.
write
(
"Quota for %s: %s
\n
"
%
(
user
,
backend
.
get_account_policy
(
user
,
user
)[
'quota'
]))
self
.
stdout
.
write
(
"Quota for %s: %s
\n
"
%
(
user
,
backend
.
get_account_policy
(
user
,
user
)[
'quota'
]))
backend
.
close
()
snf-pithos-app/pithos/api/public.py
View file @
7ac5bef1
...
...
@@ -59,6 +59,7 @@ def public_demux(request, v_public):
else
:
return
method_not_allowed
(
request
)
@
api_method
(
'HEAD'
,
user_required
=
False
)
def
public_meta
(
request
,
v_public
):
# Normal Response Codes: 204
...
...
@@ -67,11 +68,13 @@ def public_meta(request, v_public):
# badRequest (400)
try
:
v_account
,
v_container
,
v_object
=
request
.
backend
.
get_public
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
=
request
.
backend
.
get_public
(
request
.
user_uniq
,
decode_url
(
v_public
))
meta
=
request
.
backend
.
get_object_meta
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
,
'pithos'
)
public
=
request
.
backend
.
get_object_public
(
request
.
user_uniq
,
v_account
,
public
=
request
.
backend
.
get_object_public
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
)
except
:
raise
ItemNotFound
(
'Object does not exist'
)
...
...
@@ -84,6 +87,7 @@ def public_meta(request, v_public):
put_object_headers
(
response
,
meta
,
True
)
return
response
@
api_method
(
'GET'
,
user_required
=
False
)
def
public_read
(
request
,
v_public
):
# Normal Response Codes: 200, 206
...
...
@@ -93,13 +97,14 @@ def public_read(request, v_public):
# itemNotFound (404),
# badRequest (400),
# notModified (304)
try
:
v_account
,
v_container
,
v_object
=
request
.
backend
.
get_public
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
=
request
.
backend
.
get_public
(
request
.
user_uniq
,
decode_url
(
v_public
))
meta
=
request
.
backend
.
get_object_meta
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
,
'pithos'
)
public
=
request
.
backend
.
get_object_public
(
request
.
user_uniq
,
v_account
,
public
=
request
.
backend
.
get_object_public
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
)
except
:
raise
ItemNotFound
(
'Object does not exist'
)
...
...
@@ -121,8 +126,10 @@ def public_read(request, v_public):
hashmaps
=
[]
if
'X-Object-Manifest'
in
meta
:
try
:
src_container
,
src_name
=
split_container_object_string
(
'/'
+
meta
[
'X-Object-Manifest'
])
objects
=
request
.
backend
.
list_objects
(
request
.
user_uniq
,
v_account
,
src_container
,
src_name
=
split_container_object_string
(
'/'
+
meta
[
'X-Object-Manifest'
])
objects
=
request
.
backend
.
list_objects
(
request
.
user_uniq
,
v_account
,
src_container
,
prefix
=
src_name
,
virtual
=
False
)
except
:
raise
ItemNotFound
(
'Object does not exist'
)
...
...
@@ -137,7 +144,8 @@ def public_read(request, v_public):
raise
ItemNotFound
(
'Object does not exist'
)
else
:
try
:
s
,
h
=
request
.
backend
.
get_object_hashmap
(
request
.
user_uniq
,
v_account
,
s
,
h
=
request
.
backend
.
get_object_hashmap
(
request
.
user_uniq
,
v_account
,
v_container
,
v_object
)
sizes
.
append
(
s
)
hashmaps
.
append
(
h
)
...
...
@@ -152,6 +160,7 @@ def public_read(request, v_public):
return
object_data_response
(
request
,
sizes
,
hashmaps
,
meta
,
True
)
@
api_method
(
user_required
=
False
)
def
method_not_allowed
(
request
,
**
v_args
):
raise
ItemNotFound
(
'Object does not exist'
)
snf-pithos-app/pithos/api/settings.py
View file @
7ac5bef1
...
...
@@ -15,26 +15,33 @@ sample_users = {
'0009'
:
'διογένης'
}
AUTHENTICATION_URL
=
getattr
(
settings
,
'PITHOS_AUTHENTICATION_URL'
,
'http://127.0.0.1:8000/im/authenticate'
)
AUTHENTICATION_URL
=
getattr
(
settings
,
'PITHOS_AUTHENTICATION_URL'
,
'http://127.0.0.1:8000/im/authenticate'
)
AUTHENTICATION_USERS
=
getattr
(
settings
,
'PITHOS_AUTHENTICATION_USERS'
,
{})
COOKIE_NAME
=
getattr
(
settings
,
'ASTAKOS_COOKIE_NAME'
,
'_pithos2_a'
)
# SQLAlchemy (choose SQLite/MySQL/PostgreSQL).
BACKEND_DB_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_DB_MODULE'
,
'pithos.backends.lib.sqlalchemy'
)
BACKEND_DB_CONNECTION
=
getattr
(
settings
,
'PITHOS_BACKEND_DB_CONNECTION'
,
'sqlite:////tmp/pithos-backend.db'
)
BACKEND_DB_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_DB_MODULE'
,
'pithos.backends.lib.sqlalchemy'
)
BACKEND_DB_CONNECTION
=
getattr
(
settings
,
'PITHOS_BACKEND_DB_CONNECTION'
,
'sqlite:////tmp/pithos-backend.db'
)
# Block storage.
BACKEND_BLOCK_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_BLOCK_MODULE'
,
'pithos.backends.lib.hashfiler'
)
BACKEND_BLOCK_PATH
=
getattr
(
settings
,
'PITHOS_BACKEND_BLOCK_PATH'
,
'/tmp/pithos-data/'
)
BACKEND_BLOCK_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_BLOCK_MODULE'
,
'pithos.backends.lib.hashfiler'
)
BACKEND_BLOCK_PATH
=
getattr
(
settings
,
'PITHOS_BACKEND_BLOCK_PATH'
,
'/tmp/pithos-data/'
)
BACKEND_BLOCK_UMASK
=
getattr
(
settings
,
'PITHOS_BACKEND_BLOCK_UMASK'
,
0o022
)
# Queue for billing.
BACKEND_QUEUE_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_QUEUE_MODULE'
,
None
)
# Example: 'pithos.backends.lib.rabbitmq'
BACKEND_QUEUE_MODULE
=
getattr
(
settings
,
'PITHOS_BACKEND_QUEUE_MODULE'
,
None
)
# Example: 'pithos.backends.lib.rabbitmq'
BACKEND_QUEUE_CONNECTION
=
getattr
(
settings
,
'PITHOS_BACKEND_QUEUE_CONNECTION'
,
None
)
# Example: 'rabbitmq://guest:guest@localhost:5672/pithos'
# Default setting for new accounts.
BACKEND_QUOTA
=
getattr
(
settings
,
'PITHOS_BACKEND_QUOTA'
,
50
*
1024
*
1024
*
1024
)
BACKEND_QUOTA
=
getattr
(
settings
,
'PITHOS_BACKEND_QUOTA'
,
50
*
1024
*
1024
*
1024
)
BACKEND_VERSIONING
=
getattr
(
settings
,
'PITHOS_BACKEND_VERSIONING'
,
'auto'
)
# Update object checksums when using hashmaps.
...
...
snf-pithos-app/pithos/api/short_url.py
View file @
7ac5bef1
...
...
@@ -71,6 +71,7 @@ DEFAULT_ALPHABET = 'mn6j2c4rv8bpygw95z7hsdaetxuk3fq'
DEFAULT_BLOCK_SIZE
=
24
MIN_LENGTH
=
5
class
UrlEncoder
(
object
):
def
__init__
(
self
,
alphabet
=
DEFAULT_ALPHABET
,
block_size
=
DEFAULT_BLOCK_SIZE
):
self
.
alphabet
=
alphabet
...
...
@@ -78,35 +79,44 @@ class UrlEncoder(object):
self
.
mask
=
(
1
<<
block_size
)
-
1
self
.
mapping
=
range
(
block_size
)
self
.
mapping
.
reverse
()
def
encode_url
(
self
,
n
,
min_length
=
MIN_LENGTH
):
return
self
.
enbase
(
self
.
encode
(
n
),
min_length
)
def
decode_url
(
self
,
n
):
return
self
.
decode
(
self
.
debase
(
n
))
def
encode
(
self
,
n
):
return
(
n
&
~
self
.
mask
)
|
self
.
_encode
(
n
&
self
.
mask
)
def
_encode
(
self
,
n
):
result
=
0
for
i
,
b
in
enumerate
(
self
.
mapping
):
if
n
&
(
1
<<
i
):
result
|=
(
1
<<
b
)
return
result
def
decode
(
self
,
n
):
return
(
n
&
~
self
.
mask
)
|
self
.
_decode
(
n
&
self
.
mask
)
def
_decode
(
self
,
n
):
result
=
0
for
i
,
b
in
enumerate
(
self
.
mapping
):
if
n
&
(
1
<<
b
):
result
|=
(
1
<<
i
)
return
result
def
enbase
(
self
,
x
,
min_length
=
MIN_LENGTH
):
result
=
self
.
_enbase
(
x
)
padding
=
self
.
alphabet
[
0
]
*
(
min_length
-
len
(
result
))
return
'%s%s'
%
(
padding
,
result
)
def
_enbase
(
self
,
x
):
n
=
len
(
self
.
alphabet
)
if
x
<
n
:
return
self
.
alphabet
[
x
]
return
self
.
_enbase
(
x
/
n
)
+
self
.
alphabet
[
x
%
n
]
def
debase
(
self
,
x
):
n
=
len
(
self
.
alphabet
)
result
=
0
...
...
@@ -116,21 +126,27 @@ class UrlEncoder(object):
DEFAULT_ENCODER
=
UrlEncoder
()
def
encode
(
n
):
return
DEFAULT_ENCODER
.
encode
(
n
)
def
decode
(
n
):
return
DEFAULT_ENCODER
.
decode
(
n
)
def
enbase
(
n
,
min_length
=
MIN_LENGTH
):
return
DEFAULT_ENCODER
.
enbase
(
n
,
min_length
)
def
debase
(
n
):
return
DEFAULT_ENCODER
.
debase
(
n
)
def
encode_url
(
n
,
min_length
=
MIN_LENGTH
):
return
DEFAULT_ENCODER
.
encode_url
(
n
,
min_length
)
def
decode_url
(
n
):
return
DEFAULT_ENCODER
.
decode_url
(
n
)
...
...
snf-pithos-app/pithos/api/templatetags/get_type.py
View file @
7ac5bef1
...
...
@@ -35,6 +35,7 @@ from django import template
register
=
template
.
Library
()
@
register
.
filter
def
get_type
(
value
):
return
value
.
__class__
.
__name__
snf-pithos-app/pithos/api/urls.py
View file @
7ac5bef1
...
...
@@ -36,15 +36,21 @@ from django.conf.urls.defaults import include, patterns
# TODO: This only works when in this order.
api_urlpatterns
=
patterns
(
'pithos.api.functions'
,
(
r
'^$'
,
'top_demux'
),
(
r
'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$'
,
'object_demux'
),
(
r
'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$'
,
'container_demux'
),
(
r
'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$'
,
'object_demux'
),
(
r
'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$'
,
'container_demux'
),
(
r
'^(?P<v_account>.+?)/?$'
,
'account_demux'
)
)
)
urlpatterns
=
patterns
(
''
,
(
r
'^v1(?:$|/)'
,
include
(
api_urlpatterns
)),
(
r
'^v1\.0(?:$|/)'
,
include
(
api_urlpatterns
)),
(
r
'^public/(?P<v_public>.+?)/?$'
,
'pithos.api.public.public_demux'
),
(
r
'^login/?$'
,
'pithos.api.delegate.delegate_to_login_service'
),
(
r
'^feedback/?$'
,
'pithos.api.delegate.delegate_to_feedback_service'
),
)
(
r
'^public/(?P<v_public>.+?)/?$'
,
'pithos.api.public.public_demux'
),
(
r
'^login/?$'
,
'pithos.api.delegate.delegate_to_login_service'
),
(
r
'^feedback/?$'
,
'pithos.api.delegate.delegate_to_feedback_service'
),
)
snf-pithos-app/pithos/api/util.py
View file @
7ac5bef1
This diff is collapsed.
Click to expand it.
snf-pithos-app/setup.py
View file @
7ac5bef1
...
...
@@ -89,6 +89,8 @@ standard_exclude_directories = [
# Note: you may want to copy this into your setup.py file verbatim, as
# you can't import this from another package, when you don't know if
# that package is installed yet.
def
find_package_data
(
where
=
"."
,
package
=
""
,
...
...
@@ -149,7 +151,8 @@ def find_package_data(
new_package
=
package
+
"."
+
name
stack
.
append
((
fn
,
""
,
new_package
,
False
))
else
:
stack
.
append
((
fn
,
prefix
+
name
+
"/"
,
package
,
only_in_packages
))
stack
.
append
(
(
fn
,
prefix
+
name
+
"/"
,
package
,
only_in_packages
))
elif
package
or
not
only_in_packages
:
# is a file
bad_name
=
False
...
...
@@ -164,38 +167,38 @@ def find_package_data(
break
if
bad_name
:
continue
out
.
setdefault
(
package
,
[]).
append
(
prefix
+
name
)
out
.
setdefault
(
package
,
[]).
append
(
prefix
+
name
)
return
out
setup
(
name
=
'snf-pithos-app'
,
version
=
VERSION
,
license
=
'BSD'
,
url
=
'http://code.grnet.gr/'
,
description
=
SHORT_DESCRIPTION
,
name
=
'snf-pithos-app'
,
version
=
VERSION
,
license
=
'BSD'
,
url
=
'http://code.grnet.gr/'
,
description
=
SHORT_DESCRIPTION
,
long_description
=
README
+
'
\n\n
'
+
CHANGES
,
classifiers
=
CLASSIFIERS
,
classifiers
=
CLASSIFIERS
,
author
=
'Package author'
,
author_email
=
'author@grnet.gr'
,
maintainer
=
'Package maintainer'
,
maintainer_email
=
'maintainer@grnet.gr'
,
author
=
'Package author'
,
author_email
=
'author@grnet.gr'
,
maintainer
=
'Package maintainer'
,
maintainer_email
=
'maintainer@grnet.gr'
,
namespace_packages
=
[
'pithos'
],
packages
=
PACKAGES
,
package_dir
=
{
''
:
PACKAGES_ROOT
},
include_package_data
=
True
,
package_data
=
find_package_data
(
'.'
),
zip_safe
=
False
,
namespace_packages
=
[
'pithos'
],
packages
=
PACKAGES
,
package_dir
=
{
''
:
PACKAGES_ROOT
},
include_package_data
=
True
,
package_data
=
find_package_data
(
'.'
),
zip_safe
=
False
,
dependency_links
=
[
dependency_links
=
[
'http://docs.dev.grnet.gr/pypi/'
],
install_requires
=
INSTALL_REQUIRES
,
extras_require
=
EXTRAS_REQUIRES
,
tests_require
=
TESTS_REQUIRES
,
install_requires
=
INSTALL_REQUIRES
,
extras_require
=
EXTRAS_REQUIRES
,
tests_require
=
TESTS_REQUIRES
,
entry_points
=
{
entry_points
=
{
'console_scripts'
:
[
],
'synnefo'
:
[
...
...
@@ -207,4 +210,3 @@ setup(
]
},
)
snf-pithos-backend/distribute_setup.py
View file @
7ac5bef1
...
...
@@ -144,7 +144,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
except
ImportError
:
return
_do_download
(
version
,
download_base
,
to_dir
,
download_delay
)