mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-26 18:06:13 +01:00
Merge pull request #847 from marcus-h/service_old_dir
Add .old dir support for source services
This commit is contained in:
commit
224ec6eef5
21
osc/core.py
21
osc/core.py
@ -410,16 +410,27 @@ class Serviceinfo:
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
def execute(self, dir, callmode = None, singleservice = None, verbose = None):
|
def execute(self, dir, callmode = None, singleservice = None, verbose = None):
|
||||||
|
old_dir = os.path.join(dir, '.old')
|
||||||
|
if os.path.exists(old_dir) or os.path.islink(old_dir):
|
||||||
|
msg = '"%s" exists, please remove it' % old_dir
|
||||||
|
raise oscerr.OscIOError(None, msg)
|
||||||
|
try:
|
||||||
|
os.mkdir(old_dir)
|
||||||
|
return self._execute(dir, old_dir, callmode, singleservice,
|
||||||
|
verbose)
|
||||||
|
finally:
|
||||||
|
if os.path.exists(old_dir):
|
||||||
|
shutil.rmtree(old_dir)
|
||||||
|
|
||||||
|
def _execute(self, dir, old_dir, callmode=None, singleservice=None,
|
||||||
|
verbose=None):
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
# cleanup existing generated files
|
# cleanup existing generated files
|
||||||
for filename in os.listdir(dir):
|
for filename in os.listdir(dir):
|
||||||
if filename.startswith('_service:') or filename.startswith('_service_'):
|
if filename.startswith('_service:') or filename.startswith('_service_'):
|
||||||
ent = os.path.join(dir, filename)
|
os.rename(os.path.join(dir, filename),
|
||||||
if os.path.isdir(ent):
|
os.path.join(old_dir, filename))
|
||||||
shutil.rmtree(ent)
|
|
||||||
else:
|
|
||||||
os.unlink(ent)
|
|
||||||
|
|
||||||
allservices = self.services or []
|
allservices = self.services or []
|
||||||
service_names = [s['name'] for s in allservices]
|
service_names = [s['name'] for s in allservices]
|
||||||
|
Loading…
Reference in New Issue
Block a user