From 2b74caecbacac445b594e10b0c942da085c4aacd Mon Sep 17 00:00:00 2001 From: thevickypedia Date: Sat, 16 Apr 2022 11:27:53 -0500 Subject: [PATCH] Update docstrings --- analyzer.py | 21 +++--- doc_generator/_build/doctrees/README.doctree | Bin 6858 -> 6846 bytes .../_build/doctrees/environment.pickle | Bin 16772 -> 17384 bytes doc_generator/_build/doctrees/index.doctree | Bin 27118 -> 44398 bytes docs/genindex.html | 40 +++++++++++ docs/index.html | 67 ++++++++++++++++++ docs/objects.inv | Bin 362 -> 409 bytes docs/searchindex.js | 2 +- 8 files changed, 119 insertions(+), 11 deletions(-) diff --git a/analyzer.py b/analyzer.py index 290ef11..1fc25ce 100644 --- a/analyzer.py +++ b/analyzer.py @@ -26,7 +26,7 @@ LOGGER.addHandler(hdlr=handler) -def _custom_time(*args: logging.Formatter or time.time) -> time.struct_time: +def custom_time(*args: logging.Formatter or time.time) -> time.struct_time: """Creates custom timezone for ``logging`` which gets used only when invoked by ``Docker``. This is used only when triggered within a ``docker container`` as it uses UTC timezone. @@ -44,7 +44,7 @@ def _custom_time(*args: logging.Formatter or time.time) -> time.struct_time: return datetime.now().astimezone(tz=local_timezone).timetuple() -def _extract_str(input_: AnyStr) -> str: +def extract_str(input_: AnyStr) -> str: """Extracts strings from the received input. Args: @@ -57,15 +57,16 @@ def _extract_str(input_: AnyStr) -> str: return "".join([i for i in input_ if not i.isdigit() and i not in [",", ".", "?", "-", ";", "!", ":"]]).strip() -def _device_name(): +def device_name() -> str: + """Gets the device name for MacOS and Windows.""" if platform.system() == 'Darwin': system_kernel = subprocess.check_output("sysctl hw.model", shell=True).decode('utf-8').splitlines() - return _extract_str(system_kernel[0].split(':')[1]) + return extract_str(system_kernel[0].split(':')[1]) elif platform.system() == 'Windows': return subprocess.getoutput("WMIC CSPRODUCT GET VENDOR").replace('Vendor', '').strip() -def _get_ssid() -> Union[str, None]: +def get_ssid() -> Union[str, None]: """Checks the current operating system and runs the appropriate command to get the SSID of the access point. Returns: @@ -79,7 +80,7 @@ def _get_ssid() -> Union[str, None]: ) out, err = process.communicate() if out.decode(encoding='UTF-8').strip() == "AirPort: Off": - LOGGER.warning(f"{_device_name()} WiFi is turned off.") + LOGGER.warning(f"{device_name()} WiFi is turned off.") return if error := process.returncode: LOGGER.error(f"Failed to fetch SSID with exit code: {error}\n{err}") @@ -94,7 +95,7 @@ def _get_ssid() -> Union[str, None]: return info.strip('SSID').replace('SSID', '').replace(':', '').strip() -def _send_sms(msg: str) -> NoReturn: +def send_sms(msg: str) -> NoReturn: """Sens an SMS notification when invoked by the ``run`` method. Args: @@ -130,7 +131,7 @@ def __init__(self, router_pass: str = None): raise ValueError( 'Router password is required.' ) - self.ssid = _get_ssid() or 'your Network.' + self.ssid = get_ssid() or 'your Network.' self.snapshot = 'snapshot.json' self.blocked = 'blocked.yaml' self.netgear = Netgear(password=router_pass) @@ -311,12 +312,12 @@ def run(self, block: bool = False) -> NoReturn: LOGGER.info(f'{device.name} does not have internet access.') if threat: - _send_sms(msg=threat) + send_sms(msg=threat) else: LOGGER.info(f'NetScan has completed. No threats found on {self.ssid}') if __name__ == '__main__': if os.environ.get('DOCKER'): - logging.Formatter.converter = _custom_time + logging.Formatter.converter = custom_time LocalIPScan().run() diff --git a/doc_generator/_build/doctrees/README.doctree b/doc_generator/_build/doctrees/README.doctree index 70b566742fc921b1036da1a3022a650a1bea4de1..18825411f1fc757ea79b144cb23e782e263453d7 100644 GIT binary patch delta 32 ncmX?Qy3drQfpzNUjVwNlygK@!#i>Qb`em8P*_E3!851P|y@LxZ delta 44 zcmdmIddifgfpzNsjVwNlk{0@*#i>Qb`em8P*_HY(sm0kP`33svnI)TJ851P|X5bIN diff --git a/doc_generator/_build/doctrees/environment.pickle b/doc_generator/_build/doctrees/environment.pickle index 89588786c76a5d62470ca43487fa4a556d3e920a..7888f724cc74de7ab29a56386f302102db32f0d7 100644 GIT binary patch delta 987 zcmZo^W_;1k$lAa<^{(?q)=Nr4a}P?JWvypoU~qT5F>Uw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6BX*G| z?)i~#X*JkVD}}4U4Qt8Ky)GtDO&-{r>0g5{z@<{X?RP5494*W>3XTI3l!Yq@{;=gA znjmecU=`u^tz(kau;(UnshXVGcPA6W5d?5IsUCKb-TSMUtLacfvu0iseo$Bt z;uM6WmTE%wx3}Ltr$*2398ID@whTkz@EfM#{nFE$VlW0(?Qrb~XUOB)r zd+mn#m_1)?)Slr~`y+E2WsW+GdZe118jdog%&5mLqrO9px*CjvgUYSIMRr=41)R}t z24m=woedDgNA1?S+&J_Q9a=tz8_E66QIg^!kyU7|CZrx#1gf9!*6*#BI#AOUY8< w%bicbr6m1F71BAlFOu+fOu7S`5$xopGjK3d3ND?ehb;ajis%O_uq&|%Ne2Qrs%OujlVmuVlz zWWj|Z68k{%?6Fg_>KPdrG#jVXPSMC<%>qgm%vWSQ2Gk`xdHs9?ro$YQAI>*py2vqE zazPl=0glOq3k;d|fG8#DT@Wj_gDABO<_z@=jSNk{(xj~2Kurtum_9*l`h?Xcprq|W zMaEwsn^-imE^th4Sg6JH9bz2|C(t?_)vQNAtvwvM`6-!sDXA4xN;6cmB!JF^*yJq* z^wbxSQ*_xt%nyWJwRDjVlL{x;|0?&o5tJsQD z6N{2F(A^{rbch-!$W4ftX61@Q|7uxWr0uD=0v~f#od;j+f1ImeepYwR3Kk zTE3Inej!jgYaWP51iCRR4oH;taONfErj}F|q!xo?D%URyq|6Vj#IH0%5)^$|89G3H blZ94$F`eR^9JjiO9i$f+@0%spgfapELjSXN diff --git a/docs/genindex.html b/docs/genindex.html index 3ec83a3..d15e819 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -43,9 +43,13 @@

