Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
installsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Seblu
installsystems
Commits
d60d7b4d
Commit
d60d7b4d
authored
13 years ago
by
Sebastien Luttringer
Browse files
Options
Downloads
Patches
Plain Diff
Repository add now user PipeFile
Also fix some bug in PipeFile
parent
33ea2bfc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
installsystems/repository.py
+8
-3
8 additions, 3 deletions
installsystems/repository.py
installsystems/tools.py
+7
-29
7 additions, 29 deletions
installsystems/tools.py
with
15 additions
and
32 deletions
installsystems/repository.py
+
8
−
3
View file @
d60d7b4d
...
...
@@ -168,11 +168,16 @@ class Repository(object):
arrow
(
"
Skipping %s: already exists
"
%
basesrc
,
1
)
else
:
arrow
(
"
Adding %s (%s)
"
%
(
basesrc
,
obj
.
md5
),
1
)
istools
.
copy
(
obj
.
path
,
dest
,
self
.
config
.
uid
,
self
.
config
.
gid
,
self
.
config
.
fmod
)
dfo
=
open
(
dest
,
"
wb
"
)
sfo
=
PipeFile
(
obj
.
path
,
"
r
"
,
progressbar
=
True
)
sfo
.
consume
(
dfo
)
sfo
.
close
()
dfo
.
close
()
istools
.
chrights
(
dest
,
self
.
config
.
uid
,
self
.
config
.
gid
,
self
.
config
.
fmod
)
# copy is done. create a image inside repo
r_image
=
PackageImage
(
os
.
path
.
join
(
self
.
config
.
path
,
image
.
md5
),
md5name
=
True
)
md5name
=
True
)
# checking must be done with original md5
r_image
.
md5
=
image
.
md5
# checking image and payload after copy
...
...
This diff is collapsed.
Click to expand it.
installsystems/tools.py
+
7
−
29
View file @
d60d7b4d
...
...
@@ -44,7 +44,7 @@ class PipeFile(object):
self
.
mode
=
mode
self
.
timeout
=
timeout
self
.
_md5
=
hashlib
.
md5
()
self
.
size
=
None
self
.
size
=
0
self
.
mtime
=
None
self
.
consumed_size
=
0
# we already have and fo, nothing to open
...
...
@@ -68,7 +68,8 @@ class PipeFile(object):
else
:
raise
IOError
(
"
URL type not supported
"
)
# init progress bar
if
self
.
size
is
None
:
# we use 0 because a null file is cannot show a progression during write
if
self
.
size
==
0
:
widget
=
[
BouncingBar
(),
"
"
,
FileTransferSpeed
()
]
maxval
=
UnknownLength
else
:
...
...
@@ -98,7 +99,7 @@ class PipeFile(object):
if
"
Content-Length
"
in
self
.
fo
.
headers
:
self
.
size
=
int
(
self
.
fo
.
headers
[
"
Content-Length
"
])
else
:
self
.
size
=
None
self
.
size
=
0
# get mtime
try
:
self
.
mtime
=
int
(
time
.
mktime
(
time
.
strptime
(
self
.
fo
.
headers
[
"
Last-Modified
"
],
...
...
@@ -119,7 +120,7 @@ class PipeFile(object):
try
:
self
.
size
=
int
(
self
.
fo
.
headers
[
"
content-length
"
])
except
:
self
.
size
=
None
self
.
size
=
0
def
_open_ssh
(
self
,
path
):
'''
...
...
@@ -174,6 +175,7 @@ class PipeFile(object):
def
write
(
self
,
buf
):
if
self
.
mode
==
"
r
"
:
raise
IOError
(
"
Unable to write in r mode
"
)
self
.
fo
.
write
(
buf
)
length
=
len
(
buf
)
self
.
_md5
.
update
(
buf
)
self
.
consumed_size
+=
length
...
...
@@ -208,7 +210,7 @@ class PipeFile(object):
'''
Set this property to true enable progress bar
'''
if
val
==
True
:
if
val
==
True
and
not
hasattr
(
self
,
"
_progressbar_started
"
)
:
self
.
_progressbar_started
=
True
self
.
_progressbar
.
start
()
...
...
@@ -245,30 +247,6 @@ def smd5sum(buf):
m
.
update
(
buf
)
return
m
.
hexdigest
()
def
copy
(
source
,
destination
,
uid
=
None
,
gid
=
None
,
mode
=
None
,
timeout
=
None
):
'''
Copy a source to destination. Take care of path type
'''
stype
=
pathtype
(
source
)
dtype
=
pathtype
(
destination
)
# ensure destination is not a directory
if
dtype
==
"
file
"
and
os
.
path
.
isdir
(
destination
):
destination
=
os
.
path
.
join
(
destination
,
os
.
path
.
basename
(
source
))
# trivial case
if
stype
==
dtype
==
"
file
"
:
shutil
.
copy
(
source
,
destination
)
elif
(
stype
==
"
http
"
or
stype
==
"
ftp
"
)
and
dtype
==
"
file
"
:
f_dest
=
open
(
destination
,
"
w
"
)
f_source
=
urllib2
.
urlopen
(
source
,
timeout
=
timeout
)
copyfileobj
(
f_source
,
f_dest
)
elif
stype
==
"
file
"
and
dtype
==
""
:
raise
NotImplementedError
else
:
raise
NotImplementedError
# setting destination file rights
if
dtype
==
"
file
"
:
chrights
(
destination
,
uid
,
gid
,
mode
)
def
mkdir
(
path
,
uid
=
None
,
gid
=
None
,
mode
=
None
):
'''
Create a directory and set rights
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment