"""
+from __future__ import absolute_import
import pkg_resources
from invirt.config import structs as cfg
from __future__ import with_statement
+from __future__ import absolute_import
import unittest
from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN
import contextlib as clib
@clib.contextmanager
def lock_file(path, exclusive = True):
- with clib.closing(file(path, 'w')) as f:
+ with clib.closing(open(path, 'w')) as f:
if exclusive:
locktype = LOCK_EX
else:
from __future__ import with_statement
+from __future__ import absolute_import
import json
from invirt.common import *
import os
def load_master():
config = dict()
for filename in list_files():
- with closing(file(filename)) as f:
+ with closing(open(filename)) as f:
augment(config, yaml.load(f, loader))
return config
# lock with other concurrent reads). This isolation is accomplished
# using an atomic filesystem rename in the refreshing stage.
try:
- with closing(file(cache_path)) as f:
+ with closing(open(cache_path)) as f:
ns.cfg = json.read(f.read())
except: do_refresh = True
with lock_file(lock_path):
ns.cfg = load_master()
try:
- with closing(file(cache_path + '.tmp', 'w')) as f:
+ with closing(open(cache_path + '.tmp', 'w')) as f:
f.write(json.write(ns.cfg))
except: pass # silent failure
else: rename(cache_path + '.tmp', cache_path)
Functions to perform remctls.
"""
+from __future__ import absolute_import
+from __future__ import print_function
from invirt.common import CodeError
import subprocess
import sys
if kws.get('err'):
return stdout, stderr
if p.returncode:
- print >> sys.stderr, 'Error', p.returncode, 'on remctl', args, ':'
- print >> sys.stderr, stderr
+ print('Error', p.returncode, 'on remctl', args, ':', file=sys.stderr)
+ print(stderr, file=sys.stderr)
raise CodeError('ERROR on remctl')
return stdout