def init(self): self.title = _('Packages') self.icon = 'gift' self.category = _('System') self.mgr = PackageManager.get() self.append(self.ui.inflate('packages:main')) def post_item_bind(object, collection, item, ui): ui.find('install').on('click', self.on_install, item) ui.find('remove').on('click', self.on_remove, item) ui.find('cancel').on('click', self.on_cancel, item) ui.find('install').visible = item.action is None ui.find( 'remove').visible = item.action is None and item.state == 'i' ui.find('cancel').visible = item.action is not None self.find('upgradeable').post_item_bind = post_item_bind self.find('search').post_item_bind = post_item_bind self.find('pending').post_item_bind = post_item_bind self.binder = Binder(None, self.find('bind-root')) self.binder_p = Binder(self, self.find('bind-pending')) self.binder_s = CollectionAutoBinding([], None, self.find('search')).populate() self.pending = {} self.installation_running = False self.action_queue = []
def on_first_page_load(self): self.controller.new_tab(self.classconfig['root']) self.binder = Binder( self.controller, self.find('filemanager')).autodiscover().populate() self.binder_c = Binder( self, self.find('bind-clipboard')).autodiscover().populate()
def init(self): self.title = 'Configure' self.icon = 'wrench' self.category = '' self.order = 50 self.append(self.ui.inflate('configurator:main')) self.binder = Binder(ajenti.config.tree, self.find('ajenti-config')) self.ccmgr = ClassConfigManager.get() self.classconfig_binding = Binder(self.ccmgr, self.find('classconfigs')) self.classconfig_rows = {} def post_classconfig_bind(object, collection, item, ui): self.classconfig_rows[item] = ui editor = item.classconfig_editor.new(self.ui) ui.find('container').append(editor) binder = DictAutoBinding(item, 'classconfig', editor.find('bind')) binder.populate() def save(): binder.update() item.save_classconfig() self.context.notify('info', 'Saved') ui.find('save').on('click', save) self.find('classconfigs').find( 'classes').post_item_bind = post_classconfig_bind self.find('users').new_item = lambda c: UserData() def post_user_bind(object, collection, item, ui): box = ui.find('permissions') box.empty() for prov in PermissionProvider.get_all(): line = self.ui.create('tab', title=prov.get_name()) box.append(line) for perm in prov.get_permissions(): line.append(self.ui.create('checkbox', id=perm[0], text=perm[1], \ value=(perm[0] in item.permissions))) self.find('users').post_item_bind = post_user_bind def post_user_update(object, collection, item, ui): box = ui.find('permissions') for prov in PermissionProvider.get_all(): for perm in prov.get_permissions(): has = box.find(perm[0]).value if has and not perm[0] in item.permissions: item.permissions.append(perm[0]) if not has and perm[0] in item.permissions: item.permissions.remove(perm[0]) self.find('users').post_item_update = post_user_update self.refresh()
def init(self): self.title = 'Samba' self.icon = 'folder-close' self.category = _('Software') self.append(self.ui.inflate('samba:main')) self.find('servicebar').name = platform_select( debian='samba', ubuntu='smbd', mageia='smbd', centos='smb', default='samba', ) self.find('servicebar').reload() self.binder = Binder(None, self.find('config')) self.find('shares').new_item = lambda c: ShareData() self.config = SambaConfig(path=platform_select( default='/etc/samba/smb.conf', freebsd='/usr/local/etc/smb.conf', )) def post_item_bind(object, collection, item, ui): ui.find('disconnect').on('click', self.on_disconnect, item) self.find('connections').post_item_bind = post_item_bind def post_user_bind(object, collection, item, ui): def delete_user(): self.usermgr.delete(item.username) self.refresh() ui.find('delete').on('click', delete_user) def set_password(): if self.usermgr.set_password(item.username, ui.find('password').value): self.context.notify('info', _('Password updated')) ui.find('password').value = '' else: self.context.notify('error', _('Password update failed')) ui.find('password-set').on('click', set_password) self.find('user-list').post_item_bind = post_user_bind self.usermgr = SambaUsers() self.binder_u = Binder(self.usermgr, self.find('users')) self.monitor = SambaMonitor() self.binder_m = Binder(self.monitor, self.find('status'))
def init(self): self.title = _('CSF Firewall') self.icon = 'fire' self.category = _('System') self.backend = CSFBackend.get() self.append(self.ui.inflate('csf:main')) self.config = CSFConfig(path='/etc/csf/csf.conf') self.list_allow = [] self.list_deny = [] self.list_tempallow = [] self.list_tempban = [] def delete_rule(csf_option, i): self.save() subprocess.call(['csf', csf_option, i.value.split('#')[0]]) self.refresh() self.find('list_allow').on_delete = lambda i, c: delete('-ar', i) self.find('list_deny').on_delete = lambda i, c: delete('-dr', i) self.find('list_tempallow').on_delete = lambda i, c: delete('-tr', i) self.find('list_tempban').on_delete = lambda i, c: delete('-tr', i) def add_rule(csf_option, address): self.save() p = subprocess.Popen(['csf', csf_option, address], stdout=subprocess.PIPE) o, e = p.communicate() self.context.notify('info', o) self.refresh() self.find('list_allow-add').on( 'click', lambda: add_rule('-a', self.find('permanent-lists-add-address').value)) self.find('list_deny-add').on( 'click', lambda: add_rule('-d', self.find('permanent-lists-add-address').value)) self.find('list_tempallow-add').on( 'click', lambda: add_rule('-ta', self.find('temporary-lists-add-address').value)) self.find('list_tempban-add').on( 'click', lambda: add_rule('-td', self.find('temporary-lists-add-address').value)) self.binder = Binder(None, self) self.binder_lists = Binder(self, self.find('lists'))
def init(self): self.title = _('Configure') self.icon = 'wrench' self.category = '' self.order = 50 self.append(self.ui.inflate('configurator:main')) self.binder = Binder(ajenti.config.tree, self.find('ajenti-config')) self.ccmgr = ClassConfigManager.get() self.classconfig_binding = Binder(self.ccmgr, self.find('classconfigs')) def post_classconfig_bind(object, collection, item, ui): def configure(): self.configure_plugin(item, notify=False) ui.find('configure').on('click', configure) self.find('classconfigs').find('classes').post_item_bind = post_classconfig_bind self.find('users').new_item = lambda c: UserData() def post_user_bind(object, collection, item, ui): box = ui.find('permissions') box.empty() ui.find('name-edit').visible = item.name != 'root' ui.find('name-label').visible = item.name == 'root' for prov in PermissionProvider.get_all(): line = self.ui.create('tab', title=prov.get_name()) box.append(line) for perm in prov.get_permissions(): line.append( self.ui.create('checkbox', id=perm[0], text=perm[1], value=(perm[0] in item.permissions)) ) self.find('users').post_item_bind = post_user_bind def post_user_update(object, collection, item, ui): box = ui.find('permissions') for prov in PermissionProvider.get_all(): for perm in prov.get_permissions(): has = box.find(perm[0]).value if has and not perm[0] in item.permissions: item.permissions.append(perm[0]) if not has and perm[0] in item.permissions: item.permissions.remove(perm[0]) if ui.find('password').value: item.password = ui.find('password').value self.find('users').post_item_update = post_user_update
def init(self): self.title = 'Instance Manager' self.icon = 'th-list' self.category = 'System' self.mgr = lxc.lxcman() #change 'dialogging:..' to match the name of directory self.append(self.ui.inflate('dialogging:main')) def post_item_bind(object, collection, item, ui): ui.find('btnStart').on('click', self.on_start, item) ui.find('btnRestart').on('click', self.on_restart, item) ui.find('btnStop').on('click', self.on_stop, item) ui.find('btnRemove').on('click', self.on_remove, item) #ui.find('btnSnapshot').on('click', self.on_snapshot, item) running = True if item.name in self.mgr.get_running() else False frozen = True if item.name in self.mgr.get_frozen() else False ui.find('btnStart').visible = not running ui.find('btnRestart').visible = running ui.find('btnStop').visible = running ui.find('btnFreeze').visible = not frozen ui.find('btnUnfreeze').visible = frozen self.find('collection').post_item_bind = post_item_bind self.obj_collection = self.mgr.get_all() self.binder = Binder(self, self) self.find('btnSnapshot').visible = False self.refresh()
def on_remove(self, container): self.find('confirmDialog').visible = True self.conf = confirmDialog() self.conf.name = container.name.strip() self.conf.message = 'Really delete %s ?' % self.conf.name self.binder_r = Binder(self.conf, self.find('confirmDialog')).populate()
def configure_plugin(self, plugin=None, notify=True): self.find('tabs').active = 1 self.refresh() if plugin and notify: self.context.notify( 'info', _('Please configure %s plugin!') % plugin.classconfig_editor.title) self.activate() dialog = self.find('classconfigs').find('dialog') dialog.find('container').empty() dialog.visible = True editor = plugin.classconfig_editor.new(self.ui) dialog.find('container').append(editor) if editor.find('bind'): logging.warn('%s uses old dictbinding classconfig editor layout') binder = DictAutoBinding(plugin, 'classconfig', editor.find('bind')) else: binder = Binder(plugin, editor) binder.populate() def save(button=None): dialog.visible = False binder.update() plugin.save_classconfig() self.save() dialog.on('button', save)
def init(self): self.title = _('Date & Time') self.icon = 'time' self.category = _('System') self.append(self.ui.inflate('ntpd:main')) self.find('servicebar').name = self.service_name self.find('servicebar').reload() self.config = NTPDConfig(path=platform_select( default=open_ntpd_conf if self.openntpd else ntpd_conf, centos='/usr/local/etc/ntpd.conf' if self.openntpd else ntpd_conf, freebsd='/usr/local/etc/ntpd.conf' if self.openntpd else ntpd_conf, )) self.binder = Binder(None, self) self.available_zones = [] for d, dirs, files in os.walk('/usr/share/zoneinfo', followlinks=False): for f in files: if f != 'zone.tab': self.available_zones.append(os.path.join(d, f)) self.available_zones = [ x[len('/usr/share/zoneinfo/'):] for x in self.available_zones ] self.available_zones.sort() self.find('servers').new_item = lambda c: ServerData()
def init(self): self.title = _('Git') self.icon = 'folder-close' self.category = 'Software' self.append(self.ui.inflate('git:main')) self.binder = Binder(None, self) self.user = None # Find User for user in ['gitolite3', 'gitolite2', 'gitolite']: try: pwn = getpwnam(user) self.user = pwn break except: pass if self.user == None: exit(-1) # Set Conf & Key Directory self.confdir = os.path.join(self.user.pw_dir, '.gitolite/conf/') self.keydir = os.path.join(self.user.pw_dir, '.gitolite/keydir/') # Event for new items self.find('usercollection').new_item = lambda c: User('newuser', '') self.find('repocollection').new_item = lambda c: Repository('newrepo') # Remove old Gitolite.conf and replace our version os.remove(self.confdir + 'gitolite.conf') with open((self.confdir + 'gitolite.conf'), 'w+') as file: file.write('include "*.conf"')
def post_init(self): self.empty() self.append(self.ui.inflate('vh-mail:main')) self.binder = Binder(None, self) def post_mb_bind(object, collection, item, ui): ui.find('size').text = str_fsize(self.manager.get_usage(item)) def post_mb_update(object, collection, item, ui): if ui.find('password').value: item.password = ui.find('password').value if item.password[:len( "md5|" )] != "md5|": #If the password is not encrypted as md5, then encrypt it using userdbpw for consistency udbpw = subprocess.Popen(['userdbpw', '-md5'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) o, e = udbpw.communicate('%s\n%s\n' % (item.password, item.password)) item.password = "******" + o #Prefix the hash with "md5|" self.find('mailboxes').post_item_bind = post_mb_bind self.find('mailboxes').post_item_update = post_mb_update self.find('mailboxes').filter = \ lambda mb: self.context.session.identity in ['root', mb.owner] self.find('targets').new_item = lambda c: ForwardingTarget.create() self.binder.setup(self.manager.config)
def init(self): self.title = _('Tasks') self.icon = 'cog' self.category = _('Tools') self.append(self.ui.inflate('tasks:main')) self.manager = TaskManager.get() self.binder = Binder(None, self) def post_td_bind(object, collection, item, ui): if item.get_class(): params_ui = self.ui.inflate(item.get_class().ui) item.binder = DictAutoBinding(item, 'params', params_ui.find('bind')) item.binder.populate() ui.find('slot').empty() ui.find('slot').append(params_ui) def post_td_update(object, collection, item, ui): if hasattr(item, 'binder'): item.binder.update() def post_rt_bind(object, collection, item, ui): def abort(): item.abort() self.refresh() ui.find('abort').on('click', abort) self.find('task_definitions').post_item_bind = post_td_bind self.find('task_definitions').post_item_update = post_td_update self.find('running_tasks').post_item_bind = post_rt_bind self.find('job_definitions').new_item = lambda c: JobDefinition()
def init(self): self.title = _('Network') self.icon = 'globe' self.category = _('System') self.net_config = INetworkConfig.get() self.append(self.ui.inflate('network:main')) def post_interface_bind(o, c, i, u): i.add_bits(self.ui) for bit in i.bits: u.find('bits').append(self.ui.create( 'tab', children=[bit], title=bit.title, )) u.find('up').on('click', self.on_up, i) u.find('down').on('click', self.on_down, i) u.find('restart').on('click', self.on_restart, i) u.find('ip').text = self.net_config.get_ip(i) def post_interface_update(o, c, i, u): for bit in i.bits: bit.apply() self.find('interfaces').post_item_bind = post_interface_bind self.find('interfaces').post_item_update = post_interface_update self.binder = Binder(None, self)
def init(self): self.append(self.ui.inflate('webserver_common:main')) self.binder = Binder(None, self) self.find_type('servicebar').buttons = self.service_buttons self.hosts_dir = AvailabilitySymlinks(self.hosts_available_dir, self.hosts_enabled_dir) def delete_host(host, c): c.remove(host) self.hosts_dir.delete(host.name) def on_host_bind(o, c, host, u): host.__old_name = host.name def on_host_update(o, c, host, u): if host.__old_name != host.name: self.hosts_dir.rename(host.__old_name, host.name) host.save() def new_host(c): name = 'untitled' self.hosts_dir.open(name, 'w').write(self.template) return WebserverHost(self.hosts_dir, name) self.find('hosts').delete_item = delete_host self.find('hosts').new_item = new_host self.find('hosts').post_item_bind = on_host_bind self.find('hosts').post_item_update = on_host_update
def init(self): self.title = 'Cron' self.icon = 'time' self.category = _('System') self.append(self.ui.inflate('cron:main')) def create_task(cls): logging.info('[cron] created a %s' % cls.__name__) return cls() def remove_task(i, c): c.remove(i) logging.info('[cron] removed %s' % i.command) self.binder = Binder(None, self.find('config')) self.find('normal_tasks').new_item = lambda c: create_task( CrontabNormalTaskData) self.find('special_tasks').new_item = lambda c: create_task( CrontabSpecialTaskData) self.find('env_settings').new_item = lambda c: create_task( CrontabEnvSettingData) self.find('normal_tasks').delete_item = remove_task self.find('special_tasks').delete_item = remove_task self.find('env_settings').delete_item = remove_task self.current_user = '******'
def init(self): self.append(self.ui.inflate('webserver_common:main')) self.binder = Binder(None, self) self.find_type('servicebar').buttons = self.service_buttons self.hosts_dir = AvailabilitySymlinks(self.hosts_available_dir, self.hosts_enabled_dir, self.supports_host_activation) def delete_host(host, c): c.remove(host) self.hosts_dir.delete(host.name) def on_host_bind(o, c, host, u): host.__old_name = host.name def on_host_update(o, c, host, u): if host.__old_name != host.name: self.hosts_dir.rename(host.__old_name, host.name) host.save() def new_host(c): name = 'untitled' while os.path.exists(self.hosts_dir.get_path(name)): name += '_' self.hosts_dir.open(name, 'w').write(self.template) return WebserverHost(self, self.hosts_dir, name) self.find('hosts').delete_item = delete_host self.find('hosts').new_item = new_host self.find('hosts').post_item_bind = on_host_bind self.find('hosts').post_item_update = on_host_update self.find('header-active-checkbox').visible = \ self.find('body-active-line').visible = \ self.supports_host_activation
def edit(self, path): self.find('dialog').visible = True self.item = Item(path) self.item.read() self.binder_d = Binder(self.item, self.find('dialog')).populate() # Unpack u = Unpacker.find(self.item.fullpath.lower()) unpack_btn = self.find('dialog').find('unpack') unpack_btn.visible = u is not None def cb(): self.context.notify('info', _('Unpacked')) self.refresh() def unpack(): u.unpack(self.item.fullpath, cb=cb) logging.info('[fm] unpacking %s' % self.item.fullpath) unpack_btn.on('click', lambda: unpack()) # Edit edit_btn = self.find('dialog').find('edit') if self.item.size > 1024 * 1024 * 5: edit_btn.visible = False def edit(): self.context.launch('notepad', path=self.item.fullpath) edit_btn.on('click', lambda: edit())
def init(self): self.title = 'Filesystems' self.icon = 'hdd' self.category = 'System' self.append(self.ui.inflate('fstab:main')) self.find('type').labels = [ 'Auto', 'EXT2', 'EXT3', 'EXT4', 'NTFS', 'FAT', 'ZFS', 'ReiserFS', 'Samba', 'None', 'Loop' ] self.find('type').values = [ 'auto', 'ext2', 'ext3', 'ext4', 'ntfs', 'vfat', 'zfs', 'reiser', 'smb', 'none', 'loop' ] self.fstab_config = FSTabConfig(path='/etc/fstab') self.mounts = MountsBackend.get() self.binder = Binder(None, self) self.find('fstab').find( 'filesystems').new_item = lambda c: FilesystemData() def post_mount_bind(object, collection, item, ui): ui.find('umount').on('click', self.on_umount, item) self.find('mounts').find( 'filesystems').post_item_bind = post_mount_bind
def init(self): self.title = 'Website editor' self.icon = 'globe' self.category = 'Web' self.hidden = True self.manager = VHManager.get() self.binder = Binder(None, self) self.append(self.ui.inflate('vh:main-website')) self.find( 'domains').new_item = lambda c: WebsiteDomain.create('example.com') self.find('ports').new_item = lambda c: WebsitePort.create(80) def post_location_bind(object, collection, item, ui): ui.find('backend-params').empty() ui.find('backend-params').append( self.ui.inflate('vh:main-backend-params-%s' % item.backend.type)) item.backend.__binder = Binder(item.backend, ui.find('backend-params')) item.backend.__binder.populate() def post_location_update(object, collection, item, ui): item.backend.__binder.update() self.find('locations').post_item_bind = post_location_bind self.find('locations').post_item_update = post_location_update self.find('create-location-type').labels = [] self.find('create-location-type').values = [] for g in sorted(ApplicationGatewayComponent.get_classes(), key=lambda x: x.title): self.find('create-location-type').labels.append(g.title) self.find('create-location-type').values.append(g.id)
def init(self): self.title = _('Plugins') self.icon = 'cogs' self.category = '' self.order = 60 # In case you didn't notice it yet, this is the Plugins Plugin Plugin self.append(self.ui.inflate('plugins:main')) def post_plugin_bind(object, collection, item, ui): if not item.crash: ui.find('crash').visible = False def post_dep_bind(object, collection, item, ui): if not item.satisfied(): installer = ui.find('fix') if item.__class__ == ModuleDependency: installer.package = 'python-module-' + item.module_name if item.__class__ == BinaryDependency: installer.package = item.binary_name installer.recheck() self.find('plugins').post_item_bind = post_plugin_bind self.find('dependencies').post_item_bind = post_dep_bind self.binder = Binder(None, self.find('bind-root'))
def init(self): self.title = 'Режим Видео' self.icon = 'facetime-video' self.category = 'Kiosk' self.append(self.ui.inflate('kiosk_videos:main')) self.binder = Binder(self, self) self.binder.populate()
def init(self): self.title = 'Режим Браузър' self.icon = 'globe' self.category = 'Kiosk' self.append(self.ui.inflate('kiosk_browser:main')) self.binder = Binder(self, self) self.binder.populate()
def post_location_bind(object, collection, item, ui): ui.find('backend-params').empty() ui.find('backend-params').append( self.ui.inflate('vh:main-backend-params-%s' % item.backend.type)) item.backend.__binder = Binder(item.backend, ui.find('backend-params')) item.backend.__binder.populate()
def init(self): self.title = 'Browser' self.icon = 'globe' self.category = 'Sanickiosk' self.append(self.ui.inflate('sanickiosk_browser:main')) self.binder = Binder(self, self) self.binder.populate()
def init(self): self.title = 'Screensaver' self.icon = 'picture' self.category = 'Sanickiosk' self.append(self.ui.inflate('sanickiosk_screensaver:main')) self.binder = Binder(self, self) self.binder.populate()
def init(self): self.title = 'Режим Снимки' self.icon = 'picture' self.category = 'Kiosk' self.append(self.ui.inflate('kiosk_photos:main')) self.binder = Binder(self, self) self.binder.populate()
def init(self): self.title = _('Users') self.icon = 'group' self.category = _('System') self.append(self.ui.inflate('users:main')) def _filterOnlyUsers(x): u = int(x.uid) if u >= 1000: return True return False def _filterOnlySystemUsers(x): u = int(x.uid) if u >= 1000: return False return True def _sorter(x): g = int(x.gid) if g >= 1000: return g - 10000 return g self.find('users').filter = _filterOnlyUsers self.find('system-users').filter = _filterOnlySystemUsers self.find('groups').sorting = _sorter self.config = PasswdConfig(path='/etc/passwd') self.config_g = GroupConfig(path='/etc/group') self.binder = Binder(None, self.find('passwd-config')) self.binder_system = Binder(None, self.find('passwd-config-system')) self.binder_g = Binder(None, self.find('group-config')) self.mgr = UsersBackend.get() def post_item_bind(object, collection, item, ui): ui.find('change-password').on('click', self.change_password, item, ui) ui.find('remove-password').on('click', self.remove_password, item) if not os.path.exists(item.home): ui.find('create-home-dir').on('click', self.create_home_dir, item, ui) ui.find('create-home-dir').visible = True self.find('users').post_item_bind = post_item_bind
def init(self): self.title = 'Supervisor' self.icon = 'play' self.category = _('Software') self.append(self.ui.inflate('supervisor:main')) self.mgr = SupervisorServiceManager.get() self.binder = Binder(None, self.find('main')) self.find('programs').new_item = lambda c: ProgramData() self.config = SupervisorConfig(path='/etc/supervisor/supervisord.conf')
def init(self): self.title = 'LSI MegaRAID' self.icon = 'hdd' self.category = _('System') self.append(self.ui.inflate('megaraid:main')) self.mgr = RAIDManager.get() self.binder = Binder(self.mgr, self)