Package wslpy

Documentation for Ver. 0.1.0

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.

Expand source code
"""
## Documentation for Ver. 0.1.0

> `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:

```python
>>> 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

<img width="150" src="https://www.gnu.org/graphics/gplv3-with-text-136x68.png">

This project uses [GPLv3](LICENSE) License.

"""
from .__core__.check import is_interop_enabled, is_wsl

__pdoc__ = {}
__pdoc__["tests"] = False

__all__ = [
    "is_interop_enabled",
    "is_wsl",
]

Sub-modules

wslpy.convert

This is the class that helps convert between 3 types of path used widely in WSL.

wslpy.exec

This is the execution class to execute commands from different windows executables

wslpy.helper

This provides a pre-configured set of tools to use directly in WSL.

wslpy.system

Provides users with the access for Windows system information like system vatiables and registry keys.

wslpy.win

Provides easy access to the Windows information

Functions

def is_interop_enabled()

Checks if interoperability is enabled.

Returns

A boolean value, True if interoperability is enabled.

Expand source code
def is_interop_enabled():
    """
    Checks if interoperability is enabled.

    Returns
    -------
    A boolean value, `True` if interoperability is enabled.
    """
    if is_wsl():
        if path.exists("/etc/wsl.conf"):
            from configparser import ConfigParser
            c = ConfigParser()
            c.read("/etc/wsl.conf")
            if c.has_option('interop', 'enabled'):
                value = c['interop']['enabled']
                return value.lower() == 'true'
        with open('/proc/sys/fs/binfmt_misc/WSLInterop', 'r') as f:
            interop_str = f.read()
            value = interop_str.split('\n')[0]
    return value == 'enabled'
def is_wsl()

Check whether the system is WSL.

Returns

A boolean value, True if it is WSL.

Expand source code
def is_wsl():
    """
    Check whether the system is WSL.

    Returns
    -------
    A boolean value, `True` if it is WSL.
    """
    return path.exists('/proc/sys/fs/binfmt_misc/WSLInterop')