prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  "pwn template" emits a Python2 shebang
  We should probably update this to use Python3 explicitly, since that's what we recommend.
  
  </issue>
  <code>
  [start of pwnlib/commandline/template.py]
  1 #!/usr/bin/env python2
  2 from __future__ import absolute_import
  3 from __future__ import division
  4 
  5 import re
  6 
  7 from pwn import *
  8 from pwnlib.commandline import common
  9 
  10 from mako.lookup import TemplateLookup
  11 
  12 parser = common.parser_commands.add_parser(
  13     'template',
  14     help = 'Generate an exploit template',
  15     description = 'Generate an exploit template'
  16 )
  17 
  18 parser.add_argument('exe', nargs='?', help='Target binary')
  19 parser.add_argument('--host', help='Remote host / SSH server')
  20 parser.add_argument('--port', help='Remote port / SSH port', type=int)
  21 parser.add_argument('--user', help='SSH Username')
  22 parser.add_argument('--pass', '--password', help='SSH Password', dest='password')
  23 parser.add_argument('--path', help='Remote path of file on SSH server')
  24 parser.add_argument('--quiet', help='Less verbose template comments', action='store_true')
  25 parser.add_argument('--color', help='Print the output in color', choices=['never', 'always', 'auto'], default='auto')
  26 
  27 def main(args):
  28     cache = None
  29 
  30     if cache:
  31         cache = os.path.join(context.cache_dir, 'mako')
  32 
  33     lookup = TemplateLookup(
  34         directories      = [os.path.join(pwnlib.data.path, 'templates')],
  35         module_directory = cache
  36     )
  37 
  38     # For the SSH scenario, check that the binary is at the
  39     # same path on the remote host.
  40     if args.user:
  41         if not (args.path or args.exe):
  42             log.error("Must specify --path or a exe")
  43 
  44         s = ssh(args.user, args.host, args.port or 22, args.password or None)
  45 
  46         try:
  47             remote = args.path or args.exe
  48             s.download(remote)
  49         except Exception:
  50             log.warning("Could not download file %r, opening a shell", remote)
  51             s.interactive()
  52             return
  53 
  54         if not args.exe:
  55             args.exe = os.path.basename(args.path)
  56 
  57     template = lookup.get_template('pwnup.mako')
  58     output = template.render(args.exe,
  59                              args.host,
  60                              args.port,
  61                              args.user,
  62                              args.password,
  63                              args.path,
  64                              args.quiet)
  65 
  66     # Fix Mako formatting bs
  67     output = re.sub('\n\n\n', '\n\n', output)
  68 
  69     # Colorize the output if it's a TTY
  70     if args.color == 'always' or (args.color == 'auto' and sys.stdout.isatty()):
  71         from pygments import highlight
  72         from pygments.formatters import TerminalFormatter
  73         from pygments.lexers.python import PythonLexer
  74         output = highlight(output, PythonLexer(), TerminalFormatter())
  75 
  76     print(output)
  77 
  78     # If redirected to a file, make the resulting script executable
  79     if not sys.stdout.isatty():
  80         try: os.fchmod(sys.stdout.fileno(), 0o700)
  81         except OSError: pass
  82 
  83 if __name__ == '__main__':
  84     pwnlib.commandline.common.main(__file__)
  85
  [end of pwnlib/commandline/template.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pwnlib/commandline/template.py b/pwnlib/commandline/template.py
  old mode 100644
  new mode 100755
  --- a/pwnlib/commandline/template.py
  +++ b/pwnlib/commandline/template.py
  @@ -2,8 +2,6 @@
   from __future__ import absolute_import
   from __future__ import division
   
  -import re
  -
   from pwn import *
   from pwnlib.commandline import common
   
  @@ -25,14 +23,9 @@
   parser.add_argument('--color', help='Print the output in color', choices=['never', 'always', 'auto'], default='auto')
   
   def main(args):
  -    cache = None
  -
  -    if cache:
  -        cache = os.path.join(context.cache_dir, 'mako')
  -
       lookup = TemplateLookup(
           directories      = [os.path.join(pwnlib.data.path, 'templates')],
  -        module_directory = cache
  +        module_directory = None
       )
   
       # For the SSH scenario, check that the binary is at the
  @@ -44,10 +37,10 @@
           s = ssh(args.user, args.host, args.port or 22, args.password or None)
   
           try:
  -            remote = args.path or args.exe
  -            s.download(remote)
  +            remote_file = args.path or args.exe
  +            s.download(remote_file)
           except Exception:
  -            log.warning("Could not download file %r, opening a shell", remote)
  +            log.warning("Could not download file %r, opening a shell", remote_file)
               s.interactive()
               return
  
verification_info: {"golden_diff": "diff --git a/pwnlib/commandline/template.py b/pwnlib/commandline/template.py\nold mode 100644\nnew mode 100755\n--- a/pwnlib/commandline/template.py\n+++ b/pwnlib/commandline/template.py\n@@ -2,8 +2,6 @@\n from __future__ import absolute_import\n from __future__ import division\n \n-import re\n-\n from pwn import *\n from pwnlib.commandline import common\n \n@@ -25,14 +23,9 @@\n parser.add_argument('--color', help='Print the output in color', choices=['never', 'always', 'auto'], default='auto')\n \n def main(args):\n-    cache = None\n-\n-    if cache:\n-        cache = os.path.join(context.cache_dir, 'mako')\n-\n     lookup = TemplateLookup(\n         directories      = [os.path.join(pwnlib.data.path, 'templates')],\n-        module_directory = cache\n+        module_directory = None\n     )\n \n     # For the SSH scenario, check that the binary is at the\n@@ -44,10 +37,10 @@\n         s = ssh(args.user, args.host, args.port or 22, args.password or None)\n \n         try:\n-            remote = args.path or args.exe\n-            s.download(remote)\n+            remote_file = args.path or args.exe\n+            s.download(remote_file)\n         except Exception:\n-            log.warning(\"Could not download file %r, opening a shell\", remote)\n+            log.warning(\"Could not download file %r, opening a shell\", remote_file)\n             s.interactive()\n             return\n", "issue": "\"pwn template\" emits a Python2 shebang\nWe should probably update this to use Python3 explicitly, since that's what we recommend.\n", "before_files": [{"content": "#!/usr/bin/env python2\nfrom __future__ import absolute_import\nfrom __future__ import division\n\nimport re\n\nfrom pwn import *\nfrom pwnlib.commandline import common\n\nfrom mako.lookup import TemplateLookup\n\nparser = common.parser_commands.add_parser(\n    'template',\n    help = 'Generate an exploit template',\n    description = 'Generate an exploit template'\n)\n\nparser.add_argument('exe', nargs='?', help='Target binary')\nparser.add_argument('--host', help='Remote host / SSH server')\nparser.add_argument('--port', help='Remote port / SSH port', type=int)\nparser.add_argument('--user', help='SSH Username')\nparser.add_argument('--pass', '--password', help='SSH Password', dest='password')\nparser.add_argument('--path', help='Remote path of file on SSH server')\nparser.add_argument('--quiet', help='Less verbose template comments', action='store_true')\nparser.add_argument('--color', help='Print the output in color', choices=['never', 'always', 'auto'], default='auto')\n\ndef main(args):\n    cache = None\n\n    if cache:\n        cache = os.path.join(context.cache_dir, 'mako')\n\n    lookup = TemplateLookup(\n        directories      = [os.path.join(pwnlib.data.path, 'templates')],\n        module_directory = cache\n    )\n\n    # For the SSH scenario, check that the binary is at the\n    # same path on the remote host.\n    if args.user:\n        if not (args.path or args.exe):\n            log.error(\"Must specify --path or a exe\")\n\n        s = ssh(args.user, args.host, args.port or 22, args.password or None)\n\n        try:\n            remote = args.path or args.exe\n            s.download(remote)\n        except Exception:\n            log.warning(\"Could not download file %r, opening a shell\", remote)\n            s.interactive()\n            return\n\n        if not args.exe:\n            args.exe = os.path.basename(args.path)\n\n    template = lookup.get_template('pwnup.mako')\n    output = template.render(args.exe,\n                             args.host,\n                             args.port,\n                             args.user,\n                             args.password,\n                             args.path,\n                             args.quiet)\n\n    # Fix Mako formatting bs\n    output = re.sub('\\n\\n\\n', '\\n\\n', output)\n\n    # Colorize the output if it's a TTY\n    if args.color == 'always' or (args.color == 'auto' and sys.stdout.isatty()):\n        from pygments import highlight\n        from pygments.formatters import TerminalFormatter\n        from pygments.lexers.python import PythonLexer\n        output = highlight(output, PythonLexer(), TerminalFormatter())\n\n    print(output)\n\n    # If redirected to a file, make the resulting script executable\n    if not sys.stdout.isatty():\n        try: os.fchmod(sys.stdout.fileno(), 0o700)\n        except OSError: pass\n\nif __name__ == '__main__':\n    pwnlib.commandline.common.main(__file__)\n", "path": "pwnlib/commandline/template.py"}]}