Re: Log exception so traceback contains timestamp and level?

2021-02-08 Thread Peter Otten

On 07/02/2021 16:12, Peter J. Holzer wrote:

On 2021-02-06 21:01:37 -0600, Skip Montanaro wrote:

The logging package can log exceptions and call stacks, but it does
(in my opinion) a suboptimal job of it. Consider this simple example:

import logging
FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
logging.basicConfig(format=FORMAT, force=True)
log.warning("msg", stack_info=True)

2021-02-06 20:46:52,399 WARNING msg
Stack (most recent call last):
   File "", line 1, in 

It formats the warning message just fine, but simply dumps the
traceback onto the stream with no timestamp or level. For my purposes,
this is more important for exceptions. (I'm just using the stack trace
feature as it's easier in a small example.) I would like to call
something like


I suspect that it just adds the stack trace to the message, so that you
are left with a multi-line message.


If you are willing to process all multiline messages in the same way
that simplifies your custom Formatter:

def make_formatter_class(prefix, style):

class PrefixFormatter(logging.Formatter):
prefix_template = logging._STYLES[style][0](prefix)
prefix_uses_time = prefix_template.usesTime()

def usesTime(self):
return self.prefix_uses_time or super().usesTime()

def format(self, record):
# this is supposed to set asctime attribute implicitly:
text = super().format(record)

lines = text.splitlines(True)
if len(lines) > 1:
prefix = self.prefix_template.format(record)
return "".join(
lines[:1] + [prefix + line for line in lines[1:]]
)
return text

return PrefixFormatter


# optional: monkey-patch to affect basicConfig()
logging.Formatter = make_formatter_class(
prefix="X... %(asctime)s %(levelname)s ", style="%"
)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Convert MBOX thunderbird to PST outlook

2021-02-08 Thread J.O. Aho



On 08/02/2021 10.22, Paul Rubin wrote:

"J.O. Aho"  writes:

I think most migrated to use IMAP like 30 years ago


That handles email but not calendar or the other stuff.  I think there
are starting to be standards for that, but no idea whether either
Thunderbird or Outlook follows them.


Yes, that is true that the IMAP don't handle the calendar, for those you 
need caldav/webcal and then maybe carddav for address books too and I do 
think those are well supported in Thunderbird, the question is more what 
the web based Outlook handles, the company behind that one has never 
been keen on open standards but locking in customers.



--

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


Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper

On 07/02/2021 13.34, Philipp Daher wrote:

Hello,

I recently coded this snippet of code:
myString=„hello“
for i in range(len(myString):
  print(string[i])

And now for the weird part:

SOMETIMES, the output is this:

hello


Strange. When I fix the errors in what you posted:
- wrong character to start the string
- wrong variable name in the call to print()

I get[1]:


... myString="hello"
... for i in range(len(myString)):
...   print( myString[i] )
...
h
e
l
l
o
...

You must have done something to suppress the newlines after
each call to print().

So it's quite obvious that the code you posted has very little
to do with the code you ran. If you really want us to help, please
directly copy and paste the exact code that you ran. We can't
really help you with only guesses as to what you did.



[1] (leading > replaced with . to fool news clients)
--
Michael F. Stemper
Galatians 3:28
--
https://mail.python.org/mailman/listinfo/python-list


RE: Python cannot count apparently

2021-02-08 Thread Schachner, Joseph
This code works:
mystr = "hello"
for ch in mystr:
print(ch, end="")

result is: hello

Note that the for loop does not use range.  Strings are iterable, that is they 
support Python's iteration protocol.  So, for ch in mystr: assigns one 
character from mystr to ch each time, each iteration gets the next character.  
To prevent each character from appearing on a separate line (in Python 3) you 
need end="".   That is, don't put in the usual end-of-line ending.

--- Joseph S.

Teledyne Confidential; Commercially Sensitive Business Data

-Original Message-
From: Michael F. Stemper  
Sent: Monday, February 8, 2021 9:19 AM
To: python-list@python.org
Subject: Re: Python cannot count apparently

On 07/02/2021 13.34, Philipp Daher wrote:
> Hello,
> 
> I recently coded this snippet of code:
> myString=„hello“
> for i in range(len(myString):
>   print(string[i])
> 
> And now for the weird part:
> 
> SOMETIMES, the output is this:
> 
> hello

Strange. When I fix the errors in what you posted:
- wrong character to start the string
- wrong variable name in the call to print()

I get[1]:


... myString="hello"
... for i in range(len(myString)):
...   print( myString[i] )
...
h
e
l
l
o
...

You must have done something to suppress the newlines after each call to 
print().

So it's quite obvious that the code you posted has very little to do with the 
code you ran. If you really want us to help, please directly copy and paste the 
exact code that you ran. We can't really help you with only guesses as to what 
you did.



[1] (leading > replaced with . to fool news clients)
--
Michael F. Stemper
Galatians 3:28
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper

On 08/02/2021 13.12, Schachner, Joseph wrote:

This code works:
 mystr = "hello"
 for ch in mystr:
 print(ch, end="")

result is: hello

Note that the for loop does not use range.  Strings are iterable, that is they 
support Python's iteration protocol.  So, for ch in mystr: assigns one 
character from mystr to ch each time, each iteration gets the next character.
To prevent each character from appearing on a separate line (in Python 3) you need 
end="".   That is, don't put in the usual end-of-line ending.


Then you agree that the OP:


You must have done something to suppress the newlines after each call to 
print().

So it's quite obvious that the code you posted has very little to do with the 
code you ran. If you really want us to help, please directly copy and paste the 
exact code that you ran. We can't really help you with only guesses as to what 
you did.



--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Convert MBOX thunderbird to PST outlook

2021-02-08 Thread J.O. Aho



On 07/02/2021 15.06, Kr4ck ALI wrote:

Hello,

I have to migrate multiple mailbox (emails, contacts, calendar, tasks) from
thunderbird to outlook Office 365.


I'm sorry to hear that.



I plan to export all items from thunderbird files (.mbox for email, .sqlite
or .sdb for calendar, .mab to contact) to PST files and import each PST
files to Office 365.


I think most migrated to use IMAP like 30 years ago, so you tend to do 
the migration from the IMAP to IMAP server and there are usually help to 
get from the provider you move to to get all the data migrated.




My question is : Have you already make a mission like that ?


I kind of doubt this. Once alternative is that you see to enable 
IMAP/SMTP or pay for ExQuilla and let each user have their old mail on 
the computer and the new mail account will store the mail and other 
stuff remotely.


--

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


Files can only be modified in IDLE, but not via Powershell

2021-02-08 Thread Stefan Ritter



Hi,

It would be highly appreciated if you could offer me some advice to
solve a problem I'm currently facing:

I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop.

I wrote some code to insert text in a .txt-file. It works perfectly on
my laptop.

On my desktop it works only if i run it in IDLE, the text appears
afterwards in the file . However it does not work if run it in
Powershell (or anything else), there are no changes made in the file.

I do not understand why this is the case. Python version, installation
paths and user are the same on desktop and laptop. I searched a bit and
found out that this issue might be caused by my antivirus software
comodo, but even after I replaced it with antivir, an reinstalled python
this didn't change anything.

As mentionned, any help is highly appreciated. If you need any
additional information please let me know!

Best regards,
Stefan


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


RE: Convert MBOX thunderbird to PST outlook

2021-02-08 Thread pjfarley3
I can recommend the commercial product Aid4Mail from my personal experience 
moving from another mbox-based email client (not Thunderbird) to Outlook 
(though that was a few years back, well before Outlook 365 became available).

Very well supported and responsive, very reasonably priced at the time I needed 
it.

HTH

Peter

> -Original Message-
> From: Kr4ck ALI 
> Sent: Monday, February 8, 2021 1:01 AM
> To: python-list@python.org
> Subject: Re: Convert MBOX thunderbird to PST outlook
> 
> I have about 1000 mailbox to migrate and all are store in local on each
> computers.
> I know PST files store contacts, calendar, tasks... So, I think that is
> possible to build a PST file with python to integrate the differents items
> (emails, calendar, tasks,...) from thunderbird files.
> 
> 
> Le lun. 8 févr. 2021 à 00:45, Cameron Simpson  a écrit :
> 
> > On 07Feb2021 15:06, Kr4ck ALI  wrote:
> > >I have to migrate multiple mailbox (emails, contacts, calendar, tasks)
> > >from thunderbird to outlook Office 365.
> >
> > I am also sorry to hear that.
> >
> > Had you considered getting them to enable IMAP access? Then you can
> > migrate just by moving messages inside Thunderbird. And you can keep
> > using your mail reader of choice.
> >
> > >I plan to export all items from thunderbird files (.mbox for email,
> > .sqlite
> > >or .sdb for calendar, .mab to contact) to PST files and import each PST
> > >files to Office 365.
> >
> > The contacts and calendar stuff I have less idea about, alas. CalDAV for
> > the calendar? I know that's a vague and unspecific suggestion.
> >
> > Cheers,
> > Cameron Simpson 
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >


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


Re: Files can only be modified in IDLE, but not via Powershell

2021-02-08 Thread MRAB

On 2021-02-08 21:33, Stefan Ritter wrote:


Hi,

It would be highly appreciated if you could offer me some advice to
solve a problem I'm currently facing:

I have a Windows 10 ADM64 desktop and a Windows 10 AMD64 Laptop.

I wrote some code to insert text in a .txt-file. It works perfectly on
my laptop.

On my desktop it works only if i run it in IDLE, the text appears
afterwards in the file . However it does not work if run it in
Powershell (or anything else), there are no changes made in the file.

I do not understand why this is the case. Python version, installation
paths and user are the same on desktop and laptop. I searched a bit and
found out that this issue might be caused by my antivirus software
comodo, but even after I replaced it with antivir, an reinstalled python
this didn't change anything.

As mentionned, any help is highly appreciated. If you need any
additional information please let me know!


It's difficult to troubleshoot with any code.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Convert MBOX thunderbird to PST outlook

2021-02-08 Thread Christian Gollwitzer

Am 08.02.21 um 11:08 schrieb J.O. Aho:


On 08/02/2021 10.22, Paul Rubin wrote:

"J.O. Aho"  writes:

I think most migrated to use IMAP like 30 years ago


That handles email but not calendar or the other stuff.  I think there
are starting to be standards for that, but no idea whether either
Thunderbird or Outlook follows them.


Yes, that is true that the IMAP don't handle the calendar, for those you 
need caldav/webcal and then maybe carddav for address books too and I do 
think those are well supported in Thunderbird, the question is more what 
the web based Outlook handles, 


For thatm you can run radicale:

https://radicale.org/3.0.html

A Python-based calendar server. Then upload your calendars there from 
Thunderbird and download them from Outlook.


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