Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
storjstatus-client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
James Coyle
storjstatus-client
Commits
178fe013
Commit
178fe013
authored
Mar 06, 2018
by
James Coyle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using python logger for sending stats
parent
38bdcd8a
Pipeline
#1106
passed with stages
in 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
21 deletions
+12
-21
storjstatus/storjstatus_send.py
storjstatus/storjstatus_send.py
+11
-20
storjstatus/version.py
storjstatus/version.py
+1
-1
No files found.
storjstatus/storjstatus_send.py
View file @
178fe013
...
...
@@ -11,6 +11,7 @@ import time
from
crontab
import
CronTab
from
os
import
scandir
from
storjstatus
import
storjstatus_common
import
logging
### Vars
APIKEY
=
None
...
...
@@ -20,6 +21,8 @@ STORJCONFIG = None
def
init_send
():
logging
.
basicConfig
(
format
=
'%(asctime)s %(levelname)s %(message)s'
,
datefmt
=
'%d/%m/%Y %I:%M:%S %p'
)
storjstatus_common
.
setup_env
()
checks
();
...
...
@@ -62,7 +65,7 @@ def init_send():
}
json_nodes
.
append
(
json_node
)
else
:
print_warning
(
"No config file found for Node: "
+
node
[
'id'
]
+
". Data for this node will not be sent."
)
logger
.
warning
(
"No config file found for Node: %s. Data for this node will not be sent."
,
node
[
'id'
]
)
json_request
=
{
'serverId'
:
SERVERGUID
,
...
...
@@ -71,7 +74,7 @@ def init_send():
'storjshareVersion'
:
storjshare_version
(),
'nodes'
:
json_nodes
}
print_info
(
'
\n
JSON Request...
\n
'
+
json
.
dumps
(
json_request
,
indent
=
4
,
sort_keys
=
True
))
logging
.
info
(
'JSON Request:
\n
'
+
json
.
dumps
(
json_request
,
indent
=
4
,
sort_keys
=
True
))
headers
=
{
'content-type'
:
'application/json'
,
'api-key'
:
APIKEY
,
'api-secret'
:
APISECRET
}
try
:
resp
=
requests
.
post
(
storjstatus_common
.
APIENDPOINT
+
"stats"
,
json
=
json_request
,
headers
=
headers
)
...
...
@@ -134,7 +137,7 @@ def config_json():
for
f
in
filenames
:
# consume config file
with
open
(
os
.
path
.
join
(
root
,
f
),
'r'
,
encoding
=
"ISO-8859-1"
)
as
f_open
:
print_
info
(
"Parsing config file: "
+
os
.
path
.
join
(
root
,
f
))
logger
.
info
(
"Parsing config file: "
+
os
.
path
.
join
(
root
,
f
))
node
=
{}
f_data
=
f_open
.
read
()
f_clean
=
storjstatus_common
.
cleanup_json
(
f_data
)
...
...
@@ -148,13 +151,13 @@ def config_json():
node
[
'storageAllocation'
]
=
f_json
[
'storageAllocation'
]
nodes
[
f_json
[
'storagePath'
]]
=
node
print_
info
(
"Found valid config for "
+
f_json
[
'storagePath'
])
logger
.
info
(
"Found valid config for "
+
f_json
[
'storagePath'
])
except
KeyError
:
print_
warning
(
'JSON config file '
+
f
+
' invalid. Please check your config.'
)
logger
.
warning
(
'JSON config file '
+
f
+
' invalid. Please check your config.'
)
except
json
.
JSONDecodeError
:
print_
warning
(
'JSON config file '
+
f
+
' invalid. Please check your config.'
)
logger
.
warning
(
'JSON config file '
+
f
+
' invalid. Please check your config.'
)
except
:
print_
warning
(
"File "
+
f
+
" is not a valid Storjshare JSON config file"
)
logger
.
warning
(
"File "
+
f
+
" is not a valid Storjshare JSON config file"
)
if
nodes
:
return
nodes
...
...
@@ -190,21 +193,9 @@ def load_settings():
def
print_error
(
error_message
):
print
()
print
(
"ERROR : "
+
error_message
)
print
()
logging
.
error
(
error_message
)
exit
(
1
)
def
print_warning
(
warning_message
):
print
()
print
(
"WARNING : "
+
warning_message
)
print
()
def
print_info
(
warning_message
):
print
()
print
(
"INFO : "
+
warning_message
)
print
()
if
__name__
==
'__main__'
:
init_send
()
storjstatus/version.py
View file @
178fe013
__version__
=
'0.2.
5
'
__version__
=
'0.2.
6
'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment