Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
d35ecca0
Commit
d35ecca0
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Updated logging to use pymygdala's LogHandler class.
parent
8ac9f861
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cli/executables/null/setup.py
+8
-15
8 additions, 15 deletions
apps/cli/executables/null/setup.py
apps/cli/executables/null/src/null/null.py
+30
-18
30 additions, 18 deletions
apps/cli/executables/null/src/null/null.py
with
38 additions
and
33 deletions
apps/cli/executables/null/setup.py
+
8
−
15
View file @
d35ecca0
...
...
@@ -2,43 +2,36 @@
# -*- coding: utf-8 -*-
from
pathlib
import
Path
from
setuptools
import
setup
VERSION
=
open
(
'
_version.py
'
).
readlines
()[
-
1
].
split
()[
-
1
].
strip
(
"
\"
'"
)
VERSION
=
open
(
'
src/null/
_version.py
'
).
readlines
()[
-
1
].
split
()[
-
1
].
strip
(
"
\"
'"
)
README
=
Path
(
'
README.md
'
).
read_text
()
requires
=
[
'
pika>=1.1,<2
'
,
'
pycapo>=0.3.0,<1.0
'
,
'
beautifulsoup4>=4.9.1,<5.0
'
,
'
lxml>=4.3.2,<5.0
'
,
'
psycopg2>=2.8.5,<3.0
'
,
'
pyopenssl>=19.1.0,<20.0
'
,
'
requests>=2.23,<3.0
'
]
tests_require
=
[
'
pytest>=5.4,<6.0
'
]
#
tests_require = [
#
'pytest>=5.4,<6.0'
#
]
setup
(
name
=
Path
().
absolute
().
name
,
version
=
VERSION
,
description
=
'
NRAO Archive Data Fetcher Script
'
,
description
=
'
Workspaces null executable.
'
,
long_description
=
README
,
author
=
'
NRAO SSA Team
'
,
author_email
=
'
dms-ssa@nrao.edu
'
,
url
=
'
TBD
'
,
license
=
"
GPL
"
,
install_requires
=
requires
,
tests_require
=
tests_require
,
#
tests_require=tests_require,
keywords
=
[],
packages
=
[
'
datafetcher
'
],
packages
=
[
'
null
'
],
package_dir
=
{
''
:
'
src
'
},
classifiers
=
[
'
Programming Language :: Python :: 3.8
'
],
entry_points
=
{
'
console_scripts
'
:
[
'
datafetcher = datafetcher.commands
:main
'
]
'
console_scripts
'
:
[
'
null = null.null
:main
'
]
},
)
This diff is collapsed.
Click to expand it.
apps/cli/executables/null/src/null/null.py
+
30
−
18
View file @
d35ecca0
...
...
@@ -4,17 +4,22 @@ import time
import
logging
import
argparse
from
_version
import
___version___
as
version
from
pymygdala
import
LogHandler
from
pycapo
import
CapoConfig
from
._version
import
___version___
as
version
_DESCRIPTION
=
"""
Workspaces null executable, a status capture test of the system. Version {}
"""
# logging.basicConfig()
logger
=
logging
.
getLogger
(
"
null
"
)
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
setLevel
(
logging
.
INFO
)
config
=
CapoConfig
()
class
Null
:
def
__init__
(
self
,
args
,
verbose
):
self
.
args
=
args
self
.
verbose
=
verbose
if
verbose
:
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
args_to_funcs
=
{
'
greeting
'
:
self
.
print_greeting
,
'
exit
'
:
self
.
exit_with_failure
,
...
...
@@ -23,27 +28,20 @@ class Null:
}
def
print_greeting
(
self
):
logger
.
debug
(
"
Hello, world!
"
)
if
self
.
verbose
:
logger
.
debug
(
"
And goodbye, world...
"
)
logger
.
info
(
"
Hello, world!
"
)
logger
.
debug
(
"
And goodbye, world...
"
)
def
exit_with_failure
(
self
):
if
self
.
verbose
:
logger
.
error
(
"
Error purposefully induced.
"
)
logger
.
error
(
"
Error purposefully induced.
"
)
sys
.
exit
(
'
Exiting with status code -1
'
)
def
take_nap
(
self
):
print
(
self
.
verbose
)
if
self
.
verbose
:
print
(
"
wtf??
"
)
logger
.
debug
(
"
Going to sleep...
"
)
logger
.
debug
(
"
Going to sleep...
"
)
time
.
sleep
(
5
)
if
self
.
verbose
:
logger
.
debug
(
"
Waking up.
"
)
logger
.
debug
(
"
Waking up.
"
)
def
dump_core
(
self
):
if
self
.
verbose
:
logger
.
debug
(
"
Aborting and dumping core...
"
,
stack_info
=
True
)
logger
.
debug
(
"
Aborting and dumping core...
"
,
stack_info
=
True
)
os
.
abort
()
def
execute
(
self
):
...
...
@@ -54,10 +52,13 @@ class Null:
def
make_arg_parser
():
parser
=
argparse
.
ArgumentParser
(
description
=
_DESCRIPTION
.
format
(
version
),
formatter_class
=
argparse
.
RawTextHelpFormatter
)
options
=
parser
.
add_argument_group
(
'
options
'
,
'
settings for alter
ed
program behavior
'
)
options
=
parser
.
add_argument_group
(
'
options
'
,
'
settings for alter
ing
program behavior
'
)
options
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
,
required
=
False
,
dest
=
'
verbose
'
,
default
=
False
,
help
=
'
allow the program the gift of speech
'
)
options
.
add_argument
(
'
-P
'
,
'
--profile
'
,
action
=
'
store
'
,
required
=
True
,
dest
=
'
profile
'
,
default
=
False
,
help
=
'
profile name to use, e.g. test, production
'
)
functions
=
parser
.
add_mutually_exclusive_group
(
required
=
False
)
functions
.
add_argument
(
'
-g
'
,
'
--greeting
'
,
action
=
'
store_true
'
,
required
=
False
,
dest
=
'
greeting
'
,
default
=
False
,
...
...
@@ -73,10 +74,21 @@ def make_arg_parser():
help
=
'
abort program and dump core
'
)
return
parser
def
main
():
arg_parser
=
make_arg_parser
()
args
=
arg_parser
.
parse_args
()
handler
=
LogHandler
(
profile
=
args
.
profile
,
application
=
'
null_executable
'
)
logger
.
addHandler
(
handler
)
# Shamelessly stolen from epilogue with a twist: allow for explict profile setting via the CL
if
'
CAPO_PROFILE
'
not
in
os
.
environ
and
''
==
args
.
profile
:
# try to synthesize a profile from our installation root
profile
=
os
.
path
.
abspath
(
sys
.
argv
[
0
]).
split
(
os
.
path
.
sep
)[
-
3
]
os
.
environ
[
'
CAPO_PROFILE
'
]
=
profile
print
(
'
No CAPO_PROFILE explicitly set, synthesizing {0} by path
'
.
format
(
str
(
profile
)))
elif
''
!=
args
.
profile
:
os
.
environ
[
'
CAPO_PROFILE
'
]
=
args
.
profile
null
=
Null
(
args
,
args
.
verbose
)
null
.
execute
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment