aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-06-19 14:11:57 +0200
committerTeddy Wing2022-06-25 13:47:41 +0200
commit88b89ee64baeada05b906024d632c97a68920173 (patch)
treece21863d27e0e3448fcc092a5560d3fd53d138a7
parent1c1fd3c3ba017e816aafc0840e287e5b49f5ddeb (diff)
downloadcws-status-88b89ee64baeada05b906024d632c97a68920173.tar.bz2
cws-status: Add error when not authenticated
-rw-r--r--cws-status7
1 files changed, 7 insertions, 0 deletions
diff --git a/cws-status b/cws-status
index 2dc1aa9..6f6a334 100644
--- a/cws-status
+++ b/cws-status
@@ -9,6 +9,7 @@ from lxml import html
EX_USAGE = 64
+EX_NOUSER = 67
if len(sys.argv) < 2:
@@ -28,6 +29,12 @@ opener = request.build_opener(request.HTTPCookieProcessor(cookie_jar))
page_html = opener.open(url).read()
+not_logged_in_search = b'Sign in to continue to Chrome Web Store'
+
+if not_logged_in_search in page_html:
+ print('error: not authenticated', file=sys.stderr)
+ sys.exit(EX_NOUSER)
+
tree = html.fromstring(page_html)
item_names = tree.xpath('//table[//th[text()="Item"]]/tbody/tr/td[1]/a/div//text()')