mobile logo

Posts tagged Python

Here is a simple few liner password generator written in compact python. import string as s; from random import choice as c x=10; print ''.join([c(s.letters + s.digits) for i in range(x)]) # python pw.py Bz7DKuzqCL

Read More

When working with CUPS using remote print queues, you may find that the remote printer is not always available, has timed out, ran out of paper, has a paper jam, etc. Sometimes this causes a job to 'not-complete' and when running 'lpstat -o', you see old print jobs. We put together a quick script to auto-purge these jobs.  Hopefully this helps someone in the future. Please let us know if you found this useful, or if you have any suggested changes. #!/usr/bin/python # # Purge print jobs that are not-complete and older than 10 days. # from datetime import date, timedelta, datetime import time import os howmanydaysago=10 today=date.today() daysago=today-timedelta(days=howmanydaysago) epoch_today=time.mktime(today.timetuple()) epoch_daysago=time.mktime(daysago.timetuple()) date_difference=epoch_today-epoch_daysago for line in os.popen('/usr/bin/lpstat …

Read More