Weiwei | 074778b | 2015-08-07 21:30:44 -0700 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
| 3 | # Copyright (C) 2014-2015 Regents of the University of California. |
| 4 | # Author: Weiwei Liu <summerwing10@gmail.com> |
| 5 | # |
| 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU Lesser General Public License as published by |
| 8 | # the Free Software Foundation, either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU Lesser General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU Lesser General Public License |
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | # A copy of the GNU Lesser General Public License is in the file COPYING. |
| 19 | |
| 20 | import sys |
| 21 | import os |
| 22 | import sqlite3 |
| 23 | from user_access_storage import UserAccessStorage |
| 24 | |
| 25 | def showDefault(databaseFilePath = None): |
| 26 | if databaseFilePath == None or databaseFilePath == "": |
| 27 | if not "HOME" in os.environ: |
| 28 | home = '.' |
| 29 | else: |
| 30 | home = os.environ["HOME"] |
| 31 | |
| 32 | dbDirectory = os.path.join(home, '.ndn') |
| 33 | if not os.path.exists(dbDirectory): |
| 34 | os.makedirs(dbDirectory) |
| 35 | |
| 36 | databaseFilePath = os.path.join(dbDirectory, 'ndnhome-controller.db') |
| 37 | |
| 38 | database = sqlite3.connect(databaseFilePath) |
| 39 | |
| 40 | cursor = database.cursor() |
| 41 | cursor.execute("SELECT command_id, user_id, user_device, access_token_name FROM Access") |
| 42 | print 'command id: user id: user_device, access token name:' |
| 43 | for row in cursor.fetchall(): |
| 44 | print '%d %d %s %s' %(row[0], row[1], row[2], row[3]) |
| 45 | cursor.close() |
| 46 | |
| 47 | if len(sys.argv) < 2: |
| 48 | showDefault() |
| 49 | |
| 50 | else: |
| 51 | raise RuntimeError("options is not implemented yet") |
| 52 | |