Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
Is anybody aware of any Python code for the Exchange OWA protocol/API?

The OWA e-mail client I've been using has stopped working. It was a
commerical Python application named Hiri, wich has been abandoned by
the developer.

So, for now, I'm stuck with the OWA web client. It's clumsy and
everything takes 3X as long to accomplish as it would with a real
e-mail client, but I can survive with it if I have to. [Retirement's
not that far away...] The main problem with the web client is lack of
notification when new mail arrives. Even if you always have a browser
running (I don't), and have a tab that has the OWA client running (I
often don't), notification doesn't seem to work reliably (and when it
does work, it doesn't use the standard linux desktop notification
system).

Back when the Exchange IMAP server was enabled (and I used mutt as my
e-mail client), I wrote a e-mail notifier app in Python/GTK, so I knew
when new mail was waiting.

I've been wondering if it would be possible to do the same thing using
the Exchange OWA API/protocol instead of IMAP?

But, I haven't found any Python support for OWA.  I've found libraries
for the older Exchange EWS API, but AFAICT the Exchange server in
question doesn't support EWS, only OWA.

I've also found a bunch of info for Outlook/REST and Office365/REST,
but I'm pretty sure those won't work either...

--
Grant



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Cecil Westerhof via Python-list
"Peter J. Holzer"  writes:

> On 2022-03-28 15:35:07 +0200, Cecil Westerhof via Python-list wrote:
>> "Loris Bennett"  writes:
>> > Ubuntu is presumably relying on the Debian security team as well as
>> > other volunteers and at least one company, namely Canonical.
>> 
>> Nope. One important reason that I really hate that people use Ubuntu
>> for servers is that Ubuntu wants to be up to date.
>
> Not sure what you mean by that.
>
> There is an Ubuntu LTS release every 2 years. There is also a Debian
> release roughly every 2 years (although not on quite as strict a
> schedule). So that's very similar.
>
>> So Ubuntu starts very close to Debian security wise, but will shift
>> rapidly.
>
> They are are about a year apart, so they will usually contain different
> versions of most packages right from the start. So the Ubuntu and Debian
> security teams probably can't benefit much from each other.

That is is what I partly mean.

Debian is very big on security and stability. Most people think that
Ubuntu is that also, because it is based on Debian. But Ubuntu wants
also provide the newest versions of software and this will affect the
stability and security negatively.
Even for a desktop I find stability and security more important as the
newest versions. That is why I even for the desktop use Debian.
Personally I find it strange that people choose newest versions over
stability and security for a server.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Temporally disabling buffering

2022-03-31 Thread Cecil Westerhof via Python-list
In Python when the output of a script is going to a pipe stdout is
buffered. When sending output to tee that is very inconvenient.

We can set PYTHONUNBUFFERED, but then stdout is always unbuffered.

On Linux we can do:
PYTHONUNBUFFERED=T script.py | tee script.log

Now the output is only unbuffered for the current run and buffered for
other runs where the output goes to a pipe.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Cecil Westerhof via Python-list
"Peter J. Holzer"  writes:

> On 2022-03-30 08:48:36 +0200, Marco Sulla wrote:
>> On Tue, 29 Mar 2022 at 00:10, Peter J. Holzer  wrote:
>> > They are are about a year apart, so they will usually contain different
>> > versions of most packages right from the start. So the Ubuntu and Debian
>> > security teams probably can't benefit much from each other.
>> 
>> Are you sure? Since LTS of Debian and Ubuntu lasts 5 years, I suppose
>> the versions of the packages should overlap at some point in the past.
>
> Standard policy (there are exceptions) on most distros is to stay with
> the same version of any package for the entire lifetime. So for example,
> Ubuntu 20.04 was released with Apache 2.4.41 and Python 3.8.10 and
> Debian 11 was released with Apache 2.4.53 and Python 3.9.2 and they are
> still on these versions. Any security fixes and other critical bug fixes
> were back-ported to these versions.

Are you sure? In the past this was not the case, but it is possible
that this has changed. (I do not really follow other distributions. I
am quite happy with Debian.)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'äÄöÖüÜ' in Unicode (utf-8)

2022-03-31 Thread Dennis Lee Bieber
On Thu, 31 Mar 2022 00:36:10 -0700 (PDT), moi 
declaimed the following:

 'äÄöÖüÜ'.encode('utf-8')
>b'\xc3\xa4\xc3\x84\xc3\xb6\xc3\x96\xc3\xbc\xc3\x9c'
 len('äÄöÖüÜ'.encode('utf-8'))
>12
 
 ?

Is there a question in there somewhere?

Crystal ball is hazy...

However... Note that once you encode the Unicode literal, you have a
BYTE string. There are 12 bytes in that binary -- it is NOT considered
Unicode at that point (only when you decode it with the same CODEC will it
be Unicode).


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Peter J. Holzer
On 2022-03-31 09:46:14 +0200, Cecil Westerhof via Python-list wrote:
> "Peter J. Holzer"  writes:
> > Standard policy (there are exceptions) on most distros is to stay with
> > the same version of any package for the entire lifetime. So for example,
> > Ubuntu 20.04 was released with Apache 2.4.41 and Python 3.8.10 and
> > Debian 11 was released with Apache 2.4.53 and Python 3.9.2 and they are
> > still on these versions. Any security fixes and other critical bug fixes
> > were back-ported to these versions.
> 
> Are you sure? In the past this was not the case, but it is possible
> that this has changed. (I do not really follow other distributions. I
> am quite happy with Debian.)

This has always been the case with Debian (they even created a special
repo for packages where this wasn't feasible, like browsers (which
typically update every few weeks and are too large for the security team
to backport security fixes).

In my experience it's also the case for Ubuntu (see the version numbers
I posted).

