diff --git a/README.md b/README.md
index f6c742f..6c582a3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
# Common Clipboard
diff --git a/src/common_clipboard.py b/src/common_clipboard.py
index 6293e34..bb2a0c5 100644
--- a/src/common_clipboard.py
+++ b/src/common_clipboard.py
@@ -1,3 +1,7 @@
+"""
+Main file for application
+"""
+
import requests
import time
import win32clipboard as clipboard
@@ -5,7 +9,7 @@
import pickle
from socket import gethostbyname, gethostname
from threading import Thread
-from multiprocessing import Process
+from multiprocessing import Process, freeze_support
from multiprocessing.managers import BaseManager
from enum import Enum
from pystray import Icon, Menu, MenuItem
@@ -50,13 +54,16 @@ def find_server():
def get_copied_data():
- for fmt in list(Format):
- if clipboard.IsClipboardFormatAvailable(fmt.value):
- clipboard.OpenClipboard()
- data = clipboard.GetClipboardData(fmt.value)
- clipboard.CloseClipboard()
- return data, fmt
- else:
+ try:
+ for fmt in list(Format):
+ if clipboard.IsClipboardFormatAvailable(fmt.value):
+ clipboard.OpenClipboard()
+ data = clipboard.GetClipboardData(fmt.value)
+ clipboard.CloseClipboard()
+ return data, fmt
+ else:
+ raise BaseException
+ except BaseException:
try:
return current_data, current_format
except NameError:
@@ -159,6 +166,8 @@ def get_menu_items():
if __name__ == '__main__':
+ freeze_support()
+
finding_server_delay = 1
listener_delay = 0.3
@@ -189,7 +198,7 @@ def get_menu_items():
format_to_type = {Format.TEXT: 'text', Format.IMAGE: 'image'}
type_to_format = {v: k for k, v in format_to_type.items()}
- icon = Image.open('icon.ico')
+ icon = Image.open('systray_icon.ico')
systray = Icon('Common Clipboard', icon=icon, title='Common Clipboard', menu=Menu(get_menu_items))
systray.run_detached()
diff --git a/src/device_list.py b/src/device_list.py
index 2cd4319..5eb2c28 100644
--- a/src/device_list.py
+++ b/src/device_list.py
@@ -1,3 +1,7 @@
+"""
+Class to keep track of connected devices
+"""
+
import time
diff --git a/src/port_editor.py b/src/port_editor.py
index 5af4db6..c91e45d 100644
--- a/src/port_editor.py
+++ b/src/port_editor.py
@@ -1,3 +1,7 @@
+"""
+GUI to edit the current port the application is running on
+"""
+
import tkinter
from tkinter import ttk
from tkinter import messagebox
@@ -9,7 +13,7 @@ def __init__(self, current_port):
self.root = tkinter.Tk()
self.root.title('Edit Port')
- self.root.iconbitmap('icon.ico')
+ self.root.iconbitmap('systray_icon.ico')
self.root.geometry('250x75')
self.root.resizable(False, False)
self.root.bind('', lambda _: self.apply_port_number())
diff --git a/src/server.py b/src/server.py
index b9cb805..53bfbf9 100644
--- a/src/server.py
+++ b/src/server.py
@@ -1,3 +1,7 @@
+"""
+File to handle server operations
+"""
+
from flask import Flask, request, make_response, send_file
from io import BytesIO
from device_list import DeviceList
diff --git a/src/setup.py b/src/setup.py
index fbb8801..bb90d12 100644
--- a/src/setup.py
+++ b/src/setup.py
@@ -1,35 +1,84 @@
+import sys
from cx_Freeze import setup, Executable
-setup(
- name='Common Clipboard',
- author='cmdvmd',
- version='0.1-alpha',
- options={
- 'build_exe': {
- 'packages': [
- 'setuptools',
- 'requests',
- 'time',
- 'win32clipboard',
- 'socket',
- 'threading',
- 'enum',
- 'infi.systray',
- 'io',
- 'plyer'
- ],
- 'include_files': [
- 'static'
- ]
- }
- },
- executables=[
- Executable(
- script='common_clipboard.py',
- icon='icon.ico',
- shortcut_name='Common Clipboard',
- shortcut_dir='StartMenuFolder',
- base='Win32GUI'
- )
- ]
-)
+
+def generate_shortcut_table(shortcuts):
+ table = []
+ for location in shortcuts:
+ table.append((
+ f'{location}Shortcut',
+ f'{location}Folder',
+ 'Common Clipboard',
+ 'TARGETDIR',
+ '[TARGETDIR]common_clipboard.exe',
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ 'TARGETDIR'
+ ))
+ return table
+
+
+if __name__ == '__main__':
+ setup(
+ name='common_clipboard',
+ description='Common Clipboard',
+ author='cmdvmd',
+ version='1.0b0',
+ options={
+ 'build_exe': {
+ 'packages': [
+ 'setuptools',
+ 'requests',
+ 'time',
+ 'win32clipboard',
+ 'sys',
+ 'pickle',
+ 'socket',
+ 'threading',
+ 'multiprocessing',
+ 'enum',
+ 'pystray',
+ 'PIL',
+ 'io',
+ 'flask',
+ 'tkinter'
+ ],
+ 'excludes': [
+ '_distutils_hack',
+ 'asyncio'
+ 'concurrent',
+ 'distutils',
+ 'lib2to3',
+ 'pkg_resources',
+ 'pydoc_data',
+ 'test',
+ 'unittest',
+ 'xml',
+ 'xmlrpc',
+ ],
+ 'include_files': [
+ 'systray_icon.ico'
+ ],
+ 'optimize': 2
+ },
+ 'bdist_msi': {
+ 'data': {
+ 'Shortcut': generate_shortcut_table(['Desktop', 'StartMenu', 'Startup'])
+ }
+ }
+ },
+ executables=[
+ Executable(
+ script='common_clipboard.py',
+ icon='../static/icon.ico',
+ copyright='Copyright (c) cmdvmd 2023',
+ base='Win32GUI' if sys.platform == 'win32' else None,
+ shortcut_name='Common Clipboard',
+ shortcut_dir=''
+ )
+ ]
+ )
diff --git a/src/icon.ico b/src/systray_icon.ico
similarity index 100%
rename from src/icon.ico
rename to src/systray_icon.ico
diff --git a/icon.ico b/static/icon.ico
similarity index 100%
rename from icon.ico
rename to static/icon.ico
diff --git a/static/installer_icon.ico b/static/installer_icon.ico
new file mode 100644
index 0000000..14c3527
Binary files /dev/null and b/static/installer_icon.ico differ
diff --git a/logo.png b/static/logo.png
similarity index 100%
rename from logo.png
rename to static/logo.png