mirror of
https://github.com/httpie/cli.git
synced 2025-02-13 13:18:45 +02:00
Fix sessions for Windows
':' is invalid in a Windows path, and json needs output to support write(str).
This commit is contained in:
parent
47de4e2c9c
commit
898408c20c
@ -67,7 +67,10 @@ class Host(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
path = os.path.join(SESSIONS_DIR, self.name)
|
# Name will include ':' if a port is specified, which is invalid
|
||||||
|
# on windows. DNS does not allow '_' in a domain, or for it to end
|
||||||
|
# in a number (I think?)
|
||||||
|
path = os.path.join(SESSIONS_DIR, self.name.replace(':', '_'))
|
||||||
try:
|
try:
|
||||||
os.makedirs(path, mode=0o700)
|
os.makedirs(path, mode=0o700)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
@ -110,9 +113,9 @@ class Session(dict):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self['__version__'] = __version__
|
self['__version__'] = __version__
|
||||||
with open(self.path, 'wb') as f:
|
with open(self.path, 'w') as f:
|
||||||
json.dump(self, f, indent=4, sort_keys=True, ensure_ascii=True)
|
json.dump(self, f, indent=4, sort_keys=True, ensure_ascii=True)
|
||||||
f.write(b'\n')
|
f.write('\n')
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user