It also was the case for Redhat, but they seem to have switched to a
rolling updates model some time ago. I'm not sure how they handle that
now.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Temporally disabling buffering

2022-03-31 Thread Marco Sulla
Dirty suggestion: stderr?

On Thu, 31 Mar 2022 at 18:38, Cecil Westerhof via Python-list
 wrote:
>
> In Python when the output of a script is going to a pipe stdout is
> buffered. When sending output to tee that is very inconvenient.
>
> We can set PYTHONUNBUFFERED, but then stdout is always unbuffered.
>
> On Linux we can do:
> PYTHONUNBUFFERED=T script.py | tee script.log
>
> Now the output is only unbuffered for the current run and buffered for
> other runs where the output goes to a pipe.
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Temporally disabling buffering

2022-03-31 Thread Barry


> On 31 Mar 2022, at 17:39, Cecil Westerhof via Python-list 
>  wrote:
> 
> In Python when the output of a script is going to a pipe stdout is
> buffered. When sending output to tee that is very inconvenient.
> 
> We can set PYTHONUNBUFFERED, but then stdout is always unbuffered.
> 
> On Linux we can do:
>PYTHONUNBUFFERED=T script.py | tee script.log
> 
> Now the output is only unbuffered for the current run and buffered for
> other runs where the output goes to a pipe.

I prefer to use the -u when I run the output of python into the.

python -u script.py | tee script.log

And use py -u on windows.

Barry

> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Dieter Maurer
Grant Edwards wrote at 2022-3-31 07:41 -0700:
>Is anybody aware of any Python code for the Exchange OWA protocol/API?

According to "https://en.wikipedia.org/wiki/Outlook.com#Mail_client_access";
Outlook.com (the modern name for OWA) supports "pop3" and "imap",
both supported by Python library modules.

Read the "Outlook.com" documentation about how you can connect
via those protocols.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-31 Thread Marco Sulla
On Thu, 31 Mar 2022 at 18:38, Cecil Westerhof via Python-list
 wrote:
> Most people think that
> Ubuntu is that also, because it is based on Debian. But Ubuntu wants
> also provide the newest versions of software and this will affect the
> stability and security negatively.

