Server IP : 103.119.228.120 / Your IP : 3.142.200.102 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python2.7/site-packages/tuned/admin/ |
Upload File : |
import dbus import dbus.exceptions import time from dbus.mainloop.glib import DBusGMainLoop from gi.repository import GLib, GObject from .exceptions import TunedAdminDBusException __all__ = ["DBusController"] class DBusController(object): def __init__(self, bus_name, interface_name, object_name, debug = False): self._bus_name = bus_name self._interface_name = interface_name self._object_name = object_name self._proxy = None self._interface = None self._debug = debug self._main_loop = None self._action = None self._on_exit_action = None self._ret = True self._exit = False self._exception = None def _init_proxy(self): try: if self._proxy is None: DBusGMainLoop(set_as_default=True) self._main_loop = GLib.MainLoop() bus = dbus.SystemBus() self._proxy = bus.get_object(self._bus_name, self._object_name) self._interface = dbus.Interface(self._proxy, dbus_interface = self._interface_name) except dbus.exceptions.DBusException: raise TunedAdminDBusException("Cannot talk to Tuned daemon via DBus. Is Tuned daemon running?") def _idle(self): if self._action is not None: # This may (and very probably will) run in child thread, so catch and pass exceptions to the main thread try: self._action_exit_code = self._action(*self._action_args, **self._action_kwargs) except TunedAdminDBusException as e: self._exception = e self._exit = True if self._exit: if self._on_exit_action is not None: self._on_exit_action(*self._on_exit_action_args, **self._on_exit_action_kwargs) self._main_loop.quit() return False else: time.sleep(1) return True def set_on_exit_action(self, action, *args, **kwargs): self._on_exit_action = action self._on_exit_action_args = args self._on_exit_action_kwargs = kwargs def set_action(self, action, *args, **kwargs): self._action = action self._action_args = args self._action_kwargs = kwargs def run(self): self._exception = None GLib.idle_add(self._idle) self._main_loop.run() # Pass exception happened in child thread to the caller if self._exception is not None: raise self._exception return self._ret def _call(self, method_name, *args, **kwargs): self._init_proxy() try: method = self._interface.get_dbus_method(method_name) return method(*args, timeout=40) except dbus.exceptions.DBusException as dbus_exception: err_str = "DBus call to Tuned daemon failed" if self._debug: err_str += " (%s)" % str(dbus_exception) raise TunedAdminDBusException(err_str) def set_signal_handler(self, signal, cb): self._init_proxy() self._proxy.connect_to_signal(signal, cb) def is_running(self): return self._call("is_running") def start(self): return self._call("start") def stop(self): return self._call("stop") def profiles(self): return self._call("profiles") def profiles2(self): return self._call("profiles2") def profile_info(self, profile_name): return self._call("profile_info", profile_name) def log_capture_start(self, log_level, timeout): return self._call("log_capture_start", log_level, timeout) def log_capture_finish(self, token): return self._call("log_capture_finish", token) def active_profile(self): return self._call("active_profile") def profile_mode(self): return self._call("profile_mode") def switch_profile(self, new_profile): if new_profile == "": return (False, "No profile specified") return self._call("switch_profile", new_profile) def auto_profile(self): return self._call("auto_profile") def recommend_profile(self): return self._call("recommend_profile") def verify_profile(self): return self._call("verify_profile") def verify_profile_ignore_missing(self): return self._call("verify_profile_ignore_missing") def off(self): return self._call("disable") def get_plugins(self): """Return dict with plugin names and their hints Return: dictionary -- {plugin_name: {parameter_name: default_value}} """ return self._call("get_all_plugins") def get_plugin_documentation(self, plugin_name): """Return docstring of plugin's class""" return self._call("get_plugin_documentation", plugin_name) def get_plugin_hints(self, plugin_name): """Return dictionary with parameters of plugin and their hints Parameters: plugin_name -- name of plugin Return: dictionary -- {parameter_name: hint} """ return self._call("get_plugin_hints", plugin_name) def exit(self, ret): self.set_action(None) self._ret = ret self._exit = True return ret