Convert MBOX thunderbird to PST outlook
Hello, I have to migrate multiple mailbox (emails, contacts, calendar, tasks) from thunderbird to outlook Office 365. 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 know it's a tedious task ... But I know that nothing is impossible ! I found this script very helpfull to begin : #!python3 import os, sys import gzip import mailbox import urllib.request import win32com.client dispatch = win32com.client.gencache.EnsureDispatch const = win32com.client.constants PST_FILEPATH = os.path.abspath(os.path.join(os.path.expandvars("%APPDATA%"), "scratch.pst")) if os.path.exists(PST_FILEPATH): os.remove(PST_FILEPATH) ARCHIVE_URL = "https://mail.python.org/pipermail/python-list/2015-November.txt.gz"; MBOX_FILEPATH = "archive.mbox" def download_archive(url, local_mbox): with gzip.open(urllib.request.urlopen(url)) as archive: with open(local_mbox, "wb") as f: print("Writing %s to %s" % (url, local_mbox)) f.write(archive.read()) def copy_archive_to_pst(mbox_filepath, pst_folder): archive = mailbox.mbox(mbox_filepath) for message in archive: print(message.get("Subject")) pst_message = pst_folder.Items.Add() pst_message.Subject = message.get("Subject") pst_message.Sender = message.get("From") pst_message.Body = message.get_payload() pst_message.Move(pst_folder) pst_message.Save() def find_pst_folder(namespace, pst_filepath): for store in dispatch(mapi.Stores): if store.IsDataFileStore and store.FilePath == PST_FILEPATH: return store.GetRootFolder() download_archive(ARCHIVE_URL, MBOX_FILEPATH) outlook = dispatch("Outlook.Application") mapi = outlook.GetNamespace("MAPI") pst_folder = find_pst_folder(mapi, PST_FILEPATH) if not pst_folder: mapi.AddStoreEx(PST_FILEPATH, const.olStoreDefault) pst_folder = find_pst_folder(mapi, PST_FILEPATH) if not pst_folder: raise RuntimeError("Can't find PST folder at %s" % PST_FILEPATH) copy_archive_to_pst(MBOX_FILEPATH, pst_folder) My question is : Have you already make a mission like that ? Thanks in advance ! @Kr4ckali -- https://mail.python.org/mailman/listinfo/python-list
Re: Log exception so traceback contains timestamp and level?
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. I often produce multi-line log messages myself. They are much nicer to read than extremely long lines or groups of messages which should really be read as a unit ... > log.exception("Some message...") > > and find something like this in the output stream: > > 2021-02-06 20:46:52,399 ERROR Some message... > 2021-02-06 20:46:52,400 ERROR Traceback (most recent call last): > 2021-02-06 20:46:52,402 ERROR File "", line 1, in ... like this. > That way I can more easily grep log files for errors and get the > entire detail, including the traceback. Yes, grep is unfortunately very line-oriented. I often write write simple scripts to filter log files where one message can span multiple lines (Python's logging module isn't the only one - Samba and PostgreSQL come to mind). Another possibility would be to write the logs into a database. That also has the advantage that the messages are stored in a structure and you don't have to parse them. 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: Response for PING in ircbot.
‐‐‐ Original Message ‐‐‐ On Saturday, January 30, 2021 11:50 AM, Bischoop wrote: > Got problem with responding for Ping, tried so many ways to response > and always end up with time out or other error. This time: > Is it possible to share your final Ping answer? I've had a long term Flask/Python issue where the site just dies. (MY) External ping attempts still report the Flask site is functioning; but accessing the pages returns 500 errors. Apache is still running and other (non-Flask) sites are still running on the Linux server. I see no errors that might be causing this under /var/log/*, or apache's error log; or the site's access/error logs. What I'd like to do is set up my own external monitor, to at least known WHEN the site has died. And I'm wondering if your PING might be better. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Kids Python 101 free learning materials
Hello there, I have developed free learning materials for young kids (targeting 8+ kids) to learn Python from scratch on https://kidspython.com lately. I put lots of efforts on simplifying the course materials, providing plenty of good examples and sufficient exercises for kids to practice coding. The Web site even provides a Python Playground that supports visualization mode for kids to trace their code execution. I hope the information is helpful. Please give it a try, and subscribe to our YouTube channel - https://www.youtube.com/channel/UC-VGmSaLz-WGwyeWk7kyebA for watching Kids Python 101 videos. -- https://mail.python.org/mailman/listinfo/python-list
Python cannot count apparently
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 And SOMETIMES, the output changes to: ohell WHY??? Why do I get different outputs with the EXACT SAME CODE? Can someone help me please? Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via Python-list: > I recently coded this snippet of code: > myString=„hello“ I doubt you have (coded *this* snippet of code) -- because those quotes wouldn't work. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
On Mon, Feb 8, 2021 at 6:36 AM Philipp Daher via Python-list wrote: > > Hello, > > I recently coded this snippet of code: > myString=„hello“ > for i in range(len(myString): > print(string[i]) This code won't work as is. Please *copy and paste* your code when asking for help. > And now for the weird part: > > SOMETIMES, the output is this: > > hello > > And SOMETIMES, the output changes to: > > ohell Neither of those makes sense based on the code you're showing, so again, please *copy and paste* the code and output. > WHY??? Why do I get different outputs with the EXACT SAME CODE? > > Can someone help me please? Thank you I would recommend that you start by iterating over the string itself, instead of a range. My crystal ball tells me that you're getting tangled with negative indexing, but without seeing the code each time, it's impossible to be sure. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
On Sun, Feb 7, 2021 at 2:36 PM Philipp Daher via Python-list 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 > > And SOMETIMES, the output changes to: > > ohell > > WHY??? Why do I get different outputs with the EXACT SAME CODE? > > Can someone help me please? Thank you > -- > https://mail.python.org/mailman/listinfo/python-list Did you type the code using idle, or the default python interactive console? If you did, please do that again, and copy and paste your code and the results here. There is something amiss. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
That's not the only problem with the code. There's a missing close- paren and a reference to "string" which I presume was meant to be "myString". Suggest OP create a reproducible case, and paste the code and output verbatim. On Sun, 2021-02-07 at 20:40 +0100, Karsten Hilbert wrote: > Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via > Python-list: > > > I recently coded this snippet of code: > > myString=„hello“ > > I doubt you have (coded *this* snippet of code) -- because > those quotes wouldn't work. > > Karsten > -- > GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan: > That's not the only problem with the code. There's a missing close- > paren and a reference to "string" which I presume was meant to be > "myString". I know. I wasn't going to spoil everything right away. The sort of response we would get from OP would tell us what sort of help might be most suitable :-) Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
Set i = 0 at the begin of the code, that way each entry starts at Logical 0 of the array/container/list... "The only way to have experience is by having the experience"! On Sunday, February 7, 2021, 12:56:40 PM MST, Karsten Hilbert wrote: Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan: > That's not the only problem with the code. There's a missing close- > paren and a reference to "string" which I presume was meant to be > "myString". I know. I wasn't going to spoil everything right away. The sort of response we would get from OP would tell us what sort of help might be most suitable :-) Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
On 08/02/2021 09.49, Kevin M. Wilson via Python-list wrote: > Set i = 0 at the begin of the code, that way each entry starts at Logical 0 > of the array/container/list... FYI: https://docs.python.org/3/library/stdtypes.html#typesseq-range See also @Chris' contribution regarding the pythonic idiom for iterating over a container. -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Python cannot count apparently
On Sun, 7 Feb 2021 20:49:52 + (UTC), Kevin M. Wilson wrote: > Set i = 0 at the begin of the code, that way each entry starts at > Logical 0 of the array/container/list... No. The original code, as posted, was >>I recently coded this snippet of code: >>myString=„hello“ >>for i in range(len(myString): >> print(string[i]) Setting i=0 before the "for" statement would make no difference. In the first pass through the for loop, i is set to the first value in the range, which is zero. -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert MBOX thunderbird to PST outlook
On 2/7/21 7:06 AM, Kr4ck ALI wrote: Hello, I have to migrate multiple mailbox (emails, contacts, calendar, tasks) from thunderbird to outlook Office 365. So 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 know it's a tedious task ... But I know that nothing is impossible ! There's nothing wrong with trying to tackle this task, but there are some actual commercial tools available which will probably know more about the quirks of such a conversion than you are likely to find out in the course of one migration, as they'll have experiences from probably hundreds of them. -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert MBOX thunderbird to PST outlook
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
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