Skip to content
Browse files

Add logout option.

We just unlink ~/.cloudprintauth
  • Loading branch information...
1 parent 620d605 commit e681c5a85215d3ab81de36d12a7ac3aa84332323 @armooo committed May 1, 2011
Showing with 17 additions and 3 deletions.
  1. +1 −0 README.rst
  2. +16 −3 cloudprint/cloudprint.py
View
1 README.rst
@@ -13,6 +13,7 @@ Usage
cloudprint [-d] [-p pid_file] [-h]
-d : enable daemon mode (requires the daemon module)
+ -l : logout of the current google account
-p pid_file : path to write the pid to (default cloudprint.pid)
-h : display this help
View
19 cloudprint/cloudprint.py
@@ -56,11 +56,15 @@ def get_auth(self):
def get_saved_auth(self):
if os.path.exists(self.auth_path):
- auth_file = open(self.auth_path)
+ auth_file = open(self.auth_path)
self.auth = auth_file.read()
auth_file.close()
return self.auth
+ def del_saved_auth(self):
+ if os.path.exists(self.auth_path):
+ os.unlink(self.auth_path)
+
def set_auth(self, auth):
self.auth = auth
if not os.path.exists(self.auth_path):
@@ -298,18 +302,22 @@ def process_jobs(cups_connection, cpp, printers):
time.sleep(60)
def usage():
- print sys.argv[0] + ' [-d] [-p pid_file] [-h]'
+ print sys.argv[0] + ' [-d][-l][-h] [-p pid_file]'
print '-d\t\t: enable daemon mode (requires the daemon module)'
+ print '-l\t\t: logout of the google account'
print '-p pid_file\t: path to write the pid to (default cloudprint.pid)'
print '-h\t\t: display this help'
def main():
- opts, args = getopt.getopt(sys.argv[1:], 'dhp:')
+ opts, args = getopt.getopt(sys.argv[1:], 'dlhp:')
daemon = False
+ logout = False
pidfile = None
for o, a in opts:
if o == '-d':
daemon = True
+ elif o == '-l':
+ logout = True
elif o == '-p':
pidfile = a
elif o =='-h':
@@ -321,6 +329,11 @@ def main():
cups_connection = cups.Connection()
cpp = CloudPrintProxy()
+ if logout:
+ cpp.del_saved_auth()
+ print 'logged out'
+ return
+
#try to login
while True:
try:

0 comments on commit e681c5a

Please sign in to comment.
Something went wrong with that request. Please try again.