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
fb5bb9e0
Commit
fb5bb9e0
authored
13 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
introduce offline repository mode
this allow to register breaked or offline repository wihtou breaking all is
parent
9caf038c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
installsystems/repository.py
+28
-20
28 additions, 20 deletions
installsystems/repository.py
with
28 additions
and
20 deletions
installsystems/repository.py
+
28
−
20
View file @
fb5bb9e0
...
...
@@ -27,10 +27,13 @@ class Repository(object):
def
__init__
(
self
,
config
):
self
.
config
=
config
try
:
self
.
db
=
Database
(
config
.
dbpath
)
except
:
self
.
db
=
None
if
not
config
.
offline
:
try
:
self
.
db
=
Database
(
config
.
dbpath
)
except
:
self
.
config
.
offline
=
True
if
config
.
offline
:
debug
(
"
Repository %s is offline
"
%
config
.
name
)
def
__getattribute__
(
self
,
name
):
'''
...
...
@@ -38,14 +41,13 @@ class Repository(object):
Unavailable can be caused because db is not accessible or
because repository is not initialized
'''
db
=
object
.
__getattribute__
(
self
,
"
db
"
)
config
=
object
.
__getattribute__
(
self
,
"
config
"
)
# config and init are always accessible
if
name
in
(
"
init
"
,
"
config
"
):
return
object
.
__getattribute__
(
self
,
name
)
# if no db (not init or not accessible) raise error
if
db
is
No
ne
:
raise
Exception
(
"
Repository %s is
not availab
e
"
%
config
.
name
)
if
config
.
offli
ne
:
raise
Exception
(
"
Repository %s is
offlin
e
"
%
config
.
name
)
return
object
.
__getattribute__
(
self
,
name
)
def
init
(
self
):
...
...
@@ -318,6 +320,7 @@ class RepositoryConfig(object):
# set default value for arguments
self
.
name
=
name
self
.
path
=
""
self
.
offline
=
False
self
.
_dbpath
=
None
self
.
dbname
=
"
db
"
self
.
_lastpath
=
None
...
...
@@ -564,19 +567,24 @@ class RepositoryManager(object):
if
not
os
.
path
.
exists
(
filedest
):
open
(
filedest
,
"
wb
"
)
# get remote last value
rlast
=
int
(
istools
.
uopen
(
config
.
lastpath
).
read
().
strip
())
# get local last value
llast
=
int
(
os
.
stat
(
filedest
).
st_mtime
)
# if repo is out of date, download it
if
rlast
!=
llast
:
arrow
(
"
Getting %s
"
%
config
.
dbpath
)
istools
.
copy
(
config
.
dbpath
,
filedest
,
uid
=
config
.
uid
,
gid
=
config
.
gid
,
mode
=
config
.
fmod
,
timeout
=
self
.
timeout
)
os
.
utime
(
filedest
,
(
rlast
,
rlast
))
config
.
dbpath
=
filedest
try
:
rlast
=
int
(
istools
.
uopen
(
config
.
lastpath
).
read
().
strip
())
# get local last value
llast
=
int
(
os
.
stat
(
filedest
).
st_mtime
)
# if repo is out of date, download it
if
rlast
!=
llast
:
arrow
(
"
Getting %s
"
%
config
.
dbpath
)
istools
.
copy
(
config
.
dbpath
,
filedest
,
uid
=
config
.
uid
,
gid
=
config
.
gid
,
mode
=
config
.
fmod
,
timeout
=
self
.
timeout
)
os
.
utime
(
filedest
,
(
rlast
,
rlast
))
config
.
dbpath
=
filedest
except
:
# if something append bad during caching, we mark repo as offline
config
.
offline
=
True
return
Repository
(
config
)
def
get
(
self
,
name
,
version
=
None
):
...
...
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