1
# qakit - tools for UEQA engineers
2
# Copyright (C) 2014 Thomi Richards
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
from ConfigParser import RawConfigParser
24
from pprint import pprint
28
ACCOUNT_URL = 'https://canonical.leankit.com/Kanban/Api/'
29
BOARD_ID = '109656104'
32
def project_backlog():
34
username, password = get_lkkb_auth_pair()
36
ACCOUNT_URL + 'boards/' + BOARD_ID,
37
auth=(username, password)
39
resp.raise_for_status()
42
l for l in data[u'ReplyData'][0][u'Backlog'] if l[u'Title'] == u'Sorted'
52
csv_writer = csv.writer(sys.stdout)
53
csv_writer.writerow(row_keys)
54
for card in sorted_lane['Cards']:
55
row = [ clean_text(card[k]) for k in row_keys]
56
csv_writer.writerow(row)
58
handle_file_read_error()
69
text = text.replace('\n', '').replace('\r', '').replace('\t', '')
70
return text.encode('utf-8')
73
def stripIt(string, tag):
74
soup = BeautifulSoup(string)
76
rmtags = soup.findAll(tag)
78
string = string.replace(str(t), '')
82
def get_lkkb_auth_pair(config_file_path=None):
83
"""Return a tuple of (username, password) from the users config file.
85
Raises IOError if the file is not found.
86
Raises ValueError if the required configuration is not set.
88
if config_file_path is None:
89
config_file_path = os.path.expanduser('~/config/qakit.ini')
90
parser = RawConfigParser()
91
if not parser.read(config_file_path):
92
raise IOError("Could not read file %s" % (config_file_path))
93
if not parser.has_section("LeanKit"):
94
raise ValueError("Could not find 'LeanKit' section in config file.")
95
if not parser.has_option("LeanKit", "Username") or not parser.get("LeanKit", "Username"):
96
raise ValueError("No username set in config file.")
97
if not parser.has_option("LeanKit", "Password") or not parser.get("LeanKit", "Password"):
98
raise ValueError("No password set in config file.")
100
parser.get("LeanKit", "Username"),
101
parser.get("LeanKit", "Password"),
105
def handle_file_read_error():
106
path = get_default_config_file_path()
107
os.makedirs(os.path.dirname(path))
108
with open(path, 'w') as f:
111
"# Fill in your LeanKit username and password here:\n"
115
# TODO: Make this file readable by this user only!
116
print("Missing configuration details!")
117
print("A default configuration file has been written to:")
119
print("Please fill in the values in that file and re-run this command.")
123
def get_default_config_file_path():
124
return os.path.expanduser('~/config/qakit.ini')