Re: [python-win32] pythonservice.exe registration failed used by another process

2024-04-26 Thread Mark Hammond


On 2024-04-25 9:29 p.m., Jacob Nolan via python-win32 wrote:


Hi all,

I've been having a reoccurring error across multiple windows installs 
and python versions (3.9.*-3.11.*) when performing an install of a 
python windows service.


This is the result of calling *python service_config.py install *on 3.9.5

The error is:

|*copying host exe 
'E:\jacobnolan\installed_programs\programs\python39\lib\site-packages\win32\pythonservice.exe' 
-> 'E:\*|*|jacobnolan||\installed_programs\programs\python39\pythonservice.exe' 
Error installing service: The process cannot access the file because 
it is being used by another process. (32)|*


For this system, this is not the first python service I have 
installed. Additionally I've installed multiple services while other 
python services have been running.


As stated in the error it looks to be the destination 
pythonservice.exe is being used by another process, so can't be 
replaced by my installing process.



Is there an approach to handle this?

  * I'm not sure if pythonservice.exe really needs to be replaced each
install. I was contemplating looking at the service registration
process to determine if this step can be skipped.

The version of win32serviceutil you linked to isn't the latest, but I 
assume you are talking about the copy made just after it prints 
`print(f"copying host exe '{maybe}' -> '{correct}'")`? If so, as the 
comments note, it doesn't really need to be updated each install, but 
win32serviceutil takes a conservative approach because it's difficult to 
know whether pywin32 might have been upgraded. The simplest way to avoid 
that copy is to just remove the "maybe" file, leaving the "correct" file 
in-place. I'd be fine with a patch that catches an error making the 
copy, prints a warning but then continues. It might even be better if 
that script tried to *move* the file - that should mean that upgrades 
would still attempt to update it, but otherwise the file is only updated 
once.



 *


  * Or if I should specify the location of the pythonservice.exe now
it is in the correct location to access the appropriate DLL's?
e.g  win32serviceutil service use exeName?
  o 
https://github.com/mhammond/pywin32/blob/fcab71452cc8aefeb23b897a03753e34298d555f/win32/Lib/win32serviceutil.py#L215

In your other email you mentioned trying to use pyinstaller or similar 
to package your service - in that world then you almost certainly will 
want to point it at your own executable, although then you probably just 
want sys.executable, in which case sys.frozen being set is all you need.


HTH,

Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatch vs EnsureDispatch performance

2024-04-17 Thread Mark Hammond
I'm mildly surprised by that - a profiler might show some low-hanging 
fruit, and/or might show different characteristics when many more 
functions are used. However, the primary reason for EnsureDispatch is 
for better support of the object model - there's far more context 
available and this less chance of upsetting some COM objects - eg, when 
`foo.bar` is seen, EnsureDispatch knows for sure that `bar` is a method, 
but dynamic dispatch doesn't know if the resulting object is going to be 
called or not.


HTH,

Mark

On 2024-04-17 2:07 a.m., Sven Bardos via python-win32 wrote:

Hi,

shouldn't be EnsureDispatch be faster than Dispatch once the code 
generation is done?


I've measured it by calling 6000 COM calls like this:

dirpath = Path('C:/Users/sbardos/AppData/Local/Temp/gen_py/3.10/')
if dirpath.exists() and dirpath.is_dir():
shutil.rmtree(dirpath)

app = Dispatch("CT.Application")
job = app.CreateJobObject()

start = timer()

for i in range(2000):
cnt, devIds = job.GetAllDeviceIds()
cnt, sheetIds = job.GetSheetIds()
dev = job.CreateDeviceObject()

end = timer()
print(f"Time ellapsed (late): {end - start}s")
and the ensure Dispatch version:
app = EnsureDispatch("CT.Application")
job = app.CreateJobObject()
start = timer()
for i in range(2000):
cnt, devIds = job.GetAllDeviceIds(None)
cnt, sheetIds = job.GetSheetIds(None)
dev = job.CreateDeviceObject()
end = timer()
print(f"Time ellapsed (early): {end - start}s")
EnsureDispatch is a little bit slower ~4.2s compared to ~4.0s.
If I don't get a performance boost with EnsureDispatch, is there even 
a point using it?


Thanks,
Sven

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Help in deciphering error

2024-04-15 Thread Mark Hammond
The first comment of https://github.com/mhammond/pywin32/issues/2155 has 
STR that doesn't involve pyinstaller or custom executables. If you can 
reproduce that, then you are probably facing the same problem, so the 
solution is probably to use Python 3.11 until more information about the 
3.12 specific problem is known.


HTH,

Mark

On 2024-04-14 4:19 p.m., Alok Bhargava wrote:

Hello,

I would appreciate any help in diagnosing why this error occurs.

I have WinPython installed on my Windows 11 Pro machine and not 
registered (registering did not change the outcome).


I installed pyinstaller and generated a single file .exe.

This is what I have encountered as documented in a Windows Report.wer 
file:


(Many thanks for all your help (please also see here 
))
|Version=1 EventType=APPCRASH EventTime=133575902720464133 
ReportType=2 Consent=1 UploadTime=133575902725050996 
ReportStatus=268435456 
ReportIdentifier=823493c6-5512-4b81-86a2-acfde51244ee 
IntegratorReportIdentifier=4598584a-fd33-4262-89ae-0e50fc817d5b 
Wow64Host=34404 NsAppName=test.exe 
AppSessionGuid=179c--0009-95e6-c361938eda01 
TargetAppId=W:00061dd68bdd826965f6c90daa8b7ff48666!ba8b2a53d175b81101916c75210fb20beb28423c!test.exe 
TargetAppVer=2024//04//14:17:42:06!7543d8!test.exe BootId=4294967295 
TargetAsId=583 IsFatal=1 EtwNonCollectReason=1 
Response.BucketId=9fa208ac7d6291b25d2a8a0a7614126c 
Response.BucketTable=4 Response.LegacyBucketId=2101643953657090668 
Response.type=4 Sig[0].Name=Application Name Sig[0].Value=test.exe 
Sig[1].Name=Application Version Sig[1].Value=0.0.0.0 
Sig[2].Name=Application Timestamp Sig[2].Value=661c156e 
Sig[3].Name=Fault Module Name Sig[3].Value=python312.dll 
Sig[4].Name=Fault Module Version Sig[4].Value=3.12.2150.1013 
Sig[5].Name=Fault Module Timestamp Sig[5].Value=65c2a47f 
Sig[6].Name=Exception Code Sig[6].Value=c005 Sig[7].Name=Exception 
Offset Sig[7].Value=cc2f DynamicSig[1].Name=OS Version 
DynamicSig[1].Value=10.0.22631.2.0.0.256.48 DynamicSig[2].Name=Locale 
ID DynamicSig[2].Value=1033 DynamicSig[22].Name=Additional Information 
1 DynamicSig[22].Value=fa6f DynamicSig[23].Name=Additional Information 
2 DynamicSig[23].Value=fa6fb7dd40186b4810d26d1ca09a7044 
DynamicSig[24].Name=Additional Information 3 DynamicSig[24].Value=a877 
DynamicSig[25].Name=Additional Information 4 
DynamicSig[25].Value=a87723ca5a16692a5a5ebf3576a4ef47 
UI[2]=C:\Users\akbha\Desktop\test.exe UI[5]=Close UI[8]=test.exe 
stopped working and was closed UI[9]=A problem caused the application 
to stop working correctly. Windows will notify you if a solution is 
available. UI[10]= 
LoadedModule[0]=C:\Users\akbha\Desktop\test.exe 
LoadedModule[1]=C:\Windows\SYSTEM32\ntdll.dll 
LoadedModule[2]=C:\Windows\System32\KERNEL32.DLL 
LoadedModule[3]=C:\Windows\System32\KERNELBASE.dll 
LoadedModule[4]=C:\Windows\System32\USER32.dll 
LoadedModule[5]=C:\Windows\System32\win32u.dll 
LoadedModule[6]=C:\Windows\System32\GDI32.dll 
LoadedModule[7]=C:\Windows\System32\gdi32full.dll 
LoadedModule[8]=C:\Windows\System32\msvcp_win.dll 
LoadedModule[9]=C:\Windows\System32\ucrtbase.dll 
LoadedModule[10]=C:\Windows\System32\ADVAPI32.dll 
LoadedModule[11]=C:\Windows\System32\msvcrt.dll 
LoadedModule[12]=C:\Windows\System32\sechost.dll 
LoadedModule[13]=C:\Windows\System32\bcrypt.dll 
LoadedModule[14]=C:\Windows\System32\RPCRT4.dll 
LoadedModule[15]=C:\Windows\system32\_MEI27562\python312.dll 
LoadedModule[16]=C:\Windows\System32\WS2_32.dll 
LoadedModule[17]=C:\Windows\SYSTEM32\VERSION.dll 
LoadedModule[18]=C:\Windows\system32\_MEI27562\VCRUNTIME140.dll 
LoadedModule[19]=C:\Windows\System32\bcryptprimitives.dll 
LoadedModule[20]=C:\Windows\system32\_MEI27562\pywin32_system32\pywintypes312.dll 
LoadedModule[21]=C:\Windows\System32\ole32.dll 
LoadedModule[22]=C:\Windows\System32\combase.dll 
LoadedModule[23]=C:\Windows\System32\OLEAUT32.dll 
LoadedModule[24]=C:\Windows\system32\_MEI27562\VCRUNTIME140_1.dll 
LoadedModule[25]=C:\Windows\system32\_MEI27562\win32\win32api.pyd 
LoadedModule[26]=C:\Windows\System32\SHELL32.dll 
LoadedModule[27]=C:\Windows\SYSTEM32\secur32.dll 
LoadedModule[28]=C:\Windows\SYSTEM32\SSPICLI.DLL 
LoadedModule[29]=C:\Windows\system32\_MEI27562\win32\win32service.pyd 
LoadedModule[30]=C:\Windows\system32\_MEI27562\win32\servicemanager.pyd 
State[0].Key=Transport.DoneStage1 State[0].Value=1 
OsInfo[0].Key=vermaj OsInfo[0].Value=10 OsInfo[1].Key=vermin 
OsInfo[1].Value=0 OsInfo[2].Key=verbld OsInfo[2].Value=22631 
OsInfo[3].Key=ubr OsInfo[3].Value=3447 OsInfo[4].Key=versp 
OsInfo[4].Value=0 OsInfo[5].Key=arch OsInfo[5].Value=9 
OsInfo[6].Key=lcid OsInfo[6].Value=1033 OsInfo[7].Key=geoid 
OsInfo[7].Value=244 OsInfo[8].Key=sku OsInfo[8].Value=48 
OsInfo[9].Key=domain OsInfo[9].Value=0 OsInfo[10].Key=prodsuite 
OsInfo[10].Value=256 OsInfo[11].Key=ntprodtype OsInfo[11].Value=1 
OsInfo[12].Key=platid OsInfo[12].Value=10 OsInfo[13].Key=sr 
OsInfo[13].Value=0 

Re: [python-win32] __getattr__ Error

2024-03-18 Thread Mark Hammond
In general, if you `from win32com.client.gencache import 
EnsureDispatch`, you should be able to use `EnsureDispatch` anywhere you 
previously used plain `Dispatch`, and that code should be automatically 
generated and used for you. You generally only need to specify a special 
location or run makepy manually if there's something odd about the 
object which makes the above not work.


Mark

On 2024-03-18 10:25 a.m., Alok Bhargava wrote:

Many thanks Harald!

If I specify the file location when running makepy, how do I ensure 
myapplication knows where to find them?  Again this may be a silly 
question, so please bear with me.


Thank you!

On Mon, Mar 18, 2024 at 9:36 AM  wrote:

Hi Alok,

there should be a __gencache__ directory somewhere, which contains
the generated files.
But it is WAY easier to just use the

  -o    -- Create output in a specified output file. If the path
leading
           to the file does not exist, any missing directories will be
           created.
           NOTE: -o cannot be used with -d.  This will generate an
error.

parameter of makepy.py

cheers

Harald

On Mon, Mar 18, 2024 at 2:13 PM Alok Bhargava
 wrote:

Hi and thank you for your insightful guidance on Jannis'
question.  I am running into similar issues as I work with a
3rd party COM app.

This may be a silly question but could you point me to where
the generated class files are located?

Many thanks!


On Mon, Mar 18, 2024 at 7:43 AM 
wrote:

Hi Jannis,

a good way forward: create less-dynamic COM-bindings by
using makepy.py
(it is part of your win32com-client installation, but
linked here for the dokumentation)



https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32com/client/makepy.py

With makepy py you can create a (very very large)
python-file, which includes rather static bindings to
reachable exposed attributes and methods.

You can then grep or strg+f through that file for
"HybridShapes" ... maybe it is just spelled differently.

Using COM things for > 2 decades, apps run much smoother
using the makepy created files than dynamic dispatch

cheers

Harald


On Sun, Mar 17, 2024 at 7:35 PM Jannis via python-win32
 wrote:

Hello together,


I am trying to automate a point cloud creation out of
CATParts in CATIA.
The win32com client can access CATIA documents, but
NOT methods and
attributes in the parts. I get the following error:


File

"C:\Users\th80im\source\repos\PythonPointCloudCreation\PythonPointCloudCreation\PythonPointCloudCreation\py37_env_1\lib\site-packages\win32com\client\dynamic.py",
line 638, in __getattr__
     raise AttributeError("%s.%s" % (self._username_,
attr))
AttributeError: .HybridShapes


I guess, there is something wrong with the registering
of CATIA, or the
installation of the client? Or am I looking in the
wrong direction?


Thank you & Best Regards

ioannis

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



-- 
-- 
Harald Armin Massa

Spielberger Straße 49
70435 Stuttgart
0173/9409607

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



-- 
-- 
Harald Armin Massa

Spielberger Straße 49
70435 Stuttgart
0173/9409607


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] About support for Windows XP and Internet Explorer, and possible leftover code

2024-03-18 Thread Mark Hammond


On 2024-03-18 1:57 a.m., Samuel Therrien wrote:
I've been wondering, what's the state, intent, or policy on support 
for older OSes? I haven't seen it be mentioned (for example on the 
readme), yet still see a handle of areas of code referencing support 
for older OSes (XP, Vista, 7, 8.1, CE, ...), but also commits and PRs 
dropping support for them (at least building with 8.1 SDKs is dropped).


I'd assume to be "whatever still has a non-EOL CPython version that 
can be installed", but maybe not?


Yep, that's correct. As you note, dropping support for building using 
older SDKs is dropped more aggressively, but that generally doesn't 
prevent things running on those older OSs.





On a technical level, I'm also wondering if winxpgui and winxptheme 
actually serve any purpose anymore?


 *
winxpgui seems to be some patched-up win32gui for XP?
 *
I'm not sure what winxptheme is exactly. I'm not able to do much
with it. I guess "the Windows XP 'theme' API" is some old Windows
stuff that never quite went away in the background.

These were split to support older OS versions back in the day, but 
there's no longer a need given we no longer support XP at all. However, 
for backwards compatibility we can't really drop the names - IOW, these 
could all technically be rolled into a single .pyd, but `from winxpgui 
import foo` must continue to work somehow for all `foo` it worked for in 
the past.




As for Internet Explorer, technically there's a mode in Edge to allow 
some sites to run pages in "IE mode" (that thing really won't die, 
will it?), but that's still through the Edge application.
The iebutton and ietoolbar demos technically do install an addon that 
I can see and enable in "Internet Settings", but idk if they can 
really do anything (and as such, if the demos are still valid).


In that case I see no reason to not consider them valid.


Cheers,


Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] __getattr__ Error

2024-03-18 Thread Mark Hammond

On 2024-03-18 9:12 a.m., Alok Bhargava wrote:
Hi and thank you for your insightful guidance on Jannis' question.  I 
am running into similar issues as I work with a 3rd party COM app.


This may be a silly question but could you point me to where the 
generated class files are located?


I think makepy will print the path name as it generates the file, but 
`import win32com; print(win32com.__gen_path__)` will print the location.


Cheers,

Mark



Many thanks!


On Mon, Mar 18, 2024 at 7:43 AM  wrote:

Hi Jannis,

a good way forward: create less-dynamic COM-bindings by using
makepy.py
(it is part of your win32com-client installation, but linked here
for the dokumentation)



https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32com/client/makepy.py

With makepy py you can create a (very very large) python-file,
which includes rather static bindings to
reachable exposed attributes and methods.

You can then grep or strg+f through that file for "HybridShapes"
... maybe it is just spelled differently.

Using COM things for > 2 decades, apps run much smoother using the
makepy created files than dynamic dispatch

cheers

Harald


On Sun, Mar 17, 2024 at 7:35 PM Jannis via python-win32
 wrote:

Hello together,


I am trying to automate a point cloud creation out of CATParts
in CATIA.
The win32com client can access CATIA documents, but NOT
methods and
attributes in the parts. I get the following error:


File

"C:\Users\th80im\source\repos\PythonPointCloudCreation\PythonPointCloudCreation\PythonPointCloudCreation\py37_env_1\lib\site-packages\win32com\client\dynamic.py",
line 638, in __getattr__
     raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: .HybridShapes


I guess, there is something wrong with the registering of
CATIA, or the
installation of the client? Or am I looking in the wrong
direction?


Thank you & Best Regards

ioannis

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



-- 
-- 
Harald Armin Massa

Spielberger Straße 49
70435 Stuttgart
0173/9409607

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Creating COM objects in a new process

2024-02-26 Thread Mark Hammond
I'm not aware of anything, other than arranging for the existing process 
to terminate.


Cheers,

Mark

On 2024-02-26 4:12 a.m., Aviv Bergman wrote:

Hi


I'm trying to create several COM objects, each in a new process, but 
it seems DispatchEx is reusing the existing COM server process, is 
there any way to force creating new objects in a new process?



I'm using a python COM server,  minimal example attached

Thanks
Aviv

-

import os
import pythoncom

class CTest:
    _reg_progid_ = "STO.test"
    _reg_clsid_ = "{13704826-80EC-4205-ADCE-ADBE5B741731}"
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
    _public_methods_ = ["test"]

    def __init__(self):
    pass

    def test(self):
    return "process = " + str(os.getpid())


if __name__ == "__main__":
    import win32com.server.register
    win32com.server.register.UseCommandLine(CTest)


>>> import win32com.client
>>> o1 = win32com.client.DispatchEx("STO.test")
>>> o2 = win32com.client.DispatchEx("STO.test")
>>> o1.test()
'process = 26764'
>>> o2.test()
'process = 26764'
>>>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 incompatible with Python 3.12

2024-02-07 Thread Mark Hammond
pywin32 is overdue a release, compounded by the fact I no longer have a 
Windows machine available. As noted in the readme, github actions to 
create "artifacts" on some pushes, so, eg, 
https://github.com/mhammond/pywin32/actions/runs/7713784334/artifacts/1206054711 
will have a recent wheel for all supported versions including 3.12 which 
will not have that error.


HTH,

Mark

On 2024-02-07 4:03 p.m., Wuping Xin wrote:
Python 3.12 removed the module 'imp', but pyscript.py still relies on 
'import imp' - this will lead to: ModuleNotFoundError: No module named 
'imp'


pyscript.py", line 213, in InitNew
import imp
ModuleNotFoundError: No module named 'imp'

Solutions?

Wuping
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Relevance of very outdated `Pythonwin/pywin/idle`

2024-01-12 Thread Mark Hammond
Some of those modules are actually used by pythonwin, particularly by 
pywin/scintilla - so while I agree the ability to update them is 
questionable, I don't think just killing the directory makes sense. Did 
you try to remove it? I'd be surprised if Pythonwin continues to work in 
that scenario.



I also don't see a huge maintenance cost nor must automated tooling 
churn - I haven't seen much in the way of external PRs touching this, 
nor have I personally touched these files recently - indeed most of the 
churn I see if from the *introduction* of such tooling, so one solution 
to that is probably to not try and introduce new tooling which touches 
or checks these files.



Cheers,


Mark


On 2024-01-12 12:50 p.m., Samuel Therrien wrote:

Hi!

I recently had to do a deep dive into 
https://github.com/mhammond/pywin32/tree/main/Pythonwin/pywin/idle 
 as 
part of a previous PR. See comment: 
https://github.com/mhammond/pywin32/pull/2102#discussion_r1380422005 



Of course it is extremely outdated, but I think the interesting part 
is that these IDLE modules are now part of the cpython repo (although 
most have been renamed over time), and some modules seem to not even 
be used as part of pythonwin.


I basically expect that none of this works at all today, especially 
given the minimum version requirement of Python 3.7-3.8. Is this worth 
keeping around at all?


 *
Pythonwin will look for IDLE extensions first in this directory,
then on the global sys.path.  Thus, if you have IDLE installed and
run it from the CVS sources, you may remove most of the extensions
from this directory, and the latest CVS version will then be used.

Could we just delete this entire folder instead, and update 
references, reducing further maintenance cost and automated tooling 
churn? Anything special I should look for in testing?



Basic type-checking with mypy and pyright by Avasam · Pull Request 
#2102 · mhammond/pywin32 

This is the PR that finally makes basic type-checking validation of 
public methods possible, easing the addition of 3.7+ type annotations. 
In its current state, a lot of checks are disabled, and so...

github.com

//


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] PythonService was unable to locate the service manager

2024-01-12 Thread Mark Hammond

On 2024-01-11 5:46 p.m., Jacob Nolan via python-win32 wrote:


I performed a custom install for all users on my E: drive 
(E:/installs/python3). Added it to the path. It is not under my 
specific user account. My understanding is this is a global install.


What exactly is E:? If anything other than a local device it might not 
be available to the user running the service.


I then run it under administrator privileged cmd and successfully 
install the service.


Looking at security permissions for pythonservice.exe in the root 
python directory. SYSTEM and Admin users have full control.


To be clear, the entire Python tree will need those permissions, not 
just that .exe. And the question is whether the user running the service 
has access - SYSTEM and Admin should cover many common scenarios, but 
not all. You could try configuring the service for your specific user 
just to see if it works - if it does it would still point to user 
permissions.


Mark





*Jacob Nolan*
*Gayner Technical Services*
Phone: 0437210168
Email: j...@gaynertechnicalservices.com.au
On 1/12/24 01:19, Mark Hammond wrote:


The "" 
part sounds like it is failing to find Python itself. Where is Python 
installed? Is it possible the user running the service can't access 
that location? I believe Python being installed in the default 
location could cause this if the server is running as any other other 
than the user which installed Python.


Mark


On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote:


Currently experiencing this issue on my Windows machine when 
installing a Windows Service. This is the error output I get from 
running in the cmd as administrator. Restricting me from being able 
to run my services.


*- PythonService was unable to locate the service manager. Please 
see the event log for details.**

*


Here is the output from event viewer application log:

|The description for Event ID 14 from source Python Service cannot 
be found. Either the component that raises this event is not 
installed on your local computer or the installation is corrupted. 
You can install or repair the component on the local computer. If 
the event originated on another computer, the display information 
had to be saved with the event. The following information was 
included with the event: traceback.print_exception() failed> The specified resource type 
cannot be found in the image file |



This issue has happened on each of these version I've tested 
Python3.11, 3.10.10 and 3.10.8.


Currently running Python 3.10.8 64 Bit on Windows Server 2016.

- I've installed pywin32

- Run post_install in the root directory of python310

- Installed the service with install flag

- Attempted to start service with start flag

- PythonService was unable to locate the service manager. Please see 
the event log for details.


--
*Thanks*
*Jacob*

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] PythonService was unable to locate the service manager

2024-01-11 Thread Mark Hammond
The "" 
part sounds like it is failing to find Python itself. Where is Python 
installed? Is it possible the user running the service can't access that 
location? I believe Python being installed in the default location could 
cause this if the server is running as any other other than the user 
which installed Python.


Mark


On 2024-01-11 1:20 a.m., Jacob Nolan via python-win32 wrote:


Currently experiencing this issue on my Windows machine when 
installing a Windows Service. This is the error output I get from 
running in the cmd as administrator. Restricting me from being able to 
run my services.


*- PythonService was unable to locate the service manager. Please see 
the event log for details.**

*


Here is the output from event viewer application log:

|The description for Event ID 14 from source Python Service cannot be 
found. Either the component that raises this event is not installed on 
your local computer or the installation is corrupted. You can install 
or repair the component on the local computer. If the event originated 
on another computer, the display information had to be saved with the 
event. The following information was included with the event: getting traceback - traceback.print_exception() failed> The specified 
resource type cannot be found in the image file |



This issue has happened on each of these version I've tested 
Python3.11, 3.10.10 and 3.10.8.


Currently running Python 3.10.8 64 Bit on Windows Server 2016.

- I've installed pywin32

- Run post_install in the root directory of python310

- Installed the service with install flag

- Attempted to start service with start flag

- PythonService was unable to locate the service manager. Please see 
the event log for details.


--
*Thanks*
*Jacob*

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Exe not working correctly

2023-09-05 Thread Mark Hammond
Is it possible that the datetime module isn't being packaged? Directly 
importing that module at the top-level of your script might be enough to 
fix it.



HTH,


Mark

On 2023-09-05 1:46 p.m., Nasser Issa wrote:

Hello There,

Currently been working with PyWin32 to interact with the Event Log and 
I'm trying to turn my Python script into a Windows executable. I'm 
using PyInstaller to convert my script into exe, however when I run my 
exe the  TimeCreated field from the Windows Event is 'None' but when I 
run the program as a script it works perfectly fine. So, I guess what 
I'm asking is why does the program work as a python script but not as 
an executable, I also try adding the DLLs like pywintype310 and few 
others when building exe with PyInstaller.


Best,
Nas

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python Active Scripting Error - should I ignore it?

2023-06-29 Thread Mark Hammond


On 2023-06-29 2:29 p.m., Wuping Xin via python-win32 wrote:

OK,  I think this is a bug of pywin32,

Line 37 of \win32comext\axdebug\documents.py,

class DebugDocumentText(
    gateways.DebugDocumentInfo, gateways.DebugDocumentText, 
gateways.DebugDocument


 gateway.DebugDocumentText already inherits from 
gateway.DebugDocument.  This would cause Python to give a Method 
Resolution Order (MRO) error, because Python cannot determine what 
class to look methods up on first.


There is no need to list gateway.DebugDocument as the parent class, 
simply

class DebugDocumentText(
    gateways.DebugDocumentInfo, gateways.DebugDocumentText)

Agree?


That sounds correct to me!

Mark



-- Original Message --
From "Wuping Xin" 
To "Python-win32@python.org" 
Date 6/29/2023 2:15:27 PM
Subject Python Active Scripting Error - should I ignore it?

When I running a Python Active Script,  DebugView captured the 
following errrors - any advice?


[22076]   File 
"C:\Users\.\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\framework.py", 
line 729, in SetScriptSite

[22076]     from . import debug
[22076]   File 
"C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axscript\client\debug.py", 
line 9, in 
[22076]     from win32com.axdebug import adb, axdebug, contexts, 
documents, gateways, stackframe
[22076]   File 
"C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\win32comext\axdebug\documents.py", 
line 37, in 

[22076]     class DebugDocumentText(
[22076] TypeError: Cannot create a consistent method resolution
[22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, 
DebugDocument
[22076] *** Debugger Manager could not initialize - 'TypeError'>: Cannot create a consistent method resolution
[22076] order (MRO) for bases DebugDocumentInfo, DebugDocumentText, 
DebugDocument


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Question about pywin32 and Anaconda

2023-06-07 Thread Mark Hammond
pywin32_postinstall.py 
(https://github.com/mhammond/pywin32/blob/main/pywin32_postinstall.py) 
does not mention anaconda.


The fact anaconda ships a version of pywin32 with it has caused problems 
though - maybe that's in a fork of theirs? If so, you need to ask them.


Mark

On 2023-06-07 9:18 a.m., Wuping Xin wrote:

pywin32_postinstall.py, line 406, "SKIP_ANACONDA", why?

Does that mean Anaconda is NOT whole-heartedly supported by pywin32?
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to enable pywin to evaluate -X utf8 flag

2023-06-06 Thread Mark Hammond
That error typically means your Python code raised an exception before 
the service could be started. You probably need some way to track that 
down - eg, some way to discover stdout/stderr from your service - 
win32traceutil etc might help depending on how the service is 
configured. Does the demo itself work? Does it work without the 
command-line mods?


Mark

On 2023-06-06 9:57 a.m., Gualtiero Scotti wrote:
Thank you Mark for your response, and your explanation.You are right, 
python.exe is not involved but I thought you handled the flag in your 
embedded calls..

When I try to start service it doesn't start and the error message  is:
*
Error starting service: The service did not respond to the start or 
control request in a timely fashion.*

*
*
_svc_name_ = 'XXX' _svc_display_name_ = 
'XXX' _svc_description_ = 'SXXX' 
_exe_name_ = sys.executable _exe_args_ = '-X utf8 "' + 
os.path.abspath(__file__) + '"'

*
*
When I take a look to the service on Regedit I've the following situation:
ImagePath = *"C:\Program Files 
(x86)\snapp-device-manager-win32\Python\python.exe" -X utf8 
"C:\Program Files (x86)\xx\winservice_launcher32.py"*

I can't find any logs about failure windows doesn't help me..
image.png

Thanks in advance for your availability.
Best regards

Il giorno mar 6 giu 2023 alle ore 15:05 Mark Hammond 
 ha scritto:


pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone
executable which embeds Python. Thus there's no way to pass a
cmd-line param to python.exe as python.exe isn't involved. You
could patch pythonservice.exe to handle that arg, then do whatever
it is python.exe does with that arg.

If you told me more about what went wrong with using python.exe as
the executable for the service we might be able to work something
out there, but "doesn't work" has never been a useful starting point.

Cheers,

Mark

On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote:

HI Mark and Hi all,
as I wrote previously Mark's solution did not work for me. I need
pythonsevice.exe is able to pass -X utf8 parameter to python
interpreter or in alternative is able to evaluate evaluate the
environment variable PYTHONUTF8=1. Any suggestions?
Please help me.
Thanks in advance


Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti
 ha scritto:

HI Mark,
I've tried your solution but it doesn't work. When calling
python directly, service fails to start.
When i use
#_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"'
+ os.path.abspath(sys.argv[0]) + '"'
service are directly linked to my python app without using
pythonservice.exe. ( I saw this on Regedit)

_As you wrote on your example:_
_
_

# This is an example of a service hosted by python.exe rather
than
# pythonservice.exe.

# *Note that it is very rare that using python.exe is a
better option*
# than the default pythonservice.exe - the latter has better
error handling
# so that if Python itself can't be initialized or there are
very early
# i*mport errors, you will get error details written to the
event log*.  When
# using python.exe instead, you are forced to wait for the
interpreter startup
# and imports to succeed before you are able to effectively
setup your own
# error handling.

*# So in short, please make sure you *really* want to do
this, otherwise just
# stick with the default.*
*
*
 I need to use pythonservice.exe but I don't understand how
it wraps my python application. Is there a way to tell to
pythonservice.exe to call python with some interpreter arguments?
Thanks in advance.
*
    *

Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond
 ha scritto:


https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py
is a demo of using a service using python.exe and
supports specifying the command-line, so that might be an
option?

Mark

On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote:

Hi, I need to start my python application through
windows service. For this purpose I use pywin32.
I'm not able to make a Python instance to evaluate the
-X uf8 flag.

This flag must be passed during python invocation only
and not when it is already started.
After some investigations I've found the service launch
*pythonservice.exe* wrapper but I don't know how to pass
the flag to the Python interpreter.

Is there another optio

Re: [python-win32] How to enable pywin to evaluate -X utf8 flag

2023-06-06 Thread Mark Hammond
pythonservice.exe doesn't "wrap" python.exe - it's a stand-alone 
executable which embeds Python. Thus there's no way to pass a cmd-line 
param to python.exe as python.exe isn't involved. You could patch 
pythonservice.exe to handle that arg, then do whatever it is python.exe 
does with that arg.


If you told me more about what went wrong with using python.exe as the 
executable for the service we might be able to work something out there, 
but "doesn't work" has never been a useful starting point.


Cheers,

Mark

On 2023-06-06 2:56 a.m., Gualtiero Scotti wrote:

HI Mark and Hi all,
as I wrote previously Mark's solution did not work for me. I need 
pythonsevice.exe is able to pass -X utf8 parameter to python 
interpreter or in alternative is able to evaluate evaluate the 
environment variable PYTHONUTF8=1. Any suggestions?

Please help me.
Thanks in advance


Il giorno lun 5 giu 2023 alle ore 10:51 Gualtiero Scotti 
 ha scritto:


HI Mark,
I've tried your solution but it doesn't work. When calling python
directly, service fails to start.
When i use
#_exe_name_ = sys.executable #_exe_args_ = ' -X utf8 ' + '"' +
os.path.abspath(sys.argv[0]) + '"'
service are directly linked to my python app without using
pythonservice.exe. ( I saw this on Regedit)

_As you wrote on your example:_
_
_

# This is an example of a service hosted by python.exe rather than
# pythonservice.exe.

# *Note that it is very rare that using python.exe is a better option*
# than the default pythonservice.exe - the latter has better error
handling
# so that if Python itself can't be initialized or there are very
early
# i*mport errors, you will get error details written to the event
log*.  When
# using python.exe instead, you are forced to wait for the
interpreter startup
# and imports to succeed before you are able to effectively setup
your own
# error handling.

*# So in short, please make sure you *really* want to do this,
otherwise just
# stick with the default.*
*
*
 I need to use pythonservice.exe but I don't understand how it
wraps my python application. Is there a way to tell to
pythonservice.exe to call python with some interpreter arguments?
Thanks in advance.
*
*

Il giorno gio 1 giu 2023 alle ore 17:05 Mark Hammond
 ha scritto:


https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py
is a demo of using a service using python.exe and supports
specifying the command-line, so that might be an option?

Mark

On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote:

Hi, I need to start my python application through windows
service. For this purpose I use pywin32.
I'm not able to make a Python instance to evaluate the -X uf8
flag.

This flag must be passed during python invocation only and
not when it is already started.
After some investigations I've found the service launch
*pythonservice.exe* wrapper but I don't know how to pass the
flag to the Python interpreter.

Is there another option to set this flag? It is possible to
set an env variable *PYTHONUTF8=1 * but pythonservice.exe
doesn't seem to evaluate it...
*
*
*My environment*
*- Windows 11 Home 22H2*
*- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec  6 2022,
19:43:28) [MSC v.1934 32 bit (Intel)] on win32
- *Pywin32 305*
- *Pywin32-ctypes 0.2.0*

*Python documentation*


4.7. UTF-8 mode¶
<https://docs.python.org/3/using/windows.html#utf-8-mode>

New in version 3.7.

Windows still uses legacy encodings for the system encoding
(the ANSI Code Page). Python uses it for the default encoding
of text files (e.g. |locale.getencoding()|
<https://docs.python.org/3/library/locale.html#locale.getencoding>).

This may cause issues because UTF-8 is widely used on the
internet and most Unix systems, including WSL (Windows
Subsystem for Linux).

You can use the Python UTF-8 Mode
<https://docs.python.org/3/library/os.html#utf8-mode> to
change the default text encoding to UTF-8. You can enable the
Python UTF-8 Mode
<https://docs.python.org/3/library/os.html#utf8-mode> via the
|-X utf8| command line option, or the
|PYTHONUTF8=1| environment variable. See |PYTHONUTF8|
<https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUTF8> for
enabling UTF-8 mode, and Excursus: Setting environment
variables
<https://docs.python.org/3/using/windows.html#setting-envvars> for
how to modify environment variables.

When the Python UTF-8 Mode
<https://docs.python.o

Re: [python-win32] How to enable pywin to evaluate -X utf8 flag

2023-06-01 Thread Mark Hammond
https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/nativePipeTestService.py 
is a demo of using a service using python.exe and supports specifying 
the command-line, so that might be an option?


Mark

On 2023-06-01 5:28 a.m., Gualtiero Scotti wrote:
Hi, I need to start my python application through windows service. For 
this purpose I use pywin32.

I'm not able to make a Python instance to evaluate the -X uf8 flag.

This flag must be passed during python invocation only and not when it 
is already started.
After some investigations I've found the service launch 
*pythonservice.exe* wrapper but I don't know how to pass the flag to 
the Python interpreter.


Is there another option to set this flag? It is possible to set an env 
variable *PYTHONUTF8=1 * but pythonservice.exe doesn't seem to 
evaluate it...

*
*
*My environment*
*- Windows 11 Home 22H2*
*- Python 3.11.1* (tags/v3.11.1:a7a450f, Dec  6 2022, 19:43:28) [MSC 
v.1934 32 bit (Intel)] on win32

- *Pywin32 305*
- *Pywin32-ctypes 0.2.0*

*Python documentation*


4.7. UTF-8 mode¶


New in version 3.7.

Windows still uses legacy encodings for the system encoding (the ANSI 
Code Page). Python uses it for the default encoding of text files 
(e.g. |locale.getencoding()| 
).


This may cause issues because UTF-8 is widely used on the internet and 
most Unix systems, including WSL (Windows Subsystem for Linux).


You can use the Python UTF-8 Mode 
 to change the 
default text encoding to UTF-8. You can enable the Python UTF-8 Mode 
 via the |-X 
utf8| command line option, or the |PYTHONUTF8=1| environment variable. 
See |PYTHONUTF8| 
 for 
enabling UTF-8 mode, and Excursus: Setting environment variables 
 for how 
to modify environment variables.


When the Python UTF-8 Mode 
 is enabled, you 
can still use the system encoding (the ANSI Code Page) via the “mbcs” 
codec.


Note that adding |PYTHONUTF8=1| to the default environment variables 
will affect all Python 3.7+ applications on your system. If you have 
any Python 3.7+ applications which rely on the legacy system encoding, 
it is recommended to set the environment variable temporarily or use 
the |-X utf8| command line option.


Note

Even when UTF-8 mode is disabled, Python uses UTF-8 by default on 
Windows for:


 *

Console I/O including standard I/O (see *PEP 528*
 for details).

 *

The filesystem encoding


 (see
*PEP 529*  for details).

from -> https://docs.python.org/3/using/windows.html

Please help me!
Thanks in advance
*
*

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] makepy.py "Some COM library"

2023-05-30 Thread Mark Hammond
Does something like `python -c "from win32com.client.gencache import 
EnsureDispatch; EnsureDispatch('ADODB.Connection.6.0');` work? That 
should generate directly into the expected output directory.


Mark

On 2023-05-30 1:44 p.m., Steven Manross wrote:


Command I ran:

C:\Python311\Lib\site-packages\win32com\client>python makepy.py 
"ADODB.Connection.6.0"


Output:

Generating to 
C:\Users\someuser\AppData\Local\Temp\13\gen_py\3.11\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py


Building definitions from type library...

Generating...

Importing module

---

I am running the command above, and if I do this, my Classic ASP does 
not see the resulting B691E011-1797-432E-907A-4D8C69339129x0x6x1.py 
file because it saved the file in the user temp directory as opposed 
to in the site-packages directory structure.


  * When I installed Python, I told it to install the application for
“All Users” (Default Directory = C:\Program Files\Python311 -- but
I removed the Program Files portion for the installation)

Is there some way to make it save the file in the correct place for 
the python installation from the command line so I don’t have to move 
the files it generates?


Keep in mind that the files it generates seems to live in a 3.11 
directory, but python seems to want it in:


C:\Python311\Lib\site-packages\win32com\gen_py\B691E011-1797-432E-907A-4D8C69339129x0x6x1.py

C:\Python311\Lib\site-packages\win32com\gen_py\dicts.dat

C:\Python311\Lib\site-packages\win32com\gen_py\__init__.py

I saw the -o parameter in the makepy.py script but if I use that, it 
doesn’t seem to build the dicts.dat or __init__.py files – which 
already exist (is that a problem?).


Please and thank you for any comments,

Steven


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 does not have win32ui under MSYS2

2023-05-25 Thread Mark Hammond
win32ui is a wrapper around the MS "MFC" library. I suspect that there 
are reasons that can't be built for MSYS2, but you'd need to ask whoever 
packages that version up - it's not released by the pywin32 project.


Cheers,

Mark

On 2023-05-25 8:29 a.m., Kristiine Silinja wrote:

Hi!

I am running MSYS2 on Windows 10 (64bit) with Python 3.10.11. I was 
able to install 
https://packages.msys2.org/base/mingw-w64-python-pywin32 using pacman.
However, it seems that the installation is missing the win32ui 
library. I see files for other modules, but no mention of win32ui. 
win32api, win32print, win32con can be imported, but win32ui import, as 
expected, throws ModuleNotFoundError.


Has anyone encountered this issue in the MSYS2 environment? Is there a 
way to fix it?


Note: pywin32 306 build installed.

pip under MSYS2 gives
python -m pip install --upgrade pywin32
ERROR: Could not find a version that satisfies the requirement pywin32 
(from versions: none)


With best regards,
/-Kristiine Silinja/

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win32: -2147418113, 'Catastrophic failure'

2023-05-23 Thread Mark Hammond

On 2023-05-22 11:05 a.m., Pranav S Pawar wrote:

Hello Team,

My code was working fine from one week in jupyter notebook.
Today i just did a kernel restart in jupyter notebook and my code 
stopped working.


Not sure what happened after restart. Tried all options but not able 
to resolve.

So through to get help from here.

Basically i am trying to get erwin api through => 
win32com.client.Dispatch("erwin9.SCAPI")


Again, this sounds like an issue with erwin, not python/pywin32.

Cheers,

Mark




but getting error.

Giving Code as well as error below.
Please advise what corrective action should be taken.
I have tried to upgrade pywin32 module but still same error.

*Code:*
import win32com.client
erwin = win32com.client.Dispatch("erwin9.SCAPI")
print('Connected')

*Error:*

com_error  Traceback (most recent call last)
FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:84, 
in_GetGoodDispatch(IDispatch, clsctx)
83  try:
---> 84  IDispatch=  pythoncom.connect(IDispatch)
85  except  pythoncom.ole_error:

com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

com_error  Traceback (most recent call last)
InputIn [17], in()
1  import  win32com.client
> 3  erwin=  win32com.client.Dispatch("erwin9.SCAPI")
5  print('Connected')

FileC:\Python310\lib\site-packages\win32com\client\__init__.py:118, inDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, 
clsctx)

116  """Creates a Dispatch based COM object."""
117  assert  UnicodeToStringis  None,"this is deprecated and will go away"
--> 118  dispatch, userName=  
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
119  return  __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, 
clsctx=clsctx)

FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:104, 
in_GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
101  ## ??? else userName remains None ???
102  else:
103  userName=  str(userName)
--> 104  return  (_GetGoodDispatch(IDispatch,clsctx), userName)

FileC:\Python310\lib\site-packages\win32com\client\dynamic.py:86, 
in_GetGoodDispatch(IDispatch, clsctx)
84  IDispatch=  pythoncom.connect(IDispatch)
85  except  pythoncom.ole_error:
---> 86  IDispatch=  pythoncom.CoCreateInstance(
87  IDispatch,None,clsctx,pythoncom.IID_IDispatch
88  )
89  else:
90  # may already be a wrapped class.
91  IDispatch=  getattr(IDispatch,"_oleobj_", IDispatch)

com_error: (-2147418113, 'Catastrophic failure', None, None)

Thanks & Best Regards,

Pranav___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] (no subject)

