def on_pbn_set_esri_storage_location_released(self):
        print 'pbn_set_esri_storage_location released'
        from opus_core.misc import directory_path_from_opus_path
        start_dir = directory_path_from_opus_path('opus_gui.projects')

        configDialog = QFileDialog()
        filter_str = QString("*.gdb")
        fd = configDialog.getExistingDirectory(self,QString("Please select an ESRI geodatabase (*.gdb)..."), #, *.sde, *.mdb)..."),
                                          QString(start_dir), QFileDialog.ShowDirsOnly)
        if len(fd) != 0:
            fileName = QString(fd)
            fileNameInfo = QFileInfo(QString(fd))
            fileNameBaseName = fileNameInfo.completeBaseName()
            self.le_esri_storage_location.setText(fileName)
    def on_pbn_set_esri_storage_location_released(self):
        print 'pbn_set_esri_storage_location released'
        from opus_core.misc import directory_path_from_opus_path
        start_dir = directory_path_from_opus_path('opus_gui.projects')

        configDialog = QFileDialog()
        filter_str = QString("*.gdb")
        fd = configDialog.getExistingDirectory(
            self,
            QString("Please select an ESRI geodatabase (*.gdb)..."
                    ),  #, *.sde, *.mdb)..."),
            QString(start_dir),
            QFileDialog.ShowDirsOnly)
        if len(fd) != 0:
            fileName = QString(fd)
            fileNameInfo = QFileInfo(QString(fd))
            fileNameBaseName = fileNameInfo.completeBaseName()
            self.le_esri_storage_location.setText(fileName)
    def load(self, filename=None, create_if_missing=True):
        '''
        Load the gui configuration from default directory
        @param filename: Filename (String) of the XML to load. If its None, the
        default gui configuration is loaded
        @param create_if_missing (bool): Flag to create the destinated file if
        it's missing.
        '''
        # Open the GUI configuration file
        if filename is None:
            # Try the users default configuration file
            usr_conf_dir = os.path.join(os.environ['OPUS_HOME'], 'settings')
            if not os.path.exists(usr_conf_dir):
                os.mkdir(usr_conf_dir)
            filename = os.path.join(usr_conf_dir, 'gui_config.xml')

        if not os.path.exists(filename):
            # Didn't have a custom gui-configuration -- copy the default one
            # into the location before loading it
            print('Warning -- did not find GUI configuration file %s.' %
                  filename)
            if not create_if_missing:
                print('Not loading any GUI configuration file')
                return
            print('Copying the default GUI configuration to %s' % filename)
            default_config_dir = directory_path_from_opus_path('opus_gui.main')
            default_config_filename = os.path.join(
                default_config_dir, 'default_gui_configuration.xml')
            # open the file and write it to the destination
            try:
                gui_config_file = open(default_config_filename)
                user_config_file = open(filename, 'w')
                user_config_file.write(''.join(gui_config_file.readlines()))
                user_config_file.close()
                gui_config_file.close()
                # Clean up namespace
                del user_config_file, gui_config_file
            except IOError, ex:
                print(
                    'Failed to copy default configuration to %s.\n'
                    '-- Error:%s\n'
                    '!- Not loading any GUI configuration file.\n' %
                    (filename, ex))
                return
Ejemplo n.º 4
0
    def load(self, filename = None, create_if_missing = True):
        '''
        Load the gui configuration from default directory
        @param filename: Filename (String) of the XML to load. If its None, the
        default gui configuration is loaded
        @param create_if_missing (bool): Flag to create the destinated file if
        it's missing.
        '''
        # Open the GUI configuration file
        if filename is None:
            # Try the users default configuration file
            usr_conf_dir = paths.OPUS_SETTINGS_PATH 
            if not os.path.exists(usr_conf_dir):
                os.mkdir(usr_conf_dir)
            filename = os.path.join(usr_conf_dir, 'gui_config.xml')

        if not os.path.exists(filename):
            # Didn't have a custom gui-configuration -- copy the default one
            # into the location before loading it
            print('Warning -- did not find GUI configuration file %s.'%
                  filename)
            if not create_if_missing:
                print('Not loading any GUI configuration file')
                return
            print('Copying the default GUI configuration to %s'% filename)
            default_config_dir = directory_path_from_opus_path('opus_gui.main')
            default_config_filename = os.path.join(default_config_dir,
                                                'default_gui_configuration.xml')
            # open the file and write it to the destination
            try:
                gui_config_file = open(default_config_filename)
                user_config_file = open(filename, 'w')
                user_config_file.write(''.join(gui_config_file.readlines()))
                user_config_file.close()
                gui_config_file.close()
                # Clean up namespace
                del user_config_file, gui_config_file
            except IOError, ex:
                print('Failed to copy default configuration to %s.\n'
                      '-- Error:%s\n'
                      '!- Not loading any GUI configuration file.\n'%
                      (filename, ex))
                return
Ejemplo n.º 5
0
 def test_ordered(self):
     test_path = directory_path_from_opus_path('urbansim_parcel.tests.test_files')
     test_file1 = os.path.join(test_path, 'test01.yaml')
     test_file2 = os.path.join(test_path, 'test02.yaml')
     test_file3 = os.path.join(test_path, 'test03.yaml')
     sh1 = Shifters(filename=test_file1)
     sh2 = Shifters(filename=test_file2)
     self.assert_( sh1.shifters == sh2.shifters )
     self.assert_( sh1.shifters.keys() == sh2.shifters.keys() )
     self.assert_( sh1.shifters.values() == sh2.shifters.values() )
     values = sh2.getall()
     expected = [0, 2, 4, 8, 'fish', 11, 22, 'fish', 3, True, None, False]
     new_values = range(len(values))
     #print values
     self.assert_( values == expected )
     sh2.setall(new_values,filename=test_file3)
     del sh2
     sh3 = Shifters(filename=test_file3)
     self.assert_( sh3.getall() == new_values )
     os.remove(test_file3)
Ejemplo n.º 6
0
    def __init__(self,
                 source_data,
                 dataset_name,
                 attribute=None,
                 years=None,
                 operation=None,
                 name=None,
                 package=None,
                 prototype_dataset=None,
                 storage_location=None):

        Visualizer.__init__(self, source_data, dataset_name, [attribute],
                            years, operation, name, storage_location)

        if prototype_dataset is None:
            dir = directory_path_from_opus_path('%s.indicators.geotiff_files' %
                                                package)
            #todo: check indicator package and find appropriate prototype image
            prototype_dataset = os.path.join(dir, 'idgrid.tif')
            if not os.path.exists(prototype_dataset):
                raise 'Error: %s does not exist. Cannot compute GeotiffMap' % prototype_dataset

        self.prototype_dataset = prototype_dataset
Ejemplo n.º 7
0
 def __init__(self, source_data, dataset_name,
              attribute = None, 
              years = None, 
              operation = None, 
              name = None,
              package = None,
              prototype_dataset = None,
              storage_location = None):
     
     AbstractIndicator.__init__(self, source_data, 
                                dataset_name, [attribute], 
                                years, operation, name,
                                storage_location)
     
     
     
     if prototype_dataset is None:
         dir = directory_path_from_opus_path('%s.indicators.geotiff_files'%package)
         #todo: check indicator package and find appropriate prototype image
         prototype_dataset = os.path.join(dir,'idgrid.tif')
         if not os.path.exists(prototype_dataset):
             raise 'Error: %s does not exist. Cannot compute GeotiffMap'%prototype_dataset
     
     self.prototype_dataset = prototype_dataset
