one stop place for your python project
This Python module contains a class WinUtiks that provides various utility methods for Windows operations.
This class represents a collection of Windows utility methods. All methods are static and can be called directly from the class.
This method changes the desktop wallpaper to the image file at the specified path.
path(str): The path to the image file.
from win import WinUtiks
# Change the wallpaper
WinUtiks.change_wallpaper('path/to/image.jpg')This method mutes the system audio.
from win import WinUtiks
# Mute the audio
WinUtiks.mute_audio()This method locks the screen.
from win import WinUtiks
# Lock the screen
WinUtiks.lock_screen()This method shuts down the system.
from win import WinUtiks
# Shutdown the system
WinUtiks.shutdown()This method restarts the system.
from win import WinUtiks
# Restart the system
WinUtiks.restart()This method logs off the current user.
from win import WinUtiks
# Log off the current user
WinUtiks.log_off()This method returns the IP address of the system.
str: The IP address of the system.
from win import WinUtiks
# Get the IP address
ip_address = WinUtiks.get_ip_address()This Python module contains a class Process that provides a method to execute shell commands and print the output.
This class represents a process. It currently has no instance variables and only one static method.
This method executes a shell command and prints the output.
command(str): The shell command to execute.stdout(subprocess.PIPE, optional): The standard output stream. Defaults to subprocess.PIPE.stderr(subprocess.PIPE, optional): The standard error stream. Defaults to subprocess.PIPE.regex_filter(str, optional): A regular expression pattern to filter the output. Defaults to None.
int: The return code of the process.
from process import Process
# Execute a command without a regex filter
Process.shell('ls')
# Execute a command with a regex filter
Process.shell('ls', regex_filter='^d')This method uses the subprocess.Popen function to execute the command. It then reads the output line by line. If a regex_filter is provided, it only prints lines that match the filter. Otherwise, it prints all lines. The method returns the return code of the process.
This Python module contains a class PathOps that provides methods for various path operations.
This class represents a path operation. It currently has no instance variables and only static methods.
This method joins two or more pathname components, inserting '/' as needed.
*paths(str): Arbitrary number of path strings to be joined.
str: The joined path.
from pathops import PathOps
# Join multiple paths
joined_path = PathOps.join('path1', 'path2', 'path3')This method normalizes a pathname by collapsing redundant separators and up-level references.
- `
The net.py script contains a class NetUtils that provides two static methods for network-related operations.
This method retrieves the local IP address of the host machine. It does this by creating a socket, connecting to an external IP address (8.8.8.8), and then retrieving the local IP address that was used for that connection.
This method starts a simple HTTP server at the specified IP address and port, serving files from the specified directory. It uses Python's built-in http.server module to start the server. The server's state is written to a file named server.prop.state.
To use these methods, import the NetUtils class from net.py and call the methods as follows:
from net import NetUtils
# Get local IP
local_ip = NetUtils.get_local_ip()
print(local_ip)
# Start server
NetUtils.server('192.168.1.1', 8000, '/path/to/serve')This script requires Python's built-in socket and subprocess modules. No additional libraries are needed.
This script assumes that the server starts successfully and does not handle any exceptions that might occur during the server start-up process.