2023-05-17 Thread Mark Hammond
I'm sorry, but you are very unlikely to find anyone on this list with 
erwin experience. pywin32 is a general purpose library that allows 
talking to *any* COM object, so there are literally hundreds and 
hundreds of different apps it can work with. I've never even heard of 
erwin and have no idea what it does :( You might fine someone else on 
this list has, and can help you, but in the meantime...


You really need to find support for the erwin app, not pywin32. Because 
COM works in any language, you might find the help you need is written 
in terms of a language other than Python, but the answer should 
translate across to Python.


Good luck,

Mark

On 2023-05-17 5:39 a.m., Pranav S Pawar wrote:

Hello Team,

I am getting an error while using persistence_units.CloseAll() method 
of persistence_units module. of win32com


Error: AttributeError: 'Client API Type Library.ISCPersistenceUnitCollection instance at 
0x3171750852880>' object has no attribute 'CloseAll'


Below is my code where i am trying to access and erwin datamodel , 
check connection and close connection.


i/mport win32com.client as win32

# Create an instance of the erwin API
erwin_api = win32.Dispatch("erwin9.SCAPI")

# Connect to erwin Data Modeler Mart or local repository
# Get the PersistenceUnits collection
persistence_units = erwin_api.PersistenceUnits

# Open an existing persistence unit
existing_persistence_unit = persistence_units.Add(r"D:\\testdm.erwin")
print("Opened existing persistence unit:", existing_persistence_unit.Name)

# Close all persistence units
persistence_units.CloseAll()
print("Closed all persistence units")

# Save changes to all persistence units
#persistence_units.SaveAll()
print("Saved changes to all persistence units")/

Can you please let me know, what is the correct method if CloseAll is 
not the correct method.
Is there any link where I can get all the methods of 
erwin_api.PersistenceUnits ?


Thanks,

Pranav

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32com, server/policy.py bug? policy.py Line 639

2023-04-17 Thread Mark Hammond


On 16/4/2023 11:48 pm, Wuping Xin wrote:
A better fix is to change Line 639 of win32com/server/policy.py to the 
following:


import inspect
if len(inspect.getfullargspec(func).args) == 1:
return func()
else:
return func(*args)

Then we can make VBA, Delphi, C++  all clients happy.

Agree? Should I submit a pull request?


I'm not sure ATM - I'd be quite surprised if there was a bug in COM 
functions with no args, so it may be more subtle than that. But you 
should certainly get either a PR or issue on github for this, ideally 
with a complete repro. It might be quite some time (ie, many weeks) 
before I can look at this in more detail.


Thanks,

Mark




Wuping

-- Original Message --
From "Wuping Xin" 
To "Mark Hammond" 
Cc "Python-win32@python.org" 
Date 4/16/2023 9:28:48 AM
Subject win32com, server/policy.py bug? policy.py Line 639

For the following code, the method "GetPerson" has no explicit 
argument (except self).

classMyCOMObject:
_public_methods_=["GetPerson"]
#_reg_clsid_ = '{44ee76c7-1290-4ea6-8189-00d5d7cd712a}'
#_reg_desc_ = "My COM server"
#_reg_progid_ = "MyCOMObject"
defget_person(self):
person=Person("haha",45)
wrapped=win32com.server.util.wrap(person,useDispatcher=my_dispatcher)
returnwrapped
When calling from VBA, like below , it works fine.
    Set o = CreateObject("MyCOMObject")
    Set p = o.get_person()
However, when calling from C++, or Delphi, the following error will 
be thrown:
/"TypeError: MyCOMObject.get_person() takes 1 positional argument but 
2 were given"/

//
Delphi code:
/procedure TForm1.Button1Click(Sender: TObject); /
/var /
/  o: OleVariant; /
/  p: OleVariant; /
/begin /
/  o := CreateOleObject('MyCOMObject'); /
/*p := o.get_person()*; // error will be thrown /
/  s := p.name; /
/  age := p.age; /
/  ShowMessage(s); /
/end;/
//
The fix is to change Line 639 of policy.py to the following:
iflen(args)==1and(args[0]==-2147352572orargs[0]==None):
returnfunc()
else:
returnfunc(*args)___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] in-process COM DLL in Python

2023-04-15 Thread Mark Hammond
You should be able to wrap a Person object - something like ob = 
win32com.server.util.wrap(Person(...)) - and just return that. You 
probably don't need the VARIANT dance, it should just work based on the 
type returned being a Dispatch wrapper.


HTH,

Mark

On 16/4/2023 7:27 am, Wuping Xin wrote:
I'd like to return another Python object,  using a method of a COM 
object defined using Python, something like below - is that doable?
For in process COM object defined through Python,  is there any 
limitation about the types that can be returned from COM method?


class Person:
    _public_methods_ = ["Name"]

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def Name(self, age = None):
        return self.name


# Define a Python class that will be registered as a COM object
class MyCOMObject:
    _public_methods_ = ["GetPerson"]

*def GetPerson(self, name, age):*
        p = Person(name, age)
my_variant = pywintypes.VARIANT(p, VARIANT.VT_DISPATCH)
        return my_variant

# Register the class as a COM object

win32com.server.register.UseCommandLine(MyCOMObject)

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Licensing status?

2023-04-05 Thread Mark Hammond
There are various LICENCE.txt files in subdirectories, which are 
canonical. These LICENCE.txt files pre-date the PSF licence (or the 
PSF!) even existing and this package has many many contributors from 
this week back to last century, so re-licensing is almost impossible.


I don't think the PSF licence makes sense for projects not released by 
the PSF - the closest would be a new custom license exactly like the PSF 
license, but with some words change to make it clear the PSF isn't 
releasing it.


If your lawyers aren't happy with the situation I'd love to hear their 
advice for how it could be cleaned up.


Cheers,

Mark



On 5/04/2023 10:47 pm, Taras CIURIAK wrote:
Hi, can anyone please confirm the licensing status of the PyWin32 
module?  I'm under the impression that it's using the Python Software 
Foundation License, as that's what it states on the Project page, 
however I'm getting pushback from the powers that be because there's no 
clearly obvious License.txt in the source:


/"unfortunately I do not believe the Python Software Foundation License 
is still valid for this package. While in 
https://pypi.org/project/pywin32/#description 
 it does appear that it 
is licensed under a Python Software Foundation license, the license has 
unfortunately may have not (sic) been renewed for quite some time and is 
not available on github."/

/
/
Thanks for any assistance you can provide to clarify/Taras

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Recommendations for releasing pywin32 without a local windows device?

2023-03-30 Thread Mark Hammond

Hey all,

  I'm in the process of moving countries for a couple of years and for 
the first time in - um - forever - will find myself without a physical 
Windows machine. It seems unlikely I'll actually need one other than for 
pywin32 builds and testing. My primary device will end up as an M2 
macbook pro supplied by work.


Options I see are:

* Lean into CI for releases - this is problematic because obscure 
html-help and mapi/exchange sdks are needed, and manually testing stuff 
still happens - but this might make sense for the longer term health of 
the project.


* VM on the macbook - but by all accounts, anything other than ARM 
doesn't really work well on the M chips, and as above re the SDKs etc, 
I'm not sure an ARM build environment will work in practice without 
losing functionality for x86 builds.


* Buy an x86-64 laptop - $1k probably gets me something good enough if 
I'm patient waiting for things to build.


* A hosted VPS.

The latter seems a bit easier and less things to carry around, but might 
actually be more expensive over ~2 years and more of a PITA than a local 
device. I've also no experience at all with this kind of environment.


Wondering what experience/anecdotes/thoughts y'all have for this?

Thanks,

Mark.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pythoncom.Pumpwaitingmessages() overloaded

2023-03-28 Thread Mark Hammond

On 29/03/2023 5:38 am, Philip Carr wrote:

Hi

Im looking for help on pythoncom.PumpWaitingMessages(). I’m using it to 
connect to a Windows application that has a com object to stream stock 
prices.


It works fine most of the time but when the rate of new events/messages 
gets too high ( unscientifically about 50 a second i think it can 
handle) it grinds to a halt and basically stops processing new 
events/messages and doesn't catch up even if the rate of new 
events/messages slows down. .


I can't explain why it doesn't recover, but you would certainly expect 
this to be quite slow given Python is executing an infinite loop.


Replacing the loop with just pythoncom.PumpMessages() also works, but I 
have no idea if this is more or less robust?


That should be more robust and performant in your scenario. The only 
time you should use PumpWaitingMessages is when that infinite loop isn't 
what you want.


HTH,

Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pywin32 Windows Service not responding

2023-03-25 Thread Mark Hammond
The last pywin32 release was before 3.11 was officially released, so 
maybe try either 3.10 or pywin32-306


Mark

On 25/03/2023 7:25 am, jeremy.farmer1206 via python-win32 wrote:
Hi, I am looking for some assistance with utilizing pywin32 in order to 
create a Windows Service.


I've tried to create as bare-bones of an application as I could 
inheriting from win32serviceutil.ServiceFramework


import traceback
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time
import os
import sys
class MyService(win32serviceutil.ServiceFramework):
     _svc_name_ = 'MyPythonService'
     _svc_display_name_ = 'My Python Service'
     _svc_description_ = 'This is a sample Python Wind
     def __init__(self, args):
         win32serviceutil.ServiceFramework.__init__(se
         self.hWaitStop = win32event.CreateEvent(None,
         socket.setdefaulttimeout(60)
         self.is_alive = True
     def SvcStop(self):
         self.ReportServiceStatus(win32service.SERVICE
         win32event.SetEvent(self.hWaitStop)
         self.is_alive = False
     def SvcDoRun(self):
         self.ReportServiceStatus(win32service.SERVICE
         self.ReportServiceStatus(win32service.SERVICE
         # win32event.WaitForSingleObject(self.hWaitSt
         try:
             servicemanager.LogMsg(servicemanager.EVEN
PYS_SERVICE_STARTED, (self._svc_name_, ''))
             self.main()
         except Exception as ex:
             servicemanager.LogErrorMsg("Exception in
eback.format_exc()))
             raise
     def main(self):
         while self.is_alive:
             with open('test.txt', 'a') as f:
                 f.write('Service loop...')
                 time.sleep(2)
if __name__ == '__main__':
     if len(sys.argv) == 1:
         servicemanager.Initialize()
         servicemanager.PrepareToHostSingle(MyService)
         servicemanager.StartServiceCtrlDispatcher()
     else:
         win32serviceutil.HandleCommandLine(MyService)


I've installed it via opening an admin command prompt and running

python main.py install

It installs successfully but if I attempt to run it, I get

image.png

Or

>python main.py  start
Starting service MyPythonService
Error starting service: The service did not respond to the start or
control request in a timely fashion.


debugging seems to work, or at least does not give any errors

python main.py  debug
Debugging service MyPythonService - press Ctrl+C to stop.
Info 0x40001002 - The MyPythonService service has started.


I believe my pywin32 is fully up to date

python -m pip install --upgrade pywin32
Requirement already satisfied: pywin32 in
c:\users\jerem\appdata\local\programs\python\python311\lib\site-packages 
(305)


Misc

python --version
Python 3.11.2


image.png

Any assistance is very much appreciated!
Sent with Proton Mail  secure email.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 306 released

2023-03-25 Thread Mark Hammond

Hi all,
I'm happy to announce the release of pywin32 build 306. There are 
relatively few changes in this release:


 * Support for Python 3.6 was dropped, support for later versions was
   improved.
 * Add GetSystemPowerStatus (#2010, @CristiFati)
 * Add CascadeWindows (#1999, @CristiFati)
 * Add win32gui.ResetDC
 * Fix leak in win32pdh.GetFormattedCounterArray
 * Fix IIS on later python versions (#2025)
 * Fix for service registration code updated in build 305 (#1985)

Downloads are available at:

https://github.com/mhammond/pywin32/releases/tag/b306

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org). If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to enable events for Python Active Scripting?

2023-03-13 Thread Mark Hammond

Feel free to put a PR up!

Cheers,

Mark

On 14/03/2023 3:10 pm, Wuping Xin wrote:

Thank you again Mark.

In framework.py, Line 223 - Line 235, I see that it only searches for 
[source, default] interface on the coclass.  That means,  multiple 
event interface is NOT supported for now.


I think I'll have to use "win32com.client.connect.SimpleConnection()" 
to manually create the Source/EventSink connection.


Wuping


-- Original Message ------
From "Mark Hammond" 
To "Wuping Xin" 
Cc "Python-win32@python.org" 
Date 3/13/2023 10:55:03 PM
Subject Re: [python-win32] How to enable events for Python Active 
Scripting?



*WARNING EXTERNAL EMAIL *



IIRC, each of these objects is a "named item" - so whatever name you 
use when you call AddNamedItem() is the prefix and the suffix is the 
name of the function on the event interface. I'm really not sure how 
multiple event interfaces are supported, if at all.


Cheers,

Mark



On 14/03/2023 1:12 pm, Wuping Xin wrote:

Hi Mark,

- "you would define a function called "ObjectName_EventName"

Thank you again! This is valuable info.  In the following 
pseudo-code,  the Host COM Object implements TWO Events interfaces.  
How should I defined relevant event sink functions?  For example, if 
the object instance is named "MyHostObject", should I just directly 
define the following event sink functions?


MyHostObject.Do_A_Event()
MyHostObject.Do_B_Event()
MyHostObject.Do_C_Event()
MyHostObject.Do_D_Event()


interface _IMondayEvents
{
    Do_A_Event;
    Do_B_event;
}

interface _ITuesdayEvents
{
        Do_C_Event;
        Do_D_event;
}

    coclass HostApplication
    {
        [default] interface IHostApplication;
        [source] interface _IMondayEvents;
        [source] interface _ITuesdayEvents;
    };


-- Original Message --
From "Mark Hammond" 
To "Wuping Xin" 
Cc "Python-win32@python.org" 
Date 3/13/2023 8:45:37 PM
Subject Re: [python-win32] How to enable events for Python Active 
Scripting?



*WARNING EXTERNAL EMAIL *



[adding the list back in]

I'm still not quite sure what you are trying to do. If you are 
trying to use Active Scripting, then things should "just work" in 
the same way they work for other Active Scripting languages. The IE 
demos show us handling events from IE. This all ties together with 
interfaces described in typelibs and using IConnectionPoint etc. In 
this world you don't implement Python classes which derive from 
EventSink or ScriptItem, you would define a function called 
"ObjectName_EventName"  - eg the "Image_OnClick()" you will find in 
mousetrack.htm.


If you are just trying to use the IConnectionPoint etc without the 
Active Scripting framework, then your best bet is to check out 
win32com\demos\connect.py, and specifically how it uses 
"win32com.client.connect.SimpleConnection()" with the CLSID of an 
object implementing the interface which fires the events.


I'm afraid it has been many years since I've worked on anything 
related to COM or events, so I really don't have great insights 
into the finer details. I've also no additional demos - everything 
relevant I have is in the repo.


Cheers,

Mark

On 14/03/2023 10:41 am, Wuping Xin wrote:

Hi Mark,

Thank you again for your suggestion.

Here is my use case:
1.  C++ Host Application, which exposes a COM object model (with COM
events).
2.  Users are expected to write Python script to interact with the COM
object model.

Following your advice, I read the following source files
- win32comext\axscript\client\framework.py
- win32comext\axscript\test\testHost.py

But I am still somewhat unsure how to create event sinks at the Python
script side.
- Should I add a user-define Python class that inherits from EventSink
or ScriptItem?

Do you think you might be able to provide more hints or it would be
great if there is an example to illustrate this?

Much appreciated!

Wuping Xin, PE, PhD
Chief Technology Officer | Caliper Corporation
|||||
1172 Beacon St, Ste 300 • Newton MA 02461 USA
Mobile: 617-564-1676 • Main: 617-527-4700

-- Original Message --
 From "Mark Hammond"

To "Wuping Xin";python-win32@python.org
Date 3/12/2023 10:54:23 PM
Subject Re: [python-win32] How to enable events for Python Active
Scripting?


It's difficult to know what exactly you mean, but if it is how to use 
IConnectionPoint etc from Python in general, then you should check out the 
following files in the distribution:

com\win32com\demos\connect.py
com\win32com\server\connect.py
com\win32com\client\connect.py

If it is about the use of these interfaces specifically with ActiveScripting, 
then you should find win32comext\axscript\test\testHost.py useful. 
win32comext\axscript\client\framework.py is where the implementation of Active 
Scripting's event handling is 

Re: [python-win32] How to enable events for Python Active Scripting?

2023-03-13 Thread Mark Hammond
IIRC, each of these objects is a "named item" - so whatever name you use 
when you call AddNamedItem() is the prefix and the suffix is the name of 
the function on the event interface. I'm really not sure how multiple 
event interfaces are supported, if at all.


Cheers,

Mark



On 14/03/2023 1:12 pm, Wuping Xin wrote:

Hi Mark,

- "you would define a function called "ObjectName_EventName"

Thank you again! This is valuable info.  In the following 
pseudo-code,  the Host COM Object implements TWO Events interfaces.  
How should I defined relevant event sink functions?  For example, if 
the object instance is named "MyHostObject",  should I just directly 
define the following event sink functions?


MyHostObject.Do_A_Event()
MyHostObject.Do_B_Event()
MyHostObject.Do_C_Event()
MyHostObject.Do_D_Event()


interface _IMondayEvents
{
Do_A_Event;
Do_B_event;
}

interface _ITuesdayEvents
{
        Do_C_Event;
        Do_D_event;
}

    coclass HostApplication
    {
        [default] interface IHostApplication;
        [source] interface _IMondayEvents;
        [source] interface _ITuesdayEvents;
    };


-- Original Message --
From "Mark Hammond" 
To "Wuping Xin" 
Cc "Python-win32@python.org" 
Date 3/13/2023 8:45:37 PM
Subject Re: [python-win32] How to enable events for Python Active 
Scripting?



*WARNING EXTERNAL EMAIL *



[adding the list back in]

I'm still not quite sure what you are trying to do. If you are trying 
to use Active Scripting, then things should "just work" in the same 
way they work for other Active Scripting languages. The IE demos show 
us handling events from IE. This all ties together with interfaces 
described in typelibs and using IConnectionPoint etc. In this world 
you don't implement Python classes which derive from EventSink or 
ScriptItem, you would define a function called "ObjectName_EventName" 
- eg the "Image_OnClick()" you will find in mousetrack.htm.


If you are just trying to use the IConnectionPoint etc without the 
Active Scripting framework, then your best bet is to check out 
win32com\demos\connect.py, and specifically how it uses 
"win32com.client.connect.SimpleConnection()" with the CLSID of an 
object implementing the interface which fires the events.


I'm afraid it has been many years since I've worked on anything 
related to COM or events, so I really don't have great insights into 
the finer details. I've also no additional demos - everything 
relevant I have is in the repo.


Cheers,

Mark

On 14/03/2023 10:41 am, Wuping Xin wrote:

Hi Mark,

Thank you again for your suggestion.

Here is my use case:
1.  C++ Host Application, which exposes a COM object model (with COM
events).
2.  Users are expected to write Python script to interact with the COM
object model.

Following your advice, I read the following source files
- win32comext\axscript\client\framework.py
- win32comext\axscript\test\testHost.py

But I am still somewhat unsure how to create event sinks at the Python
script side.
- Should I add a user-define Python class that inherits from EventSink
or ScriptItem?

Do you think you might be able to provide more hints or it would be
great if there is an example to illustrate this?

Much appreciated!

Wuping Xin, PE, PhD
Chief Technology Officer | Caliper Corporation
|
1172 Beacon St, Ste 300 • Newton MA 02461 USA
Mobile: 617-564-1676 • Main: 617-527-4700

-- Original Message --
 From "Mark Hammond"

To "Wuping Xin";python-win32@python.org
Date 3/12/2023 10:54:23 PM
Subject Re: [python-win32] How to enable events for Python Active
Scripting?


It's difficult to know what exactly you mean, but if it is how to use 
IConnectionPoint etc from Python in general, then you should check out the 
following files in the distribution:

com\win32com\demos\connect.py
com\win32com\server\connect.py
com\win32com\client\connect.py

If it is about the use of these interfaces specifically with ActiveScripting, 
then you should find win32comext\axscript\test\testHost.py useful. 
win32comext\axscript\client\framework.py is where the implementation of Active 
Scripting's event handling is implemented - eg, see the functions Connect, 
CreateConnections, ConnectEventHandlers etc in that file.

HTH,

Mark

On 13/03/2023 1:05 am, Wuping Xin wrote:

I have a host application that uses Python Active Scripting.   That host 
application implements IConnectionPoint / IConnectionPointContainers etc, and I 
am able to set COM event callbacks in C++.

But I am having a hard time to figure out how to set COM event callback with Python 
Active Scripting - I bought the book "/Python Programming On Win32, but /it 
doesn't provide much information about//Python Active Scripting COM events.

Need help and much appreciate any advice.

Wu

_

Re: [python-win32] How to enable events for Python Active Scripting?

2023-03-13 Thread Mark Hammond

[adding the list back in]

I'm still not quite sure what you are trying to do. If you are trying to 
use Active Scripting, then things should "just work" in the same way 
they work for other Active Scripting languages. The IE demos show us 
handling events from IE. This all ties together with interfaces 
described in typelibs and using IConnectionPoint etc. In this world you 
don't implement Python classes which derive from EventSink or 
ScriptItem, you would define a function called "ObjectName_EventName"  - 
eg the "Image_OnClick()" you will find in mousetrack.htm.


If you are just trying to use the IConnectionPoint etc without the 
Active Scripting framework, then your best bet is to check out 
win32com\demos\connect.py, and specifically how it uses 
"win32com.client.connect.SimpleConnection()" with the CLSID of an object 
implementing the interface which fires the events.


I'm afraid it has been many years since I've worked on anything related 
to COM or events, so I really don't have great insights into the finer 
details. I've also no additional demos - everything relevant I have is 
in the repo.


Cheers,

Mark

On 14/03/2023 10:41 am, Wuping Xin wrote:

Hi Mark,

Thank you again for your suggestion.

Here is my use case:
1.  C++ Host Application, which exposes a COM object model (with COM
events).
2.  Users are expected to write Python script to interact with the COM
object model.

Following your advice, I read the following source files
- win32comext\axscript\client\framework.py
- win32comext\axscript\test\testHost.py

But I am still somewhat unsure how to create event sinks at the Python
script side.
- Should I add a user-define Python class that inherits from EventSink
or ScriptItem?

Do you think you might be able to provide more hints or it would be
great if there is an example to illustrate this?

Much appreciated!

Wuping Xin, PE, PhD
Chief Technology Officer | Caliper Corporation
|
1172 Beacon St, Ste 300 • Newton MA 02461 USA
Mobile: 617-564-1676 • Main: 617-527-4700

------ Original Message --
 From "Mark Hammond"
To "Wuping Xin";python-win32@python.org
Date 3/12/2023 10:54:23 PM
Subject Re: [python-win32] How to enable events for Python Active
Scripting?


It's difficult to know what exactly you mean, but if it is how to use 
IConnectionPoint etc from Python in general, then you should check out the 
following files in the distribution:

com\win32com\demos\connect.py
com\win32com\server\connect.py
com\win32com\client\connect.py

If it is about the use of these interfaces specifically with ActiveScripting, 
then you should find win32comext\axscript\test\testHost.py useful. 
win32comext\axscript\client\framework.py is where the implementation of Active 
Scripting's event handling is implemented - eg, see the functions Connect, 
CreateConnections, ConnectEventHandlers etc in that file.

HTH,

Mark

On 13/03/2023 1:05 am, Wuping Xin wrote:

I have a host application that uses Python Active Scripting.   That host 
application implements IConnectionPoint / IConnectionPointContainers etc, and I 
am able to set COM event callbacks in C++.

But I am having a hard time to figure out how to set COM event callback with Python 
Active Scripting - I bought the book "/Python Programming On Win32, but /it 
doesn't provide much information about//Python Active Scripting COM events.

Need help and much appreciate any advice.

Wu

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

>


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to enable events for Python Active Scripting?

2023-03-12 Thread Mark Hammond
It's difficult to know what exactly you mean, but if it is how to use 
IConnectionPoint etc from Python in general, then you should check out 
the following files in the distribution:


com\win32com\demos\connect.py
com\win32com\server\connect.py
com\win32com\client\connect.py

If it is about the use of these interfaces specifically with 
ActiveScripting, then you should find 
win32comext\axscript\test\testHost.py useful. 
win32comext\axscript\client\framework.py is where the implementation of 
Active Scripting's event handling is implemented - eg, see the functions 
Connect, CreateConnections, ConnectEventHandlers etc in that file.


HTH,

Mark

On 13/03/2023 1:05 am, Wuping Xin wrote:
I have a host application that uses Python Active Scripting.   That host 
application implements IConnectionPoint / IConnectionPointContainers 
etc, and I am able to set COM event callbacks in C++.


But I am having a hard time to figure out how to set COM event callback 
with Python Active Scripting - I bought the book "/Python Programming On 
Win32, but /it doesn't provide much information about//Python Active 
Scripting COM events.


Need help and much appreciate any advice.

Wu

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] possible data corruption when deleting iTunes playlist items

2023-03-06 Thread Mark Hammond
Your script is using itunes via COM - 
https://learn.microsoft.com/en-us/windows/win32/com. Many many apps 
expose APIs via COM, so almost all languages can use them in some way. 
When you reference song.Name, COM defines how Python asks itunes for a 
"name" property on a "songs" object.


Mark

On 7/03/2023 4:03 pm, Clayton Macleod wrote:

Perhaps I’m misunderstanding how those things work then. If I print song.Name 
that isn’t simply printing from the script’s own data? That’s what I thought to 
be happening. It is instead calling upon the iTunes app to get song.Name at 
print time?

--
Clayton Macleod
If no one comes from the future to stop you from doing it, then how bad of a 
decision can it really be?


On Mar 6, 2023, at 8:40 PM, Mark Hammond  wrote:

On 4/03/2023 9:55 am, Clayton Macleod wrote:

Sorry, forgot to hit reply all.  Been many years since I've used mailing lists, 
and I'm surprised anyone still does.  Heh.  Anyway...
Perhaps this isn't very clear. I've found a case where the pywin32 COM library 
is causing data corruption

I'm sorry, but I don't think you did. Any bugs here are going to be inside the 
COM objects exposed by itunes - which doesn't sound particularly surprising 
given COM doesn't even exist on the platforms they own.

It would be like saying that if you can provoke Word to create a corrupt 
document via COM that it would be a pywin32 bug - it would not - and stranger 
things have happened with many different COM interfaces over the years.

Mark.


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] possible data corruption when deleting iTunes playlist items

2023-03-06 Thread Mark Hammond

On 4/03/2023 9:55 am, Clayton Macleod wrote:
Sorry, forgot to hit reply all.  Been many years since I've used mailing 
lists, and I'm surprised anyone still does.  Heh.  Anyway...


Perhaps this isn't very clear. I've found a case where the pywin32 COM 
library is causing data corruption


I'm sorry, but I don't think you did. Any bugs here are going to be 
inside the COM objects exposed by itunes - which doesn't sound 
particularly surprising given COM doesn't even exist on the platforms 
they own.


It would be like saying that if you can provoke Word to create a corrupt 
document via COM that it would be a pywin32 bug - it would not - and 
stranger things have happened with many different COM interfaces over 
the years.


Mark.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Object type puzzle

2023-01-03 Thread Mark Hammond

On 4/01/2023 12:58 am, Bob Kline wrote:

I've made good progress on our project to port our XMetaL JScript
macros to Python (see the thread from about a month ago referring to
the project). All the macros (a couple of hundred of them) have been
rewritten in Python, and they all appear to work correctly (though
testing in earnest is still to come).

One problem we ran into was that there are a number of XMetaL API
calls which are documented to return an object of a specific type but
which actually return an interface to the base type of the documented
type. For example, the Add() method of a CommandBarControls object is
documented to return a CommandBarButton object if the parameter
specifying the control type is 1, but a CommandBarPopup if the
parameter passed is 5. However, regardless of which value that
parameter is given, what is actually returned is a CommandBarControl
object, that is, an object of the base class. Clearly that
documentation assumes that the interface navigation between base and
derived classes will be transparent to the scripting code.

Here's the mystery part. When we used the properties of the returned
object in our JScript macros, the code worked as advertised. However,
the equivalent Python code blows up, with an error claiming that we
are trying to use a property which our object does not possess. And
the error message says that our object is a CommandBarControl object,
not a CommandBarButton or CommandBarPopup object. So the mystery is:
why does the JScript code work, when Python code doing the same thing
does not?

The vendor came up with a workaround, which is for us to explicitly
cast the interface which is returned to the type we need to use
ourselves. For example, replacing

 button = toolbar.Controls.Add(1)

with

 control = toolbar.Controls.Add(1)
 button = win32com.client.CastTo(control, "CommandBarButton")

This works. We have over a dozen places in our code where we've had to
apply this workaround. However, I would like to solve the mystery if
that's possible, because I always prefer knowing how and why the tools
we use do what they do. Cuts down on the number of unpleasant
surprises. :-}

I can think of two possible explanations.

The first would be that the vendor is detecting when the scripting
engine is JScript and is behaving differently in that case, performing
the cast and actually returning the interface to the specific derived
class instead of the interface to the base class. It's hard to imagine
what the incentive would be for the vendor to do this (have the API
behave differently depending on what the scripting engine is). Also, I
asked them point blank if that's what's going on, and they said that
it isn't.

The other, more plausible explanation would be that JScript is
navigating between the interfaces using the introspection capabilities
provided by the COM architecture. When it sees a method call or
property access on an interface for which the method or property isn't
implemented, but for which derived classes exist which do implement
it, it figures out which one supports the method or property,
effectively doing the casting for us. The weak link in this
explanation is the question: what would the scripting engine do if
more than one derived class implemented the method invoked or the
property accessed? Presumably that would trigger an exception.

Normally I would clear up such a puzzle by reading the specification
for the underlying framework. However, when I asked the vendor for the
Windows Scripting Interface specification used to expose their
scripting API, they told me that such a document doesn't exist.


This is probably just defined by IDispatch and related interfaces. There 
is a good chance that JScript magically uses multiple interfaces at the 
same time for an object, whereas Python only tends to use one.


I suspect the root of the problem is that Python ends up in 
https://github.com/mhammond/pywin32/blob/main/com/win32com/client/__init__.py#L38, 
and as you can see it only uses the first possible type info for the 
IDispatch. It would be interesting to know if the objects with this 
behaviour have multiple entries there with the one you care about being 
at somewhere other than 0.


But even if that's true, I'm not quite sure what you can do to smooth 
this over - we can't just make that code use, say, `[-1]` - but it still 
would be useful to identify if that's the problem.


Cheers,

Mark



Assuming the second explanation above is correct, why is the Python
scripting support not performing the interface navigation which (for
example) JScript and VBScript are doing, and which the documentation
for the XMetaL APIs appears to assume will happen? Or is there a third
explanation for the mystery which has eluded me?

Thanks,
Bob Kline
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



Re: [python-win32] pywin32 Documentation

2022-12-05 Thread Mark Hammond

Hi Brian,
  Thanks for your interest. I probably should have written more about 
this earlier. From my POV, the main considerations I have are:


1) Much of the documentation is inside the c++ source formatted via 
"autoduck" style comments. I really don't want to abandon this 
documentation, but I don't think it's helpful in a sphinx-based world?


2) There's no where near as much docs embedded in the .py code, which is 
something that we can address. However, some work has started on 
https://github.com/mhammond/pywin32/issues/1913, which hopes to add type 
annotations - see also yesterday's mail to this list on this topic. 
While I'm not quite sure exactly what approach is being suggested for 
that, it seems possible it will have at least *some* overlap here?


3) Working out a good layout in the repo for docs is also important, but 
I don't forsee any real obstacles here - as you mention, a TOC etc are 
important. .rst seems like a perfectly reasonable format for 
hand-written docs, and given there aren't really that many hand-written 
docs in the tree which remain relevant, hand-converting them to largely 
unformatted markdown seems reasonable in the first instance. There's 
always going to be a bit of tension between keeping the docs organized 
and trying to keep the docs fairly close to the implementation they are 
documenting, but we can manage that.


4) I'd want to kill the existing tooling entirely as it's just going 
stale. Eg, the way https://mhammond.github.io/pywin32/ is built is 
interesting (it decompiles the .chm!) but that seems like a dead-end - I 
suspect that at some point it will end up extremely difficult to build 
that .chm in the first place - finding the Windows HTML Help compiler 
today is difficult enough.


So really, the big unknowns for me that need answering are:

* How exactly do the autoduck comments get handled as they change?

* How does adding docs to the .py files overlap with adding type hints?

* Does it replace the existing system rather than adding yet more 
complexity to it?


I'll look a little more at your repo over the next week or so, but I'm 
currently a bit short on time, but really am interested in improving the 
docs, so thanks!


Mark



On 6/12/2022 12:56 pm, Brian Johnson wrote:

Hi.

I took a stab at upgrading and "untangling" the documentation. I am 
willing to work on this documentation "untangling" project. Before I put 
more effort into it, I would like to get feedback from Mark and other 
contributors on what I'm proposing. If so, I'll log an Issue and/or pull 
request.


*Motivation*: I need to work with a COM server application and want to 
use python. I found it challenging to find documentation and examples. 
Also, Mark mentioned this in the repo README: /"Lots of that is very 
old, but some is auto-generated and current. Would love help untangling 
the docs!"/


*Where*: The current iteration is hosted on my forked repo at Python for 
Windows Extensions — pywin32 305 documentation (brian3johnson.github.io) 
. If this effort 
moves forward, I'll pull it down once it's built and posted from 
mhammond's repo.


*How*: I am building the documentation with sphinx Welcome — Sphinx 
documentation (sphinx-doc.org) 
 to update the narrative docs and 
automate or semi-automate the pywin32 API reference. I am using the 
default theme. I'm using reStructuredText (.rst) for the docs.


*What*: I included all the existing narrative documentation from the 
CHM. Most of it remains unformatted, except for a couple of docs. I 
added a Home page, Installation, Support, and Resources pages, and the 
start of a Getting Started Tutorial.


*Proposed Next Steps*:

1. Confirm if I move forward with sphinx. If so, confirm if we use 
reStructuredText (reStructuredText — Sphinx documentation 
(sphinx-doc.org) 
) or Markdown (Markdown — Sphinx documentation (sphinx-doc.org) ) for narrative documents.

2. Finish formatting the existing narrative docs per rst or md.
3. Add docstrings to .py source files to generate API docs.
4. Convert some of the "samples" embedded in the source files to "How-tos".

I have more ideas and suggestions, which I can share in an Issue, PR, or 
on this mailing list.


I look forward to hearing what you think.

Sincerely,
Brian

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Obsolete code paths and version-specific checks

2022-12-03 Thread Mark Hammond

On 3/12/2022 11:50 am, Samuel Therrien wrote:

Hi!
While working on adding annotations for typing support in pure python 
modules, I noticed a *lot*​ of conditions and code made to run on older 
versions of Python. Which are both EOL and no longer supported in 
pywin32. Removing those would alleviate a lot of code and help smooth 
out the addition and validation of Python 3.7+ annotations.
I would like to do a PR to tackle this, but first, is there anything 
specific I should be weary of?


Hi Samuel,
  I'm perfectly fine with removing unsupported code - a PR just doing 
that before any others would be perfect! I'd also love to know more 
about the annotations, but having that convo on github seems fine.


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Memory access violation using pywin32 as WSH

2022-11-29 Thread Mark Hammond

On 30/11/2022 9:09 am, Bob Kline wrote:


So at least part of that puzzle is cleared up, though it's still 
somewhat unsettling that only seven calls to ScriptItem.Close() are 
made, regardless of how many ScriptItem objects have been instantiated 
during a session.



The close method is 
https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.debugger.interop.iactivescript.close?view=visualstudiosdk-2019, 
so it's the responsibility of the host to call that. I agree it's a bit 
of a red flag, and may point to confusion in the host about object 
lifetimes, which could certainly end up causing what you are seeing. 
It's worth pointing out that any "obvious" bug in pywin32 here would 
probably be able to be reproduced in, and reported by, the various other 
hosts, including cscript.exe and wscript.exe (which themselves are just 
active script hosts, just like your problematic host)


Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Memory access violation using pywin32 as WSH

2022-11-29 Thread Mark Hammond

On 30/11/2022 3:06 am, Bob Kline wrote:

Cranking up the microscope (or spelunking deeper, whichever metaphor
you prefer), the first thing I'll say is that this code is devilishly
complex.

Here's what I've found in the latest pass.

First, there's a minor bug at line 353 of pyscript.py [1], where
globalNameSpaceModule is set to None when it's
self.globalNameSpaceModule which should be set to None. The bug is
currently innocuous, as the only invocation of the method in which
that assignment is made in this version of the code is from
PyScript.Close(), and that method makes the correct assignment:


Oops, yeah, that looks like a bug (but note that the links you are using 
are from sublime text, not from pywin32 - it looks quite old - the 
correct link is 
https://github.com/mhammond/pywin32/blob/main/com/win32comext/axscript/client/pyscript.py 
where it is at line 416.



 self.globalNameSpaceModule = None

It seems to me that there's a more serious problem at line 350 of that
module [2], where that same method appears to be invoking a method
which does not exist, at least as far as I can determine (bearing in
mind that I might not completely understand all the nuances of the
tricky code here).

 self.globalNameSpaceModule.ax._Reset_()

Working backward, to see if I can figure out where _Reset_ would be
defined, I found this code in the PyScript class:

 def InitNew(self):
 framework.COMScript.InitNew(self)
 import imp
 self.scriptDispatch = None
 self.globalNameSpaceModule = imp.new_module("__ax_main__")
 self.globalNameSpaceModule.__dict__['ax'] = AXScriptAttribute(self)
 

It's not completely clear how this method gets invoked (I don't see
any calls to it, but I do see that "InitNew" appears as one of the
strings in the _public_methods_ array attribute of the base class),


Yes, that's a COM method, so called by the host - see 
https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.debugger.interop.iactivescriptparse64. 
That try/except block was probably just handling the case where Reset is 
called twice without an InitNew call in between (in which case 
self.globalNameSpaceModule is None, so will not have a .ax attribute) - 
but I agree with your analysis that even if it *did* have that 
attribute, the ax object isn't going to have a Reset - so whatever 
that's trying to do isn't getting done.



As a side note, imp.new_module() [3] was deprecated back in Python 3.4.


Yep, you are looking at a very old version.


I'm attaching the logs I captured. One set is for a session in which
the macro was only invoked once (and therefore didn't result in any
observable failures) and the other for the session in which the macro
was invoked twice, with the symptoms described earlier in this thread.
Please let me know if anything else stands out as potentially useful


Nothing stands out there :( But that's not particularly surprising as it 
really should be impossible for bugs in that .py code to crash the 
process - strangeness could happen, but an access violation shouldn't be 
possible. Something like a COM reference counting bug in (either in 
axscript or in the host) could explain this.


Re your other message, when I say I'm hoping to see a stack trace, I 
mean a native stack trace, as should be shown in the event viewer or in 
a JIT debugger, which will show the symbols in the various DLLs rather 
than the Python functions. Eg, it showing the crash happening in, say, 
IUnknown::Release would imply such a reference counting bug, or if it 
instead shows it in some other COM method it would help narrow down the 
problem area. Unfortunately, without knowing your environment I can't 
offer specific advice about how to get it - but running the crashing 
program under any Visual Studio version would certainly offer it.


HTH,

Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Memory access violation using pywin32 as WSH

2022-11-28 Thread Mark Hammond
It's been years since I've looked at this, but IIRC, a "script item" is 
whatever the host wants it to be - eg, in a HTML page, it would be 
anything between  tags. I believe WSH would just use 
one for a script file.


The Close() method will generally be called by the host - not calling 
this could cause a memory leak (particularly if the COM reference count 
also didn't hit zero), but it shouldn't cause a crash. That said though, 
I certainly would not rule out a bug in pywin32's implementation.


The absolute best thing for us would be to reproduce the crash in the 
test code at 
https://github.com/mhammond/pywin32/tree/main/com/win32comext/axscript/test. 
The next best thing would probably be a stack trace of the crash.


Cheers,

Mark

On 29/11/2022 10:38 am, Bob Kline wrote:

On Mon, Nov 28, 2022 at 4:12 PM Bob Kline  wrote:


Perhaps, for example, I'll be able to find something which is supposed
to get released at application shutdown time but which isn't. 


I've added some debug logging to the top of most methods in
pyscript.py, mostly just announcing that the method was invoked. I was
a little surprised to find that for each invocation of the macro seven
instances of the ScriptItem class were created, instead of just one.
So clearly I have yet to figure out exactly what a ScriptItem is. The
really interesting thing is that if I invoke the macro once for a
given run of the host application, the ScriptItem.Close() method is
called seven times, matching the seven times the ScriptItem
constructor is hit. However, if the macro is invoked twice for a run
of the host application, I still see only seven calls to
ScriptItem.Close(), even though there are now fourteen calls to the
ScriptItem constructor. Can I assume that this is a problem? Sure
smells like one. Where does the responsibility for calling the Close()
method ultimately fall?



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Looking for PyWin32 for Python 2.3.1

2022-11-15 Thread Mark Hammond
Looks like the last to support 2.3 was build 218 and can be found at 
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/


Cheers,

Mark

On 16/11/2022 8:56 am, Paul Newton wrote:

Hi

Please don't ask why I would want to install such an old version of 
Python, but I have Python 2.3.1 installed anyway.  Now I am looking for 
the corresponding PyWin32 install files.  I believe they are available 
here https://sourceforge.net/projects/pywin32/files/pywin32/ or here 
https://www.lfd.uci.edu/~gohlke/pythonlibs/ but I cannot fathom exactly 
what I need to download or what to do with the download.


I am sure somebody can help ... Thanks

Paul Newton

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Welcome to the "python-win32" mailing list (Digest mode)

2022-11-08 Thread Mark Hammond
pythoncom.CLSCTX_LOCAL_SERVER means this COM object will be hosted by 
python.exe - so COM/office is going to look up the registry to get a 
command-line to execute. As written, that will just re-register the COM 
server - so yes, you do want that `localserver.serve()`. The default of 
CLSCTX_INPROC_SERVER generally doesn't need an explicit serve() as 
python.exe isn't used - the DLLs are loaded directly into office - but 
that probably isn't going to help in a concrete way (ie, the underlying 
problem would probably exist in both cases)


Assuming it still fails with that: it might be that this command is 
failing for reasons - eg, if you installed pywin32 via pip and didn't 
run the pywin32_postinstall script I can imagine things going wrong. The 
.exe installer runs that for you though.


You mention you found the entry in the registry - does executing that 
command in a "clean" environment (ie, without any special environment 
variables etc, from a directory unrelated to python - ie, trying to 
emulate the same environment office itself runs in) work OK? If it fails 
importing modules etc, that's probably the same failure when COM tries 
to start it.


You mention "running code as Administrator" - is Office and this 
registration code running as the exact same user?


I've currently no environments with Office available, so can't really 
test at the moment.


HTH,

Mark

On 9/11/2022 2:53 am, Brian Johnson wrote:

Hi python-win32 community.

I am trying to get this toy COM server (code is below) to work. It is 
the sample code from /"Python Programming for Win32"/ and adapted for 
python 3.10. When I test it using VBA in Word, I get this error:

Run-time error '429':
ActiveX component can't create object

  * I don't know if I am missing one a required _reg_param_ that is
needed for Win10.
  * Is there is an extra step I need to take to register/run the COM server?
  * I don't know if win32com.server.localserver.serve [] is necessary.
  * Does the class need an __init__ method to do something?


I appreciate any help or insight into getting this to work. Thank you!
Sincerely, Brian

*Context*:

  * Windows 10, python 3.10, Office 365, running python code as
Administrator
  * I have verified the python class works in python only.
  * I tried registering/unregistering using both options shown below.
Both appear to work - no error messages. I can find info about the
COM Server using Regedit.
  * I tried the --debug flag, but it didn't provide any verbosity.
  * I'm learning COM, but the info about it is sparse and generally very
abstract.


*Python script, SimpleCOMServer.py:*
"""A sample COM server - almost as small as they come."""
# import sys

importpythoncom
importwin32com.server.register


classPythonUtilities:
"""We expose a simple method in a Python COM object."""

_reg_clsctx_= pythoncom.CLSCTX_LOCAL_SERVER
_public_methods_= ["SplitString"]
_reg_progid_= "PythonDemos.Utilities"
_reg_desc_= "PythonDemos Test COM Server"
# NEVER copy the following ID
# Use "print(pythoncom.CreateGUID())" to made a new on.
_reg_clsid_= "{819E8336-00B5-4025-979A-46EE1EF411B7}"

# for Python 3.7+
# 
https://stackoverflow.com/questions/1054849/consuming-python-com-server-from-net 

_reg_verprogid_= "PythonDemos.Utilities.1"
# .
_reg_class_spec_= "SimpleCOMServer.PythonUtilities"

defSplitString(self, val, separator=None):
"""Split a string by a separator."""
# if separator is not None:
#     return val.split(separator)
# else:
#     return val.split()

ifseparatorisnotNone:
returnstr(val).split(str(separator))
else:
returnstr(val).split()


# Add code so that when this script is run by python e.e, it self-registers.
if__name__== "__main__":
print("Registering COM server...")
win32com.server.register.UseCommandLine(PythonUtilities)

# if "--register" in sys.argv[1:] or "--unregister" in sys.argv[1:]:
#     win32com.server.register.UseCommandLine(PythonUtilities)

# else:
#     # start the server.
#     from win32com.server.localserver import serve

#     serve(["{819E8336-00B5-4025-979A-46EE1EF411B7}"])

*Word VBA macro:*
Sub TestPython()
     Dim PythonUtils As Object
     Set PythonUtils = CreateObject("PythonDemos.Utilities")
     response = PythonUtils.SplitString("Hello from VB")
     For Each Item In response
     MsgBox Item
     Next
End Sub


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] [ANN] pywin32 build 305 released

2022-11-06 Thread Mark Hammond

On 6/11/2022 9:17 pm, Łukasz Jakubowski wrote:


Hello,

First, thanks for the update.

You're welcome :)


In my pywin32 installation notes I have noted that 
"pywin32_postinstall.py -install" (not needed now?)


It's still as needed as it ever was.

and "pyscript.py --register" (to enable ActiveScipting) are required 
to make everything work correctly .


I though the postinstall script did that?



What would be equivalents now?


Not sure what you mean. Are you referring to the .exe situation? The 
.exe installers run that script automatically, but pip has never offered 
that capability - so running postinstall remains important for pip 
installs if you rely on anything being globally installed/registered. 
I'm just noting .exe files will not exist soon-ish.


Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 305 released

2022-11-06 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 305.

This release has quite a few changes under the hood, updating our use of 
older deprecated Python functions etc - so there's some risk of 
unintended consequences.


Another unintended change is that .exe installers are deprecated, 
because the upstream support for building them is deprecated. Anyone 
still using them should start moving to pip:


  python -m pip install --upgrade pywin32

But while .exe files exist:

  https://github.com/mhammond/pywin32/releases/tag/b305

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:

* Installation .exe files were deprecated.

* @kxrob put a lot of work towards removing use of the deprecated
  Unicode API so we can build on Python 3.12. This should be largely
  invisible, but please report any unintended consequences.

* odbc: Handle `varchar(max)`/`nvarchar(max)` column sizes (#1954)

* win32api.GetTickCount() now returns an unsigned 64bit integer (@kxrob,
  #1946)

* win32pipe.GetNamedPipeHandleState() now takes a 3rd optional param
  indicating whether the username should be returned, and related
  constants added. (@kxrob, #1946)

* Added win32gui.GetTopWindow() and win32gui.GetAncestor() (@CristiFati,
  #1928)

* Tweaks to how pywintypes searches for DLLs to better support
  virtualenvs created with --system-site-packages. (@saaketp, #1933)

* Added win32event.CreateWaitableTimerExW (#1945, @zar9003)

* Changes in PARAM handling. Some functions which returned a WPARAM or
  LPARAM allowed you to return a pointer to a Python buffer object or a
  PyUnicode. These functions now only accept a Python long to be
  returned. Note that this DOES NOT apply to functions with accept
  WPARAM or LPARAM as arguments, only when they are being returned.
  Impacted functions are `OnNotify` handler, LV_ITEM/TV_ITEM objects,
  PyIContextMenu3::HandleMenuMsg2, and the result of a WNDPROC/DLGPROC
  (#1927).

* service registration had an overhaul, avoiding a complicated, and
  ultimately unnecessary "single globally registered service runner"
  concept. Now, when registering a service, the host pythonservice.exe
  runner will be copied to `sys.exec_prefix`, along with possibly
  `pywintypesXX.dll` and run from there. (#1908)

* Dropped support for allowing a bytes object to be passed where a COM
  BSTR is expected - this support was accidental on the path from
  2.x->3.x.

* win32crypt's PyCERTSTORE.CertCloseStore()'s `Flags` argument has been
  deprecated as it is likely to crash the process if
  `CERT_CLOSE_STORE_FORCE_FLAG` is specified. The underlying function is
  now always called with `CERT_CLOSE_STORE_CHECK_FLAG`, and support for
  this param will be dropped at some point in the future.

* Fix a bug where win32crypt.CryptQueryObject() would return a
  PyCTL_CONTEXT object instead of a PyCERT_CONTEXT for base64 encoded
  certificates (#1859)

* win32crypt.CryptQueryObject() is now able to return PyCTL_CONTEXT
  objects. This is technically a breaking change as previously it would
  return the address in memory of the object, but this address wasn't
  practically usable, so it's very unlikely anyone relied on this
  behavior. (#1859)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 in python 64bit-3.7 environment

2022-07-05 Thread Mark Hammond

On 6/07/2022 7:13 am, De Silva, Thushara via python-win32 wrote:

Hi,

I am working in python 64-bit, 3.7 environment. I want to install 
pywin32 to conda-environment.


“pip install pywin32” installed pywin32 304 to my env. But I cannot 
“import pywin32” from my jupyter notebook (No Module named ‘pywin32’).


Note that confusingly, pywin32 has many modules, but none are named 
`pywin32` - try, say, `import win32api`.


I 
assumed, I have to install 64 bit pywin 32.


So, I tried to install the module as

pip install 
https://github.com/mhammond/pywin32/releases/download/b304/pywin32-304.win-amd64-py3.7.exe 


ERROR: File "setup.py" not found for legacy project 


As Steven mentioned, pip can't install via a .exe. You either want to 
run the .exe, or just use `pip install pywin32` - which you said you did 
above, so I suspect you have already installed it correctly, but just 
specified the wrong module to import.


Cheers,

Mark



https://github.com/mhammond/pywin32/releases/download/b304/pywin32-304.win-amd64-py3.7.exe
 
.

Would you all help me?

Thanks,

Thushara


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Regarding Licence

2022-06-23 Thread Mark Hammond
Use is royalty free and you don't need permission - good luck with your 
project.


Mark

On 23/06/2022 4:12 pm, Nithyashree wrote:

Hi,
I would like to use pywin32 Api for my project. Is this royalty free? Do 
I need prior permissions or is there anything of that sort? I saw the 
Licence in GitHub but didn't understand. Just wanted to know if this 
licence is freeware and the API can be used.

Thanks.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Import Certificate with Private Key to Current Computer Certificate store

2022-05-26 Thread Mark Hammond

Hi!

I know almost nothing about certificate stores, but as luck would have 
it, someone did report some issues recently, so it turns out there is a 
PR that (a) tries to fix a couple of issues and (b) adds a test that 
adds certificates to the store - see 
https://github.com/mhammond/pywin32/pull/1863, particularly 
test_win32crypt.py, which can hopefully be found at 
https://github.com/mhammond/pywin32/pull/1863/files#diff-9f6fa3983d625ad71f59c9b4662dc07ea20602ffb5c3b1aa58e5e59fa759dff7


HTH,

Mark

On 27/05/2022 10:40 am, Steven Manross wrote:

Howdy,

I am finishing up some work on requesting certificates from an internal 
Microsoft CA, and then importing the certs to the local windows certificate 
store, butd was having difficulty determining what function to use to import a 
Certificate with Private Key (P12/PFX) to a the computer's Certificate store.  
I've got everything else handled up to this point (I think), but now I am stuck.

I see two possible functions for likely adding the certificate to the store:

http://timgolden.me.uk/pywin32-docs/win32crypt__CertAddSerializedElementToStore_meth.html
* likely the way to go, but I don't see in the documentation 
how to take my Cert with Key and convert it to the necessary structure

http://timgolden.me.uk/pywin32-docs/win32crypt__PFXImportCertStore_meth.html
* this one I'm not so sure about (not likely what I want to do)

...but  also see this:

https://stackoverflow.com/questions/61888404/how-do-i-install-a-certificate-to-trusted-root-certificates-using-python
* however I cannot read the PFX correctly (presumably due to 
the encrypted nature of the certificate with key).
* I DO have the base64 PEM crt and key files if that helps me 
in this process
* the CertStore code from this post looks like what I need to 
get to the CertStore, however

The certificates I'm trying to work with are typically for webserver renewals.

If anyone has knowledge and is willing to share, I'd appreciate it!

Please and Thank you,
Steven
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Python 3.11 and pywin32 304

2022-05-11 Thread Mark Hammond

On 12/05/2022 7:23 am, Scorby, Gary via python-win32 wrote:
I’ve looked to see if anyone else is having this issue.  I haven’t found 
anything.  When trying to call a function in the interactive window I 
get what you see below.  Appears to be trying to access a deprecated 
method.  I’d like to start testing with 3.11.  The error occurs when I 
type the left parenthesis after the function name.  Is there actually a 
problem with pywin32, or with me? – Thanks, Gary


Almost certainly with pythonwin - I opened 
https://github.com/mhammond/pywin32/issues/1877


Thanks,

Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] [ANN] pywin32 build 304 released

2022-05-02 Thread Mark Hammond

On 3/05/2022 5:31 am, Steven Manross wrote:

Thanks for the new version!

Considering I've been on build 227 forever, I tried upgrading my webserver's pywin32 
build to 304 with a base of Activestate Python 3.8 (64-bit), and now I'm getting errors 
in my ASP pages ("500" Server Error), and in ipython (below).


The README has a section dedicated to this - 
https://github.com/mhammond/pywin32/blob/main/README.md#the-specified-procedure-could-not-be-found--entry-point-not-found-errors 
- tl;dr, you probably have duplicate pywin32 DLLs installed, possibly 
because the different versions were installed using different techniques.


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 304 released

2022-05-02 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 304. There are a 
number of changes in this release with the significant ones listed below.


Note:
* There are no .exe installers for 32-bit 3.10+ due to Python dropping 
support for bdist_wininst.


* arm64 wheels for 3.10 and 3.11 64bit versions are available on pypi.

Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b304

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.

Changes:

Since build 303:

* Fixed Unicode issues in the `dde` module (#1861, @markuskimius )

* Add `PRINTER_INFO_6` support for Set/GetPrinter (#1853, @CristiFati)

* Fixed codepage/mojibake issues when non-ascii characters were included
  in COM exceptions raised by Python apps. This should be invisible, but
  might break any workarounds which were used, such as using specific
  encodings in these strings. (#1823, #1833)

* Fixed a bug triggering `win32print.SetJob` to fail due to data type
  (`char*` / `wchar_t*`) mismatch (#1849, @CristiFati)

* Fix eventlog initialization (#1845, #1846, @kxrob)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pythoncom PROPVARIANT

2022-04-25 Thread Mark Hammond

On 26/04/2022 5:00 am, Nicholas Pfeiffer wrote:

Hi there,

Where is the PROPVARIANT class located in the pythoncom library?
The docs are not helpful about this:
http://timgolden.me.uk/pywin32-docs/PyPROPVARIANT.html 



I've seen postings that use the propsys module but that one no longer 
contains the PROPVARIANT class unfortunately.


It is implemented in that module - see 
https://github.com/mhammond/pywin32/blob/main/com/win32comext/propsys/src/PyPROPVARIANT.cpp. 



I'm wondering if this class exists in a different package or if I can 
somehow recreate it?


I need to write new properties to a file but using the WriteMultiple 
method will only let me write Strings with a prop variable id of 8 and I 
need them to show up as "Text" which has a prop variable id of 30.


30 == VT_LPSTR which isn't supported by pywin32 - but VT_LPWSTR (31) is 
- you can create such an object with something like:


>>> from win32com.propsys import propsys
>>> import pythoncom
>>> propsys.PROPVARIANTType("foo", pythoncom.VT_LPWSTR)


The only way I understand how to do this is to wrap the values used in 
the WriteMultiple method in a PROPVARIANT class call, but I haven't be 
able to figure out where that class is called from.


Sorry, but I'm not familiar with using WriteMultiple and I suspect it 
will depends on what exactly is on the other end.


HTH,

Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32-223 support request

2022-04-18 Thread Mark Hammond
That uninstall capability is provided by distutils' support for .exe 
installers, and last I looked that did not offer unintended install or 
uninstall support - but things might have changed.


Another option is to use pip to both install and uninstall.

Cheers,

Mark


On 16/04/2022 4:33 am, John Pham wrote:

Good day,

Just wondering if a silent uninstall is at all possible via powershell? 
I see in the registry that the uninstall string is

""C:\Python27\Removepywin32.exe" -u "C:\Python27\pywin32-wininst.log""

but is there a way to make the uninstall silent with no user interaction?

Thanks!


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] zmq under win32service

2022-03-08 Thread Mark Hammond
I admit I've never fully understood the threading model used to control 
services, and agree that almost every "real" service will create threads 
- but it's not clear to me that they *must* - eg, I've seen demo 
services that use a similar loop, and 
https://github.com/mhammond/pywin32/blob/main/win32/Demos/service/serviceEvents.py 
has:


def SvcDoRun(self):
# do nothing at all - just wait to be stopped
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

and seems to work. So I could understand if the symptoms reported here 
were along the lines of "windows thinks my service has hung and killed 
it" or something similar, but it's not clear to me that the lack of a 
worker thread is the reason the service can't make it a single time 
around that loop.


Cheers,

Mark


On 9/03/2022 8:41 am, Tim Roberts wrote:

momc...@bojinov.info wrote:


server:

import zmq, json

context = zmq.Context()

socket = context.socket(zmq.REP)

socket.bind('ipc://cache/mm')

while True:

   message = socket.recv_json()

   print(message)

socket.send_json(json.dumps({"data" : "BLA BLA"}))

Once I start the service though I can’t send/receive content

Both service and cmd/client run under the same account (not SYSTEM)


Where is the service code?


I was wondering if I can even use while True without the spawning a 
separate thread for it ?


No.  Just like a Windows GUI app, a Windows service has a main message 
loop that has to remain in control, so it can receive and dispatch 
messages from the service manager.  The system sends "are you awake?" 
messages periodically to make sure you're still alive.  If you aren't 
getting back to the main loop, then you will be terminated.


So, if you're using the sample you mentioned, the service "def 
main(self):" will need to launch a thread to do your listening. You will 
also need to have your thread check the "stop_request" flag, so you can 
cleanly exit when the service is terminated.



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] zmq under win32service

2022-03-07 Thread Mark Hammond

I've no clear idea what might be going wrong, but:

* The `while True` should be fine - it obviously has limitations, but 
will work in the simple case.


* You need some way of working out *what* is going wrong before you can 
work out *why*. It's possible the `print` statements are failing - I 
don't think the service framework does anything to ensure sys.stdout is 
valid. Most examples use `win32traceutil` to redirect sys.stdout, or you 
can use the event-log or anything else, but knowing exactly what is 
failing (ie, exactly how far it is getting) will be necessary to understand.


Cheers,

Mark

On 8/03/2022 9:08 am, momc...@bojinov.info wrote:

Hello,

I m trying to serve 0mq listener under win32 service

Code works fine while in interactive session

Client:

import zmq, json

context = zmq.Context()

socket = context.socket(zmq.REQ)

socket.connect('ipc://cache/mm')

socket.send_json(json.dumps({"2" : "1"}))

message = socket.recv_json()

print(message)

server:

import zmq, json

context = zmq.Context()

socket = context.socket(zmq.REP)

socket.bind('ipc://cache/mm')

while True:

    message = socket.recv_json()

    print(message)

    socket.send_json(json.dumps({"data" : "BLA BLA"}))

Once I start the service though I can’t send/receive content

Both service and cmd/client run under the same account (not SYSTEM)

I was wondering if I can even use while True without the spawning a 
separate thread for it ?


I m using the service code from:

https://stackoverflow.com/questions/55677165/python-flask-as-windows-service 


(And the service skeleton /*win32_service.py*/)