class OpusGuiConfiguration(object):
    def __init__(self):
        self.application_title = 'OPUS'  # correct default value?
        self.xml_node = None
        self.xml_filename = None
        self.splash_screen = None
        self.fonts = {'tabs': 10, 'menu': 10, 'general': 10}
        self.load_latest_on_start = False
        self.latest_project_filename = ''

    def load(self, filename=None, create_if_missing=True):
        '''
        Load the gui configuration from default directory
        @param filename: Filename (String) of the XML to load. If its None, the
        default gui configuration is loaded
        @param create_if_missing (bool): Flag to create the destinated file if
        it's missing.
        '''
        # Open the GUI configuration file
        if filename is None:
            # Try the users default configuration file
            usr_conf_dir = os.path.join(os.environ['OPUS_HOME'], 'settings')
            if not os.path.exists(usr_conf_dir):
                os.mkdir(usr_conf_dir)
            filename = os.path.join(usr_conf_dir, 'gui_config.xml')

        if not os.path.exists(filename):
            # Didn't have a custom gui-configuration -- copy the default one
            # into the location before loading it
            print('Warning -- did not find GUI configuration file %s.' %
                  filename)
            if not create_if_missing:
                print('Not loading any GUI configuration file')
                return
            print('Copying the default GUI configuration to %s' % filename)
            default_config_dir = directory_path_from_opus_path('opus_gui.main')
            default_config_filename = os.path.join(
                default_config_dir, 'default_gui_configuration.xml')
            # open the file and write it to the destination
            try:
                gui_config_file = open(default_config_filename)
                user_config_file = open(filename, 'w')
                user_config_file.write(''.join(gui_config_file.readlines()))
                user_config_file.close()
                gui_config_file.close()
                # Clean up namespace
                del user_config_file, gui_config_file
            except IOError, ex:
                print(
                    'Failed to copy default configuration to %s.\n'
                    '-- Error:%s\n'
                    '!- Not loading any GUI configuration file.\n' %
                    (filename, ex))
                return

        root = ElementTree(file=filename)

        self.xml_node = root
        self.xml_filename = filename

        # GUI Setting -- Splash screen
        node = root.find('startup_options/splash_logo')
        if node is None:
            # TODO Use a default ?
            self.splash_screen = QSplashScreen(QPixmap())
            self.splash_screen.showMessage('OPUS')
        else:
            # Load user splash
            dir_ = directory_path_from_opus_path('opus_gui.main.views.Images')
            splash_abs_filename = os.path.join(dir_, node.text)
            splash_pix = QPixmap(splash_abs_filename)
            splash_pix = splash_pix.scaled(600, 252, Qt.KeepAspectRatio)
            self.splash_screen = QSplashScreen(splash_pix)

        # GUI Setting -- Application Title
        node = root.find('application_options/application_title')
        if node is not None:
            self.application_title = node.text

        # GUI Setting -- Font sizes
        for group, node_name in [('menu', 'menu_font_size'),
                                 ('tabs', 'main_tabs_font_size'),
                                 ('general', 'general_text_font_size')]:
            try:
                node = root.find('font_settings/%s' % node_name)
                self.fonts[group] = int(node.text)
            except ValueError:
                print 'Could not set font %s to "%s"' % (group, node.text
                                                         or '')

        # GUI Setting -- Previous projects
        node = root.find('project_history/previous_project')
        if node is not None:
            self.latest_project_filename = node.text
        node = root.find('project_history/open_latest_project_on_start')
        if node is not None:
            self.load_latest_on_start = (node.text == "True")
Ejemplo n.º 9
0
# Opus/UrbanSim urban simulation software.
# Copyright (C) 2010-2011 University of California, Berkeley, 2005-2009 University of Washington
# See opus_core/LICENSE 


##TODO: remove this directory once everything settles
from opus_core.misc import directory_path_from_opus_path
__path__.append(directory_path_from_opus_path('opus_core.simulation'))
Ejemplo n.º 10
0
# Opus/UrbanSim urban simulation software.
# Copyright (C) 2010-2011 University of California, Berkeley, 2005-2009 University of Washington
# See opus_core/LICENSE 

##TODO: remove this directory once everything settles
from opus_core.misc import directory_path_from_opus_path
__path__.append(directory_path_from_opus_path('opus_core.estimation'))