Created
July 2, 2015 20:46
-
-
Save MarZab/5676f0a8b7ede84a0253 to your computer and use it in GitHub Desktop.
Ajenti Widget Arbitrary Shell Command Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ajenti.api import * | |
from ajenti.plugins import * | |
info = PluginInfo( | |
title='Shiget', | |
icon='cog', | |
dependencies=[ | |
PluginDependency('main'), | |
PluginDependency('dashboard'), | |
], | |
) | |
def init(): | |
import shiget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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