Google does not delete all messages at once according to http://support.google.com/mail/answer/78755?hl=en.
So, first, you have to delete messages in each folder:
# -*- coding: utf-8 -*-
from imapclient import IMAPClient
client = IMAPClient('imap.googlemail.com', use_uid=True, ssl=True)
folders = [
for f in folders:
fold = client.select_folder(f)
res = client.delete_messages(client.search())
res = client.expunge()
#Google automatically will move deleted messages to "All Mail" folder.
#Now we can remove all messages from "All Mail"
More information on how to work with Gmail using python IMAPClient can be found directly at http://imapclient.freshfoo.com/browser/imapclient/livetest.py
Read the source code, Luke 🙂
This simple script pings your websites and notifies when a website is down.
It’s written in python >= 2.5 and might be usefull for administrators and programmers.
Some parts of it was found somewhere in the internet and adjusted a bit for my needs.
Required packages can be installed easily from repository ( Ubuntu example ):
sudo apt-get install python-notify
or using pip/easy_install as well
sudo pip install notify
Running this script from command line is a bit annoying so I put to run it by crontab each 30 min:
$ crontab -e
*/30 * * * * DISPLAY=:0 /usr/bin/python /home/vs/bin/pingwebsites.py
Note that you need to set DISPLAY option to make notification visible for current X session.
from threading import Thread
from Queue import Queue
from pynotify import *
num_threads = 4
queue = Queue()
hosts = [
#wraps system ping command
def pinger(i, q):
host = q.get()
#print "Thread %s: Pinging %s" % (i, host)
ret = subprocess.call("ping -c 5 %s" % host,
if ret == 0:
#print "%s: is alive" % host
msg = "%s: did not respond" % host
Notification("Server checker", msg).show()
#Spawn thread pool
for i in range(num_threads):
worker = Thread(target=pinger, args=(i, queue))
#Place work in queue
for host in hosts:
#Wait until worker threads are done to exit