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

Commit fdece27

Browse files
committed
Handle r/w corretly on py3k #1
1 parent 5c515c8 commit fdece27

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: cloudflare-partner-cli.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,12 @@ def check_hostkey(force = False):
320320
while not HOSTKEY or len(HOSTKEY) != 32:
321321
HOSTKEY = raw_input(i18n("Please enter your Cloudflare partner hostkey (https://partners.cloudflare.com/api-management)> ")).strip()
322322
import re
323-
with open(__file__) as f:
323+
with open(__file__, "rb") as f:
324324
script = f.read()
325-
script = re.sub("HOSTKEY.+HOSTKEY_ANCHOR", "HOSTKEY = \"%s\" # HOSTKEY_ANCHOR" % HOSTKEY, script, count = 1)
326-
with open(__file__, 'w') as f:
325+
if PY3K:
326+
HOSTKEY = HOSTKEY.encode('ascii')
327+
script = re.sub(b"HOSTKEY.+HOSTKEY_ANCHOR", b"HOSTKEY = \"%s\" # HOSTKEY_ANCHOR" % HOSTKEY, script, count = 1)
328+
with open(__file__, 'wb') as f:
327329
f.write(script)
328330

329331
def menu(act = None):

0 commit comments

Comments
 (0)