Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
925151c4
Commit
925151c4
authored
Jul 23, 2015
by
Maxime Perrotin
Browse files
Update standalone ASN.1 editor
parent
ccf5d42d
Changes
5
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/__init__.py
View file @
925151c4
...
...
@@ -19,4 +19,5 @@
import
asn1_value_editor
import
gui
import
errCode
import
standalone_editor
__version__
=
asn1_value_editor
.
__version__
asn1_value_editor/asn1_value_editor.py
View file @
925151c4
...
...
@@ -16,7 +16,7 @@
__author__
=
"Maxime Perrotin"
__license__
=
"LGPLv3"
__version__
=
"1.0.
3
"
__version__
=
"1.0.
4
"
__url__
=
"http://taste.tuxfamily.org"
import
sys
...
...
asn1_value_editor/gui.py
View file @
925151c4
...
...
@@ -137,6 +137,8 @@ def gui():
''' Application entry point '''
# Exit app on Ctrl-C
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
if
'opengeode-simulator'
in
sys
.
argv
[
0
]:
sys
.
argv
.
append
(
'-l'
)
#usage = 'usage: gui.py [--udp=IP_Address:in_Port:out_Port]'
version
=
'taste auto-gui %s'
%
(
__version__
)
...
...
asn1_value_editor/standalone_editor.py
View file @
925151c4
...
...
@@ -35,8 +35,8 @@ from shutil import rmtree
import
resources
__author__
=
'Maxime Perrotin'
__version__
=
'1.0'
__licence__
=
'
ESA License for open-source software
'
__version__
=
'1.0
.0
'
__licence__
=
'
LGPL v3
'
__url__
=
'http://taste.tuxfamily.org'
try
:
...
...
@@ -44,6 +44,7 @@ try:
from
PySide.QtCore
import
QObject
from
PySide.QtGui
import
QApplication
,
QToolButton
from
PySide.QtUiTools
import
QUiLoader
from
opengeode.Asn1scc
import
parse_asn1
,
ASN1
except
ImportError
:
print
'PySide is missing. You must install it...'
print
'Try "sudo apt-get install python-pyside"'
...
...
@@ -51,25 +52,17 @@ except ImportError:
usable
=
True
try
:
# if hasattr(sys, 'frozen'):
# CUR_DIR = os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding()))
# else:
# CUR_DIR = os.path.dirname(os.path.realpath(__file__))
# sys.path.append(CUR_DIR)
#UI_FILE = os.path.join(CUR_DIR, 'singleEditor.ui')
UI_FILE
=
':/singleEditor.ui'
# sys.path.append(taste_inst+'/share/asn1-editor/')
dmt
=
os
.
popen
(
'taste-config --dmt'
).
readlines
()[
0
].
strip
()
asn1scc
=
os
.
path
.
join
(
dmt
,
'asn1scc'
)
PYTHON_STG
=
os
.
path
.
join
(
asn1scc
,
'python.stg'
)
sys
.
path
.
append
(
'.'
)
#
dmt = os.popen('taste-config --dmt').readlines()[0].strip()
#
asn1scc = os.path.join(dmt, 'asn1scc')
#
PYTHON_STG = os.path.join(asn1scc, 'python.stg')
#
sys.path.append('.')
from
asn1_value_editor
import
asn1Editor
from
vn
import
fromValueNotationToPySide
,
toASN1ValueNotation
from
ColorFormatter
import
ColorFormatter
except
:
#print 'Missing TASTE modules: make sure the program taste-config is in your PATH'
usable
=
False
#******************************************************************************
...
...
@@ -166,26 +159,38 @@ class SingleValueEditor(QObject):
sys
.
path
.
insert
(
0
,
self
.
tempdir
)
# Create list of types
pyDataViewPath
=
"{}/DataView.py"
.
format
(
self
.
tempdir
)
try
:
logger
.
info
(
' '
.
join
([
"asn1.exe"
,
"-customStg"
,
PYTHON_STG
+
":"
,
pyDataViewPath
,
asnFile
]))
subprocess
.
check_call
(
[
"asn1.exe"
,
"-customStg"
,
PYTHON_STG
+
':'
+
pyDataViewPath
,
asnFile
])
except
subprocess
.
CalledProcessError
:
logger
.
error
(
"ASN1 Compiler returned with value < 0"
)
raise
ValueError
(
"ASN1 Compiler returned with value < 0"
)
except
:
logger
.
error
(
"Missing ASN1 Compiler"
)
raise
ValueError
(
"Missing ASN1 Compiler"
)
# pyDataViewPath = "{}/DataView.py".format(self.tempdir)
# try:
# logger.info(' '.join(["asn1.exe", "-customStg", PYTHON_STG+":", pyDataViewPath, asnFile]))
# subprocess.check_call(
# ["asn1.exe", "-customStg", PYTHON_STG+':'+pyDataViewPath,
# asnFile])
# except subprocess.CalledProcessError:
# logger.error("ASN1 Compiler returned with value < 0")
# raise ValueError("ASN1 Compiler returned with value < 0")
# except:
# logger.error("Missing ASN1 Compiler")
# raise ValueError("Missing ASN1 Compiler")
# try:
# reload(dataView)
# except:
# try:
# dataView = __import__('DataView')
# except ImportError:
# logger.error('DataView import error')
# raise ValueError('DataView import error')
try
:
reload
(
dataView
)
except
:
try
:
dataView
=
__import__
(
'DataView'
)
except
ImportError
:
logger
.
error
(
'DataView import error'
)
raise
ValueError
(
'DataView import error'
)
dataView
=
parse_asn1
(
tuple
(
asn1File
),
ast_version
=
ASN1
.
UniqueEnumeratedNames
,
flags
=
[
ASN1
.
AstOnly
])
except
(
ImportError
,
NameError
)
as
err
:
# Can happen if DataView.py is not there
logger
.
error
(
'Error loading ASN.1 model'
)
logger
.
debug
(
str
(
err
))
except
TypeError
as
err
:
logger
.
debug
(
traceback
.
format_exc
())
raise
ValueError
(
'ASN.1 compiler failed - {}'
.
format
(
str
(
err
)))
# convert dataView types to a list of tc as needed by asn1-value-editor
for
t
,
v
in
dataView
.
types
.
items
():
self
.
tc
[
t
]
=
asn1sccToasn1ValueEditorTypes
(
dataView
.
types
,
t
,
v
.
type
)
...
...
@@ -291,7 +296,8 @@ class SingleValueEditor(QObject):
''' Remove temp files '''
rmtree
(
self
.
tempdir
)
if
__name__
==
'__main__'
:
def
main
():
# Exit app on Ctrl-C
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
...
...
@@ -301,7 +307,7 @@ if __name__ == '__main__':
# Set up the logging facilities
log
=
logging
.
getLogger
(
"asn1-editor"
)
console
=
logging
.
StreamHandler
(
sys
.
__stdout__
)
console
.
setFormatter
(
ColorFormatter
(
True
))
console
.
setFormatter
(
ColorFormatter
())
log
.
addHandler
(
console
)
log
.
info
(
'Starting ASN.1 Value Editor'
)
...
...
@@ -344,3 +350,7 @@ if __name__ == '__main__':
else
:
sys
.
exit
(
1
)
app
.
exec_
()
if
__name__
==
'__main__'
:
main
()
setup.py
View file @
925151c4
...
...
@@ -30,7 +30,9 @@ setup(
entry_points
=
{
'console_scripts'
:
[
'taste-gui = asn1_value_editor.gui:gui'
,
'taste-asn1-errCodes = asn1_value_editor.errCode:errCode'
'opengeode-simulator = asn1_value_editor.gui:gui'
,
'taste-asn1-errCodes = asn1_value_editor.errCode:errCode'
,
'asn1-value-editor = asn1_value_editor.standalone_editor:main'
,
]
},
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment