Esempio n. 1
0
 def develop(self, parameter_s=''):
     # reload(classes)
     import reimport, os
     mod = reimport.modified()
     reimport.reimport(*mod)
     print 'Done re-importing'
     # reload(periodograms)
     # reload(core)
     os.system('python scons/scons.py --gfortran=/home/joao/Software/mesasdk/bin/gfortran')
Esempio n. 2
0
def languageReloader():
    print "Reloading languages..."
    # Why doesn't this work?
    # modified_modules = modified(MACROSYSTEM_DIRECTORY + "\\languages")
    # for mod in modified_modules:
    #     reimport(mod)
    reimport(specs)
    reimport(python_rule, java_rule, yaml_rule)
    utils.touch(MACROSYSTEM_DIRECTORY + "\\_language_switcher.py")
    utils.toggleMicrophone()
Esempio n. 3
0
def languageReloader():
    print "Reloading languages..."
    # Why doesn't this work?
    # modified_modules = modified(MACROSYSTEM_DIRECTORY + "\\languages")
    # for mod in modified_modules:
    #     reimport(mod)
    reimport(specs)
    reimport(python_rule, java_rule)
    utils.touch(MACROSYSTEM_DIRECTORY + "\\_language_switcher.py")
    utils.toggleMicrophone()
Esempio n. 4
0
def ccrReloader():
    print "Reloading CCR..."
    reimport(editing_commands, text_formatting, scan_line, window_control)
    try:  # putstringcommands is not included in the pushed source, because it contains personal data.
        if putstringcommands:
            reimport(putstringcommands)
    except NameError:
        pass

    utils.touch(MACROSYSTEM_DIRECTORY + "\\_global_continuous_recognition.py")
    utils.toggleMicrophone()
Esempio n. 5
0
def LoadManager(name):
    import reimport

    try:
        if name in sys.modules:
            reimport.reimport(name)
        else:
            __import__(name, globals(), locals())

        mgr = sys.modules[name]
        return mgr.GetManager()
    except KeyError, e:
        GEUtil.Warning("Failed to find manager named: %s!\n" % name)
        raise e
Esempio n. 6
0
def LoadManager( name ):
    import reimport

    try:
        if name in sys.modules:
            reimport.reimport( name )
        else:
            __import__( name, globals(), locals() )

        mgr = sys.modules[name]
        return mgr.GetManager()
    except KeyError, e:
        GEUtil.Warning( "Failed to find manager named: %s!\n" % name )
        raise e
Esempio n. 7
0
 def button_reload(self, cr, uid, ids, context=None):
     for module_record in self.browse(cr, uid, ids, context=context):
         #Remove any report parsers registered for this module.
         module_path = 'addons/' + module_record.name
         for service_name, service in Service._services.items():
             template = getattr(service, 'tmpl', '')
             if type(template) == type(''):
                 if template.startswith(module_path):
                     Service.remove(service_name)
         
         #Remove any model classes registered for this module
         MetaModel.module_to_models[module_record.name] = []                    
         
         #Reload all Python modules from the OpenERP module's directory.
         modulename = 'openerp.addons.' + module_record.name
         root = __import__(modulename)
         module = getattr(root.addons, module_record.name)
         
         reimport(module)
     RegistryManager.delete(cr.dbname)
     RegistryManager.new(cr.dbname)
     return {}
