I'm trying to load my tar image in podman.
Python 3.7.8 (default, Jun 29 2020, 05:46:05)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import podman
>>> c = podman.Client(uri='unix://var/run/docker.sock') #docker.sock is my mount point for podman socket
>>> c.
c.containers c.images c.pods c.system
>>> c.images.
c.images.build( c.images.get( c.images.list( c.images.search(
c.images.delete_unused( c.images.import_image( c.images.pull(
>>> c.images.
I don't see any load image method.
Is there any method like c.load_image("/tmp/se.tgz")? similar method exists for docker and easily doable.
There is an existing API that can be used like this.
c = podman.Client(uri='unix://var/run/docker.sock')
with c._client() as podman:
results = podman.LoadImage("", "/tmp/se.tgz", False, False)
Related
I don't have an M1 Mac to work with, I read that python supports it. What's the return of these functions on m1 Macs?
platform.system()
platform.architecture()
Thanks.
On the actual M1 Mac, the platform module returns the following values:
shuuji3#momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:03)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-arm64-arm-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'arm'
In addition to that, under the Rosetta 2 (Intel mode), the platform module returns the different values like followings:
shuuji3#momo ~ % env /usr/bin/arch -x86_64 /bin/zsh --login
shuuji3#momo ~ % python3
Python 3.8.2 (default, Dec 21 2020, 15:06:04)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.platform()
'macOS-11.2.3-x86_64-i386-64bit'
>>> platform.system()
'Darwin'
>>> platform.architecture()
('64bit', '')
>>> platform.processor()
'i386'
Note: For the first command, I'm following the instruction in the article, How to Run Legacy Command Line Apps on Apple Silicon | Walled Garden Farmers.
We could use these values to distinguish under which mode the current M1 mac runs an application.
I got an M1 pro and the outputs are:
Python 3.8.15 (default, Nov 10 2022, 13:17:42)
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> import platform
>>> platform.platform()
'macOS-10.16-x86_64-i386-64bit'
>>> platform.system()
'Darwin'
I don't quite understand why no results are returned when the value is empty. Is there a way to get the key value pair when the value is empty? Thanks.
>>> urllib.parse.parse_qsl('a=b')
[('a', 'b')]
>>> urllib.parse.parse_qsl('a=')
[]
You can use keep_blank_values parameter. By the way, what version of python are you using. This is what I get when I use the keep_blank_values. By default it is set to False. And I use python version 3.8.2
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import parse_qsl
>>> parse_qsl('a=b')
[('a', 'b')]
>>> parse_qsl('a=')
[]
>>> parse_qsl('a=', keep_blank_values=True)
[('a', '')]
>>>
If my file name is 5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843_20200616T10_50_UTC.wav .. Output to be 5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843.wav . How can we trim the file name using python?
There are several ways to do, for instance
import os
l=os.path.splitext("5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843_20200616T10_50_UTC.wav")
l[0].split("_")[0] + l[1]
I use os.path.splitext to separate the possible extension
Execution with and without '_' and with and without extension :
pi#raspberrypi:~ $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>>
>>> def f(s):
... l = os.path.splitext(s)
... return l[0].split("_")[0] + l[1]
...
>>> f("5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843_20200616T10_50_UTC.wav")
'5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843.wav'
>>>
>>> f("5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843.wav")
'5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843.wav'
>>>
>>> f("5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843_20200616T10_50_UTC")
'5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843'
>>>
>>> f("5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843")
'5f0756fa-75bc-4c70-9ba8-fbd1b6a9f843'
>>>
The following is a snippet from my Python 3.5 interpreter. I don't understand why this produces the error (Listed bellow). Any suggestions?
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64
bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, Tensorflow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Then it gives me just a list of internal Errors starting with:
E c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\framework\op_kernel.cc:943]
In interpreter 'urllib.request.urlretrieve' work great like this:
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>>urllib.request.urlretrieve('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key', 'Release.key')
('Release.key', <http.client.HTTPMessage object at 0x7fa008f76518>)
In this function will not work:
def owncloudI():
print(ok('Installing OwnCloud...\n'))
urllib.request.urlretrieve('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key', 'Release.key') #<---- stuck here
call(['apt-key', 'add', 'Release.key'])
rep = open('/etc/apt/sources.list.d/owncloud.list', 'a')
print('deb http://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/', file=rep)
rep.close()
call(['apt-get', 'update'])
call(['apt-get', 'install', 'owncloud'])
Code launch with sudo and execute in /tmp cat, therefore i think with rights all ok. Maybe someone has solved a similar problem.
Fix it this with
with urllib.request.urlopen('https://download.owncloud.org/download/repositories/stable/Ubuntu_15.10/Release.key') as response, open('resp.key', 'wb') as out_file:
data = response.read()
out_file.write(data)