Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automating git bisect - part IV #37

Open
dpshelio opened this issue Nov 17, 2022 · 0 comments
Open

Automating git bisect - part IV #37

dpshelio opened this issue Nov 17, 2022 · 0 comments
Labels
week06 Documenting projects and findging bugs

Comments

@dpshelio
Copy link
Contributor

dpshelio commented Nov 17, 2022

Continuation from #36.

Now that you have created two arrays, can read and save them, and compare expected values.

Step 4

Use subprocess to call a system command from within python. The aim is for later to call Charlene's programme.

On a different python file (e.g., test_call_command.py) start with this content:

import subprocess

subprocess.run(["ls", "-aF"])

and run it!

Are you using Windows and getting errors?

If you're on Windows, ideally use Git Bash (If you're on the Windows Command Prompt cmd, you need to pass cmd-compatible commands to subprocess, e.g. dir instead of ls). On Windows, you might also need to pass shell=True as an additional argument.

subprocess.run(["ls", "-lh"], shell=True)

run it and iterate a couple of times changing the command that runs with others like:

  • ls -aF (which lists files),
  • echo 'hello world' (which prints hello world in the screen),
  • date +%Y%m%d (which prints today's date with the selected format)
  • wc -l sagittal_brain.py (which counts the number of lines of the sagittal_brain.py file)
  • wc -c AFileThatDoesNot.exist (which should counts the number of characters, but should fail as the file doesn't exist)

Once you've understood how subprocess.run works, try to call Charlene's programme.

Hint

How do you call a Python script from the command line? ______ filename.py.

React to this issue (#37) with a ❤ when your team has completed this task.

@dpshelio dpshelio added the week06 Documenting projects and findging bugs label Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
week06 Documenting projects and findging bugs
Projects
None yet
Development

No branches or pull requests

1 participant