2016-04-05 20:02:02 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- Coding: UTF-8 -*-
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# Open Asset Import Library (ASSIMP)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
#
|
2020-01-20 13:53:12 +00:00
|
|
|
# Copyright (c) 2006-2020, ASSIMP Development Team
|
2016-04-05 20:02:02 +00:00
|
|
|
#
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use of this software in source and binary forms,
|
|
|
|
# with or without modification, are permitted provided that the following
|
|
|
|
# conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above
|
|
|
|
# copyright notice, this list of conditions and the
|
|
|
|
# following disclaimer.
|
|
|
|
#
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the
|
|
|
|
# following disclaimer in the documentation and/or other
|
|
|
|
# materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# * Neither the name of the ASSIMP team, nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior
|
|
|
|
# written permission of the ASSIMP Development Team.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
# ---------------------------------------------------------------------------
|
2016-04-16 16:42:49 +00:00
|
|
|
from tkinter import *
|
2016-04-05 20:02:02 +00:00
|
|
|
import sys
|
2016-04-19 14:01:21 +00:00
|
|
|
import os
|
|
|
|
import platform
|
2016-04-05 20:02:02 +00:00
|
|
|
import run
|
2016-04-18 14:13:18 +00:00
|
|
|
import subprocess
|
2016-04-05 20:02:02 +00:00
|
|
|
import result_checker as rc
|
|
|
|
|
2016-04-19 14:01:21 +00:00
|
|
|
INFO = 0
|
|
|
|
WARN = 1
|
|
|
|
ERROR = 2
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
def log( sev, msg ):
|
|
|
|
"""
|
|
|
|
This function is used to log info, warnings and errors.
|
|
|
|
"""
|
|
|
|
logEntry = ""
|
|
|
|
if sev == 0:
|
|
|
|
logEntry = logEntry + "[INFO]: "
|
|
|
|
elif sev == 1:
|
|
|
|
logEntry = logEntry + "[WARN]: "
|
|
|
|
elif sev == 2:
|
|
|
|
logEntry = logEntry + "[ERR] : "
|
2016-07-18 06:51:53 +00:00
|
|
|
logEntry = logEntry + str( msg )
|
2016-04-19 14:01:21 +00:00
|
|
|
print( logEntry )
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
class BaseDialog( Toplevel ):
|
|
|
|
"""
|
|
|
|
Helper base class for dialogs used in the UI.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, parent, title = None, buttons=""):
|
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
|
|
|
Toplevel.__init__( self, parent )
|
|
|
|
self.transient(parent)
|
|
|
|
|
|
|
|
if title:
|
|
|
|
self.title(title)
|
|
|
|
|
|
|
|
self.parent = parent
|
|
|
|
self.result = None
|
|
|
|
body = Frame(self)
|
|
|
|
self.initial_focus = self.body(body)
|
|
|
|
body.pack(padx=5, pady=5)
|
|
|
|
self.buttonbox(buttons)
|
|
|
|
self.grab_set()
|
|
|
|
if not self.initial_focus:
|
|
|
|
self.initial_focus = self
|
|
|
|
self.protocol("WM_DELETE_WINDOW", self.cancel)
|
|
|
|
self.geometry("+%d+%d" % (parent.winfo_rootx() + 50,
|
|
|
|
parent.winfo_rooty() + 50))
|
|
|
|
self.initial_focus.focus_set()
|
|
|
|
self.wait_window(self)
|
|
|
|
|
|
|
|
def body(self, master):
|
|
|
|
# create dialog body. return widget that should have
|
|
|
|
# initial focus. this method should be overridden
|
|
|
|
pass
|
|
|
|
|
|
|
|
def buttonbox(self, buttons):
|
|
|
|
# add standard button box. override if you don't want the
|
|
|
|
# standard buttons
|
|
|
|
box = Frame(self)
|
|
|
|
w = Button(box, text="OK", width=40, command=self.ok, default=ACTIVE)
|
|
|
|
w.pack(side=LEFT, padx=5, pady=5)
|
|
|
|
self.bind("<Return>", self.ok)
|
|
|
|
box.pack()
|
|
|
|
|
|
|
|
def ok(self, event=None):
|
|
|
|
if not self.validate():
|
|
|
|
self.initial_focus.focus_set() # put focus back
|
|
|
|
return
|
|
|
|
|
|
|
|
self.withdraw()
|
|
|
|
self.update_idletasks()
|
|
|
|
self.apply()
|
|
|
|
self.cancel()
|
|
|
|
|
|
|
|
def cancel(self, event=None):
|
|
|
|
# put focus back to the parent window
|
|
|
|
self.parent.focus_set()
|
|
|
|
self.destroy()
|
|
|
|
|
|
|
|
def validate(self):
|
|
|
|
return 1 # override
|
|
|
|
|
|
|
|
def apply(self):
|
|
|
|
pass # override
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
class VersionDialog( BaseDialog ):
|
|
|
|
"""
|
|
|
|
This class is used to create the info dialog.
|
|
|
|
"""
|
|
|
|
def body(self, master):
|
|
|
|
# info will be read from assimp command line tool
|
|
|
|
version = "Asset importer lib version unknown"
|
|
|
|
exe = run.getEnvVar( "assimp_path" )
|
|
|
|
if len( exe ) != 0:
|
|
|
|
command = [exe, "version" ]
|
|
|
|
log( INFO, "command = " + str(command))
|
|
|
|
stdout = subprocess.check_output(command)
|
|
|
|
for line in stdout.splitlines():
|
|
|
|
pos = str(line).find( "Version" )
|
|
|
|
if -1 != pos:
|
|
|
|
version = line
|
|
|
|
Label(master, text=version).pack()
|
|
|
|
|
|
|
|
def apply(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
class SetupDialog( BaseDialog ):
|
|
|
|
"""
|
|
|
|
This class is used to create the setup dialog.
|
|
|
|
"""
|
|
|
|
def body(self, master):
|
|
|
|
Label(master, justify=LEFT, text="Assimp: " ).grid(row=0, column=0)
|
|
|
|
Label(master, justify=LEFT, text=run.getEnvVar("assimp_path")).grid(row=0, column=1)
|
|
|
|
Label(master, text="New executable:").grid(row=1)
|
|
|
|
self.e1 = Entry(master)
|
|
|
|
self.e1.grid(row=1, column=1)
|
|
|
|
return self.e1 # initial focus
|
|
|
|
|
|
|
|
def apply(self):
|
|
|
|
exe = str( self.e1.get() )
|
|
|
|
if len( exe ) == 0:
|
|
|
|
return 0
|
|
|
|
if os.path.isfile( exe ):
|
|
|
|
log( INFO, "Set executable at " + exe)
|
|
|
|
self.assimp_bin_path = exe
|
|
|
|
run.setEnvVar("assimp_path", self.assimp_bin_path)
|
|
|
|
else:
|
|
|
|
log( ERROR, "Executable not found at "+exe )
|
|
|
|
return 0
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
2016-04-05 20:02:02 +00:00
|
|
|
class RegDialog( object ):
|
2016-04-18 14:13:18 +00:00
|
|
|
"""
|
|
|
|
This class is used to create a simplified user interface for running the regression test suite.
|
|
|
|
"""
|
2016-04-19 14:01:21 +00:00
|
|
|
|
2016-04-05 20:02:02 +00:00
|
|
|
def __init__(self, bin_path ):
|
2016-04-19 14:01:21 +00:00
|
|
|
"""
|
|
|
|
Constructs the dialog, you can define which executable shal be used.
|
|
|
|
@param bin_path [in] Path to assimp binary.
|
|
|
|
"""
|
|
|
|
run.setEnvVar( "assimp_path", bin_path )
|
2016-04-05 20:02:02 +00:00
|
|
|
self.b_run_ = None
|
|
|
|
self.b_update_ = None
|
|
|
|
self.b_res_checker_ = None
|
|
|
|
self.b_quit_ = None
|
2016-04-21 17:19:06 +00:00
|
|
|
if platform.system() == "Windows":
|
|
|
|
self.editor = "notepad"
|
|
|
|
elif platform.system() == "Linux":
|
|
|
|
self.editor = "vim"
|
2016-04-19 14:01:21 +00:00
|
|
|
self.root = None
|
|
|
|
self.width=40
|
2016-04-05 20:02:02 +00:00
|
|
|
|
|
|
|
def run_reg(self):
|
2016-04-19 14:01:21 +00:00
|
|
|
log(INFO, "Starting regression test suite.")
|
2016-04-05 20:02:02 +00:00
|
|
|
run.run_test()
|
|
|
|
rc.run()
|
|
|
|
self.b_update_.config( state=ACTIVE )
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def reg_update(self):
|
2016-04-19 14:01:21 +00:00
|
|
|
assimp_exe = run.getEnvVar( "assimp_path" )
|
|
|
|
if len( assimp_exe ) == 0:
|
|
|
|
return 1
|
|
|
|
exe = "python"
|
|
|
|
command = [ exe, "gen_db.py", assimp_exe ]
|
|
|
|
log(INFO, "command = " + str(command))
|
|
|
|
stdout = subprocess.call(command)
|
|
|
|
|
|
|
|
log(INFO, stdout)
|
2016-04-05 20:02:02 +00:00
|
|
|
return 0
|
|
|
|
|
2016-04-19 14:01:21 +00:00
|
|
|
def shop_diff( self ):
|
|
|
|
log(WARN, "ToDo!")
|
|
|
|
return 0
|
|
|
|
|
2016-04-18 14:13:18 +00:00
|
|
|
def open_log(self):
|
|
|
|
command = [ self.editor, "../results/run_regression_suite_output.txt", ]
|
2016-04-19 14:01:21 +00:00
|
|
|
log(INFO, "command = " + str( command ) )
|
2016-04-18 14:13:18 +00:00
|
|
|
r = subprocess.call(command)
|
|
|
|
return 0
|
|
|
|
|
2016-04-19 14:01:21 +00:00
|
|
|
def show_version( self ):
|
|
|
|
d = VersionDialog( self.root )
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
d = SetupDialog( self.root )
|
|
|
|
return 0
|
|
|
|
|
2016-04-05 20:02:02 +00:00
|
|
|
def quit(self):
|
2016-04-19 14:01:21 +00:00
|
|
|
log( INFO, "quit" )
|
2016-04-05 20:02:02 +00:00
|
|
|
sys.exit( 0 )
|
|
|
|
|
|
|
|
def initUi(self):
|
2016-04-19 14:01:21 +00:00
|
|
|
# create the frame with buttons
|
|
|
|
self.root = Tk()
|
|
|
|
self.root.title( "Assimp-Regression UI")
|
|
|
|
self.b_run_ = Button( self.root, text="Run regression ", command=self.run_reg, width = self.width )
|
|
|
|
self.b_update_ = Button( self.root, text="Update database", command=self.reg_update, width = self.width )
|
|
|
|
self.b_show_diff_ = Button( self.root, text="Show diff", command=self.shop_diff, width = self.width )
|
|
|
|
self.b_log_ = Button( self.root, text="Open log", command=self.open_log, width = self.width )
|
|
|
|
self.b_setup_ = Button( self.root, text="Setup", command=self.setup, width = self.width )
|
|
|
|
self.b_version_ = Button( self.root, text="Show version", command=self.show_version, width = self.width )
|
|
|
|
self.b_quit_ = Button( self.root, text="Quit", command=self.quit, width = self.width )
|
|
|
|
|
|
|
|
# define the used grid
|
|
|
|
self.b_run_.grid( row=0, column=0, sticky=W+E )
|
|
|
|
self.b_update_.grid( row=1, column=0, sticky=W+E )
|
|
|
|
self.b_show_diff_.grid( row=2, column=0, sticky=W+E )
|
|
|
|
self.b_log_.grid( row=3, column=0, sticky=W+E )
|
|
|
|
self.b_setup_.grid( row=4, column=0, sticky=W+E )
|
|
|
|
self.b_version_.grid( row=5, column=0, sticky=W+E )
|
|
|
|
self.b_quit_.grid( row=6, column=0, sticky=W+E )
|
|
|
|
|
|
|
|
#self.b_update_.config( state=DISABLED )
|
|
|
|
self.b_show_diff_.config( state=DISABLED )
|
|
|
|
|
|
|
|
# run mainloop
|
|
|
|
self.root.mainloop()
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
def getDefaultExecutable():
|
|
|
|
assimp_bin_path = ""
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
assimp_bin_path = '..\\..\\bin\\debug\\assimpd.exe'
|
|
|
|
elif platform.system() == "Linux":
|
|
|
|
assimp_bin_path = '../../bin/assimp'
|
2016-04-05 20:02:02 +00:00
|
|
|
|
2016-04-19 14:01:21 +00:00
|
|
|
return assimp_bin_path
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
2016-04-05 20:02:02 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
assimp_bin_path = sys.argv[1]
|
|
|
|
else:
|
2016-04-19 14:01:21 +00:00
|
|
|
assimp_bin_path = getDefaultExecutable()
|
|
|
|
log( INFO, 'Using assimp binary: ' + assimp_bin_path )
|
2016-04-05 20:02:02 +00:00
|
|
|
dlg = RegDialog(assimp_bin_path)
|
|
|
|
dlg.initUi()
|
|
|
|
|
2016-04-19 14:01:21 +00:00
|
|
|
# vim: ai ts=4 sts=4 et sw=4
|