Auto-complete origin on missing port, magic shutil terminal size

This commit is contained in:
lash 2022-01-21 14:38:06 +00:00
parent fe410e0fc6
commit 0bfe054b90
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# import notifier
from clicada.cli.notify import NotifyWriter
notifier = NotifyWriter()
notifier.notify('loading script')
#notifier.notify('loading script')
# standard imports
import os

View File

@ -3,6 +3,7 @@ import hashlib
import urllib.parse
import os
import logging
from socket import getservbyname
# external imports
from usumbufu.client.base import (
@ -48,7 +49,15 @@ class HTTPSession:
def __init__(self, url, auth=None, origin=None):
self.base_url = url
url_parts = urllib.parse.urlsplit(self.base_url)
url_parts_origin = (url_parts[0], url_parts[1], '', '', '',)
url_parts_origin_host = url_parts[1].split(":")
host = url_parts_origin_host[0]
try:
host = host + ':' + url_parts_origin_host[1]
except IndexError:
host = host + ':' + str(getservbyname(url_parts[0]))
logg.info('changed origin with missing port number from {} to {}'.format(url_parts[1], host))
url_parts_origin = (url_parts[0], host, '', '', '',)
self.origin = origin
if self.origin == None:
self.origin = urllib.parse.urlunsplit(url_parts_origin)

View File

@ -1,12 +1,13 @@
# standard imports
import os
import sys
import shutil
class NotifyWriter:
def __init__(self, writer=sys.stdout):
(c, r) = os.get_terminal_size()
(c, r) = shutil.get_terminal_size()
self.cols = c
self.fmt = "\r{:" + "<{}".format(c) + "}"
self.w = writer

View File

@ -1,6 +1,6 @@
[metadata]
name = clicada
version = 0.0.6a1
version = 0.0.6a2
description = CLI CRM tool for the cic-stack custodial wallet system
author = Louis Holbrook
author_email = dev@holbrook.no