Skip to content

Instantly share code, notes, and snippets.

@MarZab
Created July 2, 2015 20:46
Show Gist options
  • Save MarZab/5676f0a8b7ede84a0253 to your computer and use it in GitHub Desktop.
Save MarZab/5676f0a8b7ede84a0253 to your computer and use it in GitHub Desktop.
Ajenti Widget Arbitrary Shell Command Output
from ajenti.api import *
from ajenti.plugins import *
info = PluginInfo(
title='Shiget',
icon='cog',
dependencies=[
PluginDependency('main'),
PluginDependency('dashboard'),
],
)
def init():
import shiget
import subprocess
from ajenti.api import plugin
from ajenti.plugins.dashboard.api import ConfigurableWidget
@plugin
class Shiget (ConfigurableWidget):
name = _('Shell output')
icon = 'cog'
def on_prepare(self):
self.append(self.ui.inflate('shiget:shiget'))
def on_start(self):
if self.config['command']:
self.find('value').text = subprocess.check_output(
self.config['command'],
stderr=subprocess.STDOUT,
shell=True
)
def create_config(self):
return {'command': ''}
def on_config_start(self):
self.dialog.find('command').value = self.config['command']
def on_config_save(self):
self.config['command'] = self.dialog.find('command').value
<hc>
<label id="value" escape="False" />
<dialog id="config-dialog" visible="False">
<pad>
<formline text="{Command}">
<textbox id="command"/>
</formline>
</pad>
</dialog>
</hc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment