l#gd dZddlZddlZddlZddlmZddlmZddlm Z ddl Z ddl Z dZ dZ dZd Zd Zd Zd Zed ZdZdefdZdefdZde edefdZdedefdZdedefdZdZdZdefdZdZdZdS)z2Helper for integrate sentry in stand-alone scriptsN)suppress)Path)List imunify360zimunify-antiviruszimunify360-firewallz/var/imunify360/license.jsonz!/var/imunify360/license-free.json IMUNIFYAVUNKNOWNz,/opt/imunify360/venv/share/imunify360/sentryzQhttps://6de77a2763bd40c58fc9e3a89285aaa8@im360.sentry.cloudlinux.com/3?timeout=20returnc tdS#ttf$r t cYSwxYw)z,Return dsn from the file or the default one.ascii)encoding)SENTRY_DSN_PATH read_textstripOSErrorUnicodeDecodeErrorSENTRY_DSN_DEFAULTK/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/sentry.pyget_sentry_dsnrsW"(('(::@@BBB ' ("""!!!!"s,/A  A c tt5ttfD]}tt5t |5}t j|dcdddcdddccdddS#1swxYwYdddn #1swxYwY dddn #1swxYwYtS)Nid) r ExceptionLICENSE LICENSE_FREEFileNotFoundErroropenjsonload UNKNOWN_ID)filenamefiles r get_server_idr# s )  -- ,/ - -H+,, - -d8nn -yt, - - - - - - - - - - - - - - - --------- - - - - - - - - - - - - - - - - - - - - - - - ---------------- s^%B;B" B $ B"0B; B B"B B" B;"B& &B;)B& *B;;B?B?cmdc tj|tjtjtj}n#t$rYdSwxYw|jdkrdSt j|jS)N)stdinstdoutstderrr) subprocessrunDEVNULLPIPEr returncodeosfsdecoder')r$cps rcollect_outputr2(s{ ^ $?%     rr }r ;ry ! !!s69 AApkgc,ddd|g}t|S)Nrpmz-qz#--queryformat=%{VERSION}-%{RELEASE}r2r3r$s rget_rpm_versionr87s $=s CC #  rc,ddd|g}t|S)Nz dpkg-queryz--showformat=${Version}z--showr6r7s rget_dpkg_versionr:<s 2Hc BC #  rc\tjd}|S)Nr)distrolinux_distributionlower) platform_oss rget_current_osr@As'+--a0K     rct}t}|dkrttrt}nt}|SNubuntu)r@IMUNIFY360_PKGr8r IMUNIFY360)r? service_names rget_package_namerGFs< ""K!Lh?9#=#= ! rclt}|dkrt|}nt|}|SrB)r@r8r:)rFr?versions rget_service_versionrJPs9 ""Kh!,//"<00 NrcXtjttj5}t }dt i|_|d||dt|ddddS#1swxYwYdS)N)dsnrnamerI) sentry_sdkinitrconfigure_scoperGr#userset_tagrJ)scopepackages rconfigure_sentryrUYsO(())))  # % %?"$$MOO,  fg&&& i!4W!=!=>>> ??????????????????sABB#&B#cftjjj}||ddSdS)Ng@)timeout)rNHubcurrentclientflush)rZs r flush_sentryr\ds7 ^ # *F  S !!!!!r) __doc__rr/r* contextlibrpathlibrtypingrr<rNrErrDrrFREE_IDr r rstrrr#r2r8r:r@rGrJrUr\rrrrcs88     & (2   $EFFh"""""s "S "c " " " " ##  ???"""""r