I think you're referring to the fact that Ubuntu releases a new stable
version every 6 months, while Debian every 2 years. This is true, but
Ubuntu also releases a LTS every 2 years. You can install a LTS and
change the options so you'll update the system only where a new LTS is
coming out. Furthermore you're not forced to upgrade, you can do it
when the LTS comes to the end.

On the other hand, you can live on the edge with Debian too. You can
install an unstable branch.

Furthermore, there's the company factor. According to Google, Debian
has about 1k devs, while Ubuntu only about 250. But these devs work
full time on Ubuntu and they are paid for. Not sure this is not an
important point. For what I know, historically the distros with the
reputation to be more stable are distros maintained by companies, Red
Hat and Gentoo for example.

About stability and security, I can't disagree. But I suppose the
people that use the unstable version of some Linux distro are useful
for testing and reporting bugs, also security one. So they contribute
to the stable versions, and I think we have to be grateful to these
"pioneers".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Dan Ciprus (dciprus) via Python-list
Our org does not have imap nor pop enabled so I guess it depends on your IT and 
what's enabled for your org. Just my $.02 ..


On Thu, Mar 31, 2022 at 07:12:10PM +0200, Dieter Maurer wrote:

Grant Edwards wrote at 2022-3-31 07:41 -0700:

Is anybody aware of any Python code for the Exchange OWA protocol/API?


According to "https://en.wikipedia.org/wiki/Outlook.com#Mail_client_access";
Outlook.com (the modern name for OWA) supports "pop3" and "imap",
both supported by Python library modules.

Read the "Outlook.com" documentation about how you can connect
via those protocols.
--
https://mail.python.org/mailman/listinfo/python-list


--
Daniel Ciprus  .:|:.:|:.
CONSULTING ENGINEER.CUSTOMER DELIVERY   Cisco Systems Inc.
dcip...@cisco.com
tel: +1-703-484-0205
mob: +1-540-223-7098

