Permalink
Browse files

Handle r/w corretly on py3k #1

  • Loading branch information...
fffonion committed Apr 19, 2018
1 parent 5c515c8 commit fdece27aa90079e7a625dabf2be4886ca5773ee3
Showing with 5 additions and 3 deletions.
  1. +5 −3 cloudflare-partner-cli.py
@@ -320,10 +320,12 @@ def check_hostkey(force = False):
while not HOSTKEY or len(HOSTKEY) != 32:
HOSTKEY = raw_input(i18n("Please enter your Cloudflare partner hostkey (https://partners.cloudflare.com/api-management)> ")).strip()
import re
with open(__file__) as f:
with open(__file__, "rb") as f:
script = f.read()
script = re.sub("HOSTKEY.+HOSTKEY_ANCHOR", "HOSTKEY = \"%s\" # HOSTKEY_ANCHOR" % HOSTKEY, script, count = 1)
with open(__file__, 'w') as f:
if PY3K:
HOSTKEY = HOSTKEY.encode('ascii')
script = re.sub(b"HOSTKEY.+HOSTKEY_ANCHOR", b"HOSTKEY = \"%s\" # HOSTKEY_ANCHOR" % HOSTKEY, script, count = 1)
with open(__file__, 'wb') as f:
f.write(script)
def menu(act = None):

0 comments on commit fdece27

Please sign in to comment.