diff --git a/bin/pytop-0-0-1-x64.deb b/bin/pytop-0-0-1-x64.deb index e1fe45e..90874b2 100644 Binary files a/bin/pytop-0-0-1-x64.deb and b/bin/pytop-0-0-1-x64.deb differ diff --git a/src/Pytop/PyTop.sh b/src/Pytop/PyTop.sh deleted file mode 100644 index 6cf9f3f..0000000 --- a/src/Pytop/PyTop.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# set -o xtrace ## To debug scripts -# set -o errexit ## To exit on error -# set -o errunset ## To exit if a variable is referenced but not set - - -function main() { - # GTK_DEBUG=interactive python3 ./PyTop.py - python3 ./PyTop.py -} -main $@; diff --git a/src/Pytop/PyTop.py b/src/Pytop/__init__.py old mode 100644 new mode 100755 similarity index 97% rename from src/Pytop/PyTop.py rename to src/Pytop/__init__.py index 0bf676f..787e0a9 --- a/src/Pytop/PyTop.py +++ b/src/Pytop/__init__.py @@ -19,7 +19,7 @@ from signal_classes import CrossClassSignals, GridSignals, TaskbarSignals, DrawS class Main: - def __init__(self): + def __init__(self, args): setproctitle('Pytop') GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit) faulthandler.enable() # For better debug info @@ -74,4 +74,4 @@ if __name__ == "__main__": main = Main() gtk.main() except Exception as e: - print(e) + print( repr(e) ) diff --git a/src/Pytop/__main__.py b/src/Pytop/__main__.py new file mode 100644 index 0000000..06514d9 --- /dev/null +++ b/src/Pytop/__main__.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + + +# Python imports +import argparse +import pdb # For trace debugging +from setproctitle import setproctitle + +# Gtk imports +import gi, faulthandler, signal +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk as gtk +from gi.repository import GLib + +# Application imports +from __init__ import Main + + + +if __name__ == "__main__": + try: + # pdb.set_trace() + setproctitle('Pytop') + GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, gtk.main_quit) + faulthandler.enable() # For better debug info + parser = argparse.ArgumentParser() + # Add long and short arguments + parser.add_argument("--file", "-f", default="default", help="JUST SOME FILE ARG.") + + # Read arguments (If any...) + args = parser.parse_args() + main = Main(args) + gtk.main() + except Exception as e: + print( repr(e) ) diff --git a/src/Pytop/resources/PyTop.glade b/src/Pytop/resources/Main_Window.glade similarity index 88% rename from src/Pytop/resources/PyTop.glade rename to src/Pytop/resources/Main_Window.glade index 46b1731..2a958f2 100644 --- a/src/Pytop/resources/PyTop.glade +++ b/src/Pytop/resources/Main_Window.glade @@ -7,14 +7,6 @@ inode/directory - - 1 - 100 - 1 - 1 - 10 - - False 800 @@ -42,6 +34,26 @@ + + True + False + start + + + + + + + + + + False + True + end + 3 + + + True False @@ -50,26 +62,11 @@ Directory Chooser - - False - True - 1 - - - - - True - False - start - - - - False True end - 0 + 2 @@ -108,58 +105,6 @@ 0 - - - True - False - - - True - True - True - True - rgb(138,226,52) - - - - False - True - 1 - - - - - 60 - True - False - - - - - True - True - 2 - - - - - True - True - brushSizeProp - - - False - True - 2 - - - - - False - True - 2 - - True @@ -265,6 +210,9 @@ 126 True False + 10 + 10 + center False @@ -304,6 +252,68 @@ + + 1 + 100 + 1 + 1 + 10 + + + + 500 + 0 + False + taskBarWorkspacesVer + bottom + + + True + False + + + True + True + True + True + rgb(138,226,52) + + + + False + True + 1 + + + + + 60 + True + False + + + + + True + True + 2 + + + + + True + True + brushSizeProp + + + False + True + 2 + + + + + True False diff --git a/src/Pytop/signal_classes/CrossClassSignals.py b/src/Pytop/signal_classes/CrossClassSignals.py index 9876233..d1d6007 100644 --- a/src/Pytop/signal_classes/CrossClassSignals.py +++ b/src/Pytop/signal_classes/CrossClassSignals.py @@ -18,8 +18,10 @@ class CrossClassSignals: # Displays Timer def displayclock(self): - now = datetime.now() - timeStr = now.strftime("%I:%M %p %m/%d/%Y") + now = datetime.now() + hms = now.strftime("%I:%M %p") + mdy = now.strftime("%m/%d/%Y") + timeStr = hms + "\n" + mdy self.timeLabel.set_label(timeStr) return True diff --git a/src/Pytop/signal_classes/DrawSignals.py b/src/Pytop/signal_classes/DrawSignals.py old mode 100644 new mode 100755 index 8b2296c..b47ee2b --- a/src/Pytop/signal_classes/DrawSignals.py +++ b/src/Pytop/signal_classes/DrawSignals.py @@ -111,7 +111,7 @@ class DrawSignals: ah = area.get_allocated_height() self.aw = aw self.ah = ah - self.xStep = aw / 200 # For x-axis 60 * 2 per 1 sec steps + self.xStep = aw / 200 # For x-axis self.yStep = ah / 100 # For y-axis %s self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, aw, ah) self.brush = cairo.Context(self.surface) diff --git a/src/Pytop/signal_classes/TaskbarSignals.py b/src/Pytop/signal_classes/TaskbarSignals.py index 5a90075..cff148b 100644 --- a/src/Pytop/signal_classes/TaskbarSignals.py +++ b/src/Pytop/signal_classes/TaskbarSignals.py @@ -16,6 +16,13 @@ from gi.repository import GLib # Application imports + +class MouseButton: + LEFT_BUTTON = 1 + MIDDLE_BUTTON = 2 + RIGHT_BUTTON = 3 + + class TaskbarSignals: def __init__(self, settings): self.settings = settings @@ -32,7 +39,7 @@ class TaskbarSignals: now = datetime.now() timeStr = now.strftime("%m/%d/%Y") parts = timeStr.split("/") - month = int(parts[0]) + month = int(parts[0]) - 1 day = int(parts[1]) year = int(parts[2]) calendarWid.select_day(day) @@ -42,6 +49,10 @@ class TaskbarSignals: calendarPopup.popdown() + def showSystemStats(self, widget, eve): + if eve.type == gdk.EventType.BUTTON_RELEASE and eve.button == MouseButton.RIGHT_BUTTON: + self.builder.get_object('systemStats').popup() + def setPagerWidget(self): pager = wnck.Pager() diff --git a/src/Pytop/utils/Logger.py b/src/Pytop/utils/Logger.py new file mode 100644 index 0000000..c8dc0db --- /dev/null +++ b/src/Pytop/utils/Logger.py @@ -0,0 +1,55 @@ +# Python imports +import os, logging + +# Application imports + + +class Logger: + def __init__(self): + self.USER_HOME = os.path.expanduser("~") + + def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True): + """ + Create a new logging object and return it. + :note: + NOSET # Don't know the actual log level of this... (defaulting or literally none?) + Log Levels (From least to most) + Type Value + CRITICAL 50 + ERROR 40 + WARNING 30 + INFO 20 + DEBUG 10 + :param loggerName: Sets the name of the logger object. (Used in log lines) + :param createFile: Whether we create a log file or just pump to terminal + + :return: the logging object we created + """ + + globalLogLvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels + chLogLevel = logging.CRITICAL # Prety musch the only one we change ever + fhLogLevel = logging.DEBUG + log = logging.getLogger(loggerName) + + # Set our log output styles + fFormatter = logging.Formatter('[%(asctime)s] %(pathname)s:%(lineno)d %(levelname)s - %(message)s', '%m-%d %H:%M:%S') + cFormatter = logging.Formatter('%(pathname)s:%(lineno)d] %(levelname)s - %(message)s') + + ch = logging.StreamHandler() + ch.setLevel(level=chLogLevel) + ch.setFormatter(cFormatter) + log.addHandler(ch) + + if createFile: + folder = self.USER_HOME + ".config/pytop/logs" + file = folder + "/application.log" + + if not os.path.exists(folder): + os.mkdir(folder) + + fh = logging.FileHandler(file) + fh.setLevel(level=fhLogLevel) + fh.setFormatter(fFormatter) + log.addHandler(fh) + + return log diff --git a/src/Pytop/utils/Settings.py b/src/Pytop/utils/Settings.py index 1afaecc..c9c4174 100644 --- a/src/Pytop/utils/Settings.py +++ b/src/Pytop/utils/Settings.py @@ -15,6 +15,7 @@ import os, json class Settings: def __init__(self, monIndex = 0): self.builder = None + self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__)) + "/" # 'Filters' self.office = ('.doc', '.docx', '.xls', '.xlsx', '.xlt', '.xltx', '.xlm', @@ -76,7 +77,7 @@ class Settings: def attachBuilder(self, builder): self.builder = builder - self.builder.add_from_file("resources/PyTop.glade") + self.builder.add_from_file(self.SCRIPT_PTH + "../resources/Main_Window.glade") def createWindow(self): # Get window and connect signals @@ -93,7 +94,7 @@ class Settings: # bind css file cssProvider = gtk.CssProvider() - cssProvider.load_from_path('resources/stylesheet.css') + cssProvider.load_from_path(self.SCRIPT_PTH + '../resources/stylesheet.css') screen = gdk.Screen.get_default() styleContext = gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER) @@ -113,6 +114,10 @@ class Settings: return monitors + def returnMonitorsInfo(self): + return self.monitors + + def saveSettings(self, startPath): data = {} data['pytop_settings'] = [] @@ -125,10 +130,6 @@ class Settings: json.dump(data, outfile) - - def returnMonitorsInfo(self): - return self.monitors - def returnSettings(self): returnData = [] diff --git a/src/Pytop/utils/__init__.py b/src/Pytop/utils/__init__.py index 590b2ca..548f6d4 100644 --- a/src/Pytop/utils/__init__.py +++ b/src/Pytop/utils/__init__.py @@ -1,3 +1,4 @@ from utils.Dragging import Dragging -from utils.Settings import Settings +from .Logger import Logger from utils.FileHandler import FileHandler +from utils.Settings import Settings diff --git a/src/Pytop/widgets/Grid.py b/src/Pytop/widgets/Grid.py index 3154bd9..f8363f5 100644 --- a/src/Pytop/widgets/Grid.py +++ b/src/Pytop/widgets/Grid.py @@ -48,7 +48,6 @@ class Grid: self.grid.connect("button_release_event", self.iconSingleClick, (self.grid,)) def setNewDirectory(self, path): - self.store.clear() self.currentPath = path dirPaths = ['.', '..'] vids = [] @@ -109,9 +108,15 @@ class Grid: @threaded def updateGrid(self, model, dirPath, file, i): - image = self.iconFactory.createThumbnail(dirPath, file).get_pixbuf() - iter = model.get_iter_from_string(str(i)) - glib.idle_add(self.replaceInGrid, (iter, image,)) + # Sinking errors b/c too lazy to find why we get some invalid tree paths when starting.. + # I really should take time to figure it out...buuuutttt....it's non-fatal. (For now.) + # Images don't seem to always load which is curious... + try: + image = self.iconFactory.createThumbnail(dirPath, file).get_pixbuf() + iter = model.get_iter_from_string(str(i)) + glib.idle_add(self.replaceInGrid, (iter, image,)) + except Exception as e: + print("widgets/Grid.py sinking errors on updateGrid method...") def addToGrid(self, dataSet): self.store.append([dataSet[0], dataSet[1]]) @@ -127,6 +132,7 @@ class Grid: fileName = model[item][1] dir = self.currentPath file = dir + "/" + fileName + self.store.clear() if fileName == ".": self.setNewDirectory(dir) diff --git a/src/Pytop/widgets/Icon.py b/src/Pytop/widgets/Icon.py index 7b97926..3cb5acf 100644 --- a/src/Pytop/widgets/Icon.py +++ b/src/Pytop/widgets/Icon.py @@ -58,7 +58,7 @@ class Icon: return thumbnl except Exception as e: print("Thumbnail generation issue:") - print(e) + print( repr(e) ) return gtk.Image.new_from_file(self.SCRIPT_PTH + "../resources/icons/video.png") @@ -85,7 +85,7 @@ class Icon: return thumbnl except Exception as e: print("Icon generation issue:") - print(e) + print( repr(e) ) return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH) @@ -141,7 +141,7 @@ class Icon: return self.createScaledImage(altIconPath, self.systemIconImageWH) except Exception as e: print(".desktop icon generation issue:") - print(e) + print( repr(e) ) return None @@ -162,7 +162,7 @@ class Icon: return None except Exception as e: print("system icon generation issue:") - print(e) + print( repr(e) ) return None @@ -173,7 +173,7 @@ class Icon: return gtk.Image.new_from_pixbuf(scaledPixBuf) except Exception as e: print("Image Scaling Issue:") - print(e) + print( repr(e) ) return None def generateVideoThumbnail(self, fullPath, hashImgPth): @@ -209,4 +209,4 @@ class Icon: proc.wait() except Exception as e: print("Video thumbnail generation issue in thread:") - print(e) + print( repr(e) ) diff --git a/src/Pytop_exec_bin.cpp b/src/Pytop_exec_bin.cpp index 93af3d7..cc6c27f 100644 --- a/src/Pytop_exec_bin.cpp +++ b/src/Pytop_exec_bin.cpp @@ -5,6 +5,6 @@ using namespace std; int main() { chdir("/opt/Pytop/"); - system("python3 PyTop.py"); + system("python3 ."); return 0; }