Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 compatiblity fixes #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions bin/make-deb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def main():
debconf = DebianConfiguration(os.getcwd())
debconf.render()
except DebianConfigurationException as e:
print e
print(e)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add from __future__ import print_function as the first line, otherwise this can have surprising behavior when modified.

return 1

print "'debian' directory successfully placed at the root of your repository"
print("'debian' directory successfully placed at the root of your repository")
return 0

if __name__ == "__main__":
Expand Down
14 changes: 7 additions & 7 deletions make_deb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ def _context_from_setuppy(self):
"--name", "--version", "--maintainer", "--maintainer-email",
"--description"], stdout=subprocess.PIPE).communicate()

setup_values = stdout[0].split("\n")[0:-1]
setup_values = stdout[0].decode('utf-8').split("\n")[0:-1]
setup_names = ["name", "version", "maintainer", "maintainer_email",
"description"]

context = {}
for name, value in zip(setup_names, setup_values):
while not value or value == UNKNOWN:
value = raw_input(
value = input(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't safe for python2, input on python2 is eval(raw_input())

"The '{}' parameter is not defined in setup.py. "
"Please define it for debian configuration: ".format(name))
if not value:
print "Invalid value. Please try again"
print("Invalid value. Please try again")

context[name] = value

Expand All @@ -81,17 +81,17 @@ def render(self):

for template in self.DEBIAN_CONFIGURATION_TEMPLATES:
filename = os.path.basename(template).replace(".j2", "")
content = Template(resource_string("make_deb", template)) \
content = Template(resource_string("make_deb", template).decode('utf-8')) \
.render(self.context)

with open(os.path.join(output_dir, filename), "wb") as f:
f.write(content)
f.write(content.encode('utf-8'))

# Need to to trigger separately because filename must change
trigger_content = Template(
resource_string("make_deb", "resources/debian/triggers.j2")
resource_string("make_deb", "resources/debian/triggers.j2").decode('utf-8')
).render(self.context)

trigger_filename = "%s.triggers" % self.context['name']
with open(os.path.join(output_dir, trigger_filename), "wb") as f:
f.write(trigger_content+"\n")
f.write((trigger_content+"\n").encode('utf-8'))