search for: __str__

Displaying 20 results from an estimated 26 matches for "__str__".

Did you mean: __str
2005 Dec 22
3
bug report of xm list and xm vcpu-list
Hi, Xm list and xm vcpu-list show wrong DomID(name). Under this situation, # xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 512 1 r----- 1064.6 test1 13 64 1 r----- 83879.7 # xm list 1 13 Error: Domain ''1'' not found when running ''xm list'' # xm list
2019 Jun 28
3
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Following Eric's suggestions from v2, this adds .string, .errno and .__str__ properties. The .string property returns the error string. The .errno property returns the errno (from the errno module), or None. The __str__ property makes the exception nicely printable. Rich.
2018 Sep 20
0
[PATCH v2 3/3] v2v: -o rhv-upload: Add a test.
...ect): + def __init__(self, name): + pass + +class Configuration(object): + def __init__(self, type=None, data=None): + pass +class ConfigurationType(Enum): + OVA = 'ova' + OVF = 'ovf' + + def __init__(self, image): + self._image = image + + def __str__(self): + return self._image + +class DiskFormat(Enum): + COW = "cow" + RAW = "raw" + + def __init__(self, image): + self._image = image + + def __str__(self): + return self._image + +class DiskStatus(Enum): + ILLEGAL = "illegal" +...
2018 Sep 20
7
[PATCH v2 0/3] v2v: -o rhv-upload: Add a test.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-September/msg00121.html v2: - Rewrote patch 2 from scratch so it incorporates Nir's suggestions. - Add fake module to EXTRA_DIST. - Retested. Unfortunately I am no longer able to test the ordinary conversion path because ovirtsdk4 is incompatible with Fedora 29 / Python 3.7:
2019 Jun 28
2
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...except KeyError: > + return None > +Error.errno = property (_errno) > + > +def _str (self): > + if self.errno: > + return (\"%%s (%%s)\" %% (self.string, self.errno)) > + else: > + return (\"%%s\" %% self.string) > +Error.__str__ = _str Looks good to me now! Thanks for figuring this out while I was struggling with reading lots of documentation on C bindings. ACK -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
2018 Sep 19
4
[PATCH 0/3] v2v: -o rhv-upload: Add a test.
This adds a test of -o rhv-upload. Obviously for an upstream test we cannot require a working oVirt server. This test works by faking the ovirtsdk4 Python module, setting PYTHONPATH so that the fake module is picked up instead of the real module (if installed). However it's more complex than that because the nbdkit plugin also expects to talk to a working imageio HTTPS server. Therefore
2018 Oct 09
2
Re: [PATCH v2 3/3] v2v: -o rhv-upload: Add a test.
...t; +class Configuration(object): > + def __init__(self, type=None, data=None): > + pass > +class ConfigurationType(Enum): > + OVA = 'ova' > + OVF = 'ovf' > + > + def __init__(self, image): > + self._image = image > + > + def __str__(self): > + return self._image > + > +class DiskFormat(Enum): > + COW = "cow" > + RAW = "raw" > + > + def __init__(self, image): > + self._image = image > + > + def __str__(self): > + return self._image > + >...
2019 Jun 28
1
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...umber is effectively lost, should that really be an > issue. Maybe we want two fields, both .errno (string name, or None if Python errno.errorcode couldn't map it to a name), and .errnum (raw numeric value, accessible no matter what). Maybe as simple as this (or with one further tweak to __str__ to at least output .errnum when .errno is None): diff --git i/generator/generator w/generator/generator index 7c2fb59..9192988 100755 --- i/generator/generator +++ w/generator/generator @@ -3944,11 +3944,14 @@ from libnbdmod import Error Error.__doc__ = ''' Exception thrown when the...
2019 Jun 28
3
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
This kind of fixes the problems in v1. The exception still primarily lives in the libnbdmod and you could still refer to it using libnbdmod.Error (but don't do that). However when the exception is printed it now appears as nbd.Error, and you can catch it also using the same name. Other problems: - There is no "nice" interface to accessing the exception fields. You have to use
2020 Jan 10
7
[v2v PATCH 0/6] Various Python pycodestyle fixes
Fixes the majority of the pycodestyle issues in the Python scripts, and fix the existing test-v2v-python-syntax.sh to use pycodestyle to actually perform style checks. Pino Toscano (6): PEP 8: adapt whitespaces in lines PEP 8: move imports at the top PEP 8: adapt empty lines tests: find all the Python scripts for syntax checks -o rhv-upload: remove unused Python imports Revamp check
2008 Aug 16
1
python how do i stem words in python?
...can use? thanks a lot! >>> stemmer = xapian.Stem('english') >>> stemmer. stemmer.__call__ stemmer.__reduce_ex__ stemmer.__class__ stemmer.__repr__ stemmer.__delattr__ stemmer.__setattr__ stemmer.__dict__ stemmer.__str__ stemmer.__doc__ stemmer.__swig_destroy__ stemmer.__getattribute__ stemmer.__weakref__ stemmer.__hash__ stemmer.get_available_languages stemmer.__init__ stemmer.get_description stemmer.__module__ stemmer.this stemmer.__new__...
2019 Aug 10
0
[PATCH libnbd 8/9] generator: Enhance Flags/OFlags with optional "all flags" mask.
...let all = List.fold_left (lor) 0 (List.map snd flags) in + let n = sprintf "LIBNBD_%s_ALL" flag_prefix in + pr "#define %-40s %d\n" n all; + ); + pr "\n"; ) all_flags; List.iter ( fun (n, i) -> @@ -4606,12 +4613,17 @@ Error.__str__ = _str pr "\n" ) all_enums; List.iter ( - fun { flag_prefix; flags } -> + fun { flag_prefix; all_flags_bitmask; flags } -> List.iter ( fun (flag, i) -> let flag = sprintf "%s_%s" flag_prefix flag in pr "%-30s...
2020 Jan 28
0
[v2v PATCH 2/2] -o rhv-upload: check guest arch with cluster
.../test-v2v-o-rhv-upload-module/ovirtsdk4/types.py @@ -22,9 +22,25 @@ from enum import Enum from ovirtsdk4 import imageio_port +class Architecture(Enum): + UNDEFINED = "undefined" + X86_64 = "x86_64" + + def __init__(self, arch): + self._arch = arch + + def __str__(self): + return self._arch + + +class Cpu(object): + architecture = Architecture.X86_64 + + class Cluster(object): id = "2e97537b-a783-4706-af9e-75cb2e032dcd" name = "Default" + cpu = Cpu() class Configuration(object): diff --git a/v2v/output_rhv_upl...
2019 Jun 28
0
Re: [PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...n None > > +Error.errno = property (_errno) > > + > > +def _str (self): > > + if self.errno: > > + return (\"%%s (%%s)\" %% (self.string, self.errno)) > > + else: > > + return (\"%%s\" %% self.string) > > +Error.__str__ = _str > > Looks good to me now! Thanks for figuring this out while I was > struggling with reading lots of documentation on C bindings. > > ACK I pushed it, but there may be a few issues still: - Still no error checking in raise_exception(). We're on an error path alread...
2020 Jan 28
2
[v2v PATCH 1/2] Add back guestcaps as parameter of output#prepare_targets
It will be used to do extra checks in the output before copying the disks. Partially revert commit 3bafec4e693a25ef1c84abc0fd1bc3251862c7de. --- v2v/output_glance.ml | 2 +- v2v/output_json.ml | 2 +- v2v/output_libvirt.ml | 2 +- v2v/output_local.ml | 2 +- v2v/output_null.ml | 2 +- v2v/output_openstack.ml | 2 +- v2v/output_qemu.ml | 2 +- v2v/output_rhv.ml
2013 Dec 10
1
[LLVMdev] lit: deprecating trailing \ in RUN lines
On 10/12/2013 04:20, Sean Silva wrote: > The classic way to do this sort of checking is by hacking into the > tool that actually interprets it (i.e. lit in this case). Considering > that lit is Python, it should be pretty easy to insert an ad-hoc regex > check (or even something substantially more sophisticated). E.g. > insert code into TestRunner.py's
2019 Jun 28
0
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...return errno.errorcode[self.args[1]] + except KeyError: + return None +Error.errno = property (_errno) + +def _str (self): + if self.errno: + return (\"%%s (%%s)\" %% (self.string, self.errno)) + else: + return (\"%%s\" %% self.string) +Error.__str__ = _str + "; List.iter (fun (n, i) -> pr "%-30s = %d\n" n i) constants; diff --git a/python/t/610-exception.py b/python/t/610-exception.py new file mode 100644 index 0000000..847dfac --- /dev/null +++ b/python/t/610-exception.py @@ -0,0 +1,32 @@ +# libnbd Python bindings +# C...
2019 Aug 10
0
[PATCH libnbd 1/5] python: Change aio_buffer into nbd.Buffer class.
...io_buffer"; + "aio_buffer_from_bytearray"; + "aio_buffer_to_bytearray"; + "aio_buffer_size" ] @ List.map fst handle_calls); pr " { NULL, NULL, 0, NULL }\n"; pr "};\n"; pr "\n"; @@ -4502,17 +4506,28 @@ Error.__str__ = _str pr "\ -# AIO buffer functions. -def aio_buffer (len): - '''allocate an AIO buffer used for nbd.aio_pread and nbd.aio_pwrite''' - return libnbdmod.alloc_aio_buffer (len) - -def aio_buffer_from_bytearray (ba): - '''create an AIO buffer f...
2019 Aug 10
7
[PATCH libnbd 0/5] WIP: python: Add test for doing asynch copy.
This doesn't yet work. However it does make me more convinced than ever that we really need to sort out persistent buffer lifetimes in the library (similar to what we did for closures). Rich.
2019 Aug 10
0
[PATCH libnbd 3/9] generator: Add Enum type for enumerated types / unions.
...et_error } = | BytesIn (n, _) -> pr " PyBuffer_Release (&%s);\n" n | BytesPersistIn _ | BytesOut _ | BytesPersistOut _ -> () | Closure _ -> () + | Enum _ -> () | Int _ -> () | Int64 _ -> () | Path n -> @@ -4505,6 +4543,15 @@ Error.__str__ = _str "; + List.iter ( + fun { enum_prefix; enums } -> + List.iter ( + fun (enum, i) -> + let enum = sprintf "%s_%s" enum_prefix enum in + pr "%-30s = %d\n" enum i + ) enums; + pr "\n" + ) all_enums; List...