-
Notifications
You must be signed in to change notification settings - Fork 52
New module, speccy.py #208
base: gonzobot
Are you sure you want to change the base?
Changes from 22 commits
7f19215
e4adf75
ef2487f
3ed293c
f46eabb
cec4812
31aae3d
f2d3c28
4245df6
07e8a30
efceb1d
42e876d
dc2480a
48d1711
bafcc32
ee495da
fb17d50
c977e3c
d49eb27
601e599
9d2d695
cadcfa4
efa4758
bf3cb84
1ca2b0b
dc5a781
60cefc9
55bcc6c
1a2d613
ec039fc
a0baf00
6ee430c
c211e9a
4725b3f
288f03d
b10c6b0
9487894
196a1b5
1b73957
241abb2
77123d9
2dcd32a
a739caa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from cloudbot import hook | ||
|
||
import re | ||
import requests | ||
|
||
from bs4 import BeautifulSoup as BS | ||
from contextlib import closing | ||
|
||
url_re = re.compile('https?:\/\/speccy\.piriform\.com\/results\/[a-zA-Z0-9]+', re.I) | ||
|
||
GPU_RE = re.compile('.*(amd|radeon|intel|integrated|nvidia|geforce|gtx).*\n.*', re.I) | ||
PICO_RE = re.compile('.*pico', re.I) | ||
KMS_RE = re.compile('.*kms', re.I) | ||
BOOSTER_RE = re.compile('.*booster', re.I) | ||
REVIVER_RE = re.compile('.*reviver', re.I) | ||
KILLER_RE = re.compile('.*Killer.+Service', re.I) | ||
|
||
|
||
@hook.regex(url_re) | ||
def get_speccy_url(match): | ||
|
||
with closing(requests.get(match.group(), )) as response: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extraneous comma and whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you're referring to, these 4 lines have been the same since many reviewed (by you) revisions ago. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm referring to the comma and space after |
||
soup = BS(response.content, "lxml", from_encoding=response.encoding) | ||
|
||
body = soup.body | ||
|
||
data = [] | ||
|
||
osspec = body.find("div", text='Operating System') | ||
if osspec: | ||
data.append( | ||
"\x02OS:\x02" + " " + osspec.next_sibling.next_sibling.text) | ||
|
||
ramspec = body.find("div", text='RAM') | ||
if ramspec: | ||
data.append( | ||
"\x02RAM:\x02" + " " + ramspec.next_sibling.next_sibling.text) | ||
|
||
cpuspec = body.find("div", text='CPU') | ||
if cpuspec: | ||
data.append( | ||
"\x02CPU:\x02" + " " + cpuspec.next_sibling.next_sibling.text) | ||
|
||
gpufind = body.find("div", text='Graphics').next_sibling.next_sibling.text | ||
gpuspec = "" | ||
for gpustring in GPU_RE.finditer(gpufind): | ||
gpuspec += gpustring.group() | ||
if gpuspec: | ||
data.append("\x02GPU:\x02" + " " + gpuspec) | ||
|
||
picospec = body.find("div", text=PICO_RE) | ||
if picospec: | ||
data.append("\x02Badware:\x02" + " " + picospec.text) | ||
|
||
kmsspec = body.find("div", text=KMS_RE) | ||
if kmsspec: | ||
data.append("\x02Badware:\x02" + " " + kmsspec.text) | ||
|
||
boosterspec = body.find("div", text=BOOSTER_RE) | ||
if boosterspec: | ||
data.append("\x02Badware:\x02" + " " + boosterspec.text) | ||
|
||
reviverspec = body.find("div", text=REVIVER_RE) | ||
if reviverspec: | ||
data.append("\x02Badware:\x02" + " " + reviverspec.text) | ||
|
||
killerspec = body.find("div", text=KILLER_RE) | ||
if killerspec: | ||
data.append("\x02Badware:\x02" + " " + killerspec.text) | ||
|
||
def smartcheck(): | ||
drivespec = body.find_all("div", text="05") | ||
|
||
values = [] | ||
for i, spec in enumerate(drivespec): | ||
drives = spec.next_sibling.next_sibling.stripped_strings | ||
SMART = list(drives) | ||
rv_index = SMART.index("Raw Value:") | ||
raw_value = SMART[rv_index + 1] | ||
if raw_value != "0000000000": | ||
values.append(str(i + 1)) | ||
return values | ||
|
||
drives = smartcheck() | ||
if drives: | ||
for item in drives: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
data.append("\x02Bad Disk:\x02 #{}".format(item)) | ||
|
||
specout = re.sub(r"\s+", " ", ' ● '.join(data)) | ||
|
||
return specout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't pinpoint what you see, as again, it's since been the same many revisions ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the extra line after the
def
line. I just didn't catch it in earlier reviews.