Skip to content
Permalink
Browse files

Added script for deleting accounts

  • Loading branch information
simoncadman committed May 1, 2013
1 parent d9eb4e9 commit 11e04165d9911618672fb150fc27441df559985d
Showing with 62 additions and 0 deletions.
  1. +19 −0 auth.py
  2. +43 −0 deleteaccount.py
19 auth.py
@@ -25,6 +25,25 @@ class Auth:
clientsecret = 'MzTBsY4xlrD_lxkmwFbBrvBv'
config = '/etc/cloudprint.conf'

def DeleteAccount(userid=None): # pragma: no cover
"""Delete an account from the configuration file
Args:
storage: storage, instance of storage to store credentials in.
userid: string, reference for the account
Returns:
deleted: boolean , true on success
"""
storage = multistore_file.get_credential_storage(
Auth.config,
Auth.clientid,
userid,
['https://www.googleapis.com/auth/cloudprint'])
return storage.delete()

DeleteAccount = staticmethod(DeleteAccount)

def AddAccount(storage, userid=None): # pragma: no cover
"""Adds an account to the configuration file
@@ -0,0 +1,43 @@
#! /usr/bin/env python2
# CUPS Cloudprint - Print via Google Cloud Print
# Copyright (C) 2011 Simon Cadman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import cups, os, json
from auth import Auth

while True:
result = Auth.SetupAuth(False)
if not result:
print("No accounts are currently setup")
break
else:
requestors, storage = result
print("You currently have these accounts configured: ")
i=0
accounts = []
for requestor in requestors:
i+=1
accounts.append(requestor.getAccount())
print(str(i) + ") " + requestor.getAccount())
print("0) Exit")
answer = raw_input("Which account to delete (1-" + str(i) + ") ? ")
if ( answer.isdigit() and int(answer) <= i and int(answer) >= 1 ):
Auth.DeleteAccount(accounts[int(answer)-1])
print(accounts[int(answer)-1] + " deleted.")
elif ( answer == "0" ):
break
else:
print("Invalid response, use '0' to exit")

0 comments on commit 11e0416

Please sign in to comment.
You can’t perform that action at this time.