def importMetaData(moduleName, site=None):
    locPath = 'HazardServices/hazardMetaData/'
    # Use the base class to get the BASE file path
    scriptName = 'CommonMetaData.py'
    fileName = locPath + scriptName

    pathMgr = PathManager()
    filePath = pathMgr.getLocalizationFile(fileName,
                                           loctype='COMMON_STATIC',
                                           loclevel='BASE').getFile().name
    basePath = filePath.replace(scriptName, '')

    # Import all the modules in the formats BASE directory using PythonOverrider.
    for s in basePath.split(os.path.pathsep):
        if os.path.exists(s):
            scriptfiles = os.listdir(s)
            for filename in scriptfiles:
                split = string.split(filename, ".")
                if len(split) == 2 and len(split[0]) > 0 and split[1] == "py":
                    if sys.modules.has_key(split[0]):
                        clearModuleAttributes(split[0])
                    tmpModule = importModule(locPath + filename,
                                             localizedSite=site)

    # Reload the desired metadata module again since above import order
    # is random which may cause subclasses to have old references to superclasses.
    return importModule(locPath + moduleName + '.py', localizedSite=site)
Пример #2
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(745, 683)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.pathWidget = PathManager(self.centralwidget)
        self.pathWidget.setMinimumSize(QtCore.QSize(0, 256))
        self.pathWidget.setObjectName("pathWidget")
        self.verticalLayout_3.addWidget(self.pathWidget)
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setMaximumSize(QtCore.QSize(16777215, 25))
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
        self.verticalLayout.setContentsMargins(-1, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label = QtWidgets.QLabel(self.frame)
        self.label.setObjectName("label")
        self.horizontalLayout_2.addWidget(self.label)
        self.root = QtWidgets.QLineEdit(self.frame)
        self.root.setObjectName("root")
        self.horizontalLayout_2.addWidget(self.root)
        self.browse = QtWidgets.QPushButton(self.frame)
        self.browse.setObjectName("browse")
        self.horizontalLayout_2.addWidget(self.browse)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.verticalLayout_3.addWidget(self.frame)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 745, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionOpen = QtWidgets.QAction(MainWindow)
        self.actionOpen.setObjectName("actionOpen")
        self.actionSave = QtWidgets.QAction(MainWindow)
        self.actionSave.setObjectName("actionSave")
        self.actionSave_As = QtWidgets.QAction(MainWindow)
        self.actionSave_As.setObjectName("actionSave_As")
        self.actionNew = QtWidgets.QAction(MainWindow)
        self.actionNew.setObjectName("actionNew")
        self.menuFile.addAction(self.actionNew)
        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSave)
        self.menuFile.addAction(self.actionSave_As)
        self.menubar.addAction(self.menuFile.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Пример #3
0
    def writeJsonFile(self, filename, id, dataDicts, replaceFile=False):
        if replaceFile:
            mode = "w"
        else:
            mode = "w+"

        pathMgr = PathManager()
        vtecFile = pathMgr.getLocalizationFile(str(filename + ".json"),
                                               'CAVE_STATIC', 'USER')
        fd = vtecFile.getFile(mode)
        fd.write(json.dumps(dataDicts, sort_keys=True, indent=4))
        fd.close()
        vtecFile.save()
Пример #4
0
def importModule(name,
                 loctype='COMMON_STATIC',
                 level=None,
                 localizedSite=None,
                 localizationUser=None):
    """
    Takes a name (filename and localization path) and the localization type and finds the 
    file and overrides it, and returns the module
    
    Args:
            name : the name and path of the file in localization
            loctype : a string representation of the localization type
            level : a string representation of the localization level (BASE, SITE, etc.)
            localizedSite: the site that localization information should be
                retrieved for (if applicable)
            localizationUser: the user that localization information should
                be retrieved for (if applicable)
    
    Returns:
            a module that has all the correct methods after being overridden
    """
    if not JEP_AVAILABLE:
        if localizationHost is None:
            localizationHost = THRIFT_HOST

        if localizationPort is None:
            localizationPort = THRIFT_PORT

        return PythonOverriderPure.importModule(name, localizationHost,
                                                localizationPort,
                                                localizedSite,
                                                localizationUser, loctype,
                                                level)

    pathManager = PathManager()
    tieredFiles = pathManager.getTieredLocalizationFile(loctype, name)
    availableLevels = pathManager.getAvailableLevels()
    levels = PythonOverriderCore._buildLocalizationLevelsList(
        availableLevels, level)

    lfiles = []
    for _level in levels:
        if _level in tieredFiles:
            lfiles.append(tieredFiles[_level].getPath())
    themodule = PythonOverriderCore._internalOverride(lfiles)
    return themodule
Пример #5
0
    def __init__(self, scriptPath, localizationPath, site):
        super(ProductInterface, self).__init__(scriptPath, localizationPath,
                                               site)
        self.pathMgr = PathManager()
        # TODO - every file that exists in localization and is class based needs
        # to be imported via PythonOverrider. Not just the 2 below directories.

        # Import the textUtilities dir using PythonOverrider
        self.importTextUtility(reloadModules=False)
        # Import the eventUtilities dir using PythonOverrider
        self.importEventUtility(reloadModules=False)
        # Import all the generator modules using PythonOverrider.
        self.importModules()
        # Import all the formatter modules using PythonOverrider.
        self.importFormatters()
        self.logger = logging.getLogger("ProductInterface")
        self.logger.addHandler(
            UFStatusHandler.UFStatusHandler(
                "com.raytheon.uf.common.hazards.productgen",
                "ProductInterface",
                level=logging.INFO))
        self.logger.setLevel(logging.INFO)
Пример #6
0
    def __init__(self, markers, occupancy_map, pos_init, pos_goal, max_speed,
                 min_speed, max_omega, x_spacing, y_spacing, t_cam_to_body,
                 mode):
        """
        Initialize the class
        """
        # plan a path around obstacles using dijkstra's algorithm
        print('Planning path...')
        path = findShortestPath(occupancy_map,
                                x_spacing,
                                y_spacing,
                                pos_init[0:2],
                                pos_goal[0:2],
                                dilate=2)
        print('Done!')
        self.path_manager = PathManager(path)
        self.kalman_filter = KalmanFilter(markers, pos_init)
        self.diff_drive_controller = DiffDriveController(
            max_speed, min_speed, max_omega)

        if 'HARDWARE' in mode:
            # Handles all the ROS related items
            self.ros_interface = ROSInterface(t_cam_to_body)

        elif 'SIMULATE' in mode:
            self.robot_sim = RobotSim(markers, occupancy_map, pos_init,
                                      pos_goal, max_speed, max_omega,
                                      x_spacing, y_spacing,
                                      self.path_manager.path, mode)

        self.user_control = UserControl()
        self.vel = 0  # save velocity to use for kalman filter
        self.goal = self.path_manager.getNextWaypoint()  # get first waypoint

        # for logging postion data to csv file
        self.stateSaved = []
        self.tagsSaved = []
        self.waypoints = []
    def __init__(self, scriptPath, localizationPath, site):
        super(RecommenderInterface, self).__init__(scriptPath,
                                                   localizationPath, site)
        self.pathMgr = PathManager()
        # Import the textUtilities dir using PythonOverrider
        self.importTextUtility(reloadModules=False)
        # Import the eventUtilities dir using PythonOverrider
        self.importEventUtility(reloadModules=False)
        # Import all the generator modules using PythonOverrider.
        self.importModules()

        # This variable will be used to cache the Pythonic version of the
        # event set supplied by the last call to getDialogInfo(), or the
        # last call to getSpatialInfo() that included a non-None event set.
        # It is then used as the event set between then and the next
        # invocation of execute() for calls to the methods getSpatialInfo(),
        # handleDialogParameterChange(), and isSpatialInfoComplete().
        #
        # This is done because event sets can have complex attributes that
        # take a while to convert to Python values from the original Java
        # objects (e.g. the geometry associated with CWAs if the scope is
        # national), and since the event set should not change during
        # parameter gathering, reusing it is OK.
        self.parameterGatheringEventSet = None
Пример #8
0
 def getUserPath(self, category):
     pathMgr = PathManager()
     lf = pathMgr.getLocalizationFile(str(self._localizationPath),
                                      'CAVE_STATIC', 'USER')
     fullpath = lf.getPath()
     return fullpath + "/"
Пример #9
0
def main():
    mIns = MissionManager()
    PathManagerIns = PathManager()
    targetPos = [7, 5]  # set target position
    startPos = [0, 0]  # set start position
    PathManagerIns.pathGenerator(0, mIns, startPos, targetPos, PathManagerIns)
Пример #10
0
 def run(cls):
     super(Builder, Builder).run()
     saveOldFuncs()
     injectNewFuncs()
     Builder.pm = PathManager()
Пример #11
0
# ========== My class inport ==========
# from EncodeManager import NetManager  # 呼び出すネットによって変える
NetManager = import_module(IMPORT_NET_CLS).NetManager
from DataManager import DataManager
from PathManager import PathManager
from ImageGenerator import ImageGenerator
from FitManager import FitManager
import ShareNetFunc as nfunc
import PlotFunc

# ========== NetManager呼び出し ==========
net_cls = NetManager()

# ========== PathManager呼び出し ==========
path_cls = PathManager(tfrecord_folder=TFRECORD_FOLDER,
                       output_rootfolder=OUT_ROOT_FOLDER,
                       epoch_output_rootfolder=EPOCH_OUT_ROOT_FOLDER)
path_cls.all_makedirs()  # 結果保存フォルダ生成

# ========== DataSet呼び出し ==========
# プロパティデータ読み込み
df = pd.read_csv(path_cls.get_property_path())
shuf_train_ds_cls = DataManager(
    tfrecord_path=path_cls.get_train_ds_path(),
    img_root=IMAGE_ROOT_PATH,
    batch_size=SHUF_LEARN_BATCH_SIZE,
    net_cls=net_cls,
    data_n=df.at[0, 'total_learn_data'],
    suffle_buffer=SUFFLE_BUFFER_SIZE,
)
train_ds_cls = DataManager(