Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslpy
Commits
425a3a28
Commit
425a3a28
authored
Oct 25, 2017
by
Paul McCarthy
🚵
Browse files
Merge remote-tracking branch 'upstream/master' into v1.3
parents
d816ebc8
272f3c51
Pipeline
#1115
passed with stages
in 2 minutes and 13 seconds
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
CHANGELOG.rst
View file @
425a3a28
...
@@ -2,6 +2,14 @@ This document contains the ``fslpy`` release history in reverse chronological
...
@@ -2,6 +2,14 @@ This document contains the ``fslpy`` release history in reverse chronological
order.
order.
1.3.1 (Wednesday 25th October 2017)
-----------------------------------
* Fixed bug in :meth:`.Platform.wxPlatform` causing it to always return
``WX_UNKNOWN``.
1.3.0 (Wednesday 25th October 2017)
1.3.0 (Wednesday 25th October 2017)
-----------------------------------
-----------------------------------
...
...
fsl/utils/platform.py
View file @
425a3a28
...
@@ -233,7 +233,7 @@ class Platform(notifier.Notifier):
...
@@ -233,7 +233,7 @@ class Platform(notifier.Notifier):
:data:`WX_MAC_CARBON`, or :data:`WX_GTK`, indicating the wx platform.
:data:`WX_MAC_CARBON`, or :data:`WX_GTK`, indicating the wx platform.
"""
"""
if
not
self
.
h
aveGui
:
if
not
self
.
canH
aveGui
:
return
WX_UNKNOWN
return
WX_UNKNOWN
import
wx
import
wx
...
@@ -245,7 +245,7 @@ class Platform(notifier.Notifier):
...
@@ -245,7 +245,7 @@ class Platform(notifier.Notifier):
elif
any
([
'gtk'
in
p
for
p
in
pi
]):
plat
=
WX_GTK
elif
any
([
'gtk'
in
p
for
p
in
pi
]):
plat
=
WX_GTK
else
:
plat
=
WX_UNKNOWN
else
:
plat
=
WX_UNKNOWN
if
plat
form
is
WX_UNKNOWN
:
if
plat
is
WX_UNKNOWN
:
log
.
warning
(
'Could not determine wx platform from '
log
.
warning
(
'Could not determine wx platform from '
'information: {}'
.
format
(
pi
))
'information: {}'
.
format
(
pi
))
...
@@ -258,7 +258,7 @@ class Platform(notifier.Notifier):
...
@@ -258,7 +258,7 @@ class Platform(notifier.Notifier):
indicating the wx flavour.
indicating the wx flavour.
"""
"""
if
not
self
.
h
aveGui
:
if
not
self
.
canH
aveGui
:
return
WX_UNKNOWN
return
WX_UNKNOWN
import
wx
import
wx
...
...
fsl/version.py
View file @
425a3a28
...
@@ -41,7 +41,7 @@ import re
...
@@ -41,7 +41,7 @@ import re
import
string
import
string
__version__
=
'1.3.
0
'
__version__
=
'1.3.
1
'
"""Current version number, as a string. """
"""Current version number, as a string. """
...
...
setup.cfg
View file @
425a3a28
...
@@ -6,7 +6,7 @@ universal=1
...
@@ -6,7 +6,7 @@ universal=1
[tool:pytest]
[tool:pytest]
testpaths = tests
testpaths = tests
addopts =
-s
-v --niters=50 --cov=fsl
--cov-report=html
addopts = -v --niters=50 --cov=fsl
[flake8]
[flake8]
ignore = E127,E201,E203,E221,E222,E241,E271,E272,E301,E302,E303,E701
ignore = E127,E201,E203,E221,E222,E241,E271,E272,E301,E302,E303,E701
\ No newline at end of file
tests/test_platform.py
View file @
425a3a28
...
@@ -8,9 +8,12 @@
...
@@ -8,9 +8,12 @@
import
os
import
os
import
os.path
as
op
import
os.path
as
op
import
sys
import
shutil
import
shutil
import
tempfile
import
tempfile
import
mock
import
fsl.utils.platform
as
fslplatform
import
fsl.utils.platform
as
fslplatform
...
@@ -32,11 +35,11 @@ def test_atts():
...
@@ -32,11 +35,11 @@ def test_atts():
p
.
glIsSoftwareRenderer
p
.
glIsSoftwareRenderer
def
test_
g
ui
():
def
test_
haveG
ui
():
import
wx
import
wx
p
=
fslplatform
.
p
latform
p
=
fslplatform
.
P
latform
()
app
=
wx
.
App
()
app
=
wx
.
App
()
frame
=
wx
.
Frame
(
None
)
frame
=
wx
.
Frame
(
None
)
passed
=
[
False
]
passed
=
[
False
]
...
@@ -45,10 +48,7 @@ def test_gui():
...
@@ -45,10 +48,7 @@ def test_gui():
def
runtest
():
def
runtest
():
try
:
try
:
assert
p
.
haveGui
p
.
haveGui
p
.
wxPlatform
p
.
wxFlavour
passed
[
0
]
=
True
passed
[
0
]
=
True
finally
:
finally
:
frame
.
Destroy
()
frame
.
Destroy
()
...
@@ -61,14 +61,94 @@ def test_gui():
...
@@ -61,14 +61,94 @@ def test_gui():
assert
passed
[
0
]
assert
passed
[
0
]
def
test_wxatts
():
with
mock
.
patch
.
dict
(
'sys.modules'
,
wx
=
None
):
p
=
fslplatform
.
Platform
()
assert
not
p
.
canHaveGui
assert
not
p
.
haveGui
assert
p
.
wxFlavour
==
fslplatform
.
WX_UNKNOWN
assert
p
.
wxPlatform
==
fslplatform
.
WX_UNKNOWN
with
mock
.
patch
(
'wx.App.IsDisplayAvailable'
,
return_value
=
False
):
p
=
fslplatform
.
Platform
()
assert
not
p
.
canHaveGui
assert
not
p
.
haveGui
assert
p
.
wxFlavour
==
fslplatform
.
WX_UNKNOWN
assert
p
.
wxPlatform
==
fslplatform
.
WX_UNKNOWN
with
mock
.
patch
(
'wx.App.IsDisplayAvailable'
,
return_value
=
True
),
\
mock
.
patch
(
'wx.PlatformInfo'
,
(
'gtk'
,
'phoenix'
)):
p
=
fslplatform
.
Platform
()
assert
p
.
canHaveGui
assert
not
p
.
haveGui
assert
p
.
wxFlavour
==
fslplatform
.
WX_PHOENIX
assert
p
.
wxPlatform
==
fslplatform
.
WX_GTK
# (wx.PlatformInfo, expected platform, expected flavour)
platflavtests
=
[
((
'__WXMAC__'
,
'wxMac'
,
'unicode'
,
'unicode-wchar'
,
'wxOSX'
,
'wxOSX-cocoa'
,
'wx-assertions-on'
,
'phoenix'
,
'wxWidgets 3.0.4'
),
fslplatform
.
WX_MAC_COCOA
,
fslplatform
.
WX_PHOENIX
),
((
'__WXMAC__'
,
'wxMac'
,
'unicode'
,
'wxOSX'
,
'wxOSX-cocoa'
,
'wx-assertions-on'
,
'SWIG-1.3.29'
),
fslplatform
.
WX_MAC_COCOA
,
fslplatform
.
WX_PYTHON
),
((
'__WXGTK__'
,
'wxGTK'
,
'unicode'
,
'unicode-wchar'
,
'gtk2'
,
'wx-assertions-on'
,
'phoenix'
,
'wxWidgets 3.0.4'
),
fslplatform
.
WX_GTK
,
fslplatform
.
WX_PHOENIX
),
((
'__WXGTK__'
,
'wxGTK'
,
'unicode'
,
'gtk2'
,
'wx-assertions-on'
,
'SWIG-1.3.29'
),
fslplatform
.
WX_GTK
,
fslplatform
.
WX_PYTHON
)]
for
platinfo
,
expplatform
,
expflavour
in
platflavtests
:
with
mock
.
patch
(
'wx.PlatformInfo'
,
platinfo
):
p
=
fslplatform
.
Platform
()
assert
p
.
wxFlavour
==
expflavour
assert
p
.
wxPlatform
==
expplatform
def
test_gl
():
def
test_gl
():
p
=
fslplatform
.
p
latform
p
=
fslplatform
.
P
latform
()
p
.
glVersion
=
'2.1'
p
.
glVersion
=
'2.1'
p
.
glRenderer
=
'Fake renderer'
p
.
glRenderer
=
'Fake renderer'
assert
p
.
glVersion
==
'2.1'
assert
p
.
glRenderer
==
'Fake renderer'
def
test_fsldir
():
def
test_fsldir
():
# We have to make a dummy directory that looks like FSL
# We have to make a dummy directory that looks like FSL
...
@@ -84,7 +164,7 @@ def test_fsldir():
...
@@ -84,7 +164,7 @@ def test_fsldir():
makeFSL
()
makeFSL
()
p
=
fslplatform
.
p
latform
p
=
fslplatform
.
P
latform
()
newFSLDir
=
[
None
]
newFSLDir
=
[
None
]
def
fsldirChanged
(
p
,
t
,
val
):
def
fsldirChanged
(
p
,
t
,
val
):
...
@@ -105,6 +185,28 @@ def test_fsldir():
...
@@ -105,6 +185,28 @@ def test_fsldir():
shutil
.
rmtree
(
testdir
)
shutil
.
rmtree
(
testdir
)
def
test_detect_ssh
():
sshVars
=
[
'SSH_CLIENT'
,
'SSH_TTY'
]
vncVars
=
[
'VNCDESKTOP'
,
'X2GO_SESSION'
,
'NXSESSIONID'
]
for
sv
in
sshVars
:
with
mock
.
patch
.
dict
(
'os.environ'
,
**
{
sv
:
'1'
}):
p
=
fslplatform
.
Platform
()
assert
p
.
inSSHSession
for
vv
in
vncVars
:
with
mock
.
patch
.
dict
(
'os.environ'
,
**
{
vv
:
'1'
}):
p
=
fslplatform
.
Platform
()
assert
p
.
inVNCSession
with
mock
.
patch
(
'os.environ'
,
{}):
p
=
fslplatform
.
Platform
()
assert
not
p
.
inSSHSession
assert
not
p
.
inVNCSession
def
test_IsWidgetAlive
():
def
test_IsWidgetAlive
():
import
wx
import
wx
...
...
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