[Python.NET] Re: TypeError: No method matches given arguments for SetContext: (<class 'int'>)
Ron Harding via PythonNet <[email protected]> Thu, 14 Jul 2022 20:28:19 +0000 (UTC)
| Newsgroups | gmane.comp.python.dotnet |
|---|---|
| Message-ID | <[email protected]> |
--===============0810211937340007444==
Content-Type: multipart/alternative;
boundary="----=_Part_907765_517933099.1657830499605"
------=_Part_907765_517933099.1657830499605
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
what about a wrapper like you do in c# platoform invoke?
=E2=80=9CThe desire that guides me in all I do is the desire to harness the=
forces of nature to the service of mankind. =E2=80=9DNikola Tesla=E2=80=9C=
Radio Power Will Revolutionize the World=E2=80=9D (Modern Mechanix & Invent=
ions, July, 1934)=20
On Thursday, July 14, 2022 at 03:59:13 PM EDT, Steven Manross <steven@m=
anross.net> wrote: =20
=20
=20
I got my initial code working on the C DLL and it=E2=80=99s creating snapsh=
ot sets as I want.=C2=A0 I am now having a problem with a function to query=
ALL the snapshots.
=20
=C2=A0
=20
This value can be sent to SetContext()
=20
In [39]: alphavsslib.VssSnapshotContext.All
=20
Out[39]: 4294967295
=20
=C2=A0
=20
4294967295 =3D 0xFFFFFFFF
=20
A sample of the call is here:
https://github.com/alphaleonis/AlphaVSS-Samples/blob/8482e83dd13cb8467860e8=
be199d265963aa6ab8/src/SnapshotQuery/Program.cs
=20
=C2=A0
=20
# this is the declaration of SetContext
=20
virtualvoidSetContext(VssSnapshotContext context);
=20
=C2=A0
=20
This is the declaration for All:=C2=A0=C2=A0 VssSnapshotContext.All=3D0xFFF=
FFFFF
=20
https://github.com/alphaleonis/AlphaVSS/blob/13462e657f7993da5c80f835d219bb=
e82079ce75/src/AlphaVSS.Common/Enumerations/VssSnapshotContext.cs#L58
=20
=C2=A0
=20
However, this line results in a Type error=20
=20
=C2=A0
=20
In [40]: ctx =3D cmp.SetContext(alphavsslib.VssSnapshotContext.All)
=20
---------------------------------------------------------------------------
=20
TypeError=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Traceback (most recent =
call last)
=20
Input In [40], in <cell line: 1>()
=20
----> 1 ctx =3D cmp.SetContext(alphavsslib.VssSnapshotContext.All)
=20
=C2=A0
=20
TypeError: No method matches given arguments for SetContext: (<class 'int'>=
)
=20
=C2=A0
=20
=C2=A0
=20
I=E2=80=99ve tried converting the value using:
=20
=C2=A0
=20
ctx =3D cmp.SetContext(System.Convert.ToUInt32(alphavsslib.VssSnapshotConte=
xt.All))
=20
=C2=A0
=20
*And*
=20
=20
ctx =3D cmp.SetContext(ctypes.c_uint32(alphavsslib.VssSnapshotContext.All).=
value)
=20
=C2=A0
=20
but the same error occurs
=20
=C2=A0
=20
I can get the function to succeed (albeit it doesn=E2=80=99t show me what I=
want) with this:
=20
=C2=A0
=20
cmp.SetContext(ctypes.c_int32(alphavsslib.VssSnapshotContext.All).value)
=20
=C2=A0
=20
=E2=80=A6 because ctypes.c_int32(alphavsslib.VssSnapshotContext.All).value =
=3D -1
=20
=C2=A0
=20
I believe it=E2=80=99s possible that this could be related to the link belo=
w but I can=E2=80=99t be sure because I am not a C developer and I can=E2=
=80=99t determine how this was fix from the notes in the link.
=20
=C2=A0
=20
Granted, the author is on CentOS, and I=E2=80=99m on Windows=E2=80=A6 but t=
he backstory behind the issue sounds like it=E2=80=99s related.
=20
=C2=A0
=20
https://github.com/pythonnet/pythonnet/issues/950
=20
=C2=A0
=20
I=E2=80=99m currently running on pythonnet 2.5.2 and
=20
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 =
bit (AMD64)] on win32
=20
=C2=A0
=20
Any thoughts or suggestions would be greatly appreciated.
=20
=C2=A0
=20
Steven
_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: rharding64-/[email protected]
=20
------=_Part_907765_517933099.1657830499605
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head></head><body><div class=3D"ydp33b442yahoo-style-wrap" style=3D"=
font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><=
div><div>what about a wrapper like you do in c# platoform invoke?</div><div=
><br></div><div class=3D"ydp33b442signature">=E2=80=9CThe desire that guide=
s me in all I do is the desire to harness the forces of nature to the servi=
ce of mankind.
=20
=20
=E2=80=9DNikola Tesla=E2=80=9CRadio Power Will Revolutionize the World=E2=
=80=9D (Modern Mechanix & Inventions, July, 1934)</div></div>
<div><br></div><div><br></div>
=20
<div id=3D"ydp33b442yahoo_quoted_8682694850" class=3D"ydp33b442yaho=
o_quoted">
<div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
=20
<div>
On Thursday, July 14, 2022 at 03:59:13 PM EDT, Steven M=
anross <[email protected]> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id=3D"ydp33b442yiv7148264326">
=20
=20
<div>
<div class=3D"ydp33b442yiv7148264326WordSection1">
<p class=3D"ydp33b442yiv7148264326MsoNormal">I got my initial code working =
on the C DLL and it=E2=80=99s creating snapshot sets as I want. I am =
now having a problem with a function to query ALL the snapshots.</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">This value can be sent to SetC=
ontext()</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">In [39]: alphavsslib.VssSnapsh=
otContext.All</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Out[39]: 4294967295</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">4294967295 =3D 0xFFFFFFFF<br>
<br>
</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">A sample of the call is here:<=
br>
<a href=3D"https://github.com/alphaleonis/AlphaVSS-Samples/blob/8482e83dd13=
cb8467860e8be199d265963aa6ab8/src/SnapshotQuery/Program.cs" rel=3D"nofollow=
" target=3D"_blank">https://github.com/alphaleonis/AlphaVSS-Samples/blob/84=
82e83dd13cb8467860e8be199d265963aa6ab8/src/SnapshotQuery/Program.cs</a></p>=
=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"><span class=3D"ydp33b442yiv714=
8264326pl-k"><span style=3D"font-size:9.0pt;font-family:Consolas;"># this i=
s the declaration of SetContext</span></span></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"><span class=3D"ydp33b442yiv714=
8264326pl-k"><span style=3D"font-size:9.0pt;font-family:Consolas;">virtual<=
/span></span><span style=3D"font-size:9.0pt;font-family:Consolas;color:#242=
92F;background:#FFF8C5;">
</span><span class=3D"ydp33b442yiv7148264326pl-k"><span style=3D"font-size:=
9.0pt;font-family:Consolas;">void</span></span><span style=3D"font-size:9.0=
pt;font-family:Consolas;color:#24292F;background:#FFF8C5;">
</span><span class=3D"ydp33b442yiv7148264326pl-en"><span style=3D"font-size=
:9.0pt;font-family:Consolas;">SetContext</span></span><span style=3D"font-s=
ize:9.0pt;font-family:Consolas;color:#24292F;background:#FFF8C5;">(VssSnaps=
hotContext context);</span></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">This is the declaration for Al=
l: VssSnapshotContext.<span class=3D"ydp33b442yiv7148264326pl-e=
n"><span style=3D"font-size:9.0pt;font-family:Consolas;">All</span></span><=
span style=3D"font-size:9.0pt;font-family:Consolas;color:#24292F;background=
:#FFF8C5;">
</span><span class=3D"ydp33b442yiv7148264326pl-k"><span style=3D"font-size:=
9.0pt;font-family:Consolas;">=3D</span></span><span style=3D"font-size:9.0p=
t;font-family:Consolas;color:#24292F;background:#FFF8C5;">
</span><span class=3D"ydp33b442yiv7148264326pl-c1"><span style=3D"font-size=
:9.0pt;font-family:Consolas;">0xFFFFFFFF</span></span></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"><a href=3D"https://github.com/=
alphaleonis/AlphaVSS/blob/13462e657f7993da5c80f835d219bbe82079ce75/src/Alph=
aVSS.Common/Enumerations/VssSnapshotContext.cs#L58" rel=3D"nofollow" target=
=3D"_blank">https://github.com/alphaleonis/AlphaVSS/blob/13462e657f7993da5c=
80f835d219bbe82079ce75/src/AlphaVSS.Common/Enumerations/VssSnapshotContext.=
cs#L58</a></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">However, this line results in =
a Type error </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">In [40]: ctx =3D cmp.SetContex=
t(alphavsslib.VssSnapshotContext.All)</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">------------------------------=
---------------------------------------------</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">TypeError &nb=
sp; =
&nb=
sp; Traceback (most recent call last)</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Input In [40], in <cell lin=
e: 1>()</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">----> 1 ctx =3D cmp.SetCont=
ext(alphavsslib.VssSnapshotContext.All)</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">TypeError: No method matches g=
iven arguments for SetContext: (<class 'int'>)</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"><span class=3D"ydp33b442yiv714=
8264326pl-k"><span style=3D"font-size:9.0pt;font-family:Consolas;"> <=
/span></span></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">I=E2=80=99ve tried converting =
the value using:</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">ctx =3D cmp.SetContext(System.=
Convert.ToUInt32(alphavsslib.VssSnapshotContext.All))</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p style=3D"margin-left:2.25pt;" class=3D"ydp33b442yiv7148264326MsoNormal">=
*<b>And</b>*</p>=20
<p style=3D"margin-left:2.25pt;" class=3D"ydp33b442yiv7148264326MsoNormal">=
</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">ctx =3D cmp.SetContext(ctypes.=
c_uint32(alphavsslib.VssSnapshotContext.All).value)</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">but the same error occurs</p>=
=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">I can get the function to succ=
eed (albeit it doesn=E2=80=99t show me what I want) with this:</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p style=3D"text-indent:.5in;" class=3D"ydp33b442yiv7148264326MsoNormal">cm=
p.SetContext(ctypes.c_int32(alphavsslib.VssSnapshotContext.All).value)</p>=
=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">=E2=80=A6 because ctypes.c_int=
32(alphavsslib.VssSnapshotContext.All).value =3D -1</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">I believe it=E2=80=99s possibl=
e that this could be related to the link below but I can=E2=80=99t be sure =
because I am not a C developer and I can=E2=80=99t determine how this was f=
ix from the notes in the link.</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Granted, the author is on Cent=
OS, and I=E2=80=99m on Windows=E2=80=A6 but the backstory behind the issue =
sounds like it=E2=80=99s related.</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"><a href=3D"https://github.com/=
pythonnet/pythonnet/issues/950" rel=3D"nofollow" target=3D"_blank">https://=
github.com/pythonnet/pythonnet/issues/950</a></p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">I=E2=80=99m currently running =
on pythonnet 2.5.2 and</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Python 3.9.13 (tags/v3.9.13:6d=
e2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Any thoughts or suggestions wo=
uld be greatly appreciated.</p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal"> </p>=20
<p class=3D"ydp33b442yiv7148264326MsoNormal">Steven</p>=20
</div>
</div>
</div>_______________________________________________<br>PythonNet mailing =
list -- <a href=3D"mailto:[email protected]" rel=3D"nofollow" target=3D"=
_blank">[email protected]</a><br>To unsubscribe send an email to <a href=
=3D"mailto:[email protected]" rel=3D"nofollow" target=3D"_blank">p=
[email protected]</a><br><a href=3D"https://mail.python.org/mailman=
3/lists/pythonnet.python.org/" rel=3D"nofollow" target=3D"_blank">https://m=
ail.python.org/mailman3/lists/pythonnet.python.org/</a><br>Member address: =
<a href=3D"mailto:rharding64-/[email protected]" rel=3D"nofollow" target=3D"_blank">=
rharding64-/[email protected]</a><br></div>
</div>
</div></div></body></html>
------=_Part_907765_517933099.1657830499605--
--===============0810211937340007444==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]
--===============0810211937340007444==--