[CRIU] [PATCH] p.haul: images: create img_dir if it doesn't exist

Ruslan Kuprieiev kupruser at gmail.com
Tue Oct 14 08:01:06 PDT 2014


On 14.10.2014 17:07, Pavel Emelyanov wrote:
> On 10/13/2014 01:37 PM, Ruslan Kuprieiev wrote:
>> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>> ---
>>   images.py | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/images.py b/images.py
>> index ef5691f..1fd9610 100644
>> --- a/images.py
>> +++ b/images.py
>> @@ -9,6 +9,7 @@ import time
>>   import shutil
>>   import time
>>   import threading
>> +import errno
>>   import util
>>   import criu_api
>>   
>> @@ -76,6 +77,13 @@ class phaul_images:
>>   		self._keep_on_close = opts["keep_images"]
>>   
>>   		suf = time.strftime("-%y.%m.%d-%H.%M", time.localtime())
>> +		try:
>> +			os.makedirs(opts["img_path"])
>> +		except OSError as er:
>> +			if er.errno == errno.EEXIST and os.path.isdir(opts["img_path"]):
>> +				pass
>> +			else:
>> +				raise
> Can we have this as a helper call in util.py?

Sure, already sent it as a response to your msg ([PATCH] p.haul: images: 
create img_dir if it doesn't exist, v2).

>>   		wdir = tempfile.mkdtemp(suf, "%s-" % self._typ, opts["img_path"])
>>   		self._wdir = opendir(wdir)
>>   		self._img_path = os.path.join(self._wdir.name(), "img")
>>



More information about the CRIU mailing list