Git Product home page Git Product logo

wslpy's Introduction

wslpy

pypi

wslpy is far from complete. the API will change frequently.

This is a Python3 library for WSL specific tasks, and you can use it to do something amazing:

>>> import wslpy as wp
>>> wp.is_wsl()
True
>>> wp.exec.cmd('ver')
Microsoft Windows [Version 10.0.18219.1000]
>>> wp.convert.to('/mnt/c/Windows/')
'c:\\Windows\\'
>>>

Installation

you can install from pypi using pip install wslpy, or install from source using python3 setup.py install

License

This project uses GPLv3 License.

wslpy's People

Contributors

hayashiesme avatar mveril avatar patrick330602 avatar shubhsboson avatar westxu avatar wilt00 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

wslpy's Issues

Looking for Maintainers

Why looking for maintainers?

I am currently working in Canonical (as you might already know) to work on Ubuntu for WSL and Ubuntu for Hyper-V. With the works I have, while spending my free time on building wslu, I find myself unable to spare enough time for wslpy. Hence, I am looking for one or two maintainers to help to complete and improving this project.

What should I do?

Currently, wslpy is half baked if you look into the code. Here are the current TO-DOs:

  • implement wslpy.system;
    • implement registry(input, key);
    • implement RegEnvVarList() using __regInfoFetch__(input, key);
    • implement regEnvVar(input) to get environment variables via Registry.
  • reimplement wslpy.exec.

Here are the goals:

  • implement the same features provided by wslvar, wslsys and wslupath from wslu;
  • (Optional) implement features by wslusc and wslact from wslu;
  • Build a documentation/wiki for the project.

What should I do to become a maintainer?

You should submit at least one PR to the project for fixing one of the issues in TO-DOs. Once it is reviewed and merged, I will add you to the maintainer list. I will be using IRC for communication (#wslu in Freenode.net). You will also get an email address ending with wslutiliti.es with your name.

On Code Comment Formatting

Are there plans format the function's comments with the same format+information as the ones in the triple quotes?

Originally posted by @HayashiEsme in 6facbfb

Yes, please do.

Originally posted by @patrick330602 in #13

With reference to a desire to format comments like so I tried to keep to the formatting of wrapping multi line comments with triple quotes as the case has been in the other functions but I ran into an interesting issue:

esme@Esme-Prestige14W:/mnt/c/Users/Esme/Developer/wslpy/wslpy$ python3 system.py
File "system.py", line 112
"""
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 663-664: truncated \UXXXXXXXX escape

This isn't a feature of Python I was familiar with so I'll add some context: Python understands triple quotes that follow the start of a function as docstrings (https://www.python.org/dev/peps/pep-0257/), and expect text within it to follow 'coding styles'. In this case with code like this:

"""
Given a valid registry path, retrieves the value of an entry in the registry.
Eg: registry("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","OS") returns "WINDOWS_NT"

MAY return string type TODO: Doees this make sense?

A valid registry path typically includes (this this and this) 
"""

The use of the double quotes and \s create issues and require escaping. The result is that documentation looks like this:

"""
Given a valid registry path, retrieves the value of an entry in the registry.
Eg: registry(\"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\",\"OS\") returns \"WINDOWS_NT\"

MAY return string type TODO: Doees this make sense?

A valid registry path typically includes (this this and this)
"""

Shall we change it to #-tagged comments to avoid this issue? Is there another place you'd like the comments to be placed otherwise Patrick?

In using #-tagged it should be alright to expect that a developer can use their text editor to quickly add #s to the comments made with a shortcut like ctrl-/ in VScode

Creating CONTRIBUTE.md for WSLpy

I thought it would be important to create this in the same style as the ones in repos before, but to create this detailing pre-requisites specific to WSLpy (This would mean: WSL installed, and commands to pull and install)

I'm thinking of writing the pull request for this fix. I'll update as I know more about my day today

Implement wslpy.system

  • implement wslpy.system;
    • implement registry(input, key);
    • implement RegEnvVarList() using regInfoFetch(input, key);
    • implement regEnvVar(input) to get environment variables via Registry.

Error when importing wslpy

Background Information:

  • Windows Build: 22000
  • WSL: Ubuntu 21.04
  • WSL Version: [e.g. 1 store]
  • Version: 0.0.13

Describe the bug
Error when importing wslpy

from .__core__.check import is_interop_enabled, is_wsl
ModuleNotFoundError: No module named 'wslpy.__core__

To Reproduce

pip install wslpy
import wslpy

Expected behavior

No error

Additional context

Workaround:
Manually add the __core__ folder to the site-packages/wslpy/
the wslpy.__core__ package could be added in the setup.py packages argument at this line

isWSL always returns True

pathlib.Path.resolve doesn't verify the existence of the path - it just builds it based on your input and converts it to the OS-specific format. As a result, isWSL would always return True.

>>> from pathlib import Path
>>> p = Path('/proc/sys/fs/binfmt_misc/WSLInterop').resolve()
>>> p
WindowsPath('C:/proc/sys/fs/binfmt_misc/WSLInterop')
>>> p.exists()
False

Module 'wslpy' has no attribute 'convert' (i.e. documentation out of sync)

Is it possible that your documentation given in README.md represents some older architecture?
None of your examples

wslpy.isWSL
wslpy.convert.reg_list()
wslpy.convert.from_reg(input)
wslpy.convert.to_path(input, toType = PathConvType.AUTO)
wslpy.winsys.build
wslpy.winsys.branch
wslpy.winsys.long_build
wslpy.winsys.CmdExec(command)
wslpy.winsys.PwShExec(command)
wslpy.winsys.PwShCrExec(command)

can work.

isWSL is a function, not an attribute. And neither convert nor winsys are imported into the module, so any of the lines above would just give module 'wslpy' has no attribute 'winsys' (or 'convert')

Would you mind updating either the documentation or your __init__.py to reflect your new module structure?

This little tool was what I had been looking for and it would be a shame if it became unusable for others. And I don't want to create a pull request as the changes need a decision best made by the author, I think (change the docs or __init__.py ?)

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.