yakdriver / oschmod Goto Github PK
View Code? Open in Web Editor NEWchmod for Windows, macOS and Linux
Home Page: https://pypi.org/project/oschmod/
License: Apache License 2.0
chmod for Windows, macOS and Linux
Home Page: https://pypi.org/project/oschmod/
License: Apache License 2.0
Is your feature request related to a problem? Please describe.
Most of the time, when using GNU Coreutils chmod, I use the following syntax
chmod +x script.sh,
chmod go-rwx readonly.txt
But python doesn't have this, sadly ...
Describe the solution you'd like
Let's fork and implement this, and open a pull request ! Would you accept this feature ?
From GNU coreutils chmod --help, it should support this expression
[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+
Describe alternatives you've considered
subprocess.run(["chmod", ...]) but it's not portable.
Additional context
Describe the bug
The pathlib works with oschmod on OSX and Linux pathlib.Path, but on Windows, we get TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.
Your configuration
Windows 8.1, Python 3.9.6
Steps to reproduce
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import oschmod
>>> import pathlib
>>> p = pathlib.Path('E:/Projects/test.txt')
>>> oschmod.get_mode(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 163, in get_mode
return win_get_permissions(path)
File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 364, in win_get_permissions
return _win_get_permissions(path, get_object_type(path))
File "E:\Projects\oschmod_venv\lib\site-packages\oschmod\__init__.py", line 376, in _win_get_permissions
sec_des = win32security.GetNamedSecurityInfo(
TypeError: Objects of type 'WindowsPath' can not be converted to Unicode.
>>> oschmod.get_mode('E:/Projects/test.txt')
7
Expected behavior
pathlib.Path works with oschmod operations
What happened instead
pathlib.Path with oschmod operations fails with TypeError
Additional context
Add any other context about the problem here.
Currently, on Windows, oschmod removes/disables inheritance to simplify permissions. However, it might be helpful to add some inheritance capabilities.
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
If this utility is useful, it could use a CLI. Should be easy to add.
Describe the bug
Calling get_mode
on a Windows machine which is a member of a domain but which is disconnected from its domain controller produces an exception from win32security.LookupAccountSid()
.
Your configuration
Windows 10 x64, Python 3.7, oschmod==0.3.9
Steps to reproduce
oschmod.get_mode(pathname)
What happened
Traceback (most recent call last)
File "...\oschmod\__init__.py", line 163, in get_mode
return win_get_permissions(path)
File "...\oschmod\__init__.py", line 364, in win_get_permissions
return _win_get_permissions(path, get_object_type(path))
File "...\oschmod\__init__.py", line 387, in _win_get_permissions
win32security.LookupAccountSid(None, ace[2]) != \
pywintypes.error: (1789, 'LookupAccountSid', 'The trust relationship between this workstation and the primary domain controller failed.')
Additional context
I'm not an expert in windows security (traceback was retyped from a screenshot of a teamviewer session!) so am not sure if this is even resolvable or oschmod's problem. But apparently being part of a domain, but not connected to a domain controller, is a reasonable scenario for Windows devices.
On Windows, for any permissions set for others, oschmod uses the built-in "Users" group. However, it might be helpful to allow this to be specified by the user and default to "Users" if not.
In BSD chmod and probably others, there is a verbose option:
-v Cause chmod to be verbose, showing filenames as the mode is modified. If the
-v flag is specified more than once, the old and new modes of the file will also be
printed, in both octal and symbolic notation.
Currently, oschmod removes permissions for SYSTEM on Windows. I'm not sure how much this will mess with things but it shouldn't be too hard to add an option to put in a full-privilege ACE for SYSTEM.
It would be nice if there was a conda distribution available from conda-forge.
Pip really is not sufficient for conda users, especially those who might want to publish conda packages that depend on this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.