mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Bump cherrypy from 18.8.0 to 18.9.0 (#2266)
* Bump cherrypy from 18.8.0 to 18.9.0 Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.8.0 to 18.9.0. - [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst) - [Commits](https://github.com/cherrypy/cherrypy/compare/v18.8.0...v18.9.0) --- updated-dependencies: - dependency-name: cherrypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update cherrypy==18.9.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
cfefa928be
commit
faef9a94c4
673 changed files with 159850 additions and 11583 deletions
144
lib/adodbapi/process_connect_string.py
Normal file
144
lib/adodbapi/process_connect_string.py
Normal file
|
@ -0,0 +1,144 @@
|
|||
""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)"""
|
||||
from . import is64bit as is64bit
|
||||
|
||||
|
||||
def macro_call(macro_name, args, kwargs):
|
||||
"""allow the programmer to perform limited processing on the server by passing macro names and args
|
||||
|
||||
:new_key - the key name the macro will create
|
||||
:args[0] - macro name
|
||||
:args[1:] - any arguments
|
||||
:code - the value of the keyword item
|
||||
:kwargs - the connection keyword dictionary. ??key has been removed
|
||||
--> the value to put in for kwargs['name'] = value
|
||||
"""
|
||||
if isinstance(args, (str, str)):
|
||||
args = [
|
||||
args
|
||||
] # the user forgot to pass a sequence, so make a string into args[0]
|
||||
new_key = args[0]
|
||||
try:
|
||||
if macro_name == "is64bit":
|
||||
if is64bit.Python(): # if on 64 bit Python
|
||||
return new_key, args[1] # return first argument
|
||||
else:
|
||||
try:
|
||||
return new_key, args[2] # else return second argument (if defined)
|
||||
except IndexError:
|
||||
return new_key, "" # else return blank
|
||||
|
||||
elif (
|
||||
macro_name == "getuser"
|
||||
): # get the name of the user the server is logged in under
|
||||
if not new_key in kwargs:
|
||||
import getpass
|
||||
|
||||
return new_key, getpass.getuser()
|
||||
|
||||
elif macro_name == "getnode": # get the name of the computer running the server
|
||||
import platform
|
||||
|
||||
try:
|
||||
return new_key, args[1] % platform.node()
|
||||
except IndexError:
|
||||
return new_key, platform.node()
|
||||
|
||||
elif macro_name == "getenv": # expand the server's environment variable args[1]
|
||||
try:
|
||||
dflt = args[2] # if not found, default from args[2]
|
||||
except IndexError: # or blank
|
||||
dflt = ""
|
||||
return new_key, os.environ.get(args[1], dflt)
|
||||
|
||||
elif macro_name == "auto_security":
|
||||
if (
|
||||
not "user" in kwargs or not kwargs["user"]
|
||||
): # missing, blank, or Null username
|
||||
return new_key, "Integrated Security=SSPI"
|
||||
return new_key, "User ID=%(user)s; Password=%(password)s" % kwargs
|
||||
|
||||
elif (
|
||||
macro_name == "find_temp_test_path"
|
||||
): # helper function for testing ado operation -- undocumented
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
return new_key, os.path.join(
|
||||
tempfile.gettempdir(), "adodbapi_test", args[1]
|
||||
)
|
||||
|
||||
raise ValueError("Unknown connect string macro=%s" % macro_name)
|
||||
except:
|
||||
raise ValueError("Error in macro processing %s %s" % (macro_name, repr(args)))
|
||||
|
||||
|
||||
def process(
|
||||
args, kwargs, expand_macros=False
|
||||
): # --> connection string with keyword arguments processed.
|
||||
"""attempts to inject arguments into a connection string using Python "%" operator for strings
|
||||
|
||||
co: adodbapi connection object
|
||||
args: positional parameters from the .connect() call
|
||||
kvargs: keyword arguments from the .connect() call
|
||||
"""
|
||||
try:
|
||||
dsn = args[0]
|
||||
except IndexError:
|
||||
dsn = None
|
||||
if isinstance(
|
||||
dsn, dict
|
||||
): # as a convenience the first argument may be django settings
|
||||
kwargs.update(dsn)
|
||||
elif (
|
||||
dsn
|
||||
): # the connection string is passed to the connection as part of the keyword dictionary
|
||||
kwargs["connection_string"] = dsn
|
||||
try:
|
||||
a1 = args[1]
|
||||
except IndexError:
|
||||
a1 = None
|
||||
# historically, the second positional argument might be a timeout value
|
||||
if isinstance(a1, int):
|
||||
kwargs["timeout"] = a1
|
||||
# if the second positional argument is a string, then it is user
|
||||
elif isinstance(a1, str):
|
||||
kwargs["user"] = a1
|
||||
# if the second positional argument is a dictionary, use it as keyword arguments, too
|
||||
elif isinstance(a1, dict):
|
||||
kwargs.update(a1)
|
||||
try:
|
||||
kwargs["password"] = args[2] # the third positional argument is password
|
||||
kwargs["host"] = args[3] # the fourth positional argument is host name
|
||||
kwargs["database"] = args[4] # the fifth positional argument is database name
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
# make sure connection string is defined somehow
|
||||
if not "connection_string" in kwargs:
|
||||
try: # perhaps 'dsn' was defined
|
||||
kwargs["connection_string"] = kwargs["dsn"]
|
||||
except KeyError:
|
||||
try: # as a last effort, use the "host" keyword
|
||||
kwargs["connection_string"] = kwargs["host"]
|
||||
except KeyError:
|
||||
raise TypeError("Must define 'connection_string' for ado connections")
|
||||
if expand_macros:
|
||||
for kwarg in list(kwargs.keys()):
|
||||
if kwarg.startswith("macro_"): # If a key defines a macro
|
||||
macro_name = kwarg[6:] # name without the "macro_"
|
||||
macro_code = kwargs.pop(
|
||||
kwarg
|
||||
) # we remove the macro_key and get the code to execute
|
||||
new_key, rslt = macro_call(
|
||||
macro_name, macro_code, kwargs
|
||||
) # run the code in the local context
|
||||
kwargs[new_key] = rslt # put the result back in the keywords dict
|
||||
# special processing for PyRO IPv6 host address
|
||||
try:
|
||||
s = kwargs["proxy_host"]
|
||||
if ":" in s: # it is an IPv6 address
|
||||
if s[0] != "[": # is not surrounded by brackets
|
||||
kwargs["proxy_host"] = s.join(("[", "]")) # put it in brackets
|
||||
except KeyError:
|
||||
pass
|
||||
return kwargs
|
Loading…
Add table
Add a link
Reference in a new issue