Reading \Seen, \Unseen flags using imaplib in Python - python

Is it possible to read e-mail flags Seen, Unseen and restore them as the were before reading e-mail using imaplib in Python?
I couldn't find yet any information regarding reading these flags but there is plenty of examples setting Seen, Unseen etc. flags. I would appreciate if somebody would guide me to the right direction.

A big thanks goes to #stovfl and #Max in comments. I successfully made my program work using imap_conn.fetch(uid, '(BODY.PEEK[HEADER])'). On the other side if somebody needs read-only access they can use imap_conn.select('Inbox', readonly=True)

Related

Is pytesseract safe to use with confidential images?

I am working on a project for my company which tries to read scanned pdfs and classify them depending on their contents.
After doing some research online, the easiest way to solve this seems to be by using a Python Library called pytesseract.
My question is: Is this library safe to use with images containing confidential customer data? Do the images/the extracted text get saved in some server?
I found this link which suggests that it is. But I am lacking understandment of what exactly happens 'behind the scenes' everytime I read an image with the module.
Thanks in advance for any help!

How to run two function from same resource(plot graphic and saving infinite data to txt file)

I'm new in Python, try to develop gui app. My data source is from serial port. When i pressed buttons, it should plot graphics and print it on the screen and print to new txt file.
All of above that i mentioned should do separetely.
My expected is: How can i run both saving data and plotting many graphics concurrently from same resource
I used threading, time.sleep, wx.Timer. but I couldn't succeed on it. Anybody can help me? Thanks a lot.
You can certainly use a wx.Timer event to fetch the latest data from the serial port. With that data, you can stream it to an open file and update a graph of the data.
Without a more detailed question, it's hard to give a detailed answer. But, you may find the wxmplot library (https://newville.github.io/wxmplot/) useful. In fairness, I am the lead author of that library. One of its features I use it for is very similar to your need: "live updated plots" of data from an external source, and without recreating a new matplotlib figure for each new data set.
You might find the example at https://github.com/newville/wxmplot/blob/master/examples/stripchart.py to be a useful example. It has a function that simulates data, but you can replace this with "read from serial port" or fetching other data sources.

Analyze sound live with aubio?

Is there any way for the aubio library to analyze sound live? I can get it to analyze a saved audio file just fine, but it does not seem to want to work with microphone inputs. Documentation for the Python library seems just about non-existent. All I found were these examples, none of which seem to deal with analysis of live input. Has anyone managed to work with live input before, and how is it done?
See https://github.com/aubio/aubio/issues/78 and https://github.com/aubio/aubio/issues/6
Demo here: https://github.com/aubio/aubio/blob/master/python/demos/demo_pyaudio.py
Please open a new issue whenever you have a question, or use https://aubio.org/contact

Dbus.Array (Reading pidgin messages from python)

I am trying to read a message on a pidgin window using python. I have read Pidgin how to and I using the following code:
purple.PurpleGetConversations()
and I get the following output:
dbus.Array([dbus.Int32(14414)], signature=dbus.Signature('i'))
I dont know how to access the elements of this dbus.Array
Best Regards
PD: I am interested in reading the messages, if there is a better way please let me know
Progress update: If anyone else is interested in this, I came up with an alternative solution. Pidgin leaves chat logs in ~/purple, from python you can open this files and use regex to read all msgs.
(If there is a more straigthforward way please tell me)
I found it, Here is the resulting code:
convID = purple.PurpleGetConversations()
msgpos = purple.PurpleConversationGetMessageHistory(convID[0])[0]
print purple.PurpleConversationMessageGetMessage(msgpos)
This will print the last message from an open chat
You need to use PurpleConversationGetChatData method, it takes conversation id as a parameter (14414 in your case).
I have javascript client generated from introspection xml, it might be helpful addition to a dbus documentation - https://github.com/sidorares/node-pidgin/blob/master/index.js

django/python: How to convert pptx/docx formats to PDF using python?

First of all, I agree that this might sound like a question which has already been asked many times in the past. However I couldn't find any answer that was relevant to me in the similar questions so I'll try to be more specific.
I would need to transform PPTX/DOCX files into PDF using Python but I don't have any experience in file format conversion. I have been looking in many places/forums/websites, read a lot of documentation and came across some useful libraries (python-pptx and pyPdf mainly), but I still don't know where to start.
When looking on the Internet, I can see many websites that offer file format conversions as a paying service, even with advanced API's: submit a file via POST and get the transformed PDF file in return. This could work for me, but I am really interested in writing myself the code that does the conversion work from OOXML to PDF.
How would you start doing this? Or is it just impossible on my own?
Thanks for your help!
After some research and with the help of python-pptx's creator, I was able to write to the PowerPoint COM interface using a Virtual Machine.
In case someone reads this thread, this is how I managed to get this done:
- Setup a VM with Microsoft Windows/Office installed on it ;
- Install Python, Django and win32com libraries on the VM.
The files are sent locally from the original Django project to the virtual machine (which are on the same network) through a simple POST request. The file is converted on the VM using win32com.client (which is just a simple call to the win32com.client library) and then sent back as a response to the original Django view, which in turn processes the response.
Note: it took me some time to realize I needed to use the #csrf_exempt decorator for this setup to work.

Categories