[ curl -L http://git.io/unix ]


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'äÄöÖüÜ' in Unicode (utf-8)

2022-03-31 Thread Chris Angelico
On Fri, 1 Apr 2022 at 03:45, Dennis Lee Bieber  wrote:
>
> On Thu, 31 Mar 2022 00:36:10 -0700 (PDT), moi 
> declaimed the following:
>
>  'äÄöÖüÜ'.encode('utf-8')
> >b'\xc3\xa4\xc3\x84\xc3\xb6\xc3\x96\xc3\xbc\xc3\x9c'
>  len('äÄöÖüÜ'.encode('utf-8'))
> >12
> 
>  ?
>
> Is there a question in there somewhere?
>
> Crystal ball is hazy...
>
> However... Note that once you encode the Unicode literal, you have a
> BYTE string. There are 12 bytes in that binary -- it is NOT considered
> Unicode at that point (only when you decode it with the same CODEC will it
> be Unicode).
>

That's jmf. Ignore him. He knows nothing about Unicode and is
determined to make everyone aware of that fact.

He got blocked from the mailing list ages ago, and I don't think
anyone's regretted it.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Christian Gollwitzer

Am 31.03.22 um 16:41 schrieb Grant Edwards:

Is anybody aware of any Python code for the Exchange OWA protocol/API?

The OWA e-mail client I've been using has stopped working. It was a
commerical Python application named Hiri, wich has been abandoned by
the developer.

So, for now, I'm stuck with the OWA web client. It's clumsy and
everything takes 3X as long to accomplish as it would with a real
e-mail client, but I can survive with it if I have to. 


I can recommend davmail as a workaround:

http://davmail.sourceforge.net/

Davmail converts OWA into regular mail protocols like POP3, IMAP, SMTP. 
You can use any email/calender client (I've used thunderbird) and most 
of it worked well.


Davmail is written in Java, not Python, but basically this should not 
matter if you only use it.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Dan Ciprus (dciprus) via Python-list
Yes, this ... I've been using this successfully for years and it obviously has 
its sad parts but it works pretty well overall.


From: Python-list  on behalf 
of Christian Gollwitzer 
Sent: Thursday, March 31, 2022 3:22 PM
To: python-list@python.org
Subject: Re: Exchange OWA using Python?

Am 31.03.22 um 16:41 schrieb Grant Edwards:
> Is anybody aware of any Python code for the Exchange OWA protocol/API?
>
> The OWA e-mail client I've been using has stopped working. It was a
> commerical Python application named Hiri, wich has been abandoned by
> the developer.
>
> So, for now, I'm stuck with the OWA web client. It's clumsy and
> everything takes 3X as long to accomplish as it would with a real
> e-mail client, but I can survive with it if I have to.

I can recommend davmail as a workaround:

http://davmail.sourceforge.net/

Davmail converts OWA into regular mail protocols like POP3, IMAP, SMTP.
You can use any email/calender client (I've used thunderbird) and most
of it worked well.

Davmail is written in Java, not Python, but basically this should not
matter if you only use it.

Christian
--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
On 2022-03-31, Dieter Maurer  wrote:
> Grant Edwards wrote at 2022-3-31 07:41 -0700:
>>Is anybody aware of any Python code for the Exchange OWA protocol/API?
>
> According to "https://en.wikipedia.org/wiki/Outlook.com#Mail_client_access";
> Outlook.com (the modern name for OWA) supports "pop3" and "imap",
> both supported by Python library modules.

No, outlook.com is a Microsft web hosting service.

OWA is an HTTP-based API suspport by MS Exchange server.

> Read the "Outlook.com" documentation about how you can connect
> via those protocols.

I don't want to connect to Outlook.com. I want to connect to an
Exchange server that doesn't not have IMAP, POP3, or SMTP enabled.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
On 2022-03-31, Christian Gollwitzer  wrote:
> Am 31.03.22 um 16:41 schrieb Grant Edwards:
>> Is anybody aware of any Python code for the Exchange OWA protocol/API?
>> 
>> The OWA e-mail client I've been using has stopped working. It was a
>> commerical Python application named Hiri, wich has been abandoned by
>> the developer.
>> 
>> So, for now, I'm stuck with the OWA web client. It's clumsy and
>> everything takes 3X as long to accomplish as it would with a real
>> e-mail client, but I can survive with it if I have to. 
>
> I can recommend davmail as a workaround:
>
>   http://davmail.sourceforge.net/
>
> Davmail converts OWA into regular mail protocols like POP3, IMAP, SMTP. 
> You can use any email/calender client (I've used thunderbird) and most 
> of it worked well.

I used Davmail in the past when the server supported EWS. AFAICT, it
does not work with the current server. If you look at the Exchange
protocols listed at http://davmail.sourceforge.net/gettingstarted.html,
OWA is not one of them:

 * O365Modern Office 365 modern authentication (Oauth2)
 
 * O365Interactive Office 365 with interactive browser window, not
   available in headless mode (OpenJFX required)

 * O365Manual Office 365 with interactive dialog, not available in
   headless mode
 
 * O365 Office 365 EWS mode
 
 * EWS Exchange 2007 and later
 
 * WebDav Exchange 2007 and earliear WebDav mode
 
 * Auto WebDav mode with EWS failover

> Davmail is written in Java, not Python, but basically this should
> not matter if you only use it.

Have you used it with OWA as the protocol?

--
Grant

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
On 2022-03-31, Dan Ciprus (dciprus) via Python-list  
wrote:

> Yes, this ... I've been using this successfully for years and it
> obviously has its sad parts but it works pretty well overall.

Using the _OWA_ protocol? When our server switched from EWS to OWA, I
could no longer get it to work.

--
Grant


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
On 2022-03-31, Grant Edwards  wrote:

> Is anybody aware of any Python code for the Exchange OWA protocol/API?
>
> The OWA e-mail client I've been using has stopped working. It was a
> commerical Python application named Hiri, wich has been abandoned by
> the developer.

I'm trying out Thunderbird with an OWA plugin

https://www.beonex.com/owl/

and it's working very nicely. There are some quirks in Thunderbird
that I'm still tring to figure out, but I have the same issues if it
were using IMAP/SMTP.

--
Grant

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'äÄöÖüÜ' in Unicode (utf-8)

2022-03-31 Thread Dennis Lee Bieber
On Fri, 1 Apr 2022 03:59:32 +1100, Chris Angelico 
declaimed the following:


>That's jmf. Ignore him. He knows nothing about Unicode and is
>determined to make everyone aware of that fact.
>
>He got blocked from the mailing list ages ago, and I don't think
>anyone's regretted it.
>
Ah yes... Unfortunately, when gmane made the mirror read-only, I had to
revert to comp.lang.python... and all the junk that gets in via that and
Google Groups...


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Dennis Lee Bieber
On Thu, 31 Mar 2022 16:22:33 -0700 (PDT), Grant Edwards
 declaimed the following:

>
>OWA is an HTTP-based API suspport by MS Exchange server.
>
From what I found, M$ doesn't consider OWA to be an API... It expands
to "Outlook Web App", period, (and more recently is called "Outlook for the
Web").

That would explain why there is no documentation of an "API"... I get
the impression that any so-called API programs have had to reverse engineer
(maybe using things like WireShark) the HTTP communication.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: asyncio+tkinter

2022-03-31 Thread Skip Montanaro
>
> > Given that both asyncio & tkinter are modules in the standard lib and
> both
> > have event loops, I would have expected to find some "best practice"
> > solution to mixing the two.
>
> Agreed. For GTK, you can use a dedicated loop policy like this:
>
> import asyncio_glib
> asyncio.set_event_loop_policy(asyncio_glib.GLibEventLoopPolicy())
>
> It should be possible to make it this easy for asyncio + tkinter.
>

I haven't used GTK in ages and ages, but I do still have a tkinter program
that I drag out every now and then when my wrists start acting up. After
opining about this on the PyIdeas discuss forum, I spent a few minutes and
came up with a simple AsyncTk subclass of tkinter.Tk. Here's its hello
world:

https://gist.github.com/smontanaro/5e12c557602a76c609e46ca59387ad1c

I modified my activity watcher to use it:

https://github.com/smontanaro/python-bits/blob/master/src/watch.py

A few warnings:

   1. copy/paste reuse of that AsyncTk class
   2. the code is a mess (it's probably 20-25 years old, I make no
   apologies for the mess)
   3. as of about an hour ago it now uses pynput to watch for mouse/kbd
   watching

So, Tk+asyncio turns out to be fairly easy to do, at least for simple stuff.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exchange OWA using Python?

2022-03-31 Thread Grant Edwards
On 2022-03-31, Dennis Lee Bieber  wrote:
> On Thu, 31 Mar 2022 16:22:33 -0700 (PDT), Grant Edwards
> declaimed the following:
>
>>
>>OWA is an HTTP-based API suspport by MS Exchange server.
>
> From what I found, M$ doesn't consider OWA to be an API... It expands
> to "Outlook Web App", period, (and more recently is called "Outlook for the
> Web").

Right. There used to be an API called "EWS", but that's no longer
available (at least on the servers I've dealt with). Instead, there's
a REST/JSON api that's used by the outlook web client.

There are a few email clients (that I'm aware of) that have figured
out how to use that API:

 Hiri

    (now abandoned) which stopped working for
   me yesterday.

 Webmail for OWA

   https://play.google.com/store/apps/details?id=smtb.owa Android app.

 OWL Thunderbird plug-in

   This is working nicely for me.

There is an older Thunderbird plugin (by the developers of OWL) that
used the EWS protocol (but not OWA) called ExQuilla.

I think that the protocol used by Outlook is MAPI/RPC or MAPI/HTTP. I
believe that Evolution used to be able to use that protocol, but from
what I've read it only works with very old versions of Exchange. For
newer Exchange servers, Evolution supports EWS, but the servers I've
dealt with over the past few years didn't seem to support EWS. [Though
I haven't tried for a while.]
-- 
https://mail.python.org/mailman/listinfo/python-list