Mike London

+ Follow
since Jul 12, 2002
Merit badge: grant badges
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike London

You mentioned you were going to try to create something, but I don't see it on the thread you referred to.

Perhaps I misunderstood your posting?

The requirement lives on....

4 weeks ago
Does anyone know of a full example (not just the snippets on the MS site) that demonstrates, if possible, how to send a programmatic email using the MS Graphi API and OAUTH with no user interaction?  I have the example working from the MS Graph site (no easy feat to get working), but there's a manual click-the-link-to-get-a-code step that won't work for programmatic emails.

Currently, to send emails, we're using SMTP. I've been told by MS that if you have 2FA + app password on your 365 account, you can still use SMTP (not being deprecated).

In any case, if there is a way to use the GRAPH API so I can send an OAUTH email with no user interaction, I'd like to know about it.


P.S. I have this OAUTH, no user interaction, approach working with DropBox, so I think it's possible. But DB is totally different, of course.
1 month ago
Thanks Tim.

The problem seems to be fixed.

pip3 installs the Python libs to "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/"

But Java appears to be looking at the site-packages folder beneath my user folder.

Once I copied that GB of site-packages, everything is now working.

Thanks for your comments...you got me thinking!

-- mike
1 month ago
I am executing a python program using exec().

Sometimes it works and other times, later in the day or something (???), I get errors like

   from gensim import corpora
ModuleNotFoundError: No module named 'gensim'

Now, when I go look at the Python installed libraries, gensim is there.

The path on the mac (in .bash_profile) has the full path to the installed python libraries.

And, as I was saying, sometimes the python execution works.

Extremely baffling.

(Sadly, being a Mac guy, this same code works perfectly -- every time -- on Windows.)

I guess what I'm asking is how does Java search for things? How can the code work one time, but not later? Nothing had changed in code or in the system. What could be going haywire on the Mac?

Thanks in advance for any ideas!

-- mike
1 month ago
Thanks! Your suggestion about the errorstream (why do I keep forgetting this?!) was the key.

Some of the NLTK libraries were still not installed.

And, although the "stop words" were in the correct location this was still reported as an error until a reboot.

Thanks again for your splendid help!

-- mike
1 month ago
The two lines in question are here:

process = Runtime.getRuntime().exec(cmdArray);
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

(On Windows Server 2019, Tomcat running as service "reader" is null. Works Otherwise -- on Mac and regular Windows 10.).

The "cmdArray" variable has three values:

1. "python" (for Windows)
2. The path to the python program to run.
3. The path to the data file to read.

Not sure this is a readily solvable problem.

Will try to have the client bump up the Windows server on AWS.

1 month ago
There is no information in the log that indicates anything is wrong.

The basic code runs some python code by doing a shell exec(). With smaller examples, it works fine.

This library has all the dependencies installed.

The method should return the output from the "Gensim" analysis, but it returns nothing on Windows under the Windows service. When I walk through the code in the debugger, connected to Tomcat, frustratingly, it works then. It also works when Tomcat is standalone.

Same code, same Tomcat version, same endpoints, work perfectly on the Mac (though that's standalone Tomcat).
Same code, same Tomcat version (running as service), same endpoints, work perfectly on Windows 10.

We've had trouble with Python Gensim models in the past. On PythonAnywhere, they would crash and they told us we would need a $149/month special server. We then setup a Linux AWS instance and used Flask (web service for python) and after bumping up the instance, it worked there, too.

Since I can't debug this code and get it to fail (it only fails with the service running normally), not sure what to try next.

1 month ago
I have a REST service (Springboot) where a particular method works OK if the service is started standalone, but not when the service is started from the Windows (2019 Windows Server) Tomcat service in Windows services.

I have the memory set for 1024 MB initially and max memory of 4096, but I've tried max up to 12224 MB.

It may be that the code is taking more resources somehow than my AWS instance allows or something.

I'm using a t3a.xlarge instance.

No errors in any of the Tomcat logs or the application logs.

Would really appreciate some other things to try. I'm baffled.


-- mike
1 month ago

Tim Holloway wrote:Oh, sorry about that. This link is one I'd actually intended to post:


I was surprised to see aspose coming up in my "PDFBox searches", but didn't realise that it was being quite that pernicious.

Thanks Tim.

I'm focusing on trying to take their already-correct HTML and getting it converted to PDF now.

I saw this link before, but doing a simple search and replace in the PDF for text and then trying to use this approach from you link appears to be extremely difficult. Their PDF has about 50 links I need to update.  The challenge is their mailto links are long and have seemingly illegal characters like "|". However, bringing up their HTML in the browser and saving it there as a PDF works fine so I'm sure it's "doable" just possibly not with the free libraries available.

Perhaps the best solution would be for the client to just create a portal and invite their clients to visit. That way, no HTML conversion tasks are involved.

Thanks again.

-- mike
3 months ago
Hi Tim,

The link you put at the top appears to be for Excel not HTML, but perhaps I misread that.

The simple example, the one you were correcting, actually works. The problem comes with more complicated HTML.

I can't figure out how to get either FlyingSaucer or openhtmltopdf to work with more complicated HTML (with lots of DIVS and style tags). It just skips all the styling and the output PDF is a mess with little relation to the HTML.

The ASPOSE is an interesting library, but I want to avoid spending $4,000 if possible. (eek!).


- mike
3 months ago

Stephan van Hulst wrote:You're saying you're replacing text with mailto links, but in what? Existing PDFs? And if your goal is to replace text in an existing PDF, then how is converting HTML to PDF going to help you at all?

The HTML pages already have the working HTML mailto links correctly added so there's no trying to add them after the fact in the PDF. The simple example I did, as shown above, DID work when converting the HTML -> PDF.

I just need a better solution for more complicated HTML or for manipulating the PDF directly.

Hope that clarifies.

-- mike
3 months ago
I tried using PDFBox to replace text with a mailto link, but since the "a" tag wasn't rendered correctly, all that happened was that the mailto string was replaced in the PDF. Very ugly and not as wanted. (It did work, however).

Taking a different approach ... I also tried the Java libraries mentioned on various sites to convert HTML -> PDF where the mailto links were already present.

For a simple HTML like this, it works:

The output is a PDF with a single (workable) mailto click-able link. All was encouraging at this point.

Yet, with more complicated HTML, this approach fails terribly and the output is just a mess with little relation to the HTML.


Do I need to invest in the ultra expensive apose software or something like that ($4,000 for Java) or is there a better way to do this?

Appreciate any ideas.


-- mike
3 months ago
Shouldn't be necessary but try adding a Class.forName(....) statement.

I've had this same error with some drivers.
I would generally recommend to create private class variables unless there's a reason not to. You already have public getter/setters.


To calculate the sum, create a variable like "sum" and increment that in your loop, Stream, or whatever.
3 months ago
You need to track (via a variable) when a customer(s) has arrived and have logic for the next arrival.

Rather than going "straight to code", I'd write down on a piece of paper, what happens when customers arrive. Make sure you account for all the activities. Then, once you have it solved manually, move it to your program with good comments that possibly come from the steps you wrote down on paper. Using this approach will help you solve more complex problems.
3 months ago