Help appreciated

Momchil


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] What happens in a Python service in case of exception thrown?

2022-03-02 Thread Mark Hammond

On 3/03/2022 4:21 pm, Siyuan Ren wrote:
I'm trying to subclass win32serviceutil.ServiceFramework in order to 
create a Windows service in Python. I vaguely understand how each stage 
of service works, but I wonder, what happens if any of the python code 
throws an exception? Will the service stop, or put in an abnormal state 
without recourse?


In general it will log a message to the eventlog and stop. Up until 
https://github.com/mhammond/pywin32/issues/1563 & 
https://github.com/mhammond/pywin32/pull/1566, it ended up reporting a 
normal `SERVICE_STOPPED` with an exit code of zero, but now it reports a 
non-zero code so you can configure it to auto-restart on exceptions.


HTH,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 303 released

2021-12-19 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 303. There are a 
small number of changes in this release, but maybe virtualenv will work 
better!


3.11 gets support, but no .exe installers for 32-bit 3.10+ due to Python 
dropping support for bdist_wininst.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b303

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.

Changes:

Since build 302:

* Tweaks to how DLLs are loaded and our installation found, which should
  improve virtualenv support and version mismatch issues (#1787, #1794)

* Fixed a bug where `win32clipboard.GetClipboardData()` may have 
returned extra

  data.

* Binary installers for 32-bit 3.10+ are no longer released (#1805)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Outlook Add-In Demo Question ... A runtime error occurred during the loading of the com add-in

2021-12-08 Thread Mark Hammond
Another possibility for the failure is the environment office is running 
under (which broadly speaking can be described as the PATH).


Back in the day, it was very common for Python and pywin32 to end up 
sticking stuff in the system32 directory, then things like COM would 
work in almost every context, as the system directory was (almost) 
always on the path.


However, these days that's far less likely to be true - so the problem 
might be as simple as the fact that pythonXX.dll and pythoncomXX.dll 
can't be located when office is running, although can be in your pycharm 
environment.


Ensuring the directory with these files is on the PATH for office is the 
generic advice, but it's difficult to give more specific advice without 
knowing more about your specific environment.


Cheers,

Mark

On 8/12/2021 1:49 pm, Dan Moisan wrote:
I apologize in advance for the basic question, but I have spent about 40 
hours researching how to make the demo "outlookAddin.py" load on my 
Outlook 2016 32 bit application. I am running Python version 3.7 and I 
can successfully run the outlookAddin.py script from PyCharm. But then 
when I open outlook, I always receive the message "... not loaded. a 
runtime error occurred during the loading of the com add-in".


I am sure that I missing a very basic step to make this run, but I can't 
seem to find anything online. Do I need to do something to compile the 
outlookAddin.py script before or after I run it? Or should the add-in 
load after it is registered? I'm so sorry for such a basic question.


Thank you!

Dan

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 302 released

2021-10-10 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 302. There are a 
relatively small number of visible changes in this release, although 
there are quite a few changes underneath the covers (eg, the entire 
repository has been formatted with `black`, so files with a mix of tabs 
and spaces is finally a thing of the past), most should be invisible.


Most notably, Python 3.10 is supported. Thanks heaps to @kxrob for 
helping with the heavy-lifting there.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b302

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.

Changes:

Since build 301:

* Fixed support for unicode as a `win32crypt.CREDENTIAL_ATTRIBUTE.Value`

* Support for Python 10, dropped support for Python 3.5 (3.5 security
  support ended 13 Sep 2020)

* Merged win2kras into win32ras. In the unlikely case that anyone is
  still using win2kras, there is a win2kras.py that imports all of
  win32ras. If you import win2kras and it fails with 'you must import
  win32ras first', then it means an old win2kras.pyd exists, which you
  should remove.

* github branch 'master' was renamed to 'main'.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] help needed, missing pythoncomload[37].dll ?

2021-10-06 Thread Mark Hammond

On 7/10/2021 12:07 am, Lewis, Michael L wrote:

Hi,

Working on an internal system that we’re trying to update (sadly we were 
still on Python 2.7 ☹…


One think I noticed is amongst the scripts we have is a dependency on:

pythoncomloader27.dll (which appears at least to have been part of 
pywin32_system32


This is referenced in some registry files, e.g.

[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{80e81c1f-9b39-4a49-9c16-65e7404b809c2}\InprocServer32]

@="pythoncomloader27.dll"  … presumably I need to update this too….

"ThreadingModel"="both"

However when I install the win32 package for Python 3.7; this file seems 
missing (I just see the pythoncom & wintypes dlls)


any idea on how I can find/build this? (I’m assuming it’s still needed 
for the com stuff).


It was only needed with earlier MSVC versions, so isn't necessary for 
3.x. You can use pythoncom37.dll in its place.


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.error: (5, 'OpenEventLogW', 'Access is denied.')

2021-09-16 Thread Mark Hammond

On 16/09/2021 7:17 pm, Ruggero Paolo Basile wrote:

OK , let's explain the case


My goal is to read the event log of the remote windows machine. I have 
experienced the *wmi library,* the wmi problem is that I have to create 
parsers, I have not found any code. On the remote machine I have no 
authentication problems as I connect to the local network.


If you have a username and password that works on the *server*, you may 
be able to use win32security.LogonUser().


You still haven't answered:


Tim also suggested a specific experiment you should try - did you try
it? What happened?


It's likely you will be prompted for a username and password here. If 
you have a username/password that works, win32security.LogonUser() is 
likely to work with the same username/password.


Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywintypes.error: (5, 'OpenEventLogW', 'Access is denied.')

2021-09-16 Thread Mark Hammond

On 16/09/2021 6:41 pm, Ruggero Paolo Basile wrote:
ok , i have the username and password of local machine, i'am a starter 
in python


Tim noted that the issue is what permissions you have on the *remote* 
machine - having the username and password of the local machine means 
nothing to the remote machine you are trying to access.


Tim also suggested a specific experiment you should try - did you try 
it? What happened?


(To put it another way - the issue is not about your code, nor about 
your account on the local machine - it's about your permissions on the 
server. The server apparently does not trust either your local machine 
or the account you are using on your local machine)


Cheers,

Mark





this is my code, the arguments "server" take only

an ip and when i tray to run the code i can't know

how i have to authenticate the connection.



Thanks.



#python C:\python\5_Forensic_Basic\eventlog.py

# Windows Event Log Viewer
# FB - 201012116
import win32evtlog # requires pywin32 pre-installed


import pdb

server = '192.168.1.10' # name of the target computer to get event logs


try:

     logtype = 'System' # 'Application' # 'Security'
     hand = win32evtlog.OpenEventLog(server,logtype)
     flags = 
win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ

     total = win32evtlog.GetNumberOfEventLogRecords(hand)
     pdb.set_trace()
     while True:
         print ("test")
         events = win32evtlog.ReadEventLog(hand, flags,0)
         if events:
             for event in events:
                 print ('Event Category:', event.EventCategory)
                 print ('Time Generated:', event.TimeGenerated)
                 print ('Source Name:', event.SourceName)
                 print ('Event ID:', event.EventID)
                 print ('Event Type:', event.EventType)
                 data = event.StringInserts
                 if data:
                     print ('Event Data:')
                     for msg in data:
                         print (msg)
                 print()
except Exception as err:
     print("Exception")
     print(str(err))
if __name__ == "__main__":
     try:
         print ("start")
     except getopt.GetoptError as err:
         print(str(err))



/Ruggero Paolo Basile/

/Cellulare: 3403216393/
/Mail:/ruggeropaolo.bas...@ora-0.it 
Privacy Policy Company Policy 




*Da:* python-win32 
 per conto 
di Tim Roberts 

*Inviato:* giovedì 16 settembre 2021 03:17:56
*A:* python-win32@python.org
*Oggetto:* Re: [python-win32] pywintypes.error: (5, 'OpenEventLogW', 
'Access is denied.')

Ruggero Paolo Basile wrote:



Good morning i'am try to connect to remote host and get the eventlog 
from windows , but in the


module i can't find a value for authentication.
Have you some news?

this is my error "pywintypes.error: (5, 'OpenEventLogW', 'Access is 
denied.')"



To do that operation, your username has to have permission on that
remote machine.  Are you using a domain?  Are you logged in as a domain
administrator?


This article talks about it, but since Windows security is a vast, dark,
confusing, twisted mess, I'm not sure you'll be able to make it work.


https://docs.microsoft.com/en-us/archive/blogs/janelewis/giving-non-administrators-permission-to-read-event-logs-windows-2003-and-windows-2008 




If you bring up the Event Viewer application ("eventvwr"), under Action,
there's a "Connect to Another Computer" option.  Does that work for you?

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Troubleshooting with moving Outlook emails to subfolders

2021-08-18 Thread Mark Hammond

On 19/08/2021 4:37 am, Giraud Ludovic (AMUNDI) wrote:

Hello Mark,

I am stuck on this issue: https://github.com/mhammond/pywin32/issues/1743

I am trying to move outlook emails into subfolders and this works well most of 
the time.

However in some cases, probably when a copy of the email I am trying to move 
already exists into the subfolder, I get the error below using:
x.Move(self.folder.Folders("Inbox").Folders("VALORISATIONS").Folders("Allianz"))

Is there a way to specify that you want to eventually crush the existing email 
in the folder?


I'm afraid it's been over 10 years since I used Outlook's COM model. 
Hopefully someone else here will comment, but 2 observations:


* Search and delete for the mail firstt to see if the problem goes away? 
That will at least validate your hypothesis.


* Don't restrict your googling to Python - this issue will exist in all 
languages which use Outlook via COM and the subsequent solution will be 
identical.


Good luck,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM: Minimal example of a custom server working with DispatchWithEvents()

2021-07-31 Thread Mark Hammond



On 1/08/2021 12:21 am, William Belanger wrote:

Hi,


Thank you for the follow up. Perhaps I did not express my need clearly 
enough, so I made this minimal example;



# https://gitlab.com/-/snippets/2155778


import pythoncom
import sys
import threading
import win32com.client
import win32com.server.util
from win32com.server import localserver


def init_server():
pythoncom.CoInitialize()
localserver.serve(["{D390AE78-D6A2-47CF-B462-E4F2DC9C70F5}"])


class Main:
def __init__(self):
self.server = win32com.client.Dispatch("Minimal.Example")
self.server.parent = self # TypeError: must be real number, not Main


That exception is very odd and I should look into it - but the problem 
here is that you are trying to set an attribute on a COM object which is 
a Python instance, which doesn't really make sense. What you want is to 
set it to a COM object - which `self` is not. So something like:



class Main:
_public_methods_ = ["pong"]
def __init__(self):
self.server = win32com.client.Dispatch("Minimal.Example")
self.server.parent = win32com.server.util.wrap(self)
self.server.Ping()

def pong(self):
return "pong"

works. Sadly another paper-cut here is that the server just sees this as 
a plain IDispatch object rather than a `Dispatch` wrapper - so `Ping` 
needs to look something like:


def Ping(self):
parent_as_object = win32com.client.Dispatch(self.parent)
print(parent_as_object.pong())

I guess you could, say, change `parent` into `set_parent()`, or 
intercept via __setattr__() and do the wrapping just once.


HTH,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM: Minimal example of a custom server working with DispatchWithEvents()

2021-07-30 Thread Mark Hammond

On 30/07/2021 11:24 pm, William Belanger wrote:

Hi,


However, products are free to define events in whatever makes sense
for them - eg, the object could take a plain IDispatch and try and
dynamically query and deliver events to the methods here. If that's
what the app in question does, then yeah, you don't need
DispatchWithEvents and can do something simpler.


In short, Antidote binary is launched, then its IApiOle interface takes 
the Dispatch object of the custom server I made and uses it to 
communicate back and forth.


self.server = win32com.client.Dispatch("Correcteur.Antidote")
self.antidote = win32com.client.Dispatch("Antidote.ApiOle")
self.antidote.LanceOutilDispatch2(self.server, "C", "",
str(version)) # Server, tool, lang, API version


Using the Dispatch() method, the interface I made is working as 
expected, which means that the methods exposed in AdapteurAntidote are 
then being queried (updated example below). I did not try delivering 
back the resuts but I assume it should work.



What I could not achieve is to get the server adapter class 
(AdapteurAntidote) to work with objects which are created at runtime, 
namely instances of other classes. I cannot set another runtime object 
as an attribute of the adapter class, nor pass it on instantiation. 
Thus, the adapter is quite useless in this case. Is it even possible 
using pywin32? If so, how?


You can get and set properties which are COM objects in the same way you 
can get and set any other properties.




Looking back at Antiote's C++ example, there is an idl file available 
from them.


A .idl file isn't much good to pywin32 - it wants a compiled version 
(aka a typelib.) I'd be quite surprised if their DLL had a .idl file and 
not a compiled version of it.



Is it necessary though? I would rather do everything 
dynamically, such as setting the GUID, just like I did for the DBus 
interface.


In general, early-binding via a typelib should not be necessary - 
however, pywin32 does far less guessing about things when a typelib 
exists. It will be clearer what properties exist, what type they are and 
how to call them. It may well be that it is the difference between 
things working and not working. - so in this case it may well be 
necessary in practice.


Mark

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Troubleshooting with pip install pywin32 using WSL2:Ubuntu and Python 3.8.8

2021-07-29 Thread Mark Hammond



On 29/07/2021 11:05 pm, Giraud Ludovic (AMUNDI) wrote:

Hello,

When I run pip install pywin32 in WSL2:Ubuntu using Python 3.8.8 I get 
the following error log:


WSL is a linux environment - pywin32 simply doesn't work there. You can 
install it via a Windows command-prompt, or in WSL stick to the versions 
of Python that work for Ubuntu but without pywin32.


HTH,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM: Minimal example of a custom server working with DispatchWithEvents()

2021-07-28 Thread Mark Hammond



On 29/07/2021 9:56 am, William Belanger wrote:

Hi,


There is no typelib file unfortunately. The interface needs to 
communicate with Antidote's API by creating a COM server which exposes 
the methods defined in the AdapteurAntidote class.



The problem is that the widget queried (a QTextEdit) is instantiated in 
another class (MainWindow), and I cannot attribute a "parent" to the 
dispatched COM object (self.server), as it raises either an 
AttributeError or a TypeError, depending on its declaration in 
__public_attrs__.



 From the documentation, I thought I needed to use DispatchWithEvents to 
handle the events in a separate "sink" class (ImplementationAntidote) 
that would behave more like a generic python object. Is there any other 
way to achieve this? It is quite a trivial feature so I assume it is 
possible to do so?


DispatchWithEvents helps with the most common pattern used for COM 
events, particularly with MS products - in this model, the interfaces 
are described in a typelib. However, products are free to define events 
in whatever makes sense for them - eg, the object could take a plain 
IDispatch and try and dynamically query and deliver events to the 
methods here. If that's what the app in question does, then yeah, you 
don't need DispatchWithEvents and can do something simpler. However, 
I've no idea how that product works nor what it does, so can't really 
answer the question.


I suspect you aren't the first person to run into this though and I 
assume the object is usable in a number of languages which support COM, 
so you might be better off asking in a forum specific to the product.


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] COM: Minimal example of a custom server working with DispatchWithEvents()

2021-07-28 Thread Mark Hammond



On 28/07/2021 7:58 am, William Belanger wrote:

Hi everyone,


I'm trying to make a cross-platform Python interface for a third-party 
API (Druide Antidote). The D-Bus part is done and working 
(https://gitlab.com/-/snippets/2151173 
), it consist of a server adapter 
(AdaptateurAntidote), which relay the events to an handler class 
(ImplementationAntidote).


Traceback (most recent call last):

File

"C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\win32com\client\__init__.py",
line 256, in DispatchWithEvents

ti = disp._oleobj_.GetTypeInfo()

pywintypes.com_error: (-2147352567, 'Exception occurred.', None, None)


DispatchWithEvents creates a COM object, then gets the typeinfo needed 
to implement the interfaces defined for events - but this COM object is 
failing to provide that type info at runtime. It might still have a .tlb 
available though, and if it does, you can run `makepy.py` once and the 
snippet should work. The typelib can also live in a .dll, but I've never 
heard of Antidote so have no better suggestions.


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 301 released

2021-05-30 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 301. There are a 
number of relatively small changes in this release.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b301

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.

Changes:

Since build 300:

* Fix some confusion on how dynamic COM object properties work. The old
  code was confused, so there's a chance there will be some subtle
  regression here - please open a bug if you find anything, but this
  should fix #1427.

* COM objects are now registered with the full path to pythoncomXX.dll,
  fixes #1704.

* Creating a `win32crypt.CRYPT_ATTRIBUTE` object now correctly sets
  `cbData`.

* Add wrap and unwrap operations defined in the GSSAPI to the sspi
  module and enhance the examples given in this module.
  (#1692, Emmanuel Coirier)

* Fix a bug in `win32profile.GetEnvironmentStrings()` relating to
  environment variables with an equals sign (@maxim-krikun in #1661)

* Fixed a bug where certain COM dates would fail to be converted to a
  Python datetime object with `ValueError: microsecond must be in
  0..99`. Shoutout to @hujiaxing for reporting and helping
  reproduce the issue (#1655)

* Added win32com.shell.SHGetKnownFolderPath() and related constants.

* CoClass objects should work better with special methods like __len__
  etc. (#1699)

* Shifted work in win32.lib.pywin32_bootstrap to Python's import system
  from manual path manipulations (@wkschwartz in #1651)

* Fixed a bug where win32print.DeviceCapabilities would return strings
  containing the null character followed by junk characters.
  (#1654, #1660, Lincoln Puzey)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to access IID_IPropertyStore interface

2021-05-02 Thread Mark Hammond



On 3/05/2021 4:37 am, Piotr Miedzik wrote:

I'm trying to write Jump Lists without PyQt5. In fact I'm rewriting
this source 
https://github.com/qt/qtwinextras/blob/18bee52fe48500bca46de7e47d134940c48b524c/src/winextras/qwinjumplist.cpp#L141

To set title or separator I need to access `IID_IPropertyStore`
interface (`{886D8EEB-8CF2-4446-8d02-CDBA1DBDCF99}`)


This is in the win32com.propsys.propsys module:

>>> from win32com.propsys import propsys
>>> propsys.IID_IPropertyStore
IID('{886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99}')

Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] pywin32 building under mingw64/msys2

2021-03-03 Thread Mark Hammond
There is some work going on in 
https://github.com/mhammond/pywin32/pull/1612, but that's largely 
stalled at the moment. Frankly, I've no interest in this myself, so if 
it happens it would need to be driven by contributors.


Cheers,

Mark

On 4/03/2021 1:27 am, Kristiine Silinja wrote:

Good day!

I have just pulled the master state of pywin32 from github. When 
building it under mingw64/msys2 on Windows I get a following error:

Building pywin32 3.8.300.1
Windows 10 SDK version 10.0.16299.0 is preferred, but that's not installed
Installed versions are ['10.0.19041.0']
Using 10.0.19041.0
running install
running build
running build_py
running build_ext
error: don't know how to compile C/C++ code on platform 'nt' with 
'mingw64' compiler


Python version: Python 3.8.7 [GCC 10.2.0 64 bit (AMD64)] on win32

Would appreciate any help in getting pywin32 installed to Python under 
msys2. Perhaps other libraries could be tweaked (e.g. distutils)? A 
quick search on the topic was not as helpful.


With best regards,
/-Kristiine Silinja/

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Compiling pywin32 with PyOxidizer

2021-02-02 Thread Mark Hammond

On 2/02/2021 11:54 pm, Will Deem wrote:

Good morning Pywin32 mailing list,

  I appear to be running into an issue compiling my program using pyoxidizer 
with pywin32. It appears there is some reliance on the __file__ attribute, 
which is breaking as pyoxidizer is loading the modules into memory and there is 
no __file__ attribute.

  Has anyone created a successful workaround for this issue? If not, is there a 
means of monkey patching the __file__ attribute for the win32evtlog module so 
the program can successfully compile?


That traceback isn't very helpful as it doesn't say what reference to 
__file__ is a problem - but everywhere __file__ is referenced the code 
is trying to find an actual file - often a DLL file.


The traceback also says "ModuleNotFoundError: No module named 
'win32evtlog'" - I don't think that's related to __file__.


I've never heard of anyone using pywin32 with pyoxidizer, so you are 
blazing the trail here :)


Mark.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Error: VARIANT Type is unknown

2021-01-21 Thread Mark Hammond


On 21/01/2021 10:00 pm, Olle Pontén wrote:

Hello!

I'm quite new to the pywin32 package (as in I have never interacted with 
it before).

I'm currently trying to implement a python interface to a win32 bit program
that I can connect to using the ordinary win32com.client.Dispatch method.
This program controls an microscope camera and the only way to connect to
it is via this COM connection.
There is already an version of this software written in pascal by the 
manufacturers

so I'm trying to create an expanded python version of this software.

I've managed to get the connection working and I can send commands that 
do not

require any inputs and access the attributes of the interface/program.

The problem is that when I try to send commands to one of two exposed 
methods that require input I get the

follow error:

s = win32com.client.VARIANT(pythoncom.VT_LPWSTR, 'On\0')

r = win32com.client.VARIANT(pythoncom.VT_LPWSTR, 'AL\0')

Response = AIPam.scriptCmd(r,s)
Traceback (most recent call last):

   File "", line 1, in 
     Response = AIPam.scriptCmd(r,s)

   File 
"C:\Users\GWHLAB~2\AppData\Local\Temp\gen_py\3.8\E07C24C7-56CE-409F-AB60-DC7EDE9D9888x0x1x0.py", 
line 37, in scriptCmd
     return self._oleobj_.InvokeTypes(216, LCID, 1, (3, 0), ((31, 1), 
(31, 1)),cmd


TypeError: The VARIANT type is unknown (0x001f)


If you look at 
https://docs.microsoft.com/en-us/windows/win32/api/wtypes/ne-wtypes-varenum#remarks, 
VT_LPWSTR is not valid in a VARIANT, so pywin32 doesn't let you create 
them. Use VT_BSTR (or just pass a Python string) and see if that works - 
if it doesn't you probably need to contact the vendor of the package.


HTH,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 300 released

2020-11-13 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 300. 
Significantly, this is the first release to exclusively support Python 3 
- Python 2 is no longer supported. All Python source files in the repo 
are now in Python 3 syntax. To celebrate, the build numbers have jumped 
to 300 - there will not be a build 229.


There were significant changes in this release - you are encouraged to 
read the changes below carefully


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b300

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs - there were a number of new 
contributors which is great to see,


Cheers,

Mark.

Changes:

Since build 228:

* Fixed a bug where win32com.client.VARIANT params were returned in the 
reverse order. This only happened when win32com.client.VARIANT was 
explicitly used (ie, not when normal params were passed) For example:


  arg1 = VARIANT(pythoncom.VT_R4 | pythoncom.VT_BYREF, 2.0)
  arg2 = VARIANT(pythoncom.VT_BOOL | pythoncom.VT_BYREF, True)
  object.SomeFunction(arg1, arg2)

after this call, `arg1.value` was actually the value for `arg2`, and 
vice-versa (#1303, #622).


* Fixed a bug that Pythonwin had an empty `sys.argv` (@kxrob in #1607)

* Fixed a bug that prevented win32process.ReadProcessMemory() from 
working in all scenarios (#1599)


* Changed how Services implemented with 
win32serviceutil.ServiceFramework  report that they have stopped. Now if 
the SvcRun() method (or the SvcDoRun() method, which is called by 
SvcRun() by default) raises on Exception, the Service will report a 
final SERVICE_STOPPED status with a non-zero error code. This will cause 
the Service's recovery actions to be triggered if the Service has the 
"Enable actions for stops with errors" option enabled. (#1563, Lincoln 
Puzey)


* adodbapi connect() method now accepts a "mode" keyword argument which 
is the "Mode" property to set on the ADO "Connection" object before 
opening the Connection. See "ConnectModeEnum" for valid values. (Lincoln 
Puzey)


* The Windows 10 SDK is now used to build the project. This shouldn't 
cause any visible changes, but should make it much easier to build the 
project yourself.


Python 2 is no longer supported - so long, Python 2, you served us well!

Notable changes in this transition:

* Python 3 builds used to erroneously turn "bytes" into a tuple of 
integers instead of a buffer type object. Because this special-casing is 
important for performance when using massive buffers, this has been 
fixed in Python 3 so it matches the old Python 2 behavior. If you use 
arrays of VT_UI1 and expect get back tuples of integers, your code may 
break.


* Pythonwin's default encoding is now utf-8 (#1559)

* The build environment has been greatly simplified - you just need 
Visual Studio and a Windows 10 SDK. (The free compilers probably work 
too, but haven't been tested - let me know your experiences!)


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] IIS and ASP: If blocks that span multiple code blocks

2020-11-02 Thread Mark Hammond
IIS/ASP sends Python different strings to evaluate, and Python evaluates 
them individually. It's much like wanting Python code such as:


if foo:
  bar()

To be handled in Python by using:

>>> exec("if foo:\n")
>>> exec("  bar()\n")

Which doesn't work.

The semantics are largely defined by the "Active Scripting" 
specifications. I haven't kept up with that recently, so it's possible 
there have been enhancements to that spec which might make this 
possible, but if there were, they would have been targeted at making 
languages offered directly by MS better than Python.


So I'm afraid that I think you are out of luck.

Cheers,

Mark

On 2/11/2020 12:12 pm, Steven Manross wrote:

I was wondering if there's any way to support this style of coding in 
ASP/Python.

This works in VBScript (but I'm trying to remove all my VBScript), but I seem to be 
getting hit by the fact that each block of code is being analyzed as a single block of 
code and the "if" not being able to span multiple code blocks.

#VBScript
<%
If This = "THAT" Then
 Response.Write("BEFORE")
%>
 This does == THAT
 
<%
 Response.Write("AFTER")
End If
%>

What I am trying to show you is that in VBScript, an IF block can span the multiple 
code regions (<% code %>) and conditionally display the HTML in between the IF 
and END IF if the condition matches

Note that in VBScript if This = "THAT", this VBScript would display:

BEFORE
This does == THAT
  *** whatever the include file displayed
AFTER

And of course, if This <> "THAT" it wouldn't display anything from above!

However in Python, and a similarly structured code-block:

#Python
<%
if This == "THAT":
 Response.Write("BEFORE")
%>
 This does == THAT
 
<%
Response.Write("AFTER")
%>

In python, We would get (if This == "THAT"):

BEFORE
This does == THAT
  *** and whatever the include file displayed (if the include file had no 
additional logic to filter the data)
AFTER

However, in python, we would get (if This != "THAT"):

This does == THAT
  *** and whatever the include file displayed (if the include file had no 
additional logic to filter the data)
AFTER

Lastly, if I indent the Response.Write("AFTER") in this second code block 
to try and span the code block to the same conditional started in the first code block, I get a 
syntax error like this:

unexpected indent
/folder/somefile.asp, line ###
 Response.Write("AFTER")
---^

is there any way around this without doing a lot of other if blocks in each section 
of <% code %>

It sounds like an RFE to me (and probably not an easy one), but maybe I'm 
missing something?

IIS on W2016 (most recent patches)
Activestate Python: 3.8.2
pywin32==227

Please and Thank You,
Steven
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Setting service exit code on stop

2020-08-09 Thread Mark Hammond
Do you mean the process exit code? There's no direct way to influence 
that, although you can probably just arrange to kill your own process - 
you'll need to manually ensure you've set the service status before you 
do this.


See also https://github.com/mhammond/pywin32/issues/1563 where there's a 
request for something slightly different (specifically, for pywin32 to 
*not* update the status as STOPPED on an exception so Windows sees it as 
an abnormal exit) - but the work-around there is similar - just kill 
your own process.


A feature request would be fine, but a PR would be even better ;) Te 
feature request would need to be a very concrete proposal.


Cheers,

Mark

On 9/08/2020 11:19 am, Robert Kearns wrote:
> Hello all,
>
> I am having a look through the C++ source code (in
> particular win32/src/PythonService.cpp), trying to deduce a way to have
> the Python service set the exit code on stop.
>
> It appears that on a successful stop, both exit codes (svc and win32)
> are set to 0, overriding any previously set value.
>
> Does anyone know of any way around this? If not, would this be a welcome
> feature request?
>
> Best regards,
> Rob
>
> ___
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Question about DDE Advise mode

2020-08-02 Thread Mark Hammond
I'm afraid I can't remember almost anything about DDE :) I suggest you 
find the modules and examples to determine this.


Cheers,

Mark

On 2/08/2020 4:57 pm, Hylston N. Barbosa wrote:

Hi all,

I would like to know if pywin32 supports the method conversation.advise 
or only conversation.request?


If only has request, is there any other library you may know that 
supports advise?


Thank you!

--

Hylston Natann

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Pythonwin.exe - trouble on the starting line

2020-07-21 Thread Mark Hammond
Try running the command listed in README.md under the "Installing via 
PIP" section.


Mark

On 21/07/2020 9:37 am, ejohn...@earthlink.net wrote:

I wanted to look into using Pythonwin to see how difficult it would be to build 
GUIs using MFC.

I'm having problem in two different places:

1) On remote work machine, I found the path to pythonwin.exe and can launch 
that.
Under the help menu there, it looks like the "Python Manuals" manual works 
as expected.
The other option "PythonWin Reference" seemed like the place to start.
Unfortunately, that simply displays an error dialog: "The help file is not 
registered!"
I don't know where that file would be or how to get it registered.



So, I figured maybe something wasn't quite right with that installation.



2) On my local machine, I simply used pip (v 20.1.1) to install pywin32. That 
seemed to install without error.

I found Pythonwin.exe under


...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pythonwin\

But things seem even worse off here.

When I try to execute Pythonwin.exe, I get an error dialog stating:
 "The application can not locate win32ui.pyd (or Python) (126). The specified 
module could not be found."


But win32.ui.pyd exists in that same directory with Pythonwin.exe?



I see the home page for the project here: https://github.com/mhammond/pywin32
The Wiki seems to be empty.
I'm not really seeing links to documentation - am I missing those?
I'm interested in finding introductory tutorials about how to create GUIs under 
the win32 environment.

This is not going smoothly. :(


Can someone help me:
 * sort out the complaint about Help file not registered on my remote 
machine?
 * get a proper installation on my local machine so I can run Pythonwin.exe 
without error (preferably with working menu item as above)
 * point me to general tutorials about how to build GUI using win32 wrapper 
to MFC?

Thanks,
Erik Johnson


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 228 released

2020-06-13 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 228.

If all goes well, this release will be the last release that supports 
Python 2! If no significant issues are reported in the Python 2 builds 
of this release, I'll be removing all support for Python 2 from the 
repository, convert all .py files to Python 3 syntax, etc.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b228

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:

* Support for for win32evtlog.EvtFormatMessage and
  EvtCreateRenderContext (#1308)

* Support more elements in the SECURITY_LOGON_SESSION_DATA struct
  returned by win32security.LsaGetLogonSession (#1515)

* Remove trailing \0 char from win32file.FindFileNames results (#1511)

* Added win32process.ReadProcessMemory/WriteProcessMemory (#1502)

* Added win32process.VirtualAllocEx/VirtualFreeEx (#1509)

* Added win32gui.ValidateRect (#1504)

* Adodbapi corrected and updated to version 2.6.2. With this change the
  pywin32 repo will become the definitive source code for adodbapi, so
  files should never be missing again. Includes bug fix for 'named'
  paramstyle SF#28.

* Added a __repr__ implementation for PySecBufferDesc and PySecBuffer.

* Fix bug when trying to free a PySecBuffer object when the buffer was
  not allocated by the caller. This can occur when decrypting a message
  with a SECBUFFER_STREAM and SECBUFFER_DATA buffer when calling
  DecryptMessage().

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 227 released

2019-11-13 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 227 (although 
slightly sad it had to be made so quickly after 226 due to issues with 
that release and virtual environments - apologies for the inconvenience!)


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b227

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:

* This release should address problems in build 226 in virtual environments.

* Added MAPI IMsgServiceAdmin2 interface (Nick Czeczulin, #1411)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 226 released

2019-11-09 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 226.

Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b226

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:

* The directory with the pywin32 system DLLs is now added to the start 
of PATH for version 3.7 and earlier, and passed to 
os.add_dll_directory() on 3.8 and later. This will hopefully work around 
problems loading pywintypes.dll in various situations.


* Conversions to and from COM VT_DATE types should no longer lose 
milliseconds.


* Formatting eventlog messages should now handle larger messages and 
inserts (Ofek Lev via #1421)


* Fixed that win32help was very broken everywhere except 32bit 2.7 (#1434)

* A number of MAPI improvements from Nick Czeczulin.
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 225 released

2019-09-14 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 225.

Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b225

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:
* Huge shout-out to @thopiekar for helping with github triage, getting
  CI working and sane, and other general help and patches!

* Significant work by @joankaradimov in porting pywin32 so that it works
  in a MingGW/msys2 environment.

* ntsecuritycon.FILE_ALL_ACCESS had an incorrect value (#1354)

* SetSecurityDescriptorGroup now accepts None as group value (#1382)

* Fix an issue where win32gui.EnumChildWindows may throw a spurious
  exception. (#1350)

* Better support for numpy objects in COM methods (#1388, @panikc and
  @SReicheltPTV)

* PythonWin is now able to start with non-English active keyboard
  layout.

* Corrected wMilliseconds truncation in PyTime::getattro (Dorian
  Bivolaru)

* Implement PdhGetFormattedCounterArray (#1306, konserw)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 224 released

2018-09-28 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 224.

There are a few changes in this release, but the most significant one is 
that many "date" related issues with build 223 in Python 3.7 should be 
fixed.


This should help when installing pywin32 via pypi. While I still 
consider wheel support to be experimental, I encourage everyone to try 
it out and report any issues via https://github.com/mhammond/pywin32/issues.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b224

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:
* Built with a released version of Python 3.7, which fixes various date
  related issues with Python 3.7

* Fix a regression introduced in build 220 around how some COM
  properties are handled (#1211 and #1199)

* Everything is now build with the Windows 8.1 SDK. While this should
  typically be invisible, it is mentioned because it might explain
  obscure issues that creep in, so it should be explicitly called out as
  a change. On the plus side, this makes building the extensions far
  simpler.

* win32serviceutil - in GetServiceClassString, skip rewrite of file name
  (fname) when win32api.FindFiles returns an empty list, e.g., if the
  service has been packaged in a zip or exe. (fixes issue #642)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Questions regarding pypiwin32 and python 2.7

2018-05-02 Thread Mark Hammond

On 3/05/2018 9:49 am, Daniel Spisak wrote:

Mark,

      If its possible, could the wheels be published? I have an 
installer I need to update which I have to give wheels to in case of an 
offline install scenario. Thanks for the explanation of everything, 
there wasn't exactly a dearth of information I could find on what was what.


Can't you grab them directly from https://pypi.org/project/pywin32/#files ?

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Questions regarding pypiwin32 and python 2.7

2018-05-02 Thread Mark Hammond

On 3/05/2018 6:39 am, Daniel Spisak wrote:

Hello!

I am trying to do some updates of some systems that utilize pypiwin32 
and python 2.7 and I have some confusion about how to go about this. 
First, a few things:


What is the difference between pypiwin32 and pywin32? Is it just 
packaging in wheel format?


pypiwin32 is a "fork" of pywin32 which existed purely to have support 
for pypi. @xoviat helped roll the necessary changes into pywin32 itself, 
so pypiwin32 is effectively deprecated.


Why does https://github.com/Googulator/pypiwin32/releases show 220 as 
latest, but https://pypi.org/project/pypiwin32/#files shows 223?


As part of helping the migration, pywin32 builds with wheel support were 
also added to pypiwin32, but that's unlikely to continue happening.



Is that not the official repo for pypiwin32?


It is, but pypiwin32 isn't really official. You should move to using 
https://pypi.python.org/pypi/pywin32 which is built from 
https://github.com/mhammond/pywin32 - although note that the wheels 
aren't directly on github - the pywin32 release process builds both 
executable installers and wheels with the former uploaded only to github 
and the latter uploaded only to pypi. If there was a good reason to put 
the wheels directly on github, I'd be happy to also do that for future 
releases.


HTH,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug reporting

2018-03-05 Thread Mark Hammond

That sounds fine to me.

On 5/03/2018 6:53 am, Vernon D. Cole wrote:

Here is what I propose:

1) This time, rather than copy a selected (major) part of the adodbapi 
source files over to their pywin32 directory,

I would copy _all_ of the files.

2) Adjust adodbapi/MANIFEST.in and setup.py to create a proper PyPi 
submission from that directory.


That sounds good, but could you please tweak setup.py so that it sticks 
the files into "../dist", so everything I need to release ends up in the 
same dir.


You'll probably also need to tweak adodbapi on pypi so I can upload.

3) Adjust the pywin32 MANIFEST.in to include a subset of adodbapi files 
that actually works.


4) Put a simple go/no-go test of adodbapi (perhaps ACCESS database only) 
into the pywin32 test suite.


5) document in SourceForge that future updates will take place in the 
pywin32 repo.


I guess I'll look forward to a PR :)

Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug reporting

2018-02-26 Thread Mark Hammond

On 27/02/2018 5:40 am, Vernon D. Cole wrote:
Second: the effective "bus size" of the adodbapi repo is *one*. The 
other three authorized maintainers are inactive.  Indeed, the way I got 
approved as a maintainer 15 years ago (has it really been that long?) 
was to document to SourceForge that the then-existing two maintainers 
were unresponsive. Moving the working source into the pywin32 repo would 
solve that problem.


It's not immediately clear that it would though. pywin32 itself has the 
exact same issue (ie, it's largely just me), and I don't use or know 
much about adodbapi - so it seems somewhat likely you'd have the same 
"bus size" - just on a different bus :)


My research this morning suggests that by suitable editing of the 
MANIFEST.in file in the pywin32 root, and the  /adodbapi/MANIFEST.in and 
./setup.py we could effectively send two seemingly independent (but 
source locked) versions of adodbapi to PyPi.  That should keep both 
CPython/pywin32 and IronPython use cases covered.  Should I pursue that?


When building pywin32 I don't send *any* versions of adodbapi to pypi, 
so I'm really not sure what that means. I'm reluctant to agree that 
building pywin32 will create many discrete wheels - I already need to 
upload wheels for each python version supported and for 64 and 32 bits 
and making the build and release process more convoluted doesn't sound 
like a win for me.


So can you please explain in more detail what is being proposed here, 
and why it would be preferred to splitting adodbapi into its own repo on 
github, possibly including removal of it from pywin32 if the duplication 
causes problems?


Cheers,

Mark


--
Vernon


I spent the morning reviewing the documentation for setuptools and 
wheels and such.




On Sun, Feb 25, 2018 at 7:35 PM, Bob Kline <bkl...@rksystems.com 
<mailto:bkl...@rksystems.com>> wrote:


On Sun, Feb 25, 2018 at 6:18 PM, Mark Hammond
<mhamm...@skippinet.com.au <mailto:mhamm...@skippinet.com.au>> wrote:

> 1) There's a relatively easy fix that can be made to the copy of adodbapi
> which is inside pywin32.

Right. Basically, I think what needs to happen is for the fork on
GitHub to be brought in sync with the working code on SF. I'm going to
guess it's not quite as simple as that, because we'd want to be
careful to preserve any patches which got applied on GitHub, but
didn't make it to the original repo. Don't know for sure that there
are any, but we should check.

> 2) There's a concern regarding some IronPython bindings for adodbapi which
> aren't in pywin32 and Vernon was asking something whether they should also
> be included in pywin32.

As I understand it, the code to support IronPython is already included
in what's on GitHub. I think Vernon's hoping that there's a way to
script an export of just the adodbapi portion of your GitHub repo for
the use of the IronPython users (who, as you correctly point out, have
no use for the pywin32 bits). If that's possible (and I can't see why
it wouldn't be, as GitHub is pretty easy to script), he would be able
to avoid the tedium and risks involved in having to maintain the same
code base in two different places. It would also eliminate the "where
am I supposed to file bugs" confusion, as well as make it easier to
persuade others to assist with maintenance of the code. Most of the
adodbapi code is common for IronPython and CPython users, and I don't
see that the presence of "if IronPython: ..." code in the
mhammond/pywin32 repo does any harm (after all, it's already there and
I'll bet no one has noticed).

I hope that makes things a little clearer. But this explanation is
speculation on my part, and I should really let Vernon say what he
means for #2.

Regards,
Bob




___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 223 released

2018-02-25 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 223.

The only significant change in this release is to help pywin32 when 
being installed as a wheel (ie, via pypi) - the pywin32_system32 
directory is now added to PATH. Thanks to @xoviat via 
https://github.com/mhammond/pywin32/pull/1153


This should help when installing pywin32 via pypi. While I still 
consider wheel support to be experimental, I encourage everyone to try 
it out and report any issues via https://github.com/mhammond/pywin32/issues.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b223

and via pypi.

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:
* pywin32.pth now arranges for the pywin32_system32 directory to be on
  PATH to help with pypi installations (thanks to @xovian via #1153)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug reporting

2018-02-25 Thread Mark Hammond

On 26/02/2018 1:12 am, Bob Kline wrote:

On Sun, Feb 25, 2018 at 12:31 AM, Mark Hammond
<mhamm...@skippinet.com.au> wrote:


I'm afraid Bob is going to get quite frustrated if he gets upset about
responses taking more than a few days to come in.


I'm going to assume you hadn't yet read the thread leading up to
Vernon's last message. Here is some historical context which you may
be missing.


Thanks for the response. I did read the thread, but I'm still a little 
confused by some of the context.


IIUC:

1) There's a relatively easy fix that can be made to the copy of 
adodbapi which is inside pywin32.


2) There's a concern regarding some IronPython bindings for adodbapi 
which aren't in pywin32 and Vernon was asking something whether they 
should also be included in pywin32.


Assuming I'm not misunderstanding the issue, then we should just apply 
the fix for (1). However, I'm not sure what (2) would mean for pywin32's 
build process nor for existing IronPython users.


Hopefully Vernon will clear things up when he gets back.

Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Bug reporting

2018-02-24 Thread Mark Hammond

On 22/02/2018 4:04 am, Vernon D. Cole wrote:
Ummm ... "I'm buried under a project right now, and I won't be able to 
get back to you until next Friday."


I'm afraid Bob is going to get quite frustrated if he gets upset about 
responses taking more than a few days to come in. While pywin32 has 
moved to github, I honestly don't expect the release cadence, nor the 
amount of time I can offer the project to change from what it has been 
over the last few years.


My day job has been burning up a lot 
of time, and we had an important Family Occasion on Saturday that ate 
the entire weekend. Sorry.  I will try to do better at context switching.


There's no need to apologize for life getting in the way of maintaining 
free and open source software.



You are heading in exactly the correct direction with the test suite.

As for a single copy of the source -- would it work to keep the 
stand-alone (Iron Python) distribution in the /adodbapi directory on 
GitHub, and just ignore the extra files (for the big distribution) by 
not putting them in the main manifest?  @Mark -- please chime in here...


I'm afraid I don't really know what is being asked here. adodbapi has 
been in pywin32 for many years - what changes exactly are being 
proposed? I see mention of IronPython, but I don't understand how 
IronPython components in pywin32 makes sense for either the people 
releasing pywin32 packages (ie, me), nor how IronPython users would take 
advantage of them (ie, I assume asking them to install pywin32 doesn't 
make sense).


Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 222 released

2018-01-20 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 222. There are 
some notable changes with this release:


We have moved to github for development and releases. 
https://github.com/mhammond/pywin32 is the new home of pywin32 and all 
builds will be released there.


The build process now also builds "wheels", so "pip install pywin32" 
should also work - note that this support is EXPERIMENTAL - I still 
recommend you use the binary (ie, .exe installers) [Note: I'm struggling 
with PyPi refusing to allow me to upload the 3.7-64bit wheel, but 
hopefully this will be fixed soon]


Particular thanks to @xoviat, who helped with prompting me to make the 
change, imported all the issues from sourceforge, and helped with the 
process for creating the wheels.


Note also that older Python versions are no longer supported - builds 
are only made available for Python 2.7 and Python 3.5+.


As usual, this release also addresses a number of bugs with previous 
builds - I've appended the change log at the end of this mail.


Downloads are available at:

  https://github.com/mhammond/pywin32/releases/tag/b222

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://github.com/mhammond/pywin32/issues


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs.


Cheers,

Mark.

Changes:

Since build 221:

* !! Moved to github for development !!. 
https://github.com/mhammond/pywin32 is the new home of pywin32 and all 
builds will be released there. The build process now also builds 
"wheels", so "pip install pywin32" should also work (but see README.md 
for some limitiations of using pip)


  Particular thanks to @xoviat, who helped with prompting me to make 
the change, imported all the issues from sourceforge, and helped with 
the process for creating the wheels.


  As a part of this, I've changed every issue in this file from "#xxx" 
to "#sfxxx" to indicate they refer to the old sourceforge issue numbers.


* Older Python versions are no longer supported - builds are only made 
available for Python 2.7 and Python 3.5+.


* For Python 3.x, a win32 FILETIME or TimeStamp which is greater than 
the datetime module can handle will return datetime.datetime.max instead 
of throwing (fixes issue #748)


* win32file - fix ERROR_BAD_LENGTH in GetFileInformationByHandleEx in 
x86 builds(issue #752, rbschk)


* MakeModuleForTypelib no longer catches COM exceptions, so no longer 
can return None. This is what the docstring always claimed the behaviour 
was and makes things less error prone. If you explicitly call this 
function and handle None, you will need to wrap the call in an exception 
handler.


* Change PyIMAPIFolder CopyMessages, DeleteMessages, and EmptyFolder to 
return the HRESULT (Nick Czeczulin via patch #sf162)


* Fix a reference leak of Py_None in a couple of MAPI methods (Nick 
Czeczulin via patch #sf149)


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Moving pywin32 source from Sourceforge to Github

2017-10-09 Thread Mark Hammond
Hi all,
  Sourceforge appears to be in its death throes, and with Python moving
to git/github I've decided to do the same. I hope that this might
encourage more contributors, particularly for better supporting
PyPi/pip, creating wheels etc.

Effective immediately, the new repo for pywin32 is
https://github.com/mhammond/pywin32.

At some stage I will cleanup the old HG repo (eg, possibly create a
final checkin which removes all files and adds a readme pointer to
github) and I'll move the existing relevant issues from sourceforge to
github - although I looked briefly at "importing" all the old issues I
don't think there's enough value in keeping some of the ancient issues
around in github - they will still be available in sourceforge.

I haven't yet decided what to do about distributing binaries, but it's
likely I'll also use github for that and move the old binaries from
sourceforge - but for now, all binaries are still available on sourceforge.

Note also that I'm about to leave on a 4 week vacation, so most of this
will not happen until I'm back, but I wanted to make this announcement
before I left so any potential contributors can get started.

Cheers,

Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] [ANN] pywin32 build 221 released.

2017-03-28 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 221.  This release 
has addressed a number of bugs with previous builds (most notably 
failure to install in Python 3.6) and has added a few new features, 
mostly around win32com.client.exchange - I've appended the change log at 
the end of this mail.


Downloads are available at:

  https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://sf.net/projects/pywin32.


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs to the tracker.


Cheers,

Mark.

Changes:

Since build 220:

* Add PyIMapiSession::AdminServices method (Nick Czeczulin via patch
  #161)

* Allow win32com.client.CastTo() to have a typelib specified, which will
  be used to locate the object definition (Pieter Aarnoutse via patch
  #136)

* Add pythoncom.StgOpenStorageOnILockBytes (Nick Czeczulin via patch
  #135)

* IDispatch failures will try and get error information via IErrorInfo
  (Stefan Schukat via patch #130)

* A null SPropTagArray will now return None instead of crashing.

* New mapi/exchange interfaces PyIExchangeManageStoreEx,
  PyIMAPIAdviseSink, PyIMsgStore::Advise, PyIMsgStore::Unadvise,
  HrAllocAdviseSink, HrThisThreadAdviseSink, and HrDispatchNotifications
  (Nick Czeczulin)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Problem registering COM server at installation time

2016-01-31 Thread Mark Hammond

On 17/01/2016 6:51 AM, Malte Forkel wrote:

Hi,

I'm trying the register a COM server using the install script of a built
distribution, created with the  bdist_wininst format of distutils. But
the script fails with a message that MSVCR90.dll can't be found.
Registering the server after the installer is done works fine. I'm using
Python 2.7.11 and pywin32-220 on Windows 7.1 64 bit.


That sounds a little strange - the script should only be executed after 
python27.dll is loaded, which itself relies on msvcr90.dll.


Does it happen to work if you put the installer executable in the same 
directory as python27.dll?


Mark



From what I see in Process Monitor, I think that the search for
MSVCR90.dll starts in the installer's directory, moves up the directory
tree and than uses the system search path. Using Dependeny Walter
(depends), I found that ''pythoncom27.dll'' and ''pywintypes27.dll''
can't locate msvcr90.dll, while pythoncomloader27.dll finds it (i.e.,
one of them).

I tried an to import pythoncom first, hoping for some DLL magic, but
that fails as well:

  Traceback (most recent call last):
File "", line 16, in 
File "C:\Program Files\Python27\lib\site-packages\pythoncom.py", line 2, in 

  import pywintypes
File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", line 
124, in 
  __import_pywin32_system_module__("pywintypes", globals())
File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", 
line 98, in __import_pywin32_system_module__
  raise ImportError("No system module '%s' (%s)" % (modname, filename))
  ImportError: No system module 'pywintypes' (pywintypes27.dll)

I'm not a Windows guy, so I'm running out of ideas what to do. Any advice?

Thanks in advance,
Malte
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Have icon overlays persist after machine restart in Python

2016-01-12 Thread Mark Hammond

On 13/01/2016 6:09 AM, Alexander Jewell wrote:

I should have checked the setup file before attaching, that's actually
from a third test I ran that tried running an EXE.
In my earlier test I had create_dll = True.
During that test I ran "regsvr32 overlays.dll" (with terminal running as
Administrator) and got a success message, but no registry entries were
added and none of the logging present in the class was triggered, so it
didn't run the main method in the provided script or instantiate the class.

Am I mistaken in thinking that regsvr32 of the DLL replaces the use of
win32com.server.register.UseCommandLine? Do I actually need both?


No - the regsvr32 should be all that is necessary. Because you are in a 
py2exe world, the file ./py2exe/py2exe/boot_com_servers.py is used to 
perform the registration - some diagnostics there should help.



So I would need to:
Run the python script which writes the overlay handler GUID to the
registry and calls win32com.server.register.UseCommandLine
Run (with elevated privileges) regsvr32 to register the DLL
Restart explorer.exe process so that Explorer picks up the overlays

Is this correct?


It should be possible to do without an explicit script, executing 
regsvr32 in an elevated process should be all you need. I think it will 
also be possible to avoid restarting explorer (there's some 
win32com.shell function you can call IIRC) but for now, you should just 
focus on getting the registration working (ie, to see the registry 
entries being written) and then seeing your extension work when manually 
restarting explorer.


Mark



If so, I would have to ship both the script and the DLL build from the
script, which shouldn't be a problem; I guess I just assumed that having
two copies of the same code was incorrect.

Thanks for bearing with me
Alex

On Mon, Jan 11, 2016 at 5:43 PM, Mark Hammond <mhamm...@skippinet.com.au
<mailto:mhamm...@skippinet.com.au>> wrote:

setup_2.py has:

> setup(console=['overlays.py'])

So that's going to create a console program with no COM support.
setup.py has:

># specify which type of com server you want (exe and/or dll)
>create_exe=True,
>create_dll=False

So you are only going to get a COM object that can be created as a
.exe. Explorer wants only inproc objects (ie, those hosted in a
DLL), so you want create_dll=True and create_exe=False - you should
then get a DLL you can register with regsvr32.

HTH,

Mark



On 12/01/2016 4:44 AM, Alexander Jewell wrote:

Hi Mark,

I followed your suggestion and the SO threads touching on this area.

(http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7)
Using py2exe I generated a dist folder with an exe of my overlay
script.
Running this on a machine without Python installed shows all of the
proper log messages being generated and registry entry created
for my
overlay handler, however there's no indication that explorer is
loading
and running the overlay handler.

Following the SO examples I instead generated a COM DLL from the
same
source. I can copy this dist directory and new DLL over to a machine
without Python and use regsrv32 to register the DLL without
errors, but
it doesn't run the main method which is what sets the required
registry
entries and calls UseCommandLine so it doesn't look like it's being
registered correctly at all.

Sorry for the newb questions, but I seem to have a big gap in my
understanding of the mechanism.

So, the way that I'm using it at least, py2exe is either
generating an
EXE that will register correctly but not provide a COM object
with the
correct environment for explorer to run the overlay handler, or
a DLL
that should be self contained and functional but not provide the
registration functionality.

I've attached my primary script (Overlay Handler + logging and some
helper objects) as well as 2 py2exe setup scripts I've tried.

I'm hoping you can point out a huge flaw in my thinking, or an
obvious
step that I'm missing in the registration process.

Thanks again for any help you can provide.


On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell
<balexjew...@gmail.com <mailto:balexjew...@gmail.com>
<mailto:balexjew...@gmail.com <mailto:balexjew...@gmail.com>>>
wrote:

I created a fresh Python 2.7 environment with pywin and
py2exe and
stripped down my overlay handler to the basics to better
troubleshoot.

Running my script (command line or in PyCharm) registers
everything
correctly, just

Re: [python-win32] Calling unregistered COM libraries via Python

2016-01-11 Thread Mark Hammond

On 12/01/2016 4:21 AM, Manowitz, David wrote:

Is it possible, either via the win32com extensions or the comtypes
package (or some other package), to call to an unregistered COM
library?  It doesn’t seem so, but I wanted to check.


COM uses the registration info to locate and load the library, so in 
general it's not possible. You could always just register it though...


Mark





Thanks,

David Manowitz

Office of Petroleum, Natural Gas, and Biofuels Analysis

Energy Information Administration 

U.S. Department of Energy

1000 Independence Ave S.W.

Washington, DC 20585

Tel: +1-202-586-2815





___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Have icon overlays persist after machine restart in Python

2016-01-11 Thread Mark Hammond

setup_2.py has:

> setup(console=['overlays.py'])

So that's going to create a console program with no COM support. 
setup.py has:


># specify which type of com server you want (exe and/or dll)
>create_exe=True,
>create_dll=False

So you are only going to get a COM object that can be created as a .exe. 
Explorer wants only inproc objects (ie, those hosted in a DLL), so you 
want create_dll=True and create_exe=False - you should then get a DLL 
you can register with regsvr32.


HTH,

Mark


On 12/01/2016 4:44 AM, Alexander Jewell wrote:

Hi Mark,

I followed your suggestion and the SO threads touching on this area.
(http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7)
Using py2exe I generated a dist folder with an exe of my overlay script.
Running this on a machine without Python installed shows all of the
proper log messages being generated and registry entry created for my
overlay handler, however there's no indication that explorer is loading
and running the overlay handler.

Following the SO examples I instead generated a COM DLL from the same
source. I can copy this dist directory and new DLL over to a machine
without Python and use regsrv32 to register the DLL without errors, but
it doesn't run the main method which is what sets the required registry
entries and calls UseCommandLine so it doesn't look like it's being
registered correctly at all.

Sorry for the newb questions, but I seem to have a big gap in my
understanding of the mechanism.

So, the way that I'm using it at least, py2exe is either generating an
EXE that will register correctly but not provide a COM object with the
correct environment for explorer to run the overlay handler, or a DLL
that should be self contained and functional but not provide the
registration functionality.

I've attached my primary script (Overlay Handler + logging and some
helper objects) as well as 2 py2exe setup scripts I've tried.

I'm hoping you can point out a huge flaw in my thinking, or an obvious
step that I'm missing in the registration process.

Thanks again for any help you can provide.


On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell <balexjew...@gmail.com
<mailto:balexjew...@gmail.com>> wrote:

I created a fresh Python 2.7 environment with pywin and py2exe and
stripped down my overlay handler to the basics to better troubleshoot.

Running my script (command line or in PyCharm) registers everything
correctly, just like before, but running the py2exe generated EXE
seems to be registering but no overlays are appearing, which looks
just like what happens when I restarted explorer.exe in my previous
attempt (logged messages during registration, plus a manual check of
the registry look good but nothing generated by IsMemberOf.

I'm going to try generating a DLL and manually registering following
the example
here: 
http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7

It looks like this example came out of a mail thread with you back
in 2011 so I'll try to follow the advice there and report back.

Thanks again for the help Mark.

On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond
<mhamm...@skippinet.com.au <mailto:mhamm...@skippinet.com.au>> wrote:

On 7/01/2016 6:21 AM, Alexander Jewell wrote:

Unfortunately my end goal was to bundle the entire
application as an exe
with PyInstaller so that the end user does not actually have
Python
installed.

Do you think it would be possible to package the overlay
handler in such
a way that explorer would not need access to an installed Python
interpreter?
Embedding(https://docs.python.org/3.4/extending/embedding.html)
seems
to still require a Python interpreter but Cython sounds
promising.


I've used py2exe for this in the past and it works fine - you
need to end up with a stand-alone directory that functions
independently of any installed Python - py2exe bundles Python
itself, pywin32, etc in just this way. Last I tried though, it
only worked with python 2.x

Mark


-Alex

On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond
<skippy.hamm...@gmail.com <mailto:skippy.hamm...@gmail.com>
<mailto:skippy.hamm...@gmail.com
<mailto:skippy.hamm...@gmail.com>>> wrote:

My guess is that the environment (eg, PATH, PYTHONPATH
etc) for the
new explorer instance isn't setup correctly - how is the
explorer.exe process started when it *does* work? It's
hard to
answer without more info, but Python ends up inside

[python-win32] [ANN] pywin32 build 220 released.

2016-01-11 Thread Mark Hammond

Hi all,
  I'm happy to announce the release of pywin32 build 220.  This release 
has addressed a number of bugs with previous builds (most notably 
failure to install in Python 3.5) and has added a few new features - 
I've appended the change log at the end of this mail.


Downloads are available at:

  https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/

For initial support (eg, to ask questions about the release etc), please 
contact this mailing-list (python-win32@python.org).  If you want to 
report a bug, please do so at https://sf.net/projects/pywin32.


As always, thanks to everyone who contributed to this release, both in 
terms of code and reporting bugs to the tracker.  As usual, Roger Upole 
contributed a huge number of fixes and enhancements for this release - 
thanks!


(Regarding SourceForge - I'm hoping to start a discussion soon about 
moving away from their platform due to some high-profile issues with 
their site. Given Python itself is moving to github in the future, it 
may make sense to move pywin32 there too. But in the interests of 
getting a build out that works with Python 3.5, I decided to stick with 
SourceForge for now. If your browser or adblocker reports the site as 
malicious, then you probably need to add an exception)


Cheers,

Mark

Changes:

Since build 219:

* win32com - sys.argv[0] may be set to a bytes object instead of a
  string on Python 3 when implementing an in-process COM object.

* Fix that allows a property to be fetched on COM objects to work in
  more cases (Fredrik Orderud via patch #155)

* Disabled exchange and exchdapi modules on Python 2.5 due to unresolved
  build issues.

* Fix potential crash in SHGetIDListFromObject and SHGetFileInfo issues
  (rupole)

* Allow GetShortPathName to handle long paths in unicode mode (ruple)

* Fix intermittent crash in win32cred.CredRead() (bug #670, rupole)

* Support PT_MV_BINARY MAPI properties, (patch #37) and many other MAPI
  improvements (Nick Czeczulin)

* Fix username used with EvtOpenSession (bug #688, rupole)

* Fix OutputDebugString encoding in wide builds (patch #142, rupole)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Have icon overlays persist after machine restart in Python

2016-01-06 Thread Mark Hammond
My guess is that the environment (eg, PATH, PYTHONPATH etc) for the new 
explorer instance isn't setup correctly - how is the explorer.exe 
process started when it *does* work? It's hard to answer without more 
info, but Python ends up inside explorer.exe, so the environment that 
explorer.exe starts with is important.


Mark

On 6/01/2016 8:29 AM, Alexander Jewell wrote:

So, thanks to the Tim Golden guide
 
(http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) and
other questions
 on
Stack Overflow I have a script that will show overlays on files and
folders based on their "state" similar to Tortoise SVN or Dropbox. Works
great.

My problem is that once I restart the explorer.exe process or the OS
itself and open explorer there are no longer any overlays.

My first thought:

  * Have the service that actually manages file state detect that no
requests have come in and just re-register the overlay handler

The problem here is that registration requires elevated permissions
which is acceptable on initial install of the application by the end
user but not every time they restart their machine.

Can anyone suggest what I might be missing here? I have the class
BaseOverlay and its children in a single .py file and register from my
main app by calling this script using subprocess.

|subprocess.check_call("C:\scripts\register_overlays.py",shell=True)|

Is Explorer not able to re-load the script as it is Python? Do I need to
compile into a DLL or EXE? Would that change the registration process?

Here's the registration call:

|win32com.server.register.UseCommandLine(BaseOverlay)|

Here's the class(simplified):

|classBaseOverlay:_reg_clsid_
='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_
='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_
=['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_
=[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE
defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK|

Thanks for any help you can provide,

Alex Jewell




___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Have icon overlays persist after machine restart in Python

2016-01-06 Thread Mark Hammond

On 7/01/2016 6:21 AM, Alexander Jewell wrote:

Unfortunately my end goal was to bundle the entire application as an exe
with PyInstaller so that the end user does not actually have Python
installed.

Do you think it would be possible to package the overlay handler in such
a way that explorer would not need access to an installed Python
interpreter?
Embedding(https://docs.python.org/3.4/extending/embedding.html)  seems
to still require a Python interpreter but Cython sounds promising.


I've used py2exe for this in the past and it works fine - you need to 
end up with a stand-alone directory that functions independently of any 
installed Python - py2exe bundles Python itself, pywin32, etc in just 
this way. Last I tried though, it only worked with python 2.x


Mark



-Alex

On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond <skippy.hamm...@gmail.com
<mailto:skippy.hamm...@gmail.com>> wrote:

My guess is that the environment (eg, PATH, PYTHONPATH etc) for the
new explorer instance isn't setup correctly - how is the
explorer.exe process started when it *does* work? It's hard to
answer without more info, but Python ends up inside explorer.exe, so
the environment that explorer.exe starts with is important.

Mark

On 6/01/2016 8:29 AM, Alexander Jewell wrote:

So, thanks to the Tim Golden guide

<http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html>

(http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html)
and
other questions

<http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python#>
on
Stack Overflow I have a script that will show overlays on files and
folders based on their "state" similar to Tortoise SVN or
Dropbox. Works
great.

My problem is that once I restart the explorer.exe process or the OS
itself and open explorer there are no longer any overlays.

My first thought:

  * Have the service that actually manages file state detect that no
requests have come in and just re-register the overlay handler

The problem here is that registration requires elevated permissions
which is acceptable on initial install of the application by the end
user but not every time they restart their machine.

Can anyone suggest what I might be missing here? I have the class
BaseOverlay and its children in a single .py file and register
from my
main app by calling this script using subprocess.

|subprocess.check_call("C:\scripts\register_overlays.py",shell=True)|

Is Explorer not able to re-load the script as it is Python? Do I
need to
compile into a DLL or EXE? Would that change the registration
process?

Here's the registration call:

|win32com.server.register.UseCommandLine(BaseOverlay)|

Here's the class(simplified):

|classBaseOverlay:_reg_clsid_
='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_
='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_
=['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_

=[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE

defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK|

Thanks for any help you can provide,

Alex Jewell




___
python-win32 mailing list
python-win32@python.org <mailto:python-win32@python.org>
https://mail.python.org/mailman/listinfo/python-win32




___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Windows 10

2015-10-28 Thread Mark Hammond

On 26/10/2015 10:07 AM, Laura Creighton wrote:

Can I suggest a mailing list name change to reflect 64 bit windows?

python-windows would be my suggestion 


python-windows would be a better name, but I don't think it is worth the 
disruption of changing the email address of the list. I think the best 
we can do now is to ensure the summary for the list make things clear 
(which I think it does - "32" doesn't get mentioned)


Mark
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


  1   2   3   4   5   6   7   8   9   >