Пример #1
0
    def __init__(self, cx=None, selected_group=None):
        connections = mcm.common.connections.ConnectionStore()
        connections.load()
        self.aliases = connections.get_aliases()

        self.response = gtk.RESPONSE_CANCEL
        self.default_color = DefaultColorSettings().base_color
        self.new_connection = None
        self.error = None
        self.builder = gtk.Builder()
        self.builder.add_from_file(constants.glade_new_cx)

        self.widgets = {
            'dlg': self.builder.get_object('dialog_add'),
            'types_combobox': self.builder.get_object('types_combobox'),
            'group_combobox': self.builder.get_object('group_combobox'),
            'user_entry1': self.builder.get_object('user_entry1'),
            'host_entry1': self.builder.get_object('host_entry1'),
            'port_entry1': self.builder.get_object('port_entry1'),
            'options_entry1': self.builder.get_object('options_entry1'),
            'description_entry1':
            self.builder.get_object('description_entry1'),
            'password_entry1': self.builder.get_object('password_entry1'),
            'alias_entry1': self.builder.get_object('alias_entry1'),
            'title_label': self.builder.get_object('title_label'),
        }
        events = {
            'response': self.cancel_event,
            'on_button_cancel_clicked': self.cancel_event,
            'on_button_save_clicked': self.event_save,
            'on_alias_entry1_changed': self.validate_alias,
            'on_types_combobox_changed': self.insert_default_options,
        }
        self.builder.connect_signals(events)

        g_entry = self.widgets['group_combobox'].get_child()
        self.widgets['group_entry1'] = g_entry

        groups = connections.get_groups()
        if cx:
            self.aliases.remove(cx.alias)
            self.init_combos(groups, cx.group, cx.get_type())
            self.fill_fields(cx)
        else:
            self.init_combos(groups, selected_group)
Пример #2
0
Файл: add.py Проект: KsenZ/mcm
    def __init__(self, cx=None, selected_group=None):
        connections = mcm.common.connections.ConnectionStore()
        connections.load()
        self.aliases = connections.get_aliases()
        
        self.response = gtk.RESPONSE_CANCEL
        self.default_color = DefaultColorSettings().base_color
        self.new_connection = None
        self.error = None
        self.builder = gtk.Builder()
        self.builder.add_from_file(constants.glade_new_cx)
        
        self.widgets = {
                        'dlg': self.builder.get_object('dialog_add'),
                        'types_combobox': self.builder.get_object('types_combobox'),
                        'group_combobox': self.builder.get_object('group_combobox'),
                        'user_entry1': self.builder.get_object('user_entry1'),
                        'host_entry1': self.builder.get_object('host_entry1'),
                        'port_entry1': self.builder.get_object('port_entry1'),
                        'options_entry1': self.builder.get_object('options_entry1'),
                        'description_entry1': self.builder.get_object('description_entry1'),
                        'password_entry1': self.builder.get_object('password_entry1'),
                        'alias_entry1': self.builder.get_object('alias_entry1'),
                        'title_label': self.builder.get_object('title_label'),
                        }
        events = {
                        'response': self.cancel_event,
                        'on_button_cancel_clicked': self.cancel_event,
                        'on_button_save_clicked': self.event_save,
                        'on_alias_entry1_changed': self.validate_alias,
                        'on_types_combobox_changed': self.insert_default_options,
                }
        self.builder.connect_signals(events)

        g_entry = self.widgets['group_combobox'].get_child()
        self.widgets['group_entry1'] = g_entry


        groups = connections.get_groups()
        if cx:
            self.aliases.remove(cx.alias)
            self.init_combos(groups, cx.group, cx.get_type())
            self.fill_fields(cx)
        else:
            self.init_combos(groups, selected_group)
Пример #3
0
def import_csv(uri):
    import csv
    import mcm.common.connections
    import mcm.common.constants as constants
    
    connections = mcm.common.connections.ConnectionStore()
    connections.load()
    
    register_mcm_csv_dialect()
        
    existing_aliases = connections.get_aliases()
    with open(uri, 'rb') as csv_file:
        csvreader = csv.DictReader(csv_file, dialect='mcm')
        for row in csvreader:
            cx = mcm.common.connections.mapped_connections_factory(row)
            if cx:
                if cx.alias not in existing_aliases:
                    connections.add(cx.alias, cx)
                    print constants.import_not_saving % cx.alias
            else:
                print "Failed to import line %s" % csvreader.line_num
    connections.save()
Пример #4
0
def import_csv(uri):
    import csv
    import mcm.common.connections
    import mcm.common.constants as constants

    connections = mcm.common.connections.ConnectionStore()
    connections.load()

    register_mcm_csv_dialect()

    existing_aliases = connections.get_aliases()
    with open(uri, 'rb') as csv_file:
        csvreader = csv.DictReader(csv_file, dialect='mcm')
        for row in csvreader:
            cx = mcm.common.connections.mapped_connections_factory(row)
            if cx:
                if cx.alias not in existing_aliases:
                    connections.add(cx.alias, cx)
                    print constants.import_not_saving % cx.alias
            else:
                print "Failed to import line %s" % csvreader.line_num
    connections.save()
Пример #5
0
 def _export(self):
     connections = mcm.common.connections.ConnectionStore()
     connections.load()
     return mcm.common.utils.export_csv(connections)
Пример #6
0
 def _export(self):
     connections = mcm.common.connections.ConnectionStore()
     connections.load()
     return mcm.common.utils.export_csv(connections)