Jump to content
Registration disabled at the moment Read more... ×

Tom F

Members
  • Content Count

    235
  • Joined

  • Last visited

  • Days Won

    5

Tom F last won the day on March 12 2023

Tom F had the most liked content!

Community Reputation

85 Excellent

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks, Kiriakos. I really appreciate your taking the time to answer my post. Thank you. However, I decided that P4D in a thread was too difficult to use unless I had far more knowledge of threads. So, I'm now just shelling out to Python and running my .py that way. Hooking up PythonExec was too difficult for me to get working. And I heard from several other members of our group that they, too, had abandoned trying to use it for the same reason. I encourage you to create a demo that is a bare-bones "hello, world" skeleton for using PythonExec, including instantiating it (perhaps not on a form, but DM or non-form unit), launching it, receiving stdout/stderr, getting exit codes, and (particularly vexing for me) proper shutdown and cleanup. (Like most overly optimistic programmers, I think I was probably only a handful of lines from getting all this going with PythonExec.) I think such a demo would be very welcome by many. And it would ease the startup process a lot. Thank you again for your response. And thank you for your contributions to our community. Tom
  2. Goal: a standalone unit that wraps Python4Delphi so Python code runs inside a Delphi 12 Windows thread, not a Python thread. The main thread must stay responsive, and the user must be able to cancel the worker thread. Workload: Python opens ~30 files sequentially, about one second per file, and prints one line per file. (i.e. a low number of stdout and perhaps stderr lines). Less than 100 lines of py code using numpy and others. I don't need any py code written, just the Delphi piece. Reference: https://github.com/pyscripter/python4delphi/wiki/PythonThreads Status: I have a prototype that runs, but I am not confident about thread safety or correctness, especially around a clean thread stop, engine shutdown, and memory management. I redirect stdout and stderr via TInputOutput. Stdin is not needed. During development I've been using CodeSite or OutputDebug string. Later I will need to marshal messages safely to the main thread. Ask: I need someone with prior experience doing this kind of thing. Paid consulting for this small project. If you're interested, please contact me here via DM. Me: long-time Delphi programmer. Sample code to show the path I was on: procedure TForm1.InitializeEngine; // Dynamically configure paths to a begin Codesite.Clear; if PythonEngine1.AutoLoad then raise Exception.Create('Caught: So you don''t get two instances of the engine, turn off PythonEngine.AutoLoad in the Object Inspector'); PythonEngine1.UseLastKnownVersion := False; PythonEngine1.DllName := 'python312.dll'; PythonEngine1.DllPath := 'C:\Program Files (x86)\MyApp\Python\Python312-32'; PythonEngine1.SetPythonHome('C:\Program Files (x86)\MyApp\Python\Python312-32'); try PythonEngine1.LoadDll; if not PythonEngine.PythonOK then CodeSite.Send( 'Caught: PythonEngine failed to load. (Probably a DDLName or DLLPath error.' ); except On E: Exception do CodeSite.Send( 'Caught: Error in FormCreate while loading the DLL', E.Message ); end; end; procedure TForm1.btnRunClick(Sender: TObject); var CodeToRun: String; begin try CodeToRun := 'print("hello world!")' TPythonThread.Py_Begin_Allow_Threads; ThreadPythonExec( procedure {ExecuteProc} begin GetPythonEngine.IO := PythonInputOutput1; // do these assignments go here, or before the ThreadPythonExec GetPythonEngine.FatalMsgDlg := FALSE; GetPythonEngine.FatalAbort := TRUE; GetPythonEngine.Py_FatalError := @MyFatalMessage; try GetPythonEngine.ExecString(AnsiString(CodeToRun)); except on E: Exception do CodeSite.Send( 'Caught: ExecString Exit value', e.Message ); // I definitely need this end; end, procedure {TerminateProc } begin CodeSite.Send( 'Thread ended.' ); TPythonThread.Py_End_Allow_Threads; // Does this go here??? end ); except on E: Exception do CodeSite.Send( 'Caught: Exception with engine when running= ' + E.Message ); end; end;
  3. Tom F

    12.3 April Patch 1.0 failed to install

    Thanks, Michael! It's sad situation that one would have to reverse engineer the installer results to try to determine what happened.
  4. Tom F

    12.3 April Patch 1.0 failed to install

    >> But you can click "Ignore Patch", this only take away the advertise from Welcome Screen, you can always choose to install selecting the patch form the list. The point of my original post is that I have no idea if the patch was successfully installed and if it wasn't, how to install it. THAT'S the question I'm asking here. I appreciate your trying to help and understand now that you do not know the answer. Hopefully someone else will have the answer.
  5. Tom F

    12.3 April Patch 1.0 failed to install

    @DelphiUdIT Thanks for posting your answer to my question about installing the patch. You said, "No, this is the note about the April Patch. Take care that this is showed ONLY IF YOU INSTALL the patch with GETIT." Unfortunately, I'm not sure I understand your answer. Are you saying the Help screen says that the patch *is* installed??? And if that's true, then can I safely click "Ignore Patch on the screen below? In your second sentence, are you saying that the problem I'm having only occurs if I install the patch with GetIt? Of course, I've already done that, so I'm not sure what I can do now. Thanks again for your help.
  6. I got this message when installing the April Patch 1.0: "RAD Studio found some failed deferred Getlt packages. You can revise the list of packages that failed in the Getlt Packages dialog box, and decide to cancel them or try to process" I don't see any "list of packages that failed in the GetIt Packages dialog box." I'd like to get this installed rather than ignoring it. Below is my current Help > About screen. It says Update 3 has been installed. Is that April Patch 1.0?!
  7. If you haven't tried his demo projects yet, I've attached a screen recording I just made that shows to do a simple playback with Mitov's VideoLab. It literally couldn't be easier! Although I show a no-code example here, you can definitely add code using the extensive flexibility he provides. One especially important thing when implementing any video application is to keep your app responsive. Mitov has done a wonderful job using threads to keep apps responsive. And he provides hooks where your app can get access to the video frames in real-time if you want to examine them, etc. MitovVideoDemo.mp4
  8. Mitov's VideoLab will do this. It comes with sample projects that show how to do this with just a few lines of code. We've used his tools for 15 years. His libraries are unbelievably powerful. And GREAT support.
  9. @Gex99 It's always nice to know that someone benefited from the work I put it in to solve a problem. It was a tricky problem that, as you saw from my posts, took a while to solve. The solution I eventually found was easy to implement. I'm glad it worked for you too. Thanks for saying something.
  10. Sorry, I don't recall if there was a problem or if it was improved. It's been a while since I used it.
  11. As Cristian says, use a profiler! I have been happy using NexusQA profiler for many years. There are other profilers out there, some free. But, my time is worth enough that spending a little money to get a commercial product was well worth it to me. There are profiler discussions elsewhere on the forum here. Avoid AQTime. It's a good company selling an archaic, inferior (and pretty-much unsupported in my experience) Delphi Profiler. Also, evaluate your SQL. Look at the execution plan, consider stored procedures, etc. But, don't do anything until you know where your bottlenecks are in code or SQL.
  12. Another vote for Nexus Quality Suite | NexusDB. And, another downvote for AQTime. It's been terrible for years. I'm glad that SmartBear is finally abandoning it.
  13. @Brandon Staggs and @Lajos Juhász I agree: none of this should have been necessary. I've been using Delphi since Delphi 1 and it's only been in the past year that this problem appeared. I don't know of anything specifically on my machine that might have caused this. I didn't have the AppCompatFlags/Layers registry entry. I'm running a "stock" Win10 machine with main stream security software. I suppose it's likely I did something to cause this problem. But, that it happened on a clean install of D12 surprised me. It's hard to imagine how the problem came to be. But, I'm glad it's behind me. 🙂
  14. FIX FOUND! My bds.exe is no longer insisting it is run with Administrator privileges. This area of Windows is new to me, so perhaps my analysis and solution below are incorrect. Please be gentle on me if I'm wrong about all this! I know of four ways that Windows determines whether an exe requires UAC Admin elevation (Run as Admin). 1. The flag/checkbox on a desktop icon's Property screen's Security tab 2. The standard registry. 3. An Application Compatibility database (?) described by wosHub (or is this just the registry as edited by Microsoft's Application Compatibility Administrator?) 4. The .exe's manifest I found an easy way to view and edit the registry keys using Nirsoft's AppCompatibilityView (https://www.nirsoft.net/utils/app_compatibility_view.html) (Of course, RegEdit would work too, but you'd have to know all the fields and flags to do it manually like that) Nirsoft's AppCompatibilityView showed that the registry contained an entry that was forcing Windows to launch bds.exe with administrative rights. (See attached screen capture of the Nirsoft app) After I deleted that entry, the bds.exe Ran as Invoker and did not require UAC elevation. I believe that the D12 installer must have added an entry to the registry that forced UAC elevation for administrative rights. I don't know why the installer would do that. Nor do I know how else that entry could have occurred. After I deleted the registry entry using Nirsoft's app, I uninstalled (thoroughly with Revo) and re-installed D12. Now, when I launched the bds.exe, it started without the UAC popup. But... I then got: Exception Exception in module coreide290.bpl at 0000F3B3. Internal Error: AppIniFile was not initialized. If I ran as Admin, I did not get that error. Other than one unresolved RSP in the old JIRA database, I could find nothing about this error. I couldn't find a file on my machine with the name "AppIniFile." And, Procmon didn't give me any further information about what was going on either. I was able to follow the instructions at https://woshub.com/how-to-disable-uac-for-specific-applications/ to create a batch file that when run, causes the bds.exe to run with RunAsInvoker. I wasn't happy with a batch file sitting between my keyboard and launching bde.exe. (For example, what would happen if I double-clicked on a .dproj in the Windows Explorer? The .bat file wouldn't be run so bds.exe would again require UAC elevation.) As an alternate approach, I followed the instructions on the above woshub page to create a registry key that would flag bds.exe to be always RunAsInvoker. Here's the key: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers] "C:\\Program Files (x86)\\Embarcadero\\Studio\\23.0\\bin\\bds.exe"="RunAsInvoker" You could do the same thing more easily with Nirsoft's app using its Action menu or right-clicking on app there. I did not take the time to try the Application Compatibility Toolkit method (as described at woshub) to modify the Windows compatibility database. Like I said, this is all new to me... and apparently it's new to most people. I don't if my thinking is correct, but bds.exe is launching properly... at least for the time being. If this write-up helped you solve a problem you've been having, DM me to let me know it was worth the time I spent writing it out here! Tom
×