regarding wrapping a command line into a python script or function - command-line

in the command prompt, I can use nvcc --version to check the CUDA information. Is that possible to wrap this command nvcc --version into a python script to be run by python. Thanks.

I suppose for simple cases like yours, you can use Python function os.system although it has been deprecated.
Official Python documentation wants you to use the subprocess module instead. See also PEP324.
Let me add that Stackoverflow and other forums have plenty of discussions about the merits and demerits of executing programs from Python in the first place, and which function to use.

Related

Command Line on VSCode

I'm new to programming and using python. I am unable to use the terminal to use command-line work. I can run script, but nothing from the command line
I cannot even do print('hello'), though I can do that on idle
I have reviewed some tutorials, but they are of no help
If you're talking about VS Code built-in terminal (Ctrl+`), before execute print('hello') or some similar code, you should first start Python interective session by typing in python and hitting Enter.
Check this link for more details.

Which shell should be used for Bazel under Windows 10

Usually, on Windows, I use PowerShell (default shell) to call a Bazel command such as bazel build. As far as I understand Bazel makes use of MSYS2 to call and execute commands such as curl, zip or git for instance. Therefore, I wonder if I should use the MSYS2 bash terminal instead of PowerShell. Can there be any problems when using Powershell instead of the MSYS2 bash terminal? Or doesn’t it matter?
As its mentioned here by developers of bazel, using MSYS or MSYS2 is the best choice. Personally I prefer MSYS* over cmd or PowerShell for any thing.
In the current master there was recently an update of the documentation exactly about this issue:
As of 2020-01-15, we do not recommend running Bazel from bash – either
from MSYS2 shell, or Git Bash, or Cygwin, or any other Bash variant.
While Bazel may work for most use cases, some things are broken, like
interrupting the build with Ctrl+C from MSYS2). Also, if you choose to
run under MSYS2, you need to disable MSYS2’s automatic path
conversion, otherwise MSYS will convert command line arguments that
look like Unix paths (e.g. //foo:bar) into Windows paths. See this
StackOverflow answer for details.

How to write upgrade command in the program

Want to upgrade youtube-dl program in my program.
Going to pack youtube-dl and Java and use ProcessBuilder to launch youtube-dl.
Considered using pip but as long as read it's not proper way.
How should I upgrade youtube-dl python scripts in my program?
Here is my prototype. This is assume you can use youtube-dl command from your linux terminal.
Wanna port to Windows and MacOS.
I found very nice example code for downloading the latest version on Github.
https://github.com/joejoe2/wav-pcm/blob/master/updatecheck.java
When researching about wav waveform plotting I found this.
https://www.youtube.com/watch?v=FOZnBINrnXI

How to get pygmentize CLI to use the Python3 lexers?

I'm having a problem debugging and issue lexing of a language using Python3 and pygments. I had the setup working with Python2 but failing to combine it correctly for Python3.
MY primary question is how do I get the CLI pygmentize to use the Python3 lexers. It seems to always use the Python2 installed lexers. I also don't see that pygmentize is actually part of the pygments package (so I might be confused on how that's actually installed).
Note: I have the lexer installed in 3, and rebuilding the mapfiles shows that it is recognized, but when I use the markdown codehilite extension it doesn't find the lexer it seems. I want to run the CLI pygmentize to try and debug what the problem is.

Pass file to GHCi and receive output on command line?

In Python one can say this:
python script.py
from the command line and receive script.py's output inlined. Is it possible to do this with Haskell's GHCi? Basically I'm wondering if there's a way to run a Haskell program from the command line without compiling and without the user entering the interpreter.
runghc is what you're looking for. From its manpage:
runghc is considered a non-interactive interpreter and part of The Glasgow
Haskell Compiler. runghc is a compiler that automatically runs its results at
the end.
Edit: Ubuntu provides a symlink called runhaskell, but it might not be standard.