pyworkspace 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyworkspace-0.1.0/PKG-INFO +71 -0
- pyworkspace-0.1.0/README.md +47 -0
- pyworkspace-0.1.0/pyworkspace/Session.py +106 -0
- pyworkspace-0.1.0/pyworkspace/Workspace.py +48 -0
- pyworkspace-0.1.0/pyworkspace/__init__.py +6 -0
- pyworkspace-0.1.0/pyworkspace/service.py +35 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/PKG-INFO +71 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/SOURCES.txt +12 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/dependency_links.txt +1 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/entry_points.txt +2 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/requires.txt +1 -0
- pyworkspace-0.1.0/pyworkspace.egg-info/top_level.txt +1 -0
- pyworkspace-0.1.0/setup.cfg +4 -0
- pyworkspace-0.1.0/setup.py +35 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyworkspace
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A python workspace and session manager for Windows environments with hotkey support.
|
|
5
|
+
Home-page: https://github.com/yourusername/pyworkspace
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: your.email@example.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: keyboard>=0.13.5
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# PyWorkspace
|
|
26
|
+
|
|
27
|
+
A sleek python package that acts as a Windows workspace and session manager. It allows you to group different files and programs together into a "Workspace" and manage them via a "Session". Executing the class method helps to open certain files/programs together and save them into a session file, allowing you to easily resume work after shutting down your PC.
|
|
28
|
+
|
|
29
|
+
It also comes with a built-in background service that listens to global shortcut keys (e.g. `Ctrl + Shift + E` to open Explorer).
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install pyworkspace
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Managing Workspaces Programmatically
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from pyworkspace import Workspace, Session
|
|
43
|
+
|
|
44
|
+
# 1. Initialize a session manager
|
|
45
|
+
session = Session("my_daily_session.json")
|
|
46
|
+
|
|
47
|
+
# 2. Create a Workspace
|
|
48
|
+
dev_ws = Workspace("Development")
|
|
49
|
+
dev_ws.add_program(r"C:\Windows\System32\cmd.exe")
|
|
50
|
+
dev_ws.add_file(r"C:\path\to\your\code.py")
|
|
51
|
+
|
|
52
|
+
# 3. Add to session and save
|
|
53
|
+
session.add_workspace(dev_ws)
|
|
54
|
+
session.save()
|
|
55
|
+
|
|
56
|
+
# 4. Resume
|
|
57
|
+
session.resume()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Running the Background Service
|
|
61
|
+
|
|
62
|
+
Once installed, a console script is automatically generated for you. Run:
|
|
63
|
+
```bash
|
|
64
|
+
pyworkspace-service
|
|
65
|
+
```
|
|
66
|
+
This runs the background listener. Optionally, it can be launched via standard hidden `.vbs` scripts for true silent operation on login!
|
|
67
|
+
|
|
68
|
+
## Requirements
|
|
69
|
+
- Python 3.6+
|
|
70
|
+
- Windows OS
|
|
71
|
+
- `keyboard` library
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# PyWorkspace
|
|
2
|
+
|
|
3
|
+
A sleek python package that acts as a Windows workspace and session manager. It allows you to group different files and programs together into a "Workspace" and manage them via a "Session". Executing the class method helps to open certain files/programs together and save them into a session file, allowing you to easily resume work after shutting down your PC.
|
|
4
|
+
|
|
5
|
+
It also comes with a built-in background service that listens to global shortcut keys (e.g. `Ctrl + Shift + E` to open Explorer).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install pyworkspace
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Managing Workspaces Programmatically
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from pyworkspace import Workspace, Session
|
|
19
|
+
|
|
20
|
+
# 1. Initialize a session manager
|
|
21
|
+
session = Session("my_daily_session.json")
|
|
22
|
+
|
|
23
|
+
# 2. Create a Workspace
|
|
24
|
+
dev_ws = Workspace("Development")
|
|
25
|
+
dev_ws.add_program(r"C:\Windows\System32\cmd.exe")
|
|
26
|
+
dev_ws.add_file(r"C:\path\to\your\code.py")
|
|
27
|
+
|
|
28
|
+
# 3. Add to session and save
|
|
29
|
+
session.add_workspace(dev_ws)
|
|
30
|
+
session.save()
|
|
31
|
+
|
|
32
|
+
# 4. Resume
|
|
33
|
+
session.resume()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Running the Background Service
|
|
37
|
+
|
|
38
|
+
Once installed, a console script is automatically generated for you. Run:
|
|
39
|
+
```bash
|
|
40
|
+
pyworkspace-service
|
|
41
|
+
```
|
|
42
|
+
This runs the background listener. Optionally, it can be launched via standard hidden `.vbs` scripts for true silent operation on login!
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
- Python 3.6+
|
|
46
|
+
- Windows OS
|
|
47
|
+
- `keyboard` library
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import subprocess
|
|
4
|
+
from .Workspace import Workspace
|
|
5
|
+
|
|
6
|
+
class Session:
|
|
7
|
+
"""
|
|
8
|
+
Session helps manage and persist workspaces.
|
|
9
|
+
It can save the current configuration to a JSON file and resume it after a computer shutdown.
|
|
10
|
+
"""
|
|
11
|
+
def __init__(self, session_file: str = "session.json"):
|
|
12
|
+
self.session_file = session_file
|
|
13
|
+
self.workspaces = {}
|
|
14
|
+
|
|
15
|
+
def add_workspace(self, workspace: Workspace):
|
|
16
|
+
"""Add a Workspace object to the current session."""
|
|
17
|
+
self.workspaces[workspace.name] = workspace
|
|
18
|
+
|
|
19
|
+
def remove_workspace(self, workspace_name: str):
|
|
20
|
+
"""Remove a Workspace from the current session by its name."""
|
|
21
|
+
if workspace_name in self.workspaces:
|
|
22
|
+
del self.workspaces[workspace_name]
|
|
23
|
+
|
|
24
|
+
def save(self):
|
|
25
|
+
"""Save the session (all managed workspaces) to a JSON file on disk."""
|
|
26
|
+
data = {
|
|
27
|
+
'workspaces': {name: ws.to_dict() for name, ws in self.workspaces.items()}
|
|
28
|
+
}
|
|
29
|
+
with open(self.session_file, 'w', encoding='utf-8') as f:
|
|
30
|
+
json.dump(data, f, indent=4)
|
|
31
|
+
print(f"Session successfully saved to {self.session_file}")
|
|
32
|
+
|
|
33
|
+
def load(self):
|
|
34
|
+
"""Load the session from the JSON file on disk."""
|
|
35
|
+
if not os.path.exists(self.session_file):
|
|
36
|
+
print(f"Session file '{self.session_file}' does not exist. Starting fresh.")
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
with open(self.session_file, 'r', encoding='utf-8') as f:
|
|
41
|
+
data = json.load(f)
|
|
42
|
+
|
|
43
|
+
self.workspaces.clear()
|
|
44
|
+
for name, ws_data in data.get('workspaces', {}).items():
|
|
45
|
+
self.workspaces[name] = Workspace.from_dict(ws_data)
|
|
46
|
+
print(f"Session loaded successfully from {self.session_file}")
|
|
47
|
+
except Exception as e:
|
|
48
|
+
print(f"Error loading session from {self.session_file}: {e}")
|
|
49
|
+
|
|
50
|
+
def open_workspace(self, workspace_name: str):
|
|
51
|
+
"""Launch all programs and files associated with a specific workspace."""
|
|
52
|
+
if workspace_name not in self.workspaces:
|
|
53
|
+
print(f"Workspace '{workspace_name}' not found in the current session.")
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
ws = self.workspaces[workspace_name]
|
|
57
|
+
print(f"Opening Workspace: {ws.name}")
|
|
58
|
+
|
|
59
|
+
# 1. Open all defined programs
|
|
60
|
+
for prog in ws.programs:
|
|
61
|
+
path = prog.get('path')
|
|
62
|
+
args = prog.get('args', '')
|
|
63
|
+
cwd = prog.get('cwd')
|
|
64
|
+
|
|
65
|
+
if not os.path.exists(path):
|
|
66
|
+
print(f" [Warning] Program missing: {path}")
|
|
67
|
+
continue
|
|
68
|
+
|
|
69
|
+
cmd = [path]
|
|
70
|
+
if args:
|
|
71
|
+
cmd.extend(args.split())
|
|
72
|
+
|
|
73
|
+
try:
|
|
74
|
+
print(f" -> Starting program: {path}")
|
|
75
|
+
# We use subprocess.Popen to launch asynchronously so it doesn't block the Python script
|
|
76
|
+
subprocess.Popen(cmd, cwd=cwd or os.path.dirname(path))
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print(f" [Error] Failed to start {path}: {e}")
|
|
79
|
+
|
|
80
|
+
# 2. Open all defined files
|
|
81
|
+
for file_item in ws.files:
|
|
82
|
+
file_path = file_item.get('path')
|
|
83
|
+
if not os.path.exists(file_path):
|
|
84
|
+
print(f" [Warning] File missing: {file_path}")
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
print(f" -> Opening file: {file_path}")
|
|
89
|
+
# os.startfile is built-in on Windows and behaves like double-clicking a file
|
|
90
|
+
if hasattr(os, 'startfile'):
|
|
91
|
+
os.startfile(file_path)
|
|
92
|
+
else:
|
|
93
|
+
# Fallback for non-Windows (just in case, although designed for Windows)
|
|
94
|
+
subprocess.Popen(['start', '', file_path], shell=True)
|
|
95
|
+
except Exception as e:
|
|
96
|
+
print(f" [Error] Failed to open {file_path}: {e}")
|
|
97
|
+
|
|
98
|
+
def resume(self):
|
|
99
|
+
"""Load the session from disk and open all managed workspaces."""
|
|
100
|
+
self.load()
|
|
101
|
+
if not self.workspaces:
|
|
102
|
+
print("No workspaces to resume.")
|
|
103
|
+
return
|
|
104
|
+
|
|
105
|
+
for ws_name in self.workspaces:
|
|
106
|
+
self.open_workspace(ws_name)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
class Workspace:
|
|
4
|
+
"""
|
|
5
|
+
Workspace represents a collection of programs and files that belong together.
|
|
6
|
+
It stores their paths and arguments so they can be launched as a group.
|
|
7
|
+
"""
|
|
8
|
+
def __init__(self, name: str):
|
|
9
|
+
self.name = name
|
|
10
|
+
self.programs = []
|
|
11
|
+
self.files = []
|
|
12
|
+
|
|
13
|
+
def add_program(self, path: str, args: str = "", cwd: str = None):
|
|
14
|
+
"""
|
|
15
|
+
Add a program (executable) to the workspace.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
path: Absolute path to the executable.
|
|
19
|
+
args: Command line arguments for the program.
|
|
20
|
+
cwd: Working directory from which to launch the program.
|
|
21
|
+
"""
|
|
22
|
+
self.programs.append({'path': path, 'args': args, 'cwd': cwd})
|
|
23
|
+
|
|
24
|
+
def add_file(self, file_path: str):
|
|
25
|
+
"""
|
|
26
|
+
Add a specific file to be opened in the workspace.
|
|
27
|
+
It will be opened with its default associated application in Windows.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
file_path: Absolute path to the file.
|
|
31
|
+
"""
|
|
32
|
+
self.files.append({'path': file_path})
|
|
33
|
+
|
|
34
|
+
def to_dict(self) -> dict:
|
|
35
|
+
"""Convert workspace to dictionary for serialization."""
|
|
36
|
+
return {
|
|
37
|
+
'name': self.name,
|
|
38
|
+
'programs': self.programs,
|
|
39
|
+
'files': self.files
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def from_dict(cls, data: dict) -> 'Workspace':
|
|
44
|
+
"""Create a workspace instance from a dictionary."""
|
|
45
|
+
ws = cls(data['name'])
|
|
46
|
+
ws.programs = data.get('programs', [])
|
|
47
|
+
ws.files = data.get('files', [])
|
|
48
|
+
return ws
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
def open_explorer():
|
|
5
|
+
"""
|
|
6
|
+
Callback function to execute when the hotkey is pressed.
|
|
7
|
+
Opens the default Windows Explorer.
|
|
8
|
+
"""
|
|
9
|
+
try:
|
|
10
|
+
# Opens explorer at the default 'My Computer' / 'Quick Access' location
|
|
11
|
+
os.startfile('explorer.exe')
|
|
12
|
+
except Exception as e:
|
|
13
|
+
print(f"Error opening explorer: {e}")
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
try:
|
|
17
|
+
import keyboard
|
|
18
|
+
except ImportError:
|
|
19
|
+
print("The 'keyboard' library is required.")
|
|
20
|
+
print("Please install it running: pip install keyboard")
|
|
21
|
+
sys.exit(1)
|
|
22
|
+
|
|
23
|
+
# 1. Register the hotkey combinations
|
|
24
|
+
# You can bind the hotkey to the function created above.
|
|
25
|
+
keyboard.add_hotkey('ctrl+shift+e', open_explorer)
|
|
26
|
+
|
|
27
|
+
# Example: You can bind other shortcuts for pyworkspace class methods
|
|
28
|
+
# e.g., keyboard.add_hotkey('ctrl+shift+w', session.resume)
|
|
29
|
+
|
|
30
|
+
# 2. Block the script from exiting and run indefinitely
|
|
31
|
+
# The script will listen in the background until 'ctrl+shift+q' is pressed.
|
|
32
|
+
keyboard.wait('ctrl+shift+q')
|
|
33
|
+
|
|
34
|
+
if __name__ == '__main__':
|
|
35
|
+
main()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyworkspace
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A python workspace and session manager for Windows environments with hotkey support.
|
|
5
|
+
Home-page: https://github.com/yourusername/pyworkspace
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: your.email@example.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: keyboard>=0.13.5
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# PyWorkspace
|
|
26
|
+
|
|
27
|
+
A sleek python package that acts as a Windows workspace and session manager. It allows you to group different files and programs together into a "Workspace" and manage them via a "Session". Executing the class method helps to open certain files/programs together and save them into a session file, allowing you to easily resume work after shutting down your PC.
|
|
28
|
+
|
|
29
|
+
It also comes with a built-in background service that listens to global shortcut keys (e.g. `Ctrl + Shift + E` to open Explorer).
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install pyworkspace
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Managing Workspaces Programmatically
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from pyworkspace import Workspace, Session
|
|
43
|
+
|
|
44
|
+
# 1. Initialize a session manager
|
|
45
|
+
session = Session("my_daily_session.json")
|
|
46
|
+
|
|
47
|
+
# 2. Create a Workspace
|
|
48
|
+
dev_ws = Workspace("Development")
|
|
49
|
+
dev_ws.add_program(r"C:\Windows\System32\cmd.exe")
|
|
50
|
+
dev_ws.add_file(r"C:\path\to\your\code.py")
|
|
51
|
+
|
|
52
|
+
# 3. Add to session and save
|
|
53
|
+
session.add_workspace(dev_ws)
|
|
54
|
+
session.save()
|
|
55
|
+
|
|
56
|
+
# 4. Resume
|
|
57
|
+
session.resume()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Running the Background Service
|
|
61
|
+
|
|
62
|
+
Once installed, a console script is automatically generated for you. Run:
|
|
63
|
+
```bash
|
|
64
|
+
pyworkspace-service
|
|
65
|
+
```
|
|
66
|
+
This runs the background listener. Optionally, it can be launched via standard hidden `.vbs` scripts for true silent operation on login!
|
|
67
|
+
|
|
68
|
+
## Requirements
|
|
69
|
+
- Python 3.6+
|
|
70
|
+
- Windows OS
|
|
71
|
+
- `keyboard` library
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
pyworkspace/Session.py
|
|
4
|
+
pyworkspace/Workspace.py
|
|
5
|
+
pyworkspace/__init__.py
|
|
6
|
+
pyworkspace/service.py
|
|
7
|
+
pyworkspace.egg-info/PKG-INFO
|
|
8
|
+
pyworkspace.egg-info/SOURCES.txt
|
|
9
|
+
pyworkspace.egg-info/dependency_links.txt
|
|
10
|
+
pyworkspace.egg-info/entry_points.txt
|
|
11
|
+
pyworkspace.egg-info/requires.txt
|
|
12
|
+
pyworkspace.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
keyboard>=0.13.5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyworkspace
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
# Read the contents of your README file
|
|
5
|
+
this_directory = os.path.abspath(os.path.dirname(__file__))
|
|
6
|
+
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
|
|
7
|
+
long_description = f.read()
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name="pyworkspace", # You may need to change this if the name is already taken on PyPI
|
|
11
|
+
version="0.1.0",
|
|
12
|
+
author="Your Name",
|
|
13
|
+
author_email="your.email@example.com",
|
|
14
|
+
description="A python workspace and session manager for Windows environments with hotkey support.",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
url="https://github.com/yourusername/pyworkspace",
|
|
18
|
+
packages=find_packages(),
|
|
19
|
+
install_requires=[
|
|
20
|
+
"keyboard>=0.13.5",
|
|
21
|
+
],
|
|
22
|
+
# This creates a command line executable, so users can just type 'pyworkspace-service'
|
|
23
|
+
entry_points={
|
|
24
|
+
'console_scripts': [
|
|
25
|
+
'pyworkspace-service=pyworkspace.service:main',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
classifiers=[
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"License :: OSI Approved :: MIT License",
|
|
31
|
+
"Operating System :: Microsoft :: Windows",
|
|
32
|
+
"Environment :: Win32 (MS Windows)",
|
|
33
|
+
],
|
|
34
|
+
python_requires='>=3.6',
|
|
35
|
+
)
|