Index

A | B | C + | D + | E + | G | L | M | R + | S

A

@@ -79,6 +83,34 @@

C

+ +
+ +

D

+ + +
+ +

E

+ + +
+ +

G

+ +
@@ -112,6 +144,14 @@

R

+

S

+ + +
+
diff --git a/docs/index.html b/docs/index.html index c3b17ff..7b19791 100644 --- a/docs/index.html +++ b/docs/index.html @@ -123,6 +123,73 @@

Welcome to NetScan’s documentation! +
+analyzer.custom_time(*args: logging.Formatter) time.struct_time
+

Creates custom timezone for logging which gets used only when invoked by Docker.

+

This is used only when triggered within a docker container as it uses UTC timezone.

+
+
Parameters
+

*args – Takes Formatter object and current epoch time as arguments passed by formatTime from logging.

+
+
Returns
+

A struct_time object which is a tuple of: +current year, month, day, hour, minute, second, weekday, year day and dst (Daylight Saving Time)

+
+
Return type
+

struct_time

+
+
+
+ +
+
+analyzer.device_name() str
+

Gets the device name for MacOS and Windows.

+
+ +
+
+analyzer.extract_str(input_: AnyStr) str
+

Extracts strings from the received input.

+
+
Parameters
+

input_ – Takes a string as argument.

+
+
Returns
+

A string after removing special characters.

+
+
Return type
+

str

+
+
+
+ +
+
+analyzer.get_ssid() Optional[str]
+

Checks the current operating system and runs the appropriate command to get the SSID of the access point.

+
+
Returns
+

SSID of the access point/router which is being accessed.

+
+
Return type
+

str

+
+
+
+ +
+
+analyzer.send_sms(msg: str) NoReturn
+

Sens an SMS notification when invoked by the run method.

+
+
Parameters
+

msg – Message that has to be sent.

+
+
+
+

Indices and tables

diff --git a/docs/objects.inv b/docs/objects.inv index e55a9c72f85880aa54534a519d886b2989e40fca..c7de258eb880c2b637ba403699f3cb4a132a697c 100644 GIT binary patch delta 300 zcmV+{0n`5K0+|Dlc7KygPQx$|hW9yz5o}Y@ZFfj?QHi36E?8Pqdq|@C5qT!GVZ}AL z9w#A*8<9#-Qg+rq-#26V0S-*_hCx)#!g^gB6t|*u8V|FAt+|d_dLz;Vj_B;cD=@2U zqri2VGC(BeW9v732FCb(KMT3=da|{LhUEX`t?_Div84h6qkkj^6&0Q@_CxI^IjSc1 zR&r^v<6mm0xb*Ifq4Bj;C>=~T@W25SOX4um$g!oV)Dv++rzKfBk3TK%?$=8}tQXoV zkv0m2xDlzuU)fpTy!VY{8wEMOPy=<`X;CO^8Qgs}(`evH1P<%|i#a z6-mIbSGh3VLw~WWj@dX!Wvlc@($>lJ7p;ihJ;I_