Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySQM Darkersky4CE
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dario Barghini
PySQM Darkersky4CE
Commits
f10b4075
Commit
f10b4075
authored
2 years ago
by
Thorsten Alteholz
Browse files
Options
Downloads
Patches
Plain Diff
first round of pylint fixes
parent
8b367822
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
pysqm/__init__.py
+0
-1
0 additions, 1 deletion
pysqm/__init__.py
pysqm/__main__.py
+3
-3
3 additions, 3 deletions
pysqm/__main__.py
pysqm/common.py
+17
-15
17 additions, 15 deletions
pysqm/common.py
pysqm/settings.py
+10
-2
10 additions, 2 deletions
pysqm/settings.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
31 additions
and
22 deletions
pysqm/__init__.py
+
0
−
1
View file @
f10b4075
...
...
@@ -41,4 +41,3 @@ __status__ = "Development" # "Prototype", "Development", or "Production"
from
types
import
ModuleType
import
sys
This diff is collapsed.
Click to expand it.
pysqm/__main__.py
+
3
−
3
View file @
f10b4075
...
...
@@ -26,9 +26,10 @@ ____________________________
#from types import ModuleType
#import sys
import
pysqm.main
as
main
#import pysqm.main as main
from
pysqm
import
main
while
(
1
==
1
)
:
while
1
==
1
:
# Loop forever to make sure the program does not die.
try
:
main
.
loop
()
...
...
@@ -39,4 +40,3 @@ while(1==1):
print
(
e
)
print
(
'
Trying to restart
'
)
print
(
''
)
This diff is collapsed.
Click to expand it.
pysqm/common.py
+
17
−
15
View file @
f10b4075
...
...
@@ -24,8 +24,8 @@ ____________________________
'''
import
math
import
ephem
import
datetime
import
ephem
# Read the config variables from config.py
import
pysqm.settings
as
settings
...
...
@@ -37,26 +37,28 @@ def define_ephem_observatory():
OBS
.
lat
=
config
.
_observatory_latitude
*
ephem
.
pi
/
180
OBS
.
lon
=
config
.
_observatory_longitude
*
ephem
.
pi
/
180
OBS
.
elev
=
config
.
_observatory_altitude
return
(
OBS
)
return
OBS
def
remove_linebreaks
(
data
):
'''
remove linebreaks from data
'''
# Remove line breaks from data
data
=
data
.
replace
(
'
\r\n
'
,
''
)
data
=
data
.
replace
(
'
\r
'
,
''
)
data
=
data
.
replace
(
'
\n
'
,
''
)
return
(
data
)
return
data
def
format_value
(
data
,
remove_str
=
'
'
):
'''
format data
'''
# Remove string and spaces from data
data
=
remove_linebreaks
(
data
)
data
=
data
.
replace
(
remove_str
,
''
)
data
=
data
.
replace
(
'
'
,
''
)
return
(
data
)
return
data
def
format_value_list
(
data
,
remove_str
=
'
'
):
# Remove string and spaces from data array/list
data
=
[
format_value
(
line
,
remove_str
).
split
(
'
;
'
)
for
line
in
data
]
return
(
data
)
return
data
def
set_decimals
(
number
,
dec
=
3
):
str_number
=
str
(
number
)
...
...
@@ -64,37 +66,37 @@ def set_decimals(number,dec=3):
while
len
(
dec_
)
<=
dec
:
dec_
=
dec_
+
'
0
'
return
(
int_
+
'
.
'
+
dec_
[:
dec
]
)
return
int_
+
'
.
'
+
dec_
[:
dec
]
class
observatory
(
object
):
def
read_datetime
(
self
):
#
Get UTC datetime from the computer.
'''
Get UTC datetime from the computer.
'''
utc_dt
=
datetime
.
datetime
.
utcnow
()
#utc_dt = datetime.datetime.now() - datetime.timedelta(hours=config._computer_timezone)
#time.localtime(); daylight_saving=_.tm_isdst>0
return
(
utc_dt
)
return
utc_dt
def
local_datetime
(
self
,
utc_dt
):
#
Get Local datetime from the computer, without daylight saving.
return
(
utc_dt
+
datetime
.
timedelta
(
hours
=
config
.
_local_timezone
)
)
'''
Get Local datetime from the computer, without daylight saving.
'''
return
utc_dt
+
datetime
.
timedelta
(
hours
=
config
.
_local_timezone
)
def
calculate_sun_altitude
(
self
,
OBS
,
timeutc
):
#
Calculate Sun altitude
'''
Calculate Sun altitude
'''
OBS
.
date
=
ephem
.
date
(
timeutc
)
Sun
=
ephem
.
Sun
(
OBS
)
return
(
Sun
.
alt
)
return
Sun
.
alt
def
next_sunset
(
self
,
OBS
):
#
Next sunset calculation
'''
Next sunset calculation
'''
previous_horizon
=
OBS
.
horizon
OBS
.
horizon
=
str
(
config
.
_observatory_horizon
)
next_setting
=
OBS
.
next_setting
(
ephem
.
Sun
()).
datetime
()
next_setting
=
next_setting
.
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
OBS
.
horizon
=
previous_horizon
return
(
next_setting
)
return
next_setting
def
is_nighttime
(
self
,
OBS
):
#
Is nightime (sun below a given altitude)
'''
Is nightime (sun below a given altitude)
'''
timeutc
=
self
.
read_datetime
()
if
self
.
calculate_sun_altitude
(
OBS
,
timeutc
)
*
180.
/
math
.
pi
>
config
.
_observatory_horizon
:
return
False
...
...
This diff is collapsed.
Click to expand it.
pysqm/settings.py
+
10
−
2
View file @
f10b4075
...
...
@@ -23,28 +23,35 @@ along with PySQM. If not, see <http://www.gnu.org/licenses/>.
____________________________
'''
import
os
,
sys
import
os
import
sys
class
ArgParser
:
'''
parse arguments of program
'''
def
__init__
(
self
,
inputfile
=
False
):
self
.
parse_arguments
(
inputfile
)
def
parse_arguments
(
self
,
inputfile
):
'''"
do all the parsing work
'''
import
argparse
# Return config filename
self
.
parser
=
argparse
.
ArgumentParser
()
self
.
parser
.
add_argument
(
'
-c
'
,
'
--config
'
,
default
=
"
config.py
"
)
if
(
inputfile
)
:
if
inputfile
:
self
.
parser
.
add_argument
(
'
-i
'
,
'
--input
'
,
default
=
None
)
args
=
self
.
parser
.
parse_args
()
vars
(
self
).
update
(
args
.
__dict__
)
def
print_help
(
self
):
'''
print help defined by argparse
'''
self
.
parser
.
print_help
()
class
ConfigFile
:
'''
read config file
'''
def
__init__
(
self
,
path
=
"
config.py
"
):
# Guess the selected dir and config filename
# Should accept:
...
...
@@ -57,6 +64,7 @@ class ConfigFile:
self
.
config
=
None
def
read_config_file
(
self
,
path
):
'''
do all the work for reading the config file
'''
# Get the absolute path
abspath
=
os
.
path
.
abspath
(
path
)
# Is a dir? Then add config.py (default filename)
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
f10b4075
...
...
@@ -23,5 +23,5 @@ setup(name='pysqm',
"
Operating System :: OS Independent
"
,
"
Topic :: Scientific/Engineering :: Astronomy
"
,
],
long_description
=
open
(
'
README.txt
'
).
read
()
long_description
=
open
(
'
README.txt
'
,
encoding
=
"
utf-8
"
).
read
()
)
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