search for: python_return_dict

Displaying 20 results from an estimated 28 matches for "python_return_dict".

2019 Apr 03
1
[PATCH] Add missing python bindings tests
...Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +#) + +import unittest +import guestfs + + +class Test020Create(unittest.TestCase): + def test_create(self): + _ = guestfs.GuestFS(python_return_dict=True) diff --git a/python/t/test030CreateFlags.py b/python/t/test030CreateFlags.py new file mode 100644 index 000000000..2e9b48203 --- /dev/null +++ b/python/t/test030CreateFlags.py @@ -0,0 +1,27 @@ +# libguestfs Python bindings +# Copyright (C) 2019 Red Hat Inc. +# +# This program is free software...
2016 May 04
9
[PATCH 0/8] python: PEP 8 fixes
Hi, this series cleans up the Python sources, either static or generated, including also tests, to make them PEP 8 compliant; see https://www.python.org/dev/peps/pep-0008/ and tools like pep8. Almost all the issues reported by pep8 are fixed, reducing the issues from 3818 to 7. The changes should have no effect on the actual code, while it will help Python users with consistency with other
2016 Feb 22
3
[PATCH 1/3] python: tests: refactor to use unittest's discovery
...icense -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import unittest -import os -import guestfs - -class Test070OptArgs (unittest.TestCase): - def setUp (self): - self.g = guestfs.GuestFS (python_return_dict=True) - - def test_no_optargs (self): - self.g.add_drive ("/dev/null") - - def test_one_optarg (self): - self.g.add_drive ("/dev/null", readonly = True) - - def test_two_optargs (self): - self.g.add_drive ("/dev/null", iface = "virtio...
2020 Jan 10
8
[PATCH 0/7] Various Python pycodestyle fixes
Fixes the majority of the pycodestyle issues in the Python bindings, leaving only an overly length line in setup.py. Add a simple optional pycodestyle-based test to avoid regressions in the future. Pino Toscano (7): python: PEP 8: adapt empty lines python: PEP 8: adapt whitespaces in lines python: tests: catch specific exception python: tests: improve variable naming python: tests:
2020 Jan 10
9
[PATCH v2 0/8] Various Python pycodestyle fixes
Fixes all the pycodestyle issues in the Python bindings, overring one that does not make sense to change (and it's in setup.py, so almost irrelevant). Add a simple optional pycodestyle-based test to avoid regressions in the future. Pino Toscano (8): python: PEP 8: adapt empty lines python: PEP 8: adapt whitespaces in lines python: tests: catch specific exception python: tests:
2016 Feb 12
2
[PATCH] python: tests: use more targeted assert*() functions/checks
...hon/t/800-explicit-close.py index 9b425af..4086829 100644 --- a/python/t/800-explicit-close.py +++ b/python/t/800-explicit-close.py @@ -37,11 +37,7 @@ class Test800ExplicitClose (unittest.TestCase): # Expect an exception if we call a method on a closed handle. g = guestfs.GuestFS (python_return_dict=True) g.close () - try: - g.set_memsize (512) - raise Exception("expected an exception from previous statement") - except guestfs.ClosedHandle: - pass + self.assertRaises (guestfs.ClosedHandle, g.set_memsize, 512) del...
2018 Jan 24
0
Re: python 3 bindings on libguestfs
...ase > Red Hat Enterprise Linux Server release 6.5 (Santiago) > > We are trying to import guestfs in python according to manual page: > http://libguestfs.org/guestfs-py > > I should be able to initialize guestfs with following command: > import guestfs > g = guestfs.GuestFS(python_return_dict=True) > g.add_drive_opts("disk.img", format="raw", readonly=1) > g.launch() > > But I could see below issue: > [root@server190~]$ python > Python 3.5.1 (default, Feb 18 2016, 07:20:42) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux > Type "help&...
2015 Mar 23
2
Re: Inspection of disk snapshots
...> > At that point I mount it through libguestfs and inspect its content. > > As long as you use the 'readonly=1' flag (which is really *essential*, > else you'll get disk corruption), you can just point libguestfs at the > base image: > > g = guestfs.GuestFS (python_return_dict=True) > g.add_drive_opts ("base_image.qcow2", format="qcow2", readonly=1) > > That also doesn't get you a consistent snapshot, but it'll work most > of the time, and give you a clear error in libguestfs when it doesn't > (and won't corrupt your...
2014 Aug 06
2
python-guestfs rbd
how to use python-guestfs to access rbd device? The function i found is g.add_drive_opts, but i dono know how it receive ceph's configuration. I found this link http://rwmj.wordpress.com/2013/03/12/accessing-ceph-rbd-sheepdog-etc-using-libguestfs/ Is that the only way i should use to access ceph rbd? Can we use python-guestfs to get the same effect? Thanks
2016 May 05
1
[PATCH] python: use constants instead of raw values
...if not environment: - flags |= 1 + flags |= libguestfsmod.GUESTFS_CREATE_NO_ENVIRONMENT if not close_on_exit: - flags |= 2 + flags |= libguestfsmod.GUESTFS_CREATE_NO_CLOSE_ON_EXIT self._o = libguestfsmod.create(flags) self._python_return_dict = python_return_dict diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c index cf8576f..9e2debf 100644 --- a/python/guestfs-py-byhand.c +++ b/python/guestfs-py-byhand.c @@ -37,6 +37,13 @@ static PyObject **get_all_event_callbacks (guestfs_h *g, size_t *len_rtn); +void +guest...
2016 Feb 15
1
[PATCH] Start adding return values tests for bindings
...for i in range (0, 5): + self.assertIsInstance (l[i], dict) + self.assertEqual (l[i]["pv_name"], "pv%d" % i) + + self.assertRaises (RuntimeError, g.internal_test_rstructlisterr) + + + def test_rhashtable_list (self): + g = guestfs.GuestFS (python_return_dict=False) + + self.assertEqual (g.internal_test_rhashtable ("0"), []) + r = g.internal_test_rhashtable ("5") + self.assertEqual (r, [ ("0","0"), ("1","1"), ("2","2"), + (&...
2023 Feb 14
1
Issue with downloading files whose path contains multi-byte utf-8 characters
...om > virt-top is 'top' for virtual machines.? Tiny program with many > powerful monitoring features, net stats, disk stats, logging, etc. > http://people.redhat.com/~rjones/virt-top > > > import guestfs > from guestfs import GuestFS > > g = GuestFS(python_return_dict=True) > def callback(event, _event_handle, buf: str, array): > pass > > g.set_event_callback(callback, guestfs.EVENT_ALL) > g.set_verbose(True) > path = '/tmp/tmp_disk' > g.disk_create(path, format='raw', size=32*1024*1024) > g.add_drive(path) > g.launc...
2015 Mar 23
4
Inspection of disk snapshots
Greetings, I have the following typical scenario: given one or more qcow2 base images I clone them with COW and start the VMs. At a certain point I'd like to inspect them in order to see their evolution compared to the known base images. To do so I was thinking about taking a disk snapshot of each VM and inspect its content through libguestfs (using it's Python bindings). Obviously I
2015 Sep 16
0
[PATCH] python: Set program name to the true name instead of 'python'.
...f8..1e043fc 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -671,6 +671,8 @@ logvols = g.lvs () \"\"\" +import os +import sys import libguestfsmod "; @@ -714,6 +716,10 @@ class GuestFS(object): self._o = libguestfsmod.create (flags) self._python_return_dict = python_return_dict + # If we don't do this, the program name is always set to 'python'. + program = os.path.basename (sys.argv[0]) + libguestfsmod.set_program (self._o, program) + def __del__ (self): if self._o: libguestfsmod.close (se...
2017 May 06
0
[Bug 1406906] [PATCH 3/3] python: add regression test for RHBZ#1406906
...0-1301 USA. + +import os +import shutil +import tempfile +import unittest + +import guestfs + + +class Test830RHBZ1406906(unittest.TestCase): + def setUp(self): + self.filename = "rhbz1406906.img" + self.tempdir = tempfile.mkdtemp() + self.guestfs = guestfs.GuestFS(python_return_dict=True) + + self.guestfs.disk_create(self.filename, "raw", 512 * 1024 * 1024) + self.guestfs.add_drive(self.filename) + self.guestfs.launch() + + def tearDown(self): + self.guestfs.close() + os.unlink(self.filename) + shutil.rmtree(self.tempdir)...
2019 Apr 24
0
[PATCH 3/3] python: silence usage of add_cdrom in test
...@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import unittest +import warnings import guestfs class Test050HandleProperties(unittest.TestCase): @@ -44,4 +45,6 @@ class Test050HandleProperties(unittest.TestCase): def test_add_cdrom(self): g = guestfs.GuestFS(python_return_dict=True) - g.add_cdrom("/dev/zero") + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + g.add_cdrom("/dev/zero") -- 2.20.1
2013 Apr 03
1
RHashtable and the python bindings
I've discovered that libguestfs apis which return RHashtable are currently returned as a list of tuples in the python bindings rather than the obvious dict. I propose fixing this, whilst also maintaining API compatibility for a period of time. The following apis return RHashtable: inspect_get_mountpoints list_filesystems inspect_get_drive_mappings tune2fs_l mountpoints md_detail blkid
2015 Mar 25
0
Re: Inspection of disk snapshots
...t it through libguestfs and inspect its content. > > > > As long as you use the 'readonly=1' flag (which is really *essential*, > > else you'll get disk corruption), you can just point libguestfs at the > > base image: > > > > g = guestfs.GuestFS (python_return_dict=True) > > g.add_drive_opts ("base_image.qcow2", format="qcow2", readonly=1) > > > > That also doesn't get you a consistent snapshot, but it'll work most > > of the time, and give you a clear error in libguestfs when it doesn't > > (an...
2015 Mar 23
0
Re: Inspection of disk snapshots
...consistent (point in time) copy. > At that point I mount it through libguestfs and inspect its content. As long as you use the 'readonly=1' flag (which is really *essential*, else you'll get disk corruption), you can just point libguestfs at the base image: g = guestfs.GuestFS (python_return_dict=True) g.add_drive_opts ("base_image.qcow2", format="qcow2", readonly=1) That also doesn't get you a consistent snapshot, but it'll work most of the time, and give you a clear error in libguestfs when it doesn't (and won't corrupt your base disk or anything lik...
2017 May 09
1
[PATCH] RHBZ#1406906: check return value of Python object functions
...util +import tempfile +import unittest + +import guestfs + + +class Test830RHBZ1406906(unittest.TestCase): + def setUp(self): + self.tempdir = tempfile.mkdtemp() + + def tearDown(self): + shutil.rmtree(self.tempdir) + + def test_rhbz1406906(self): + g = guestfs.GuestFS(python_return_dict=True) + + g.add_drive_scratch(512 * 1024 * 1024) + g.launch() + + g.part_disk("/dev/sda", "mbr") + g.mkfs("ext4", "/dev/sda1") + g.mount("/dev/sda1", "/") + + # touch file with illegal unicode char...