Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
8dadc29d
Commit
8dadc29d
authored
Apr 28, 2011
by
Sofia Papagiannaki
Browse files
create account when create container if not exists
Refs #447
parent
06374392
Changes
1
Hide whitespace changes
Inline
Side-by-side
pithos/backends/dummy.py
View file @
8dadc29d
...
...
@@ -18,23 +18,22 @@ class BackEnd:
def
get_account_meta
(
self
,
account
):
""" returns a dictionary with the container metadata """
logging
.
info
(
"get_account_meta:
%s
%s"
,
account
)
logging
.
info
(
"get_account_meta: %s"
,
account
)
fullname
=
'/'
.
join
([
self
.
basepath
,
account
])
if
not
os
.
path
.
exists
(
fullname
):
raise
NameError
(
'Account does not exist'
)
contents
=
os
.
listdir
(
fullname
)
count
=
len
(
contents
)
size
=
sum
(
os
.
path
.
getsize
(
'/'
.
join
([
self
.
basepath
,
account
,
objectname
]))
for
objectname
in
contents
)
return
{
'name'
:
name
,
'count'
:
count
,
'bytes'
:
size
}
return
{
'name'
:
account
,
'count'
:
count
,
'bytes'
:
size
}
def
create_container
(
self
,
account
,
name
):
""" creates a new container with the given name
if it doesn't exists under the basepath """
logging
.
debug
(
"create_container: %s %s"
,
account
,
name
)
logging
.
info
(
"create_container: %s %s"
,
account
,
name
)
fullname
=
'/'
.
join
([
self
.
basepath
,
account
,
name
])
if
not
os
.
path
.
exists
(
fullname
):
os
.
chdir
(
self
.
basepath
)
os
.
mkdir
(
name
)
os
.
makedirs
(
fullname
)
else
:
raise
NameError
(
'Container already exists'
)
return
...
...
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