Giter Site home page Giter Site logo

cmdix's People

Contributors

abravalheri avatar avasam avatar bhrutledge avatar bswck avatar cclauss avatar darkvertex avatar dimitripapadopoulos avatar hnz avatar hugovk avatar jaraco avatar johnthagen avatar joycebrum avatar kolanich avatar layday avatar skriems avatar vfazio avatar webknjaz avatar wimglenn avatar zacharyburnett 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

Watchers

 avatar  avatar  avatar  avatar

Forkers

chmate

cmdix's Issues

Tests crash on pypy

Here's output from a recent run:

  tox
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/PyPy/3.9.12/x64/bin/lib/pkgconfig
python create: /home/runner/work/cmdix/cmdix/.tox/python
python installdeps: pytest >= 6.2.1
python develop-inst: /home/runner/work/cmdix/cmdix
ERROR: invocation failed (exit code -9), logfile: /home/runner/work/cmdix/cmdix/.tox/python/log/python-3.log
================================== log start ===================================

=================================== log end ====================================
___________________________________ summary ____________________________________
ERROR:   python: InvocationError for command /home/runner/work/cmdix/cmdix/.tox/python/bin/python -m pip freeze (exited with code -9 (SIGKILL)) (exited with code -9)

The process doesn't always fail precisely that way. Here's output from an earlier run:

  tox
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/PyPy/3.9.12/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/PyPy/3.9.12/x64/bin/lib/pkgconfig
python create: /home/runner/work/cmdix/cmdix/.tox/python
python installdeps: pytest >= 6.2.1
python develop-inst: /home/runner/work/cmdix/cmdix
/home/runner/work/_temp/8f22a1bd-6a25-45f6-9a61-1150bb55390b.sh: line 1:  1706 Killed                  tox
Error: Process completed with exit code 137.

How would I use cmdix in Xonsh?

Hi

How would I go about using this in Xonsh to provide me with pure python implementations of ls, cat etc?

I take it the first step is to do pip install cmdix, but then after that how would I populate the aliases of Xonsh?

env command needs implementation

The current implementation of the env command only emits the set environment variables. The usage string describes another common usage that would be useful to have implemented: running a command with environment variables set.

Project usecase?

Glad to see this project being worked on (a release 15 days ago, etc.) Also, the fact that it's maintained by a member of CPython/pypa Github organizations gives some hopes. But star count of the project (12 at this time) doesn't give much hopes. What's the usecase behind maintaining this project? What are the aims/roadmap of it?

Thanks.

