Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion imagefactory_plugins/EC2/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def __init__(self):
self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
config_obj = ApplicationConfiguration()
self.app_config = config_obj.configuration
self.oz_config = configparser.SafeConfigParser()
try:
self.oz_config = configparser.SafeConfigParser()
except AttributeError:
# SafeConfigParser was deprecated in Python 3.2
self.oz_config = configparser.ConfigParser()
self.oz_config.read("/etc/oz/oz.cfg")
self.oz_config.set('paths', 'output_dir', self.app_config["imgdir"])
self.guest = None
Expand Down
6 changes: 5 additions & 1 deletion imagefactory_plugins/IndirectionCloud/IndirectionCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ def oz_refresh_customizations(self, partial_tdl):
def _init_oz(self):
# populate a config object to pass to OZ; this allows us to specify our
# own output dir but inherit other Oz behavior
self.oz_config = configparser.SafeConfigParser()
try:
self.oz_config = configparser.SafeConfigParser()
except AttributeError:
# SafeConfigParser was deprecated in Python 3.2
self.oz_config = configparser.ConfigParser()
if self.oz_config.read("/etc/oz/oz.cfg") != []:
self.oz_config.set('paths', 'output_dir', self.app_config["imgdir"])
if "oz_data_dir" in self.app_config:
Expand Down
8 changes: 6 additions & 2 deletions imagefactory_plugins/Nova/Nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
from time import sleep
from base64 import b64decode
#TODO: remove dependency on Oz
from configparser import SafeConfigParser
try:
from configparser import SafeConfigParser as ConfigParser
except AttributeError:
# SafeConfigParser was deprecated in Python 3.2
from configparser import ConfigParser
from oz.TDL import TDL
import oz.GuestFactory

Expand Down Expand Up @@ -438,7 +442,7 @@ def _confirm_ssh_access(self, guest, addr, timeout=300):
return confirmation

def _oz_config(self, private_key_file):
config = SafeConfigParser()
config = ConfigParser()
if config.read("/etc/oz/oz.cfg"):
config.set('paths', 'output_dir', self.app_config['imgdir'])
config.set('paths', 'sshprivkey', private_key_file)
Expand Down
6 changes: 5 additions & 1 deletion imagefactory_plugins/Rackspace/Rackspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def __init__(self):
self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
config_obj = ApplicationConfiguration()
self.app_config = config_obj.configuration
self.oz_config = configparser.SafeConfigParser()
try:
self.oz_config = configparser.SafeConfigParser()
except AttributeError:
# SafeConfigParser was deprecated in Python 3.2
self.oz_config = configparser.ConfigParser()
self.oz_config.read("/etc/oz/oz.cfg")
self.oz_config.set('paths', 'output_dir', self.app_config["imgdir"])
self.active_image = None
Expand Down
6 changes: 5 additions & 1 deletion imagefactory_plugins/TinMan/TinMan.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ def _init_oz(self):

# populate a config object to pass to OZ; this allows us to specify our
# own output dir but inherit other Oz behavior
self.oz_config = configparser.SafeConfigParser()
try:
self.oz_config = configparser.SafeConfigParser()
except AttributeError:
# SafeConfigParser was deprecated in Python 3.2
self.oz_config = configparser.ConfigParser()
if self.oz_config.read("/etc/oz/oz.cfg") != []:
if self.parameters.get("oz_overrides", None) != None:
oz_overrides = json.loads(self.parameters.get("oz_overrides",None).replace("'", "\""))
Expand Down
22 changes: 12 additions & 10 deletions imgfac/rest/bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
if _cmd_options.server and _cmd_options.server.startswith('gevent'):
import gevent.monkey; gevent.monkey.patch_all()

import base64, cgi, email.utils, functools, hmac, imp, itertools, mimetypes,\
os, re, subprocess, sys, tempfile, threading, time, warnings
import base64, cgi, email.utils, functools, hmac, itertools, mimetypes,\
os, re, subprocess, sys, tempfile, threading, time, types, warnings

from datetime import date as datedate, datetime, timedelta
from tempfile import TemporaryFile
Expand Down Expand Up @@ -842,17 +842,19 @@ def default_error_handler(self, res):
return tob(template(ERROR_PAGE_TEMPLATE, e=res))

def _handle(self, environ):
path = environ['bottle.raw_path'] = environ['PATH_INFO']
if py3k:
try:
environ['PATH_INFO'] = path.encode('latin1').decode('utf8')
except UnicodeError:
return HTTPError(400, 'Invalid path string. Expected UTF-8')

try:

environ['bottle.app'] = self
request.bind(environ)
response.bind()

path = environ['bottle.raw_path'] = environ['PATH_INFO']
if py3k:
try:
environ['PATH_INFO'] = path.encode('latin1').decode('utf8')
except UnicodeError:
return HTTPError(400, 'Invalid path string. Expected UTF-8')

try:
self.trigger_hook('before_request')
route, args = self.router.match(environ)
Expand Down Expand Up @@ -1779,7 +1781,7 @@ def __init__(self, name, impmask):
''' Create a virtual package that redirects imports (see PEP 302). '''
self.name = name
self.impmask = impmask
self.module = sys.modules.setdefault(name, imp.new_module(name))
self.module = sys.modules.setdefault(name, types.ModuleType(name))
self.module.__dict__.update({'__file__': __file__, '__path__': [],
'__all__': [], '__loader__': self})
sys.meta_path.append(self)
Expand Down