It seems i have succesfully installed ecCodes. At least if i run the selfcheck in the terminal i get the expected response.
If i run the sell script which is supposed to work with ecCodes it seems to cant find the commands though. This is the Response i get:
Does it matter in which Folder ecCodes is installed? Does someone know what my System is missing?
The Shell Script looks like this:
#!/bin/bash
GFS_DATE="20161120"
GFS_TIME="06"; # 00, 06, 12, 18
RES="1p00" # 0p25, 0p50 or 1p00
BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
LEVEL="lev_10_m_above_ground=on"
GFS_URL="http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.f000&${LEVEL}&${BBOX}&dir=%2Fgfs.${GFS_DATE}${GFS_TIME}"
curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib
grib_set -r -s packingType=grid_simple utmp.grib utmp.grib
grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib
printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.json
rm utmp.grib vtmp.grib
DIR="c:\\Users\My Name\Documents\CGTutorial\CGTutorial - Minimal"
node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}
rm tmp.json
Related
I am running Ubuntu 22.04 with xorg.
I need to find a way to compile microbit python code locally to a firmware hex file. Firstly, I followed the guide here https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html.
After a lot of debugging, I got to this point: https://pastebin.com/MGShD31N
However, the file platform.h does exist.
sawntoe#uwubuntu:~/Documents/Assignments/2022/TVP/micropython$ ls /home/sawntoe/Documents/Assignments/2022/TVP/micropython/yotta_modules/mbed-classic/api/platform.h
/home/sawntoe/Documents/Assignments/2022/TVP/micropython/yotta_modules/mbed-classic/api/platform.h
sawntoe#uwubuntu:~/Documents/Assignments/2022/TVP/micropython$
At this point, I gave up on this and tried using Mu editor with the AppImage. However, Mu requires wayland, and I am on xorg.
Does anyone have any idea if this is possible? Thanks.
Mu and the uflash command are able to retrieve your Python code from .hex files. Using uflash you can do the following for example:
uflash my_script.py
I think that you want is somehow possible to do, but its harder than just using their web python editor: https://python.microbit.org/v/2
Peter Till answers the original question. The additional below adds to this answer by showing how to automate the build and load process. I use Debian. The original question states that Ubuntu is used, which is built on Debian.
A script to find and mount the micro:bit
When code is loaded to the micro:bit, the board is dismounted from the system. So each time you have new code to load, you have to remount the board.
I modified a script to find and mount the micro:bit.
#!/bin/bash
BASEPATH="/media/$(whoami)/"
MICRO="MICROBIT"
if [ $# -eq 0 ]
then
echo "no argument supplied, use 'mount' or 'unmount'"
exit 1
fi
if [ $1 == "--help" ]
then
echo "mounts or unmounts a BBC micro:bit"
echo "args: mount - mount the microbit, unmout - unmount the microbit"
fi
# how many MICRO found in udiksctl dump
RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i $MICRO)
case "$RESULTS" in
0 ) echo "no $MICRO found in 'udkisksctl dump'"
exit 0
;;
1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i $MICRO | cut -d ":" -f 2 | sed 's/^[ \t]*//')
DEVICE=$(udisksctl dump | grep -i "IdLabel: \+$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ \t]*//')
DEVICEPATH="$BASEPATH""$DEVICELABEL"
echo "found one $MICRO, device: $DEVICE"
if [[ -z $(mount | grep "$DEVICE") ]]
then
echo "$DEVICELABEL was unmounted"
if [ $1 == "mount" ]
then
udisksctl mount -b "$DEVICE"
exit 0
fi
else
echo "$DEVICELABEL was mounted"
if [ $1 == "unmount" ]
then
udisksctl unmount -b "$DEVICE"
exit 0
fi
fi
;;
* ) echo "more than one $MICRO found"
;;
esac
echo "exiting without doing anything"
I alias this script to mm in my .bashrc file.
Automate mounting the micro:bit and flashing the python file
I use the inotifywait command to run mm and to then run uflash to load the .py file I am working on. Each time that the python file is saved, the aliased command mm is run followed by the uflash command.
while inotifywait -e modify <your_file>.py ; do mm && uflash <your_file>.py ; done
Okay, so elaborating on Peter Till's answer.
Firstly, you can use uflash:
uflash path/to/your/code .
Or, you can use microfs:
ufs put path/to/main.py
Working Ubuntu 22.04 host CLI setup with Carlos Atencio's Docker to build your own firmware
After trying to setup the toolchain for a while, I finally decided to Google for a Docker image with the toolchain, and found https://github.com/carlosperate/docker-microbit-toolchain at this commit from Carlos Atencio, a Micro:Bit foundation employee, and that just absolutely worked:
# Get examples.
git clone https://github.com/bbcmicrobit/micropython
cd micropython
git checkout 7fc33d13b31a915cbe90dc5d515c6337b5fa1660
# Get Docker image.
docker pull ghcr.io/carlosperate/microbit-toolchain:latest
# Build setup to be run once.
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest yt target bbc-microbit-classic-gcc-nosd#https://github.com/lancaster-university/yotta-target-bbc-microbit-classic-gcc-nosd
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest make all
# Build one example.
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest \
tools/makecombinedhex.py build/firmware.hex examples/counter.py -o build/counter.hex
# Build all examples.
docker run -v $(pwd):/home --rm ghcr.io/carlosperate/microbit-toolchain:latest \
bash -c 'for f in examples/*; do b="$(basename "$f")"; echo $b; tools/makecombinedhex.py build/firmware.hex "$f" -o "build/${b%.py}.hex"; done'
And you can then flash the example you want to run with:
cp build/counter.hex "/media/$USER/MICROBIT/"
Some further comments at: Generating micropython + python code `.hex` file from the command line for the BBC micro:bit
I am trying to create and image from my Python Flask app, but I am still getting this format error and I have no idea why. (I am running it on a Raspberry with Raspbian)
Step 4/5 : RUN echo "test" ---> Running in ca7b48ab3d4e
standard_init_linux.go:211: exec user process caused "exec format
error"
The command '/bin/sh -c echo "test"' returned a non-zero code: 1
Here is my Dockerfile
#!/usr/bin/env bash
FROM python:3.6.1-alpine
WORKDIR /project
ADD . /project
RUN echo "test"
CMD ["python3","careerdigest.py"]
I think that there is a problem with bash, because it says, that it calls this command with sh, but I do not know, what I am missing.
This echo command will be replaced by RUN pip3 install -r requirements.txt to install dependencies.
Thanks for your help.
Okay, I manage to finally run it. I just replace Python image with this one - https://hub.docker.com/r/balenalib/raspberry-pi-python and now it works.
I have an application which exposes the urls using mutual Authentication. Now I am writing a python script which uses Popen to run the curl command to connect to the application and gets me the required data. But when I run the python script I get following error.
curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)
I am running the application on windows 7 machine. I have curl and openssl installed. The command that is run is given below
curl -v https://localhost:9400/<URL> -H "Connection:close" --cacert 'C:/local_cert/root.crt' --cert 'C:/local_cert/client.crt' --key 'C:/local_cert/client.key' --pass client_key_passwd
Now for testing I ran the same command in Git Bash for windows. I got the result successfully.
But when I run the same command in Git Cmd for windows or Windows Cmd I get the same above error.
I have checked the paths to cert are correct, they are in PEM format, I have openssl and curl installed.For some reasons I cannot use Requests or urllib3 python pacakges and only can use curl. The above make me believe that there is some setting that Windows Cmd and Git Cmd for windows is missing some settings but I am not sure what it may be.
After trying lot of things I finally figured out the answer. The error said no file found, wrong passphrase or wrong format. Since the command worked in git bash I was sure that its not a issue with file or passphrase. Concentrating on no file found I found below link
Windows PATH to posix path conversion in bash
which gave me an idea that may be the way I am specifying the path is incorrect depending on which version of curl we are using. So after trying various combination I found that if you use plain curl in git bash following both cmd will work
curl -v https://localhost:9400/<URL> -H "Connection:close" --cacert 'C:/local_cert/root.crt' --cert 'C:/local_cert/client.crt' --key 'C:/local_cert/client.key' --pass client_key_passwd
and
curl -v https://localhost:9400/<URL> -H "Connection:close" --cacert C:/local_cert/root.crt --cert C:/local_cert/client.crt --key C:/local_cert/client.key --pass client_key_passwd
But in windows Cmd or when calling curl from python only following cmd will work
curl -v https://localhost:9400/<URL> -H "Connection:close" --cacert C:/local_cert/root.crt --cert C:/local_cert/client.crt --key C:/local_cert/client.key --pass client_key_passwd
So In nutshell it was a issue with quotes because the way your curl utility is called and which version of curl is used (compiled for windows or not) the interpretation of quotes will be different.
I am trying to run a pssh command inside a shell script, but the script freezes and there are no connections made, as verified in a ps -ef command. Also, because there is only one host in the hosts file I am using.
At this point, Control-C fails to kill the script, and it will not timeout. Only a kill command works.
If I run the same command on the command-line, there is no issue. Also, a pscp command in the same script causes no issues, so it seems that the required libraries are being loaded.
$ cat /home/myusername/tmp/hosts
mysinglehostname
Here is the script being run:
$ cat /home/myusername/bin/testpssh
#!/bin/bash
source ~/.bashrc
$HOME/path/to/python-virtualenv/bin/pscp -h "/home/myusername/tmp/hosts" "/tmp/garbage" "/tmp/garbage"
$HOME/path/to/python-virtualenv/bin/pssh -h "/home/myusername/tmp/hosts" -l myusername -p 512 -t 3 -o "out" -O GSSAPIAuthentication=no -i "whoami"
Here is what happens when I run the script:
$ /home/myusername/bin/testpssh &
[1] 18553
$ [1] 14:51:12 [SUCCESS] mysinglehostname 22
$ ps -ef | grep pssh
myusername 18580 18553 0 14:33 pts/16 00:00:00 /home/myusername/path/to/python-virtualenv/bin/python /home/myusername/path/to/python-virtualenv/bin/pssh -h /home/myusername/tmp/hosts -l myusername -p 512 -t 3 -o out -O GSSAPIAuthentication=no -i whoami
$ ## The script above is hanging after completing the pscp, before pssh completes.\
> But if I copy and paste the process line, it works fine as shown here:
$ /home/myusername/path/to/python-virtualenv/bin/python \
> /home/myusername/path/to/python-virtualenv/bin/pssh \
> -h /home/myusername/tmp/hosts -l myusername \
> -p 512 -t 3 -o out -O GSSAPIAuthentication=no -i whoami
[1] 14:59:03 [SUCCESS] mysinglehostname 22
myusername
$
The first [SUCCESS] above is for the pscp action, and no subsequent [SUCCESS] comes from the pssh command, unless it is performed explicitly on the command-line.
Why will the pssh command not work inside the bash shell script?
The script works fine if I use ksh instead of bash (and remove the line to source ~/.bashrc) in the shebang line.
I am on RedHat 6.4, using python 2.6.6
I am trying to execute a python script on remote machine using psexec. The python script is already on the remote machine i only want to execute it there. I am using the following command:
psexec -i -s -d \\123 -u xyz -p xyz C:/sample.py
But i get error as :
PsExec could not start C:\sample.py on 123:
The system cannot find the file specified
I tried placing the python exe path also in the psexec comand as:
psexec -i -s -d \\123 -u xyz -p xyz C:\programs\python.exe C:/sample.py
then it opens the python.exe but does not execute the sample.py. The paths are all correct. But i am not getting why the psexec command is not able to find the script. Please suggest how shall i execute the script on the remote machine using psexec.
Remove the -d option from the command and provide the path in quotes and use backslash in path
try adding " " around the exe filename
psexec -i -s -d \\123 -u xyz -p xyz "C:\programs\python.exe" C:/sample.py
if it doesn't work, try adding " " also around the parameters
psexec -i -s -d \\123 -u xyz -p xyz "C:\programs\python.exe" "C:/sample.py"