#3866: author_name() wasn't strict about returning unicode. Converted everything to be unicode-centric to fix these issues

This commit is contained in:
Ken Conley 2012-02-28 18:44:35 +00:00
parent 34f5f42ada
commit 22c2ba0979
2 changed files with 9 additions and 4 deletions

View File

@ -59,11 +59,11 @@ def author_name():
# in case pwnam is not set
if not name:
name = login
elif type(name) == str:
name = name.decode('utf-8')
except:
#pwd failed
pass
if type(name) == str:
name = name.decode('utf-8')
return name
def read_template(tmplf):
@ -80,6 +80,8 @@ def read_template(tmplf):
r = rospkg.RosPack()
with open(os.path.join(r.get_path('roscreate'), 'templates', tmplf)) as f:
t = f.read()
if type(t) == str:
t = t.decode('utf-8')
return t

View File

@ -91,7 +91,7 @@ def create_package(package, author, depends, uses_roscpp=False, uses_rospy=False
contents = instantiate_template(template, package, package, package, author, depends)
p = os.path.abspath(os.path.join(package, filename))
with open(p, 'w') as f:
f.write(contents)
f.write(contents.encode('utf-8'))
print("Created package file", p)
print("\nPlease edit %s/manifest.xml and mainpage.dox to finish creating your package"%package)
@ -118,8 +118,11 @@ def roscreatepkg_main():
except ResourceNotFound:
print("ERROR: dependency [%s] cannot be found"%d, file=sys.stderr)
sys.exit(1)
depends = ''.join([' <depend package="%s"/>\n'%d for d in depends])
depends = u''.join([u' <depend package="%s"/>\n'%d for d in depends])
if not on_ros_path(os.getcwd()):
print('!'*80+"\nWARNING: current working directory is not on ROS_PACKAGE_PATH!\nPlease update your ROS_PACKAGE_PATH environment variable.\n"+'!'*80, file=sys.stderr)
if type(package) == str:
package = package.decode('utf-8')
create_package(package, author_name(), depends, uses_roscpp=uses_roscpp, uses_rospy=uses_rospy)