Code Monkey home page Code Monkey logo

pycrosskit's People

Contributors

darkmastermindz avatar deepsource-autofix[bot] avatar deepsourcebot avatar dependabot[bot] avatar guts avatar jiri-otoupal avatar pavlutom avatar shivenbajpai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pycrosskit's Issues

How to use an exec path with spaces

Im trying to create a shortcut to "C:\Program Files (x86)\Slay\Slay.exe" (Slay being the name of my program)
But on running the following code

from pycrosskit.shortcuts import Shortcut

Shortcut(shortcut_name="Slay", exec_path="C:\\Program Files (x86)\\Slay\\Slay.exe", description="Slay",
         icon_path="C:\\Program Files (x86)\\Slay\\icon.ico", work_dir="C:\\Program Files (x86)\\Slay", desktop=True, start_menu=False)

What happens is that it creates a shortcut with the execution target set to
"C:\Program Files (x86)\Slay\Slay.exe" Files(x86)\Slay\Slay.exe
Whereas I would want
"C:\Program Files (x86)\Slay\Slay.exe"

Running on windows 11 python 3.10.6

desktop and start_menu params get switched

Describe the bug
The start_menu and desktop parameters get switched in different functions depending on your platform
i.e specifying start_menu=True in create_shortcut would cause a desktop shortcut to be made and not a start_menu shortcut

Additional context
Within the code, the order of the parameters in the function definition is different from that in which they are passed to said function
this is true for create_shortcut() on linux
and for delete_shortcut() on desktop

Moreover since this affects the path returned to testing code, this was not caught in the tests

Hardcoded HKEY_LOCAL_MACHINE, unable to retrieve system env variables on Windows

Describe the bug

Pycrosskit hardcodes winreg values in windows.py to HKEY_CURRENT_USER. However, I'm looking to override that value HKEY_CURRENT_SYSTEM to get access to system environment variables. Without digging through the source code to override windows.py, this results in retrieving those variables from user env rather than system env as it errors out in __get_policy_key_readonly function.

To Reproduce
Setting the following reg_path to get values when retrieving from SysEnv().get(key,reg_path, registry) will result in error

reg_path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
SysEnv().get(key="Path", reg_path=reg_path, registry=True)

Snippet from windows.py example of hardcoding

    @classmethod
    def __get_policy_key_readonly(cls, reg_path: str):

        root = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
        policy_key = winreg.OpenKeyEx(root, reg_path)
        return policy_key, root

Expected behavior

I'm trying to use Pycross kit to get system environment variables instead of using the winreg implementation which works as follows:

import winreg

reg_path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'

reg_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_path)

system_environment_variables = winreg.QueryValueEx(reg_key, 'Path')[0]

propose to change windows.py to the following to allow override in values for reg_key and set winreg.HKEY_CURRENT_USER as default to not change any current behavior

    @classmethod
    def __get_policy_key_readonly(cls, reg_path: str, reg_key = winreg.HKEY_CURRENT_USER):

        root = winreg.ConnectRegistry(None, reg_key)
        policy_key = winreg.OpenKeyEx(root, reg_path)
        return policy_key, root
 @classmethod
    def set(
            cls,
            key,
            value,
            subkey="",
            reg_path=r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
            reg_key=winreg.HKEY_CURRENT_USER,
            registry=True,
            silent=False,
    ):
        """
        Set Environment Variable
        :param silent: If permission error should fail silently
        :param key: Variable Name
        :param value: Variable Value
        :param subkey: Sub-Key under key ( like file in folder )
        :param reg_path: Register path for windows
        :param reg_key: WinReg register key for windows
        :param registry: Only for windows, if true variable is set to registry path
                if false, variable is set to environment variables
        """
        if registry:
            root = winreg.ConnectRegistry(None, reg_key)

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: 22H2

Fix publishing packages

Hi @jiri-otoupal, I noticed the CI is failing for publishing packages on main. I would like the use the latest changes. Would it be possible to get a release soon?

Thanks,

  • Hansel

Value of default_reg_path?

I tried this package and when within python console I get an error that default_reg_path is not defined on the get_var example.
I am on Win 10.
Should the example be updated to make it work?

The examples should at least be extended with this line of code:
from pycrosskit.envariables import SysEnv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.