Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle r/w corretly on py3k #1
  • Loading branch information
fffonion committed Apr 19, 2018
1 parent 5c515c8 commit fdece27
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cloudflare-partner-cli.py
Expand Up @@ -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):
Expand Down

0 comments on commit fdece27

Please sign in to comment.