Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
1a5cff85
Commit
1a5cff85
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Filled in platform module, and moved to fsl.utils.
parent
71495e2c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/fsleyes/platform.py
+0
-45
0 additions, 45 deletions
fsl/fsleyes/platform.py
fsl/utils/platform.py
+159
-0
159 additions, 0 deletions
fsl/utils/platform.py
with
159 additions
and
45 deletions
fsl/fsleyes/platform.py
deleted
100644 → 0
+
0
−
45
View file @
71495e2c
#!/usr/bin/env python
#
# platform.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
os
haveGui
=
False
wxFlavour
=
None
wxPlatform
=
None
WX_PYTHON
=
1
WX_PHOENIX
=
2
WX_MAC
=
1
WX_GTK
=
2
class
Platform
(
object
):
def
__init__
(
self
):
self
.
haveGui
=
False
self
.
wxFlavour
=
None
self
.
wxPlatform
=
None
try
:
import
wx
self
.
haveGui
=
True
except
ImportError
:
pass
if
self
.
haveGui
:
if
'
phoenix
'
in
wx
.
PlatformInformation
:
self
.
wxFlavour
=
WX_PHOENIX
if
'
MAC
'
in
wx
.
Platform
:
self
.
wxPlatform
=
WX_MAC
# TODO Make Platform a notifier, so
# things can register to listen
# for changes to $FSLDIR
self
.
fsldir
=
os
.
environ
[
'
FSLDIR
'
]
This diff is collapsed.
Click to expand it.
fsl/utils/platform.py
0 → 100644
+
159
−
0
View file @
1a5cff85
#!/usr/bin/env python
#
# platform.py - Platform information
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
This module provides the :class:`Platform` class, which is a container
of information about the current platform we are running on. A single
``Platform`` instance is created when this module is first imported, and
is available as a module attribute called :attr:`platform`.
.. note:: The ``Platform`` class only contains information which is not
already accessible from the built-in ``platform`` module
(e.g. operating system information), or the ``six`` module (e.g.
python 2 vs 3).
"""
import
logging
import
os
import
fsl.utils.notifier
as
notifier
log
=
logging
.
getLogger
(
__name__
)
WX_PYTHON
=
1
"""
Identifier for the :attr:`Platform.wxFlavour` property, indicating that
we are running standard wx Python.
"""
WX_PHOENIX
=
2
"""
Identifier for the :attr:`Platform.wxFlavour` property, indicating that we
are running wx Python/Phoenix.
"""
WX_MAC_COCOA
=
1
"""
Identifier for the :attr:`Platform.wxFlavour` property, indicating that we
are running the OSX cocoa wx build.
"""
WX_MAC_CARBON
=
2
"""
Identifier for the :attr:`Platform.wxFlavour` property, indicating that we
are running the OSX carbon wx build.
"""
WX_GTK
=
3
"""
Identifier for the :attr:`Platform.wxFlavour` property, indicating that we
are running the Linux/GTK wx build.
"""
class
Platform
(
notifier
.
Notifier
):
"""
The ``Platform`` class contains a handful of properties which contain
information about the platform we are running on.
.. autosummary::
fsldir
haveGui
wxBuild
wxFlavour
"""
def
__init__
(
self
):
"""
Create a ``Platform`` instance.
"""
self
.
__fsldir
=
os
.
environ
.
get
(
'
FSLDIR
'
,
None
)
self
.
__haveGui
=
False
self
.
__wxFlavour
=
None
self
.
__wxPlatform
=
None
try
:
import
wx
self
.
__haveGui
=
True
except
ImportError
:
pass
if
self
.
__haveGui
:
pi
=
[
t
.
lower
()
for
t
in
wx
.
PlatformInfo
]
isPhoenix
=
False
for
tag
in
pi
:
if
'
phoenix
'
in
tag
:
isPhoenix
=
True
break
if
isPhoenix
:
self
.
__wxFlavour
=
WX_PHOENIX
else
:
self
.
__wxFlavour
=
WX_PYTHON
if
any
([
'
cocoa
'
in
p
for
p
in
pi
]):
build
=
WX_MAC_COCOA
elif
any
([
'
carbon
'
in
p
for
p
in
pi
]):
build
=
WX_MAC_CARBON
elif
any
([
'
gtk
'
in
p
for
p
in
pi
]):
build
=
WX_GTK
else
:
build
=
None
self
.
__build
=
build
if
self
.
__build
is
None
:
log
.
warning
(
'
Could not determine wx build from
'
'
platform information: {}
'
.
format
(
pi
))
@property
def
haveGui
(
self
):
"""
``True`` if we are running with a GUI, ``False`` otherwise.
"""
return
self
.
__haveGui
@property
def
wxBuild
(
self
):
"""
One of :data:`WX_MAC_COCOA`, :data:`WX_MAC_CARBON`, or
:data:`WX_GTK`, indicating the wx build.
"""
return
self
.
__wxBuild
@property
def
wxFlavour
(
self
):
"""
One of :data:`WX_PYTHON` or :data:`WX_PHOENIX`, indicating the wx
flavour.
"""
return
self
.
__wxFlavour
@property
def
fsldir
(
self
):
"""
The FSL installation location.
.. note:: The ``fsldir`` property can be updated - when it is changed,
any registered listeners are notified via the
:class:`.Notifier` interface.
"""
return
self
.
__fsldir
@fsldir.setter
def
fsldir
(
self
,
value
):
"""
Changes the value of the :attr:`fsldir` property, and notifies any
registered listeners.
"""
self
.
__fsldir
=
value
self
.
notify
()
platform
=
Platform
()
"""
An instance of the :class:`Platform` class. Feel free to create your own
instance, but be aware that if you do so you will not be updated of changes
to the :attr:`Platform.fsldir` property.
"""
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