Skip to content

Commit

Permalink
Merge branch 'master' of github.com:marco-c/autowebcompat into id_less
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarvijaygupta committed Feb 10, 2018
2 parents 72735fa + 1846eff commit 5d4c0bc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ The aim of this project is creating a tool to automatically detect web compatibi

- Install the dependencies in requirements.txt: `pip install -r requirements.txt`.
- Run the **get_dependencies.py** script.

## Communication

Real-time communication for this project happens on [Mozilla's IRC network](https://wiki.mozilla.org/IRC), irc.mozilla.org, in the #webcompat channel.
20 changes: 11 additions & 9 deletions collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from selenium import webdriver
from selenium.common.exceptions import NoAlertPresentException, NoSuchWindowException, TimeoutException

if sys.platform.startswith("linux"): # linux
if sys.platform.startswith("linux"):
chrome_bin = "tools/chrome-linux/chrome"
nightly_bin = 'tools/nightly/firefox-bin'
elif sys.platform.startswith("darwin"): # MAC OS X
elif sys.platform.startswith("darwin"):
chrome_bin = "tools/chrome.app/Contents/MacOS/chrome"
nightly_bin = 'tools/Nightly.app/Contents/MacOS/firefox'
elif sys.platform.startswith("win32"):
Expand Down Expand Up @@ -79,14 +79,13 @@ def close_all_windows_except_first(driver):

def get_all_attributes(driver, child):
child_attributes = driver.execute_script("""
let elem_attribute = {};
let elem_attribute = {};
for (let i = 0; i < arguments[0].attributes.length; i++) {
elem_attribute[arguments[0].attributes[i].name] = arguments[0].attributes[i].value;
}
return elem_attribute;
""", child)
for (let i = 0; i < arguments[0].attributes.length; i++) {
elem_attribute[arguments[0].attributes[i].name] = arguments[0].attributes[i].value;
}
return elem_attribute;
""", child)

return child_attributes

Expand All @@ -104,6 +103,7 @@ def do_something(driver, elem_attributes=None):
children = buttons + links + inputs

random.shuffle(children)

for child in children:

# Get all the attributes of the child.
Expand All @@ -126,7 +126,9 @@ def do_something(driver, elem_attributes=None):
links = body.find_elements_by_tag_name('a')
inputs = body.find_elements_by_tag_name('input')
children = buttons + links + inputs

for child in children:

# Get all the attributes of the child.
child_attributes = get_all_attributes(driver, child)
if elem_attributes == child_attributes:
Expand Down
6 changes: 2 additions & 4 deletions get_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ def download(url, filename):
download(url, name)

print('[*] Extracting files...')
f = tarfile.open(name, 'r:xz')
f.extractall('.')
f.close()

with tarfile.open(name, 'r:xz') as f:
f.extractall('.')
os.remove(name)

print('[*] Downloading data.zip...')
Expand Down
2 changes: 1 addition & 1 deletion network.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def accuracy(y_true, y_pred):
return K.mean(K.equal(y_true, K.cast(y_pred < 0.5, y_true.dtype)))


def compile(model, optimizer=None, loss_func=contrastive_loss):
def compile(model, optimizer='sgd', loss_func=contrastive_loss):
allOptimizers = {
'sgd': SGD(lr=0.0003, decay=1e-6, momentum=0.9, nesterov=True),
'adam': Adam(),
Expand Down
4 changes: 2 additions & 2 deletions rename_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
continue
webcompat_id = parts[0]
sequence_no = parts[-2]
elem_id = parts[1:-2]
elem_id = '_'.join(parts[1:-2])
browser = parts[-1]
if webcompat_id not in image_info.keys():
image_info[webcompat_id] = {}
Expand All @@ -22,5 +22,5 @@
seq_no_and_elem_id = sorted(seq_no_and_elem_id.items())
for value in seq_no_and_elem_id:
sequence_no = value[0]
elem_id = value[1][0]
elem_id = value[1]
text_file.write("%s %s\n" % (sequence_no, elem_id))

0 comments on commit 5d4c0bc

Please sign in to comment.