Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tomwer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tomotools
tomwer
Commits
8c9e3e63
Commit
8c9e3e63
authored
6 years ago
by
payno
Browse files
Options
Downloads
Patches
Plain Diff
[web client] small fix + move "_knows_hostname" to be a static_method
parent
cff5e43e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tomwer/web/client.py
+12
-7
12 additions, 7 deletions
tomwer/web/client.py
with
12 additions
and
7 deletions
tomwer/web/client.py
+
12
−
7
View file @
8c9e3e63
# coding: utf-8
#/*##########################################################################
#
/*##########################################################################
# Copyright (C) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
...
...
@@ -30,7 +30,6 @@ __authors__ = ["H.Payno"]
__license__
=
"
MIT
"
__date__
=
"
28/04/2017
"
import
graypy
from
.config
import
grayport_port
,
grayport_host
import
os
...
...
@@ -39,9 +38,11 @@ import logging
_logger
=
logging
.
getLogger
(
__file__
)
global
_INFO_UNKNOWN_HOST_NAME
_INFO_UNKNOWN_HOST_NAME
=
False
"""
Cache variable to avoid several log about this information
"""
class
OWClient
(
object
):
"""
Orange widget Client can emit information about his advancement
"""
...
...
@@ -51,19 +52,22 @@ class OWClient(object):
def
__init__
(
self
,
loggers
):
assert
loggers
is
not
None
if
self
.
_knows_hostname
(
hostname
=
grayport_host
)
is
False
:
if
OWClient
.
_knows_hostname
(
hostname
=
grayport_host
)
is
False
:
global
_INFO_UNKNOWN_HOST_NAME
if
_INFO_UNKNOWN_HOST_NAME
is
False
:
_logger
.
warning
(
'
unknow host %s
'
%
grayport_host
)
_INFO_UNKNOWN_HOST_NAME
=
True
return
if
type
(
loggers
)
not
in
(
list
,
tuple
):
loggers
=
(
loggers
,
)
loggers
=
(
loggers
,)
for
logger
in
loggers
:
if
os
.
environ
.
get
(
'
ORANGE_WEB_LOG
'
,
'
True
'
)
is
'
True
'
:
try
:
self
.
graylogHandler
=
graypy
.
GELFHandler
(
grayport_host
,
grayport_port
)
self
.
graylogHandler
=
graypy
.
GELFHandler
(
grayport_host
,
grayport_port
)
except
:
logger
.
error
(
'
Fail to create GELFHandler. Won
\'
t report log message
'
)
logger
.
error
(
'
Fail to create GELFHandler. Won
\'
t report log message
'
)
else
:
logger
.
addHandler
(
self
.
graylogHandler
)
logger
.
debug
(
'
- add graypy handler
'
)
...
...
@@ -72,7 +76,8 @@ class OWClient(object):
info
+=
'
ORANGE_WEB_LOG variable is setted to False
'
logger
.
info
(
info
)
def
_knows_hostname
(
self
,
hostname
):
@staticmethod
def
_knows_hostname
(
hostname
):
try
:
socket
.
gethostbyname
(
hostname
)
return
True
...
...
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