develop #11
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
Pligin Module
|
||||
"""
|
|
@ -0,0 +1,3 @@
|
|||
"""
|
||||
Pligin Package
|
||||
"""
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"manifest": {
|
||||
"name": "PyRun",
|
||||
"author": "ITDominator",
|
||||
"version": "0.0.1",
|
||||
"support": "",
|
||||
"requests": {
|
||||
"ui_target": "plugin_control_list",
|
||||
"pass_fm_events": "true",
|
||||
"bind_keys": ["PyRun||send_message:<Shift><Control>r"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
# Python imports
|
||||
import os
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from plugins.plugin_base import PluginBase
|
||||
|
||||
|
||||
# NOTE: Threads WILL NOT die with parent's destruction.
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
||||
return wrapper
|
||||
|
||||
# NOTE: Threads WILL die with parent's destruction.
|
||||
def daemon_threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
|
||||
class Plugin(PluginBase):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.name = "PyRun" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus
|
||||
# where self.name should not be needed for message comms
|
||||
|
||||
|
||||
def run(self):
|
||||
...
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
button = Gtk.Button(label=self.name)
|
||||
button.connect("button-release-event", self.start_run)
|
||||
button.set_image( Gtk.Image(stock=Gtk.STOCK_MEDIA_PLAY ) )
|
||||
button.set_always_show_image(True)
|
||||
return button
|
||||
|
||||
def start_run(self, widget=None, eve=None):
|
||||
self._event_system.emit("get_current_state")
|
||||
state = self._fm_state
|
||||
current_dir = state.tab.get_current_directory()
|
||||
isValid = False
|
||||
command = ["terminator", "-x", f"bash -c 'python . && bash'"]
|
||||
|
||||
if not state.uris:
|
||||
for file in os.listdir(current_dir):
|
||||
path = os.path.join(current_dir, file)
|
||||
if os.path.isfile(path) and file == "__main__.py":
|
||||
isValid = True
|
||||
break
|
||||
elif state.uris and len(state.uris) == 1:
|
||||
file = state.uris[0]
|
||||
if os.path.isfile(file) and file.endswith(".py"):
|
||||
command = ["terminator", "-x", f"bash -c 'python {state.uris[0]} && bash'"]
|
||||
isValid = True
|
||||
|
||||
if isValid:
|
||||
self.launch(current_dir, command)
|
||||
|
||||
def launch(self, current_dir = "/", command = []):
|
||||
subprocess.Popen(command, cwd=current_dir, shell=False, start_new_session=True, stdout=None, stderr=None, close_fds=True)
|
|
@ -37,17 +37,17 @@ class Plugin(PluginBase):
|
|||
# self._GLADE_FILE = f"{self.path}/glade_file.glade"
|
||||
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
button = Gtk.Button(label=self.name)
|
||||
button.connect("button-release-event", self.send_message)
|
||||
return button
|
||||
|
||||
def run(self):
|
||||
# self._builder = Gtk.Builder()
|
||||
# self._builder.add_from_file(self._GLADE_FILE)
|
||||
# self._connect_builder_signals(self, self._builder)
|
||||
...
|
||||
|
||||
def generate_reference_ui_element(self):
|
||||
button = Gtk.Button(label=self.name)
|
||||
button.connect("button-release-event", self.send_message)
|
||||
return button
|
||||
|
||||
def send_message(self, widget=None, eve=None):
|
||||
message = "Hello, World!"
|
||||
event_system.emit("display_message", ("warning", message, None))
|
||||
|
|
|
@ -18,7 +18,6 @@ from app import Application
|
|||
|
||||
|
||||
|
||||
|
||||
def run():
|
||||
try:
|
||||
locale.setlocale(locale.LC_NUMERIC, 'C')
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
# Python imports
|
||||
import signal
|
||||
import os
|
||||
import inspect
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
|
||||
from utils.debugging import debug_signal_handler
|
||||
from utils.ipc_server import IPCServer
|
||||
from core.window import Window
|
||||
|
||||
|
||||
|
||||
class AppLaunchException(Exception):
|
||||
...
|
||||
|
||||
|
||||
|
||||
class Application(IPCServer):
|
||||
""" Inherit from IPCServer; create Controller classe; bind any signal(s) to Builder. """
|
||||
""" docstring for Application. """
|
||||
|
||||
def __init__(self, args, unknownargs):
|
||||
super(Application, self).__init__()
|
||||
self.args, self.unknownargs = args, unknownargs
|
||||
|
||||
if not settings.is_trace_debug():
|
||||
try:
|
||||
|
@ -36,4 +35,14 @@ class Application(IPCServer):
|
|||
|
||||
raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...")
|
||||
|
||||
try:
|
||||
# kill -SIGUSR2 <pid> from Linux/Unix or SIGBREAK signal from Windows
|
||||
signal.signal(
|
||||
vars(signal).get("SIGBREAK") or vars(signal).get("SIGUSR1"),
|
||||
debug_signal_handler
|
||||
)
|
||||
except ValueError:
|
||||
# Typically: ValueError: signal only works in main thread
|
||||
...
|
||||
|
||||
Window(args, unknownargs)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import os
|
||||
import json
|
||||
from os.path import join
|
||||
from dataclasses import dataclass
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
@ -14,6 +15,7 @@ class ManifestProcessorException(Exception):
|
|||
...
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class PluginInfo:
|
||||
path: str = None
|
||||
name: str = None
|
||||
|
|
|
@ -34,14 +34,14 @@ class FileHandler:
|
|||
|
||||
return True
|
||||
|
||||
def delete_file(self, toDeleteFile):
|
||||
def delete_file(self, to_delete_file):
|
||||
try:
|
||||
print(f"Deleting: {toDeleteFile}")
|
||||
if os.path.exists(toDeleteFile):
|
||||
if os.path.isfile(toDeleteFile):
|
||||
os.remove(toDeleteFile)
|
||||
elif os.path.isdir(toDeleteFile):
|
||||
shutil.rmtree(toDeleteFile)
|
||||
print(f"Deleting: {to_delete_file}")
|
||||
if os.path.exists(to_delete_file):
|
||||
if os.path.isfile(to_delete_file):
|
||||
os.remove(to_delete_file)
|
||||
elif os.path.isdir(to_delete_file):
|
||||
shutil.rmtree(to_delete_file)
|
||||
else:
|
||||
print("An error occured deleting the file:")
|
||||
return False
|
||||
|
@ -73,7 +73,7 @@ class FileHandler:
|
|||
|
||||
return True
|
||||
|
||||
def copy_file(self,fFile, tFile, symlinks=False, ignore=None):
|
||||
def copy_file(self, fFile, tFile, symlinks = False, ignore = None):
|
||||
try:
|
||||
if os.path.isdir(fFile):
|
||||
shutil.copytree(fFile, tFile, symlinks, ignore)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
# Break into a Python console upon SIGUSR1 (Linux) or SIGBREAK (Windows:
|
||||
# CTRL+Pause/Break). To be included in all production code, just in case.
|
||||
def debug_signal_handler(signal, frame):
|
||||
del signal
|
||||
del frame
|
||||
|
||||
try:
|
||||
import rpdb2
|
||||
logger.debug("\n\nStarting embedded RPDB2 debugger. Password is 'foobar'\n\n")
|
||||
rpdb2.start_embedded_debugger("foobar", True, True)
|
||||
rpdb2.setbreak(depth=1)
|
||||
return
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from rfoo.utils import rconsole
|
||||
logger.debug("\n\nStarting embedded rconsole debugger...\n\n")
|
||||
rconsole.spawn_server()
|
||||
except StandardError as ex:
|
||||
...
|
||||
|
||||
try:
|
||||
import code
|
||||
code.interact()
|
||||
except StandardError as ex:
|
||||
logger.debug(f"{ex}, returning to normal program flow...")
|
|
@ -577,6 +577,46 @@
|
|||
<child type="tab">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="action-start">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-back</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-forward</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="action-end">
|
||||
<object class="GtkSearchEntry" id="win1_search_field">
|
||||
<property name="name">window_1</property>
|
||||
|
@ -632,6 +672,46 @@
|
|||
<child type="tab">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="action-start">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-back</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-forward</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="action-end">
|
||||
<object class="GtkSearchEntry" id="win2_search_field">
|
||||
<property name="name">window_2</property>
|
||||
|
@ -701,6 +781,46 @@
|
|||
<child type="tab">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="action-start">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-back</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-forward</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="action-end">
|
||||
<object class="GtkSearchEntry" id="win3_search_field">
|
||||
<property name="name">window_3</property>
|
||||
|
@ -755,6 +875,46 @@
|
|||
<child type="tab">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="action-start">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">start</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-back</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-go-forward</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="action-end">
|
||||
<object class="GtkSearchEntry" id="win4_search_field">
|
||||
<property name="name">window_4</property>
|
||||
|
|
Loading…
Reference in New Issue