Esempio n. 8
0
    def reload_hwr_clicked(self):
        """Reloads hardware objects"""

        #TODO: in development
        hwr = HardwareRepository.HardwareRepository()
        import reimport
        for hwr_obj in hwr.hardwareObjects:

            connections = hwr.hardwareObjects[hwr_obj].connect_dict
            for sender in connections:
                hwr.hardwareObjects[hwr_obj].disconnect(\
                    sender, connections[sender]["signal"], connections[sender]["slot"])

            #reload(hwr.hardwareObjects[hwr_obj].__class__)

        from HardwareRepository import BaseHardwareObjects
        import Qt4_VideoMockup
        reimport.reimport(BaseHardwareObjects)
        reimport.reimport(Qt4_VideoMockup)

        for hwr_obj in hwr.hardwareObjects:
            for sender in connections:
                hwr.hardwareObjects[hwr_obj].connect(\
                    sender, connections[sender]["signal"], connections[sender]["slot"])
    def reloadHardwareObjects(self):
        """
        Reloads all modified modules.
        Package reimport is used to detect modified modules.
        Hardware objects that correspond to these modules:
        1. are disconnected from gui
        2. imported in this module with __import__ and reimport is called
        3. connected back to the gui channels
        """
        # NOTE
        # reimport is supported for python 2.x and not by python 3.x
        # if needed a similar package for 3x could be used. In this case
        # code depends on a platform: platform.python_version()[0] > 2 ...

        import reimport

        modified_modules = reimport.modified()
        for hwr_obj in self.hardwareObjects:
            for item in modified_modules:
                if self.hardwareObjects[hwr_obj].__module__ == item:
                    try:
                        connections = self.hardwareObjects[hwr_obj].connect_dict
                        for sender in connections:
                            self.hardwareObjects[hwr_obj].disconnect(
                                sender,
                                connections[sender]["signal"],
                                connections[sender]["slot"],
                            )
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s disconnected from GUI" % item
                        )
                        self.hardwareObjects[hwr_obj].clear_gevent()
                    except BaseException:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to disconnect hwobj %s" % item
                        )
                        continue

                    try:
                        __import__(item, globals(), locals(), [], -1)
                        reimport.reimport(item)
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s reloaded" % item
                        )
                    except BaseException:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to reload module %s" % item
                        )

                    try:
                        for sender in connections:
                            self.hardwareObjects[hwr_obj].connect(
                                sender,
                                connections[sender]["signal"],
                                connections[sender]["slot"],
                            )
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s connected to GUI" % item
                        )
                    except BaseException:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to connect hwobj %s" % item
                        )
                    try:
                        self.hardwareObjects[hwr_obj].init()
                        self.hardwareObjects[hwr_obj].update_values()
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s initialized and updated" % item
                        )
                    except BaseException:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to initialize hwobj %s" % item
                        )
    def reloadHardwareObjects(self):
        """
        Reloads all modified modules.
        Package reimport is used to detect modified modules.
        Hardware objects that correspond to these modules:
        1. are disconnected from gui
        2. imported in this module with __import__ and reimport is called
        3. connected back to the gui channels
        """
        # NOTE
        # reimport is supported for python 2.x and not by python 3.x
        # if needed a similar package for 3x could be used. In this case
        # code depends on a platform: platform.python_version()[0] > 2 ...

        # NB reloadHardwareObjects does NOT work with beamline_opbject
        # and other yaml configs

        import reimport

        modified_modules = reimport.modified()
        for hwr_obj in self.hardwareObjects:
            for item in modified_modules:
                if self.hardwareObjects[hwr_obj].__module__ == item:
                    try:
                        connections = self.hardwareObjects[
                            hwr_obj].connect_dict
                        for sender in connections:
                            self.hardwareObjects[hwr_obj].disconnect(
                                sender,
                                connections[sender]["signal"],
                                connections[sender]["slot"],
                            )
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s disconnected from GUI",
                            item)
                        self.hardwareObjects[hwr_obj].clear_gevent()
                    except Exception:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to disconnect hwobj %s",
                            item)
                        continue

                    try:
                        __import__(item, globals(), locals(), [], -1)
                        reimport.reimport(item)
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s reloaded", item)
                    except Exception:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to reload module %s",
                            item)

                    try:
                        for sender in connections:
                            self.hardwareObjects[hwr_obj].connect(
                                sender,
                                connections[sender]["signal"],
                                connections[sender]["slot"],
                            )
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s connected to GUI", item)
                    except Exception:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to connect hwobj %s",
                            item)
                    try:
                        self.hardwareObjects[hwr_obj].init()
                        self.hardwareObjects[hwr_obj].re_emit_values()
                        logging.getLogger("HWR").debug(
                            "HardwareRepository: %s initialized and updated",
                            item)
                    except Exception:
                        logging.getLogger("HWR").exception(
                            "HardwareRepository: Unable to initialize hwobj %s",
                            item)
Esempio n. 11
0
def utilsReloader():
    print "Reloading utils..."
    reimport(utils)
    utils.toggleMicrophone()
Esempio n. 12
0
def characterReloader():
    print "Reloading character..."
    reimport(character)
    utils.toggleMicrophone()
    def __init__( self ):
        super( PYGamePlayManager, self ).__init__()

        import reimport
        reimport.reimport( GamePlay )
Esempio n. 14
0
    def __init__(self):
        super(PYGamePlayManager, self).__init__()

        import reimport
        reimport.reimport(GamePlay)
Esempio n. 15
0
def extras_rebuilder():
    print "Rebuilding extras..."
    for rebuild_me in rebuild_these:
        print(rebuild_me)
        reimport(rebuild_me)
    utils.toggleMicrophone()
Esempio n. 16
0
def utilsReloader():
    print "Reloading utils..."
    reimport(utils)
    utils.toggleMicrophone()
Esempio n. 17
0
def characterReloader():
    print "Reloading character..."
    reimport(character)
    utils.toggleMicrophone()
Esempio n. 18
0
    def __init__( self ):
        super( PYAiManager, self ).__init__()
        self.ClearSchedules()

        import reimport
        reimport.reimport( Ai )
Esempio n. 19
0
from maya import OpenMaya, cmds
import PyGML
import reimport
for module in reimport.modified():
    print module
    reimport.reimport(module)

gmlFile = open('/Users/dkeegan/dev/mercurial/projects/pygml/SampleGML/134.gml', 'r')
gml = PyGML.GML(gmlFile)
gmlFile.close()

#gml = PyGML.GML()
#stroke = PyGML.Stroke()
#stroke.addPoint(0.0, 0.0, 0.0, 0.0)
#stroke.addPoint(0.0, 1.0, 0.0, 0.1)
#stroke.addPoint(0.0, 2.0, 0.0, 0.2)
#gml.addStroke(stroke)

for stroke in gml.iterStrokes():
    meshPoints = OpenMaya.MPointArray()
    meshPolyCounts = OpenMaya.MIntArray()
    meshPolyConnects = OpenMaya.MIntArray()
    
    indices, vertices = stroke.getPolyData(radius=0.04, sides=20, rotZ=False)
    for face in indices:
        meshPolyCounts.append(len(face))
        for index in face:
            meshPolyConnects.append(index)
    for vert in vertices:
        meshPoints.append(OpenMaya.MPoint(*vert.asArray()))