(As a background, I'm trying to understand why someone would hack on this particular project, and not on some another fork of the original pycoreutils projects, or just another similar project.)

SMTPd module emits deprecation warnings on Python 3.10

cmdix/command/smtpd.py:1
  /Users/jaraco/code/main/cmdix/cmdix/command/smtpd.py:1: DeprecationWarning: The asyncore module is deprecated. The recommended replacement is asyncio
    import asyncore

cmdix/command/smtpd.py:2
  /Users/jaraco/code/main/cmdix/cmdix/command/smtpd.py:2: DeprecationWarning: The smtpd module is deprecated and unmaintained.  Please see aiosmtpd (https://aiosmtpd.readthedocs.io/) for the recommended replacement.
    import smtpd as _smtpd

../../../../../Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/smtpd.py:105
  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/smtpd.py:105: DeprecationWarning: The asynchat module is deprecated. The recommended replacement is asyncio
    import asynchat

env attempts to parse options in the command

Consider this invocation:

 @ env PYTHONPATH=devtools/py py -m switch-track --help
usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

Set each NAME to VALUE in the environment and run COMMAND.

positional arguments:
  inputs

options:
  -h, --help            show this help message and exit
  -i, --ignore-environment
                        start with an empty environment

or

 @ env PYTHONPATH=devtools/py py -m switch-track
usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
env: error: unrecognized arguments: -m switch-track

The arg parsing is failing because the -m and --help are being parsed for env. env needs to ignore any options after the first argument is encountered.

argv.pop causes crash in Python's smtpd

I have identified this line to cause problems when running the shell as an entrypoint of a docker container, without passing parameters.

This is the stacktrace that is created:

Traceback (most recent call last):
  File "/bin/sh", line 8, in <module>
    sys.exit(run())
  File "/lib/python3.10/site-packages/cmdix/__init__.py", line 102, in run
    epilog="Available Commands: " + ", ".join(listcommands()),
  File "/lib/python3.10/site-packages/cmdix/__init__.py", line 39, in _is_available
    cmd = _get_command(name)
  File "/lib/python3.10/site-packages/cmdix/__init__.py", line 51, in _get_command
    return __import__(importstring, fromlist=1).parseargs
  File "/lib/python3.10/site-packages/cmdix/command/smtpd.py", line 2, in <module>
    import smtpd as _smtpd
  File "/lib/python3.10/smtpd.py", line 97, in <module>
    program = sys.argv[0]
IndexError: list index out of range

The better option is probably to replace this line with the following two:

commandname = os.path.basename(argv[0])
argv = argv[1:]

That way, sys.argv is not mutated.

P.S.: Thanks for writing this. Now I can finally properly embark on running an almost pure python userland ๐Ÿ˜„
P.P.S.: Yes, I am running Python straight from mainline, but I've tested with older versions, and the problem persists.

Error in ls when glob resolves to a file

In a directory containing a file ending in exe:

 ~ [1] # ls *.exe
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jaraco\.local\bin\ls.exe\__main__.py", line 7, in <module>
  File "C:\Users\jaraco\AppData\Local\pipx\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 127, in run
    return run_subcommand(commandname, argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jaraco\AppData\Local\pipx\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 165, in run_subcommand    
    args.func(args)
  File "C:\Users\jaraco\AppData\Local\pipx\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\ls.py", line 47, in func
    dirlist = os.listdir(arg)
              ^^^^^^^^^^^^^^^
NotADirectoryError: [WinError 267] The directory name is invalid: 'rustup-gc-d473b855.exe'

More is broken

cmdix main $ .tox/python/bin/more setup.py
Traceback (most recent call last):
  File "/Users/jaraco/code/main/cmdix/.tox/python/bin/more", line 8, in <module>
    sys.exit(run())
  File "/Users/jaraco/code/main/cmdix/.tox/python/lib/python3.9/site-packages/cmdix/__init__.py", line 128, in run
    return run_subcommand(commandname, argv)
  File "/Users/jaraco/code/main/cmdix/.tox/python/lib/python3.9/site-packages/cmdix/__init__.py", line 166, in run_subcommand
    args.func(args)
  File "/Users/jaraco/code/main/cmdix/.tox/python/lib/python3.9/site-packages/cmdix/command/more.py", line 21, in func
    for line, filename in lib.parsefilelist(args.FILE):
ValueError: too many values to unpack (expected 2)

env.invoke tests fail on Windows

Tests on windows that cause cmdix.command.env.invoke to be invoked are failing on Windows when backslashes in the command path appear to have been lost.

For example, here are the Popen args for failing test_command_opts:

args = 'D:acmdixcmdix.toxpyScriptspython.EXE --help', executable = None

Infinite recursion in uname

After creating scripts for the package, I started to run into issues where tests would hang for a very long time during startup.

After some troubleshooting, I stumbled on this process tree, indicating the cause:

     \-+= 69252 jaraco /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /Library/Frameworks/Python.framework/Versions/3.7/bin/tox -vvv
 | |   \-+- 69297 jaraco /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/code/main/cmdix/.tox/python/bin/pytest
 | |     \-+- 69302 jaraco /bin/sh -c uname -p 2> /dev/null
 | |       \-+- 69304 jaraco /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/code/main/cmdix/.tox/python/bin/uname -p
 | |         \-+- 69308 jaraco /bin/sh -c uname -p 2> /dev/null
 | |           \-+- 69309 jaraco /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/code/main/cmdix/.tox/python/bin/uname -p
 | |             \-+- 69310 jaraco /bin/sh -c uname -p 2> /dev/null
 | |               \-+- 69311 jaraco /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/code/main/cmdix/.tox/python/bin/uname -p
 | |                 \-+- 69312 jaraco /bin/sh -c uname -p 2> /dev/null
... and so on

I'm guessing eventually the recursion hits some system limit causing the uname call to crash.

Inspecting the Python source, I can see where platform.uname actually calls sh -c uname -p. But if cmdix is providing a uname command and if tox has effectively activated the bin directory of cmdix, the platform module will end up calling cmdix.uname instead of the system one, which in turn calls platform.processor(), which calls cmdix.uname... and so on. Yuck.

TypeError in mv command

The mv command is failing:

$ mv mercurial mercurial-devel
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jaraco\.local\bin\mv.exe\__main__.py", line 7, in <module>
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 127, in run
    return run_subcommand(commandname, argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 165, in run_subcommand
    args.func(args)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\mv.py", line 22, in func
    for args.SOURCE in args:
TypeError: 'Namespace' object is not iterable

Not working as expected

Installed Python 3.10 from Windows 11 Store, ran pip install cmdix.

Powershell, nor cmd recognize the coreutils invocations.

Checked to see where it installed to, and it's in a user dir path.

Previous install was on Win10, python downloaded via choco. Worked fine.

error in ln

I recently tried to use ln on a Windows box to create symlink, but it failed:

jaraco@nobunaga ~ $ ln -s Dropbox\config\.xonshrc
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\jaraco\.local\bin\ln.exe\__main__.py", line 7, in <module>
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 128, in run
    return run_subcommand(commandname, argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 166, in run_subcommand
    args.func(args)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\ln.py", line 37, in func
    dst = os.path.basename(src)
          ^^^^^^^^^^^^^^^^^^^^^
  File "<frozen ntpath>", line 242, in basename
  File "<frozen ntpath>", line 211, in split
TypeError: expected str, bytes or os.PathLike object, not list

cp SameFileError

Attempting to copy a file to another location fails with a SameFileError:

 draft @ pwd
C:\Users\jaraco\draft
 draft @ cp z:\draft\mod.py .
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jaraco\.local\bin\cp.exe\__main__.py", line 7, in <module>
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 127, in run
    return run_subcommand(commandname, argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 165, in run_subcommand
    args.func(args)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 59, in func
    handle(_copy, args, args.DIRECTORY.pop(), src)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 73, in handle
    _copy(src, dstfile)
  File "C:\Program Files\Python 3.12\Lib\shutil.py", line 423, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Program Files\Python 3.12\Lib\shutil.py", line 240, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: 'z:\\draft\\mod.py' and 'z:\\draft\\mod.py' are the same file
 draft @ cp z:\draft\mod.py c:\users\jaraco\draft
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jaraco\.local\bin\cp.exe\__main__.py", line 7, in <module>
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 127, in run
    return run_subcommand(commandname, argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 165, in run_subcommand
    args.func(args)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 59, in func
    handle(_copy, args, args.DIRECTORY.pop(), src)
  File "C:\Users\jaraco\.local\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 73, in handle
    _copy(src, dstfile)
  File "C:\Program Files\Python 3.12\Lib\shutil.py", line 423, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Program Files\Python 3.12\Lib\shutil.py", line 240, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: 'z:\\draft\\mod.py' and 'z:\\draft\\mod.py' are the same file

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.