Cannot read .7z file in Google Colab - tensorflow

I am using Google Colab to create a deep learning model, and I face an issue when I run this code at the first time.
!p7zip -d filename.7z
I get the following message:
/usr/bin/p7zip: cannot read filename.7z
But when I re-run the same cell again, the code works.
Do you know what is the reason of this issue?

First, you have to specify path before the file name
in my case
!mkdir ~/data
!cd ~/data
!mkdir planet
!cd planet
# -c: competition name
# -f: which file you want to download
# -p: path to where the file should be saved
!kaggle competitions download -c planet-understanding-the-amazon-from-space -f train-jpg.tar.7z -p ~/data/planet/
# Unzip the 7zip files
# -d: which file to un7zip
!p7zip -d ~/data/planet/test-jpg.tar.7z

Related

Google Colab Blender render Error: cannot read file

Trying to render a single frame
following this script "Blender_script_for_Google_Colab_using_the_GPU.ipynb"
by- https://github.com/donmahallem
Successfully mounted GDrive and installed Blender.
Executed all the cells from top to bottom, one by one.
This is the OUTPUT of final Cell
found bundled python: /content/blender2.83.12/2.83/python
Error: Cannot read file '/content/{/content/drive/MyDrive/Blender/donut.blend}': No such file or directory
<bpy_struct, CyclesPreferences at 0x7f6366c38ba8>
Device found CUDA
Activating <bpy_struct, CyclesDeviceSettings("Tesla T4")>
Activating <bpy_struct, CyclesDeviceSettings("Tesla T4")>
Blender quit```
ANSWER
It should be like this
!/content/blender2.83.12/blender -P './setgpu.py' -b -noaudio '/content/drive/MyDrive/Blender/donut.blend' -E CYCLES -o '/content/drive/MyDrive/Blender/test_mixed_####.png' -f 1 |& tee '/content/drive/MyDrive/Blender/log.txt'
NOT like this
!/content/blender2.83.12/blender -P './setgpu.py' -b -noaudio '{/content/drive/MyDrive/Blender/donut.blend}' -E CYCLES -o '{/content/drive/MyDrive/Blender/test_mixed_####.png}' -f 1 |& tee '/content/drive/MyDrive/Blender/log.txt'
In short I forgot to remove the curly brackets {} from "Blend_file_path" and "Output_path"
I believe you should use 'My Drive' rather than 'MyDrive' in your directory path.

Why does Google colab say: chmod: cannot access 'RDP.sh': No such file or directory

When I put the following code in the Google Colab Run cell:
! wget https://raw.githubusercontent.com/alok676875/RDP/main/RDP.sh &> /dev/null
! chmod +x RDP.sh
! ./RDP.sh
The result is as follows:
chmod: cannot access 'RDP.sh': No such file or directory
/bin/bash: ./RDP.sh: No such file or directory
Please tell, where is the error and what is the solution. Thank you
this file
https://raw.githubusercontent.com/alok676875/RDP/main/RDP.sh
was deleted so you can't download it.

How to save output of python-swiftclient to file when dowloading a directory?

Sometimes I get errors when I download files from a cloud with python-swiftclient, like this one:
Error downloading object 'uploads/1/image.png': Object GET failed: https://orbit.brightbox.com/v1/acc-12345/uploads/1/image.png 500 Internal Error b'An error occurred'
To search for the all errors and re-download failed files I would want to save output of the swift command to a file
I tried to do the following ways:
swift-cli -A https://orbit.brightbox.com/v1/acc-12345 \
-U user -K secret download uploads 2>&1 | tee uploads.log
# and
swift-cli -A https://orbit.brightbox.com/v1/acc-12345 \
-U user -K secret download uploads > uploads.log
But this didn't work. man swift describes -o option
For a single object download, you may use the -o [--output]
option to redirect the output to a specific file or if "-" then just redirect to stdout or with --no-download actually not to write anything to disk.
but when I try to download a directory with -o option if fails with
-o option only allowed for single file downloads
How can I save log to a file when I download a directory with swift CLI?
Actually redirecting output to a file works with swift-client:
swift-cli -A https://orbit.brightbox.com/v1/acc-12345 \
-U user -K secret download uploads > uploads.log
I was confused because after I started the command above, in another terminal window I did
tail -f uploads.log
But it didn't give me any output (like I was seeing when I was running the download command without redirection).
Seems like that swift-client writes to a file in batches and I needed to wait about a minute until tail -f dumps into the console a hundred of lines like this
uploads/documents/1/image.png [auth 0.000s, headers 0.390s, total 14.361s, 0.034 MB/s]

Downloading .j2k or .png files using wget:if else condition

I am downloading folder consisting of either j2k or png file using wget.
Now i want while downloading folder if user is requesting .j2k file and if .j2k file is not existing in that folder then by default download .png file.
i.e. i want download j2k if present || download .png file.
I have used like this
wget -d any.com -i /folder -r -l 1 -nc -A j2k,png
-d: download from this Domain
-i: download from this foldern
-r: recursive
-l 1: follow only 1 link deep
-nc: no clobber = download only if file doesn't exist
-A: accept/download only all *.ogg and *.mp3
but using this it is downloading both j2k and png.
Any help will be appreciated.
Referred Links:
wget if else download condition
wget manual

SSH unzip AND change the filename (or get the filename contained therein)

/usr/bin/curl http://somewebsite.com/foo.zip -o 4232.zip
unzip -o -q -L 4232.zip
chown 508 /home/me/www/inbound/data/??????.xml
rm -f 4232.zip
I am using this SSH script to download a zip file called foo.zip, rename the file to 4232.zip, the extract the contents.
My problem is that the zip file contains a single file whose name is constantly changing. I cannot see a flag for unzip that lets me rename the file(s) inside the zip.
How can I rename the mystery file inside. There is really only ever one file in my immediate project.
-or-
How can I get that filename so I can change ownership and use it in a PHP script that will process it later on...
Any help would be appreciated.
This will tell you the name of the .xml file in the zip
unzip -l z.zip | grep -o '[^/]*\.xml'
If you want to extract and rename the xml file
unzip -p z.zip \*.xml | cat > NEWFILE.xml