Format remaining Python files

This commit is contained in:
kpj 2022-02-27 15:37:20 +01:00
parent 60ad0bb4e2
commit 992406d5a0
2 changed files with 103 additions and 100 deletions

View File

@ -6,29 +6,29 @@ exec(open("../src/paperless/version.py").read())
extensions = [ extensions = [
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
'sphinx.ext.intersphinx', "sphinx.ext.intersphinx",
'sphinx.ext.todo', "sphinx.ext.todo",
'sphinx.ext.imgmath', "sphinx.ext.imgmath",
'sphinx.ext.viewcode', "sphinx.ext.viewcode",
'sphinx_rtd_theme', "sphinx_rtd_theme",
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates'] # templates_path = ['_templates']
# The suffix of source filenames. # The suffix of source filenames.
source_suffix = '.rst' source_suffix = ".rst"
# The encoding of source files. # The encoding of source files.
# source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = u'Paperless-ngx' project = "Paperless-ngx"
copyright = u'2015-2022, Daniel Quinn, Jonas Winkler, and the paperless-ngx team' copyright = "2015-2022, Daniel Quinn, Jonas Winkler, and the paperless-ngx team"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
@ -57,7 +57,7 @@ release = ".".join([str(_) for _ in __version__[:3]])
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
exclude_patterns = ['_build'] exclude_patterns = ["_build"]
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
@ -75,7 +75,7 @@ exclude_patterns = ['_build']
# show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
# modindex_common_prefix = [] # modindex_common_prefix = []
@ -88,7 +88,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
html_theme = 'sphinx_rtd_theme' html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
@ -117,7 +117,7 @@ html_theme_path = []
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
@ -166,17 +166,15 @@ html_static_path = ['_static']
# html_file_suffix = None # html_file_suffix = None
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'paperless' htmlhelp_basename = "paperless"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', #'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', #'preamble': '',
} }
@ -185,8 +183,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
('index', 'paperless.tex', u'Paperless Documentation', ("index", "paperless.tex", "Paperless Documentation", "Daniel Quinn", "manual"),
u'Daniel Quinn', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
@ -214,10 +211,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [("index", "paperless", "Paperless Documentation", ["Daniel Quinn"], 1)]
('index', 'paperless', u'Paperless Documentation',
[u'Daniel Quinn'], 1)
]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
# man_show_urls = False # man_show_urls = False
@ -229,9 +223,15 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'Paperless', u'Paperless Documentation', (
u'Daniel Quinn', 'paperless', 'Scan, index, and archive all of your paper documents.', "index",
'Miscellaneous'), "Paperless",
"Paperless Documentation",
"Daniel Quinn",
"paperless",
"Scan, index, and archive all of your paper documents.",
"Miscellaneous",
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
@ -250,10 +250,10 @@ texinfo_documents = [
# -- Options for Epub output ---------------------------------------------- # -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info. # Bibliographic Dublin Core info.
epub_title = u'Paperless' epub_title = "Paperless"
epub_author = u'Daniel Quinn' epub_author = "Daniel Quinn"
epub_publisher = u'Daniel Quinn' epub_publisher = "Daniel Quinn"
epub_copyright = u'2015, Daniel Quinn' epub_copyright = "2015, Daniel Quinn"
# The basename for the epub file. It defaults to the project name. # The basename for the epub file. It defaults to the project name.
# epub_basename = u'Paperless' # epub_basename = u'Paperless'
@ -293,7 +293,7 @@ epub_copyright = u'2015, Daniel Quinn'
# epub_post_files = [] # epub_post_files = []
# A list of files that should not be packed into the epub file. # A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html'] epub_exclude_files = ["search.html"]
# The depth of the table of contents in toc.ncx. # The depth of the table of contents in toc.ncx.
# epub_tocdepth = 3 # epub_tocdepth = 3
@ -318,4 +318,4 @@ epub_exclude_files = ['search.html']
# Example configuration for intersphinx: refer to the Python standard library. # Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None} intersphinx_mapping = {"http://docs.python.org/": None}

View File

@ -2,35 +2,38 @@ import os
bind = f'0.0.0.0:{os.getenv("PAPERLESS_PORT", 8000)}' bind = f'0.0.0.0:{os.getenv("PAPERLESS_PORT", 8000)}'
workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 2)) workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 2))
worker_class = 'paperless.workers.ConfigurableWorker' worker_class = "paperless.workers.ConfigurableWorker"
timeout = 120 timeout = 120
def pre_fork(server, worker): def pre_fork(server, worker):
pass pass
def pre_exec(server): def pre_exec(server):
server.log.info("Forked child, re-executing.") server.log.info("Forked child, re-executing.")
def when_ready(server): def when_ready(server):
server.log.info("Server is ready. Spawning workers") server.log.info("Server is ready. Spawning workers")
def worker_int(worker): def worker_int(worker):
worker.log.info("worker received INT or QUIT signal") worker.log.info("worker received INT or QUIT signal")
## get traceback info ## get traceback info
import threading, sys, traceback import threading, sys, traceback
id2name = dict([(th.ident, th.name) for th in threading.enumerate()]) id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
code = [] code = []
for threadId, stack in sys._current_frames().items(): for threadId, stack in sys._current_frames().items():
code.append("\n# Thread: %s(%d)" % (id2name.get(threadId,""), code.append("\n# Thread: %s(%d)" % (id2name.get(threadId, ""), threadId))
threadId))
for filename, lineno, name, line in traceback.extract_stack(stack): for filename, lineno, name, line in traceback.extract_stack(stack):
code.append('File: "%s", line %d, in %s' % (filename, code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
lineno, name))
if line: if line:
code.append(" %s" % (line.strip())) code.append(" %s" % (line.strip()))
worker.log.debug("\n".join(code)) worker.log.debug("\n".join(code))
def worker_abort(worker): def worker_abort(worker):
worker.log.info("worker received SIGABRT signal") worker.log.info("worker received SIGABRT signal")