Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Commit fa80b98

Browse files
authored
Merge pull request #198 from danwoj/master
Final commit for the quarter
2 parents 5882979 + f3f8991 commit fa80b98

File tree

13 files changed

+1387
-0
lines changed

13 files changed

+1387
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
The number 6 is a truly great number. Given two int values, a and b,
5+
return True if either one is 6. Or if their sum or difference is 6. Note:
6+
the function abs(num) computes the absolute value of a number.
7+
'''
8+
9+
def love6(a, b):
10+
if a == 6 or b == 6:
11+
return True
12+
elif a-b == 6 or b-a == 6:
13+
return True
14+
elif a+b == 6:
15+
return True
16+
else:
17+
return False
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python
2+
3+
'''
4+
The number 6 is a truly great number. Given two int values, a and b,
5+
return True if either one is 6. Or if their sum or difference is 6. Note:
6+
the function abs(num) computes the absolute value of a number.
7+
'''
8+
9+
from love6 import love6
10+
11+
import pytest
12+
13+
def test_1():
14+
assert love6(6, 4) is True
15+
16+
17+
def test_2():
18+
assert love6(4, 5) is False
19+
20+
21+
def test_3():
22+
assert love6(1, 5) is True
23+
24+
25+
def test_4():
26+
assert love6(1, 6) is True
27+
28+
29+
def test_5():
30+
assert love6(1, 8) is False
31+
32+
33+
def test_6():
34+
assert love6(1, 7) is True
35+
36+
37+
def test_7():
38+
assert love6(7, 5) is False
39+
40+
41+
def test_8():
42+
assert love6(8, 2) is True
43+
44+
45+
def test_9():
46+
assert love6(6, 6) is True
47+
48+
49+
def test_10():
50+
assert love6(-6, 2) is False
51+
52+
53+
def test_11():
54+
assert love6(-4, -10) is True
55+
56+
57+
def test_12():
58+
assert love6(-7, 1) is False
59+
60+
61+
def test_13():
62+
assert love6(7, -1) is True
63+
64+
65+
def test_14():
66+
assert love6(-6, 12) is True
67+
68+
69+
def test_15():
70+
assert love6(-2, -4) is False
71+
72+
73+
def test_16():
74+
assert love6(7, 1) is True
75+
76+
77+
def test_17():
78+
assert love6(0, 9) is False
79+
80+
81+
def test_18():
82+
assert love6(8, 3) is False
83+
84+
85+
def test_19():
86+
assert love6(3, 3) is True
87+
88+
89+
def test_20():
90+
assert love6(3, 4) is False
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
import winrm, os, socket
3+
import subprocess as sub
4+
5+
class Net_data:
6+
def __init__(self):
7+
self.ip
8+
self.subnet
9+
10+
def ip(self):
11+
ip = (([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0]
12+
13+
return ip
14+
15+
def subnet(self):
16+
Popen_command = ''
17+
subnet = sub.Popen("ifconfig | grep {} | awk -F 'Mask:' '{{print $2}}'".format(self.ip()), stdout = sub.PIPE, shell = True)
18+
(output, err) = subnet.communicate()
19+
subnet = (str(output, "utf8").split("\n")).pop(0)
20+
21+
return subnet
22+
23+
x = Net_data()
24+
25+
print(x.ip())
26+
print(x.subnet())

0 commit comments

Comments
 (0)