Skip to content

Commit 6204d22

Browse files
committed
Fix imports and remove redundancy
Remove unused functions
1 parent ba7ff87 commit 6204d22

10 files changed

+55
-94
lines changed

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change Log
22
==========
33

4+
0.4.2 (05/01/2022)
5+
------------------
6+
- Fix imports and remove redundancy
7+
- Remove unused functions
8+
49
0.4.1 (01/19/2022)
510
------------------
611
- Check for app running on port before initiating tunneling

docs/genindex.html

-4
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ <h2 id="M">M</h2>
209209

210210
<h2 id="P">P</h2>
211211
<table style="width: 100%" class="indextable genindextable"><tr>
212-
<td style="width: 33%; vertical-align: top;"><ul>
213-
<li><a href="index.html#helpers.auxiliary.prefix">prefix() (in module helpers.auxiliary)</a>
214-
</li>
215-
</ul></td>
216212
<td style="width: 33%; vertical-align: top;"><ul>
217213
<li><a href="index.html#helpers.server.print_warning">print_warning() (in module helpers.server)</a>
218214
</li>

docs/index.html

-17
Original file line numberDiff line numberDiff line change
@@ -452,23 +452,6 @@ <h1>Welcome to Expose’s documentation!<a class="headerlink" href="#welcome-to-
452452
</dl>
453453
</dd></dl>
454454

455-
<dl class="py function">
456-
<dt class="sig sig-object py" id="helpers.auxiliary.prefix">
457-
<span class="sig-prename descclassname"><span class="pre">helpers.auxiliary.</span></span><span class="sig-name descname"><span class="pre">prefix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'DEBUG'</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#helpers.auxiliary.prefix" title="Permalink to this definition"></a></dt>
458-
<dd><p>Replicates the logging config to print colored statements accordingly.</p>
459-
<dl class="field-list simple">
460-
<dt class="field-odd">Parameters</dt>
461-
<dd class="field-odd"><p><strong>level</strong> – Takes the log level as an argument.</p>
462-
</dd>
463-
<dt class="field-even">Returns</dt>
464-
<dd class="field-even"><p>A well formatted prefix to be added before a print statement.</p>
465-
</dd>
466-
<dt class="field-odd">Return type</dt>
467-
<dd class="field-odd"><p>str</p>
468-
</dd>
469-
</dl>
470-
</dd></dl>
471-
472455
</section>
473456
<section id="module-helpers.cert">
474457
<span id="expose-certificates"></span><h1>Expose - Certificates<a class="headerlink" href="#module-helpers.cert" title="Permalink to this headline"></a></h1>

docs/objects.inv

-5 Bytes
Binary file not shown.

docs/searchindex.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

expose/helpers/auxiliary.py

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import json
22
import sys
3-
from datetime import datetime
4-
from inspect import currentframe, getframeinfo, getouterframes, stack
5-
from time import sleep
3+
import time
64
from urllib.request import urlopen
75

86
DATETIME_FORMAT = '%b-%d-%Y %I:%M:%S %p'
@@ -15,10 +13,10 @@ def sleeper(sleep_time: int) -> None:
1513
Args:
1614
sleep_time: Takes the time script has to sleep, as an argument.
1715
"""
18-
sleep(1)
16+
time.sleep(1)
1917
for i in range(sleep_time):
2018
sys.stdout.write(f'\rRemaining: {sleep_time - i:0{len(str(sleep_time))}}s')
21-
sleep(1)
19+
time.sleep(1)
2220
sys.stdout.flush()
2321
sys.stdout.write('\r')
2422

@@ -47,18 +45,3 @@ def time_converter(seconds: float) -> str:
4745
return f'{minutes} minutes, and {seconds} seconds'
4846
elif seconds:
4947
return f'{seconds} seconds'
50-
51-
52-
def prefix(level: str = 'DEBUG') -> str:
53-
"""Replicates the logging config to print colored statements accordingly.
54-
55-
Args:
56-
level: Takes the log level as an argument.
57-
58-
Returns:
59-
str:
60-
A well formatted prefix to be added before a print statement.
61-
"""
62-
calling_file = getouterframes(currentframe(), 2)[1][1].split('/')[-1].rstrip('.py')
63-
return f"{datetime.now().strftime(DATETIME_FORMAT)} - {level} - [{calling_file}:" \
64-
f"{getframeinfo(stack()[1][0]).lineno}] - {stack()[1].function} - "

expose/helpers/route_53.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import logging
2-
31
import boto3
42
from botocore.exceptions import ClientError
53

6-
LOGGER = logging.getLogger(__name__)
7-
handler = logging.StreamHandler()
8-
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - [%(module)s:%(lineno)d] - %(funcName)s - %(message)s',
9-
datefmt='%b-%d-%Y %I:%M:%S %p')
10-
handler.setFormatter(fmt=formatter)
11-
LOGGER.addHandler(hdlr=handler)
12-
LOGGER.setLevel(level=logging.DEBUG)
4+
from expose.helpers.logger import LOGGER
135

146
client = boto3.client('route53')
157

expose/helpers/server.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _handler(self, channel: Channel, port: int) -> None:
128128
if socket_ in read:
129129
if not (data := socket_.recv(1024)):
130130
break
131-
channel.send(data)
131+
channel.send(data.decode(encoding='UTF-8'))
132132
if channel in read:
133133
if not (data := channel.recv(1024)):
134134
break
@@ -163,7 +163,6 @@ def initiate_tunnel(self, port: int) -> None:
163163
Thread(target=self._handler, args=[channel, port], daemon=True).start()
164164
except KeyboardInterrupt:
165165
LOGGER.info("Tunneling interrupted")
166-
LOGGER.info(f"Stopping reverse tunneling on {join(transport.getpeername())}")
167166
if host_keys := self.ssh_client.get_host_keys().keys():
168167
LOGGER.info(f"Closing SSH connection on {host_keys[0]}")
169168
else:

0 commit comments

Comments
 (0)