Package: pawnlib
♟️ PawnlibA collection of libraries that can be used like pawns on a chessboard.
Pawnlib is a collection of libraries for IaC.utils, globals vars, logging, http, network, pretty printing, resource, converter ...Installing pawnlibInstalling pawnlibpawnlib is available on PyPI:pip3 install pawnlibpawnlib with wallet is available on PyPI:pip3 install pawnlib[wallet]Global ConfigGlobal ConfigYou can use the global config.frompawnlib.config.globalconfigimportpawnlib_configaspawnfrompawnlib.outputimport*defmain():current_path=get_script_path(__file__)log_time_format='%Y-%m-%d%H:%M:%S.%f'app_name="default_app"stdout=Truepawn.set(PAWN_PATH=current_path,PAWN_TIME_FORMAT=log_time_format,PAWN_LOGGER=dict(log_level="INFO",stdout_level="INFO",log_path=f"{current_path}/logs",stdout=stdout,use_hook_exception=True,),PAWN_CONSOLE=dict(redirect=True,record=True,log_time_format=f"%Y-%m-%d %H:%M:%S.%f",),PAWN_DEBUG=True,# Don't use production, because it's not stored exception log.PAWN_VERBOSE=3,app_name=app_name,app_data={},)pawn.console.log("START APP")pawn.console.log(pawn.to_dict())app builderapp builderYou can create a simple application based on pawnlib with the command below.$pawnsinit[10:35:21,837]main_cliwrappermain_cli.py:117[10:35:21,840]args=Namespace(proxy=None,init=Namespace(command='init')),command=initmain_cli.py:119

--------------------------------------------------


___..__.__.___\_|______|__||__|_/___________|__\||\||/__|/__\___\|\_\ \|/||__//_/\___/||\/|___/____/|__|____/\____|\___>__|\/\/\/-Description:InitializePythonDevelopmentEnvironment-Version:0.0.28-Author:jinwoo


--------------------------------------------------PWD=/Users/jinwoo/work/python_prj/pawnlib


What's your python3 app name? (default_app):What'syourname?(jinwoo):
Pleaseexplainthisscript.(Thisisscript):
Projectdirectory=>/Users/jinwoo/work/python_prj/pawnlib?[y/n](y):
Doyouwanttologger?[y/n](y):
Doyouwanttodaemon?[y/n](n):simple reflector proxysimple reflector proxySimple Python HTTP Server which reflects the client HTTP request header in server logs to see the header fields forwarded by web servers.$pawnsproxy-l8080-f127.0.0.1:8200[10:34:33,898]main_cliwrappermain_cli.py:117[10:34:33,902]args=Namespace(proxy=Namespace(listen='8080',forward='127.0.0.1:8200',buffer_size=4096,delay=0.0001,main_cli.py:119timeout=3),init=None),command=proxy

--------------------------------------------------



__________________________.__.\____\___\/_\\/<||||_>>|\(<_>><\___||__/|__|\____/__/\_\/____||__|\/\/_____.____
____________/____\|_________/|____________\___\_/__\__\||_/__\_/___\__\/_\___\||\/\___/||||_\___/\\___||(<_>)|\/|__|\___>__||____/\___>\___>__|\____/|__|\/\/\/-Description:proxyreflector-Version:0.0.28-Author:jinwoo


--------------------------------------------------[10:34:33,904]args=Namespace(listen='8080',forward='127.0.0.1:8200',buffer_size=4096,delay=0.0001,timeout=3)proxy.py:173[10:34:33,905]Listen0.0.0.0:8080=>Forward127.0.0.1:8200httpinghttpinghttpmodule offers a streamlined and efficient way to perform HTTP requests and handle responses.$pawnshttp

--------------------------------------------------


.______.__||___/|__/|_______|__|________||\__\__\____\||/\/___\|Y\|||||_>>||\//_/>|___|/__||__||__/|__|___|/\___/\/|__|\//_____/-Description:ThisisatooltomeasureRTTonHTTP/Srequests.-base_dir:/Users/jinwoo/work/python_prj/pawnlib-logs_dir:/Users/jinwoo/work/python_prj/pawnlib/logs-Version:1.0.84-Author:jinwoo


--------------------------------------------------[11:25:46,975]Invalidurl:name=default,url=usage:local_cli.py[-h][-cCONFIG_FILE][-v][-q][-iINTERVAL][-mMETHOD][-tTIMEOUT][-bBASE_DIR][--successSUCCESS[SUCCESS...]][--logical-operator{and,or}][--ignore-sslIGNORE_SSL][-dDATA][--headersHEADERS][-wWORKERS][--stack-limitSTACK_LIMIT][--dynamic-increase-stack-limitDYNAMIC_INCREASE_STACK_LIMIT][--slack-urlSLACK_URL][--log-levelLOG_LEVEL][-bkBLOCKHEIGHT_KEY][--dry-run][url]httping

positionalarguments:urlURLtobechecked


optionalarguments:-h,--helpshowthishelpmessageandexit-cCONFIG_FILE,--config-fileCONFIG_FILEPathtotheconfigurationfile.Defaultsto"config.ini".-v,--verboseEnablesverbosemode.Highervaluesincreaseverbositylevel.Defaultis1.-q,--quietEnablesquietmode.Suppressesallmessages.Defaultis0.-iINTERVAL,--intervalINTERVALIntervaltimeinsecondsbetweenchecks.Defaultis1second.-mMETHOD,--methodMETHODHTTPmethodtouse(e.g.,GET,POST).Defaultis"GET".-tTIMEOUT,--timeoutTIMEOUTTimeoutinsecondsforeachHTTPrequest.Defaultis10seconds.-bBASE_DIR,--base-dirBASE_DIRBasedirectoryforhttpingoperations.Defaultisthecurrentworkingdirectory.--successSUCCESS[SUCCESS...]Criteriaforsuccess.Canspecifymultiplecriteria.Defaultis["status_code==200"].--logical-operator{and,or}Logicaloperatorforevaluatingsuccesscriteria.Choicesare"and","or".Defaultis"and".--ignore-sslIGNORE_SSLIgnoresSSLcertificatevalidationifsettoTrue.DefaultisTrue.-dDATA,--dataDATADatatobesentintheHTTPrequestbody.ExpectedinJSONformat.Defaultisanemptydictionary.--headersHEADERSHTTPheaderstobesentwiththerequest.ExpectedinJSONformat.Defaultisanemptydictionary.-wWORKERS,--workersWORKERSMaximumnumberofworkerprocesses.Defaultis10.--stack-limitSTACK_LIMITErrorstacklimit.Defaultis5.--dynamic-increase-stack-limitDYNAMIC_INCREASE_STACK_LIMITDynamicallyincreasestheerrorstacklimitifsettoTrue.DefaultisTrue.--slack-urlSLACK_URLURLforsendingnotificationstoSlack.Optional.--log-levelLOG_LEVELLoglevel.-bkBLOCKHEIGHT_KEY,--blockheight-keyBLOCKHEIGHT_KEYJSONkeytoextracttheblockheightinformation,e.g.,'result.sync_info.latest_block_height'.Thescriptwillcheckiftheblockheightatthispathisincreasing.--dry-runExecutesadryrunwithoutmakingactualHTTPrequests.DefaultisFalse.

ThisscriptprovidesvariousoptionstochecktheHTTPstatusofURLs.

Usageexamples:1.Basicusage:pawnshttphttps://example.com2.Verbosemode:pawnshttphttps://example.com-v3.UsingcustomheadersandPOSTmethod:pawnshttphttps://example.com-mPOST--headers'{"Content-Type": "application/json"}'--data'{"param": "value"}'4.IgnoringSSLverificationandsettingacustomtimeout:pawnshttphttps://example.com--ignore-sslTrue--timeout55.Checkingwithspecificsuccesscriteriaandlogicaloperator:pawnshttphttps://example.com--success'status_code==200''response_time<2'--logical-operatorand6.Runningwithacustomconfigfileandinterval:pawnshttphttps://example.com-chttp_config.ini-i3http_config.ini[default]success=status_code==200slack_url=interval=3method=get;data=sdsddata={"sdsd":"sd222sd"}[post]url=http://httpbin.org/postmethod=post[http_200_ok]url=http://httpbin.org/status/200success=status_code==200[http_300_ok_and_2ms_time]url=http://httpbin.org/status/300success=['status_code==300','response_time<0.02'][http_400_ok]url=http://httpbin.org/status/400success=["status_code==400"]7.Settingmaximumworkersandstacklimit:pawnshttphttps://example.com-w5--stack-limit108.DryrunwithoutactualHTTPrequest:pawnshttphttps://example.com--dry-run9.SendingnotificationstoaSlackURLonfailure:pawnshttphttps://example.com--slack-url'https://hooks.slack.com/services/...'10.Checkingblockheightincrease:pawnshttphttp://test-node-01:26657/status--blockheight-key"result.sync_info.latest_block_height"-i5Officially supports Python 3.9+.DocumentationDocumentation and tutorials are available athttps://pawnlib.readthedocs.ioRelease Information