-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscanner.py
More file actions
66 lines (54 loc) · 1.83 KB
/
scanner.py
File metadata and controls
66 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import config
import sys
import searcher
import random
from multiprocessing import Pool
from peewee import MySQLDatabase
def main():
SCANNERS = []
with open(config.ACCOUNTS_FILE, 'r') as f:
for num, line in enumerate(f, 1):
fields = line.split(",")
fields = map(str.strip, fields)
SCANNERS.append({'username': fields[0], 'password': fields[1]})
gyms = get_gyms()
if len(gyms) == 0:
print('Found 0 gyms in queue. Please add more.')
sys.exit(1)
else:
print('Found {} gyms in queue.'.format(len(gyms)))
p = Pool()
xyl = []
ranscan = random.choice(SCANNERS)
for gym in gyms:
xyl.append({
'id': gym.get('id'),
'lat': gym.get('lat'),
'lng': gym.get('lng'),
'username': ranscan['username'],
'password': ranscan['password']
})
p.map(searcher.gym_scanner_thread, xyl)
def get_gyms():
gyms = []
database = MySQLDatabase(database=config.BASE_DB['database'], user=config.BASE_DB['username'],
password=config.BASE_DB['password'], host=config.BASE_DB['host'])
if config.BASE_DB_TYPE == 0:
cursor = database.execute_sql('SELECT * FROM gyms;')
for row in cursor.fetchall():
gyms.append({
'id': str(row['gym_id']),
'lat': row['latitude'],
'lng': row['longitude']
})
elif config.BASE_DB_TYPE == 1:
cursor = database.execute_sql('SELECT * FROM forts;')
for row in cursor.fetchall():
gyms.append({
'id': str(row[1]),
'lat': float(row[2]),
'lng': float(row[3])
})
return gyms
if __name__ == '__main__':
main()