UAForge 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uaforge/__init__.py +128 -0
- uaforge/cli.py +105 -0
- uaforge/core/__init__.py +6 -0
- uaforge/core/database.py +413 -0
- uaforge/core/user_agent.py +201 -0
- uaforge/core/version_fetcher.py +152 -0
- uaforge/core/version_updater.py +411 -0
- uaforge/data/useragent.db +0 -0
- uaforge/utils.py +31 -0
- uaforge-1.1.0.dist-info/METADATA +286 -0
- uaforge-1.1.0.dist-info/RECORD +15 -0
- uaforge-1.1.0.dist-info/WHEEL +5 -0
- uaforge-1.1.0.dist-info/entry_points.txt +2 -0
- uaforge-1.1.0.dist-info/licenses/LICENSE +21 -0
- uaforge-1.1.0.dist-info/top_level.txt +1 -0
uaforge/__init__.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from .core.user_agent import UserAgentGenerator
|
|
2
|
+
from .core.database import Database
|
|
3
|
+
from .core.version_fetcher import VersionFetcher
|
|
4
|
+
from .core.version_updater import VersionUpdater
|
|
5
|
+
|
|
6
|
+
__version__ = "1.1.0"
|
|
7
|
+
__author__ = "bolgac"
|
|
8
|
+
__email__ = "bytearchsoft@gmail.com"
|
|
9
|
+
|
|
10
|
+
__all__ = ['UserAgentGenerator', 'Database', 'VersionFetcher', 'VersionUpdater']
|
|
11
|
+
|
|
12
|
+
def init_database():
|
|
13
|
+
updater = VersionUpdater()
|
|
14
|
+
return updater.initialize_database()
|
|
15
|
+
|
|
16
|
+
def update_versions(browser_type="all"):
|
|
17
|
+
"""
|
|
18
|
+
Update browser version data for specified browser type(s).
|
|
19
|
+
This function updates version information for various browsers by delegating
|
|
20
|
+
to the appropriate update method of the VersionUpdater class.
|
|
21
|
+
Args:
|
|
22
|
+
browser_type (str, optional): The type of browser to update. Defaults to "all".
|
|
23
|
+
Supported values:
|
|
24
|
+
- "all": Updates all supported browsers
|
|
25
|
+
- "chrome": Updates Chrome browser versions
|
|
26
|
+
- "firefox": Updates Firefox browser versions
|
|
27
|
+
- "opera": Updates Opera browser versions
|
|
28
|
+
- "android": Updates Android browser versions
|
|
29
|
+
- "mac": Updates Mac browser versions
|
|
30
|
+
Returns:
|
|
31
|
+
tuple or dict:
|
|
32
|
+
- If browser_type is "all": Returns the result from update_all()
|
|
33
|
+
- If browser_type is a specific browser: Returns a tuple of (added, updated)
|
|
34
|
+
where added is the number of newly added versions and updated is the
|
|
35
|
+
number of updated versions
|
|
36
|
+
Raises:
|
|
37
|
+
ValueError: If an unsupported browser type is provided.
|
|
38
|
+
Examples:
|
|
39
|
+
>>> update_versions() # Updates all browsers
|
|
40
|
+
>>> update_versions("chrome") # Updates Chrome only
|
|
41
|
+
Chrome: +5 added, 3 updated
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
updater = VersionUpdater()
|
|
45
|
+
|
|
46
|
+
if browser_type.lower() == "all":
|
|
47
|
+
return updater.update_all()
|
|
48
|
+
elif browser_type.lower() == "chrome":
|
|
49
|
+
added, updated = updater.update_chrome()
|
|
50
|
+
print(f"Chrome: +{added} added, {updated} updated")
|
|
51
|
+
return added, updated
|
|
52
|
+
elif browser_type.lower() == "firefox":
|
|
53
|
+
added, updated = updater.update_firefox()
|
|
54
|
+
print(f"Firefox: +{added} added, {updated} updated")
|
|
55
|
+
return added, updated
|
|
56
|
+
elif browser_type.lower() == "opera":
|
|
57
|
+
added, updated = updater.update_opera()
|
|
58
|
+
print(f"Opera: +{added} added, {updated} updated")
|
|
59
|
+
return added, updated
|
|
60
|
+
elif browser_type.lower() == "android":
|
|
61
|
+
added, updated = updater.update_android()
|
|
62
|
+
print(f"Android: +{added} added, {updated} updated")
|
|
63
|
+
return added, updated
|
|
64
|
+
elif browser_type.lower() == "mac":
|
|
65
|
+
added, updated = updater.update_mac()
|
|
66
|
+
print(f"Mac: +{added} added, {updated} updated")
|
|
67
|
+
return added, updated
|
|
68
|
+
|
|
69
|
+
else:
|
|
70
|
+
raise ValueError(f"Unsupported browser type: {browser_type}")
|
|
71
|
+
|
|
72
|
+
def generate_user_agent(browser="Chrome"):
|
|
73
|
+
"""
|
|
74
|
+
Generate a random user agent string for the specified browser.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
browser (str, optional): The browser type to generate a user agent for.
|
|
78
|
+
Defaults to "Chrome". Common options include "Chrome", "Firefox",
|
|
79
|
+
"Safari", "Edge", etc.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
str: A randomly generated user agent string for the specified browser.
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
>>> ua = generate_user_agent("Firefox")
|
|
86
|
+
>>> print(ua)
|
|
87
|
+
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0
|
|
88
|
+
"""
|
|
89
|
+
generator = UserAgentGenerator()
|
|
90
|
+
return generator.create_useragent(browser)
|
|
91
|
+
|
|
92
|
+
def generate_multiple(count=10):
|
|
93
|
+
"""
|
|
94
|
+
Generate multiple random user agent strings.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
count (int, optional): The number of user agent strings to generate. Defaults to 10.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
list: A list of randomly generated user agent strings.
|
|
101
|
+
|
|
102
|
+
Example:
|
|
103
|
+
>>> user_agents = generate_multiple(5)
|
|
104
|
+
>>> len(user_agents)
|
|
105
|
+
5
|
|
106
|
+
"""
|
|
107
|
+
generator = UserAgentGenerator()
|
|
108
|
+
return generator.get_list(count)
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
from .cli import main as cli_main
|
|
112
|
+
__all__.append('cli_main')
|
|
113
|
+
except ImportError:
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
import os
|
|
118
|
+
from pathlib import Path
|
|
119
|
+
|
|
120
|
+
db_dir = Path(__file__).parent / "data"
|
|
121
|
+
db_path = db_dir / "useragent.db"
|
|
122
|
+
|
|
123
|
+
if not db_path.exists():
|
|
124
|
+
print("Warning: Database not found.")
|
|
125
|
+
print("Run the 'useragent-gen --init' command before first use.")
|
|
126
|
+
|
|
127
|
+
except Exception:
|
|
128
|
+
pass
|
uaforge/cli.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from . import generate_user_agent, generate_multiple, update_versions, init_database, __version__
|
|
4
|
+
from .core.user_agent import UserAgentGenerator
|
|
5
|
+
|
|
6
|
+
def main():
|
|
7
|
+
parser = argparse.ArgumentParser(
|
|
8
|
+
description="UAForge - UserAgent Generator CLI\n\n",
|
|
9
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
10
|
+
epilog="""
|
|
11
|
+
Examples:
|
|
12
|
+
%(prog)s --count 5 --browser Chrome
|
|
13
|
+
%(prog)s --count 10 --output useragents.txt
|
|
14
|
+
%(prog)s --update all
|
|
15
|
+
%(prog)s --init
|
|
16
|
+
"""
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
parser.add_argument("--count", "-c", type=int, default=1,
|
|
20
|
+
help="Number of user agents to be created (default: 1)")
|
|
21
|
+
|
|
22
|
+
parser.add_argument("--browser", "-b",
|
|
23
|
+
choices=["Chrome", "Firefox", "Opera", "random"],
|
|
24
|
+
default="random",
|
|
25
|
+
help="Browser type (default: random)")
|
|
26
|
+
|
|
27
|
+
parser.add_argument("--output", "-o",
|
|
28
|
+
help="Output file (optional)")
|
|
29
|
+
|
|
30
|
+
parser.add_argument("--update", "-u",
|
|
31
|
+
choices=["all", "chrome", "firefox", "opera", "android", "windows", "linux", "mac"],
|
|
32
|
+
help="Update version information.")
|
|
33
|
+
|
|
34
|
+
parser.add_argument("--init", action="store_true",
|
|
35
|
+
help="Populate the database with initial data.")
|
|
36
|
+
|
|
37
|
+
parser.add_argument("--version", "-v", action="store_true",
|
|
38
|
+
help="Show version information")
|
|
39
|
+
|
|
40
|
+
args = parser.parse_args()
|
|
41
|
+
|
|
42
|
+
if args.version:
|
|
43
|
+
print(f"UAForge v{__version__}")
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
if args.init:
|
|
47
|
+
print("Initializing the database...")
|
|
48
|
+
if init_database():
|
|
49
|
+
print("Database successfully started!")
|
|
50
|
+
else:
|
|
51
|
+
print("Database initialization failed!")
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
if args.update:
|
|
55
|
+
if args.update not in "all":
|
|
56
|
+
print(f"{args.update} versions are being updated...")
|
|
57
|
+
try:
|
|
58
|
+
update_versions(args.update)
|
|
59
|
+
print("Update complete!")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
print(f"Error: {e}")
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
if args.browser == "random":
|
|
65
|
+
import random
|
|
66
|
+
browser = random.choice(["Chrome", "Firefox", "Opera"])
|
|
67
|
+
else:
|
|
68
|
+
browser = args.browser
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
generator = UserAgentGenerator()
|
|
72
|
+
|
|
73
|
+
if args.count == 1:
|
|
74
|
+
user_agent = generator.create_useragent(browser)
|
|
75
|
+
print(user_agent)
|
|
76
|
+
|
|
77
|
+
if args.output:
|
|
78
|
+
with open(args.output, "w", encoding="utf-8") as f:
|
|
79
|
+
f.write(user_agent + "\n")
|
|
80
|
+
else:
|
|
81
|
+
user_agents = generator.get_list(args.count)
|
|
82
|
+
|
|
83
|
+
for i, ua in enumerate(user_agents, 1):
|
|
84
|
+
print(f"{i:3}. {ua}")
|
|
85
|
+
|
|
86
|
+
if args.output:
|
|
87
|
+
import os
|
|
88
|
+
from .utils import save_useragents_to_file
|
|
89
|
+
|
|
90
|
+
if os.path.exists(args.output):
|
|
91
|
+
overwrite = input(f"The {args.output} file already exists. Should it be overwritten? (yes/no)")
|
|
92
|
+
if overwrite.lower() != 'e':
|
|
93
|
+
print("The transaction has been cancelled.")
|
|
94
|
+
return
|
|
95
|
+
|
|
96
|
+
save_useragents_to_file(user_agents, args.output)
|
|
97
|
+
print(f"\n{args.count} user agent saved to file '{args.output}'.")
|
|
98
|
+
|
|
99
|
+
except Exception as e:
|
|
100
|
+
print(f"Error: {e}")
|
|
101
|
+
print("\nTip: Run the '--init' or '--update all' command for the first use.")
|
|
102
|
+
sys.exit(1)
|
|
103
|
+
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
main()
|
uaforge/core/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from ..core.user_agent import UserAgentGenerator
|
|
2
|
+
from ..core.database import Database
|
|
3
|
+
from ..core.version_fetcher import VersionFetcher
|
|
4
|
+
|
|
5
|
+
__version__ = "1.0.0"
|
|
6
|
+
__all__ = ['UserAgentGenerator', 'Database', 'VersionFetcher', 'generate_user_agent', 'generate_multiple']
|
uaforge/core/database.py
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import sqlite3
|
|
2
|
+
import os
|
|
3
|
+
from typing import List, Tuple, Dict, Any
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
class Database:
|
|
8
|
+
|
|
9
|
+
def __init__(self, db_path: str = None):
|
|
10
|
+
if db_path is None:
|
|
11
|
+
current_dir = Path(__file__).parent
|
|
12
|
+
db_dir = current_dir.parent / "data"
|
|
13
|
+
db_dir.mkdir(exist_ok=True)
|
|
14
|
+
db_path = str(db_dir / "useragent.db")
|
|
15
|
+
|
|
16
|
+
self.db_path = db_path
|
|
17
|
+
self._init_database()
|
|
18
|
+
|
|
19
|
+
def _init_database(self):
|
|
20
|
+
conn = sqlite3.connect(self.db_path)
|
|
21
|
+
cursor = conn.cursor()
|
|
22
|
+
|
|
23
|
+
cursor.execute('''
|
|
24
|
+
CREATE TABLE IF NOT EXISTS chrome_versions (
|
|
25
|
+
version TEXT PRIMARY KEY,
|
|
26
|
+
release_date TEXT,
|
|
27
|
+
last_updated TEXT
|
|
28
|
+
)
|
|
29
|
+
''')
|
|
30
|
+
|
|
31
|
+
cursor.execute('''
|
|
32
|
+
CREATE TABLE IF NOT EXISTS firefox_versions (
|
|
33
|
+
version TEXT PRIMARY KEY,
|
|
34
|
+
release_date TEXT,
|
|
35
|
+
last_updated TEXT
|
|
36
|
+
)
|
|
37
|
+
''')
|
|
38
|
+
|
|
39
|
+
cursor.execute('''
|
|
40
|
+
CREATE TABLE IF NOT EXISTS opera_versions (
|
|
41
|
+
version TEXT PRIMARY KEY,
|
|
42
|
+
release_date TEXT,
|
|
43
|
+
last_updated TEXT
|
|
44
|
+
)
|
|
45
|
+
''')
|
|
46
|
+
|
|
47
|
+
cursor.execute('''
|
|
48
|
+
CREATE TABLE IF NOT EXISTS android_versions (
|
|
49
|
+
version TEXT PRIMARY KEY,
|
|
50
|
+
release_date TEXT,
|
|
51
|
+
last_updated TEXT
|
|
52
|
+
)
|
|
53
|
+
''')
|
|
54
|
+
|
|
55
|
+
cursor.execute('''
|
|
56
|
+
CREATE TABLE IF NOT EXISTS windows_versions (
|
|
57
|
+
version TEXT PRIMARY KEY,
|
|
58
|
+
release_date TEXT,
|
|
59
|
+
last_updated TEXT
|
|
60
|
+
)
|
|
61
|
+
''')
|
|
62
|
+
|
|
63
|
+
cursor.execute('''
|
|
64
|
+
CREATE TABLE IF NOT EXISTS macos_versions (
|
|
65
|
+
version TEXT PRIMARY KEY,
|
|
66
|
+
release_date TEXT,
|
|
67
|
+
last_updated TEXT
|
|
68
|
+
)
|
|
69
|
+
''')
|
|
70
|
+
|
|
71
|
+
cursor.execute('''
|
|
72
|
+
CREATE TABLE IF NOT EXISTS platforms (
|
|
73
|
+
platform TEXT,
|
|
74
|
+
system_info TEXT,
|
|
75
|
+
PRIMARY KEY (platform, system_info)
|
|
76
|
+
)
|
|
77
|
+
''')
|
|
78
|
+
|
|
79
|
+
cursor.execute('''
|
|
80
|
+
CREATE TABLE IF NOT EXISTS version_types (
|
|
81
|
+
platform TEXT,
|
|
82
|
+
version_type TEXT,
|
|
83
|
+
PRIMARY KEY (platform, version_type)
|
|
84
|
+
)
|
|
85
|
+
''')
|
|
86
|
+
|
|
87
|
+
conn.commit()
|
|
88
|
+
conn.close()
|
|
89
|
+
|
|
90
|
+
def get_connection(self):
|
|
91
|
+
return sqlite3.connect(self.db_path)
|
|
92
|
+
|
|
93
|
+
def get_device_version(self) -> Dict[str, List[str]]:
|
|
94
|
+
platforms = {}
|
|
95
|
+
conn = self.get_connection()
|
|
96
|
+
cursor = conn.cursor()
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
cursor.execute("SELECT platform, system_info FROM platforms")
|
|
100
|
+
rows = cursor.fetchall()
|
|
101
|
+
|
|
102
|
+
for platform, system_info in rows:
|
|
103
|
+
if platform not in platforms:
|
|
104
|
+
platforms[platform] = []
|
|
105
|
+
platforms[platform].append(system_info)
|
|
106
|
+
finally:
|
|
107
|
+
conn.close()
|
|
108
|
+
|
|
109
|
+
return platforms
|
|
110
|
+
|
|
111
|
+
def get_version_type_connect(self) -> Dict[str, List[str]]:
|
|
112
|
+
version_types = {}
|
|
113
|
+
conn = self.get_connection()
|
|
114
|
+
cursor = conn.cursor()
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
cursor.execute("SELECT platform, version_type FROM version_types")
|
|
118
|
+
rows = cursor.fetchall()
|
|
119
|
+
|
|
120
|
+
for platform, version_type in rows:
|
|
121
|
+
if platform not in version_types:
|
|
122
|
+
version_types[platform] = []
|
|
123
|
+
version_types[platform].append(version_type)
|
|
124
|
+
finally:
|
|
125
|
+
conn.close()
|
|
126
|
+
|
|
127
|
+
return version_types
|
|
128
|
+
|
|
129
|
+
def get_chrome_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
130
|
+
versions = []
|
|
131
|
+
version_data = []
|
|
132
|
+
conn = self.get_connection()
|
|
133
|
+
cursor = conn.cursor()
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
cursor.execute("SELECT version, release_date, last_updated FROM chrome_versions")
|
|
137
|
+
rows = cursor.fetchall()
|
|
138
|
+
|
|
139
|
+
for version, release_date, last_updated in rows:
|
|
140
|
+
versions.append(version)
|
|
141
|
+
version_data.append((version, release_date, last_updated))
|
|
142
|
+
finally:
|
|
143
|
+
conn.close()
|
|
144
|
+
|
|
145
|
+
return (versions, version_data)
|
|
146
|
+
|
|
147
|
+
def get_firefox_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
148
|
+
versions = []
|
|
149
|
+
version_data = []
|
|
150
|
+
conn = self.get_connection()
|
|
151
|
+
cursor = conn.cursor()
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
cursor.execute("SELECT version, release_date, last_updated FROM firefox_versions")
|
|
155
|
+
rows = cursor.fetchall()
|
|
156
|
+
|
|
157
|
+
for version, release_date, last_updated in rows:
|
|
158
|
+
versions.append(version)
|
|
159
|
+
version_data.append((version, release_date, last_updated))
|
|
160
|
+
finally:
|
|
161
|
+
conn.close()
|
|
162
|
+
|
|
163
|
+
return (versions, version_data)
|
|
164
|
+
|
|
165
|
+
def get_opera_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
166
|
+
versions = []
|
|
167
|
+
version_data = []
|
|
168
|
+
conn = self.get_connection()
|
|
169
|
+
cursor = conn.cursor()
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
cursor.execute("SELECT version, release_date, last_updated FROM opera_versions")
|
|
173
|
+
rows = cursor.fetchall()
|
|
174
|
+
|
|
175
|
+
for version, release_date, last_updated in rows:
|
|
176
|
+
versions.append(version)
|
|
177
|
+
version_data.append((version, release_date, last_updated))
|
|
178
|
+
finally:
|
|
179
|
+
conn.close()
|
|
180
|
+
|
|
181
|
+
return (versions, version_data)
|
|
182
|
+
|
|
183
|
+
def get_android_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
184
|
+
versions = []
|
|
185
|
+
version_data = []
|
|
186
|
+
conn = self.get_connection()
|
|
187
|
+
cursor = conn.cursor()
|
|
188
|
+
|
|
189
|
+
try:
|
|
190
|
+
cursor.execute("SELECT version, release_date, last_updated FROM android_versions")
|
|
191
|
+
rows = cursor.fetchall()
|
|
192
|
+
|
|
193
|
+
for version, release_date, last_updated in rows:
|
|
194
|
+
versions.append(version)
|
|
195
|
+
version_data.append((version, release_date, last_updated))
|
|
196
|
+
finally:
|
|
197
|
+
conn.close()
|
|
198
|
+
|
|
199
|
+
return (versions, version_data)
|
|
200
|
+
|
|
201
|
+
def get_windows_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
202
|
+
versions = []
|
|
203
|
+
version_data = []
|
|
204
|
+
conn = self.get_connection()
|
|
205
|
+
cursor = conn.cursor()
|
|
206
|
+
|
|
207
|
+
try:
|
|
208
|
+
cursor.execute("SELECT version, release_date, last_updated FROM windows_versions")
|
|
209
|
+
rows = cursor.fetchall()
|
|
210
|
+
|
|
211
|
+
for version, release_date, last_updated in rows:
|
|
212
|
+
versions.append(version)
|
|
213
|
+
version_data.append((version, release_date, last_updated))
|
|
214
|
+
finally:
|
|
215
|
+
conn.close()
|
|
216
|
+
|
|
217
|
+
return (versions, version_data)
|
|
218
|
+
|
|
219
|
+
def get_macos_vers(self) -> Tuple[List[str], List[Tuple]]:
|
|
220
|
+
versions = []
|
|
221
|
+
version_data = []
|
|
222
|
+
conn = self.get_connection()
|
|
223
|
+
cursor = conn.cursor()
|
|
224
|
+
|
|
225
|
+
try:
|
|
226
|
+
cursor.execute("SELECT version, release_date, last_updated FROM macos_versions")
|
|
227
|
+
rows = cursor.fetchall()
|
|
228
|
+
|
|
229
|
+
for version, release_date, last_updated in rows:
|
|
230
|
+
versions.append(version)
|
|
231
|
+
version_data.append((version, release_date, last_updated))
|
|
232
|
+
finally:
|
|
233
|
+
conn.close()
|
|
234
|
+
|
|
235
|
+
return (versions, version_data)
|
|
236
|
+
|
|
237
|
+
def add_chrome_versions(self, dt_add: list, dt_update: list = None):
|
|
238
|
+
conn = self.get_connection()
|
|
239
|
+
cursor = conn.cursor()
|
|
240
|
+
|
|
241
|
+
try:
|
|
242
|
+
for version, release_date, last_updated in dt_add:
|
|
243
|
+
cursor.execute('''
|
|
244
|
+
INSERT OR REPLACE INTO chrome_versions
|
|
245
|
+
(version, release_date, last_updated)
|
|
246
|
+
VALUES (?, ?, ?)
|
|
247
|
+
''', (version, release_date, last_updated))
|
|
248
|
+
|
|
249
|
+
if dt_update:
|
|
250
|
+
for version, release_date, last_updated in dt_update:
|
|
251
|
+
cursor.execute('''
|
|
252
|
+
UPDATE chrome_versions
|
|
253
|
+
SET release_date = ?, last_updated = ?
|
|
254
|
+
WHERE version = ?
|
|
255
|
+
''', (release_date, last_updated, version))
|
|
256
|
+
|
|
257
|
+
conn.commit()
|
|
258
|
+
finally:
|
|
259
|
+
conn.close()
|
|
260
|
+
|
|
261
|
+
def add_firefox_versions(self, dt_add: list, dt_update: list = None):
|
|
262
|
+
conn = self.get_connection()
|
|
263
|
+
cursor = conn.cursor()
|
|
264
|
+
|
|
265
|
+
try:
|
|
266
|
+
for version, release_date, last_updated in dt_add:
|
|
267
|
+
cursor.execute('''
|
|
268
|
+
INSERT OR REPLACE INTO firefox_versions
|
|
269
|
+
(version, release_date, last_updated)
|
|
270
|
+
VALUES (?, ?, ?)
|
|
271
|
+
''', (version, release_date, last_updated))
|
|
272
|
+
|
|
273
|
+
if dt_update:
|
|
274
|
+
for version, release_date, last_updated in dt_update:
|
|
275
|
+
cursor.execute('''
|
|
276
|
+
UPDATE firefox_versions
|
|
277
|
+
SET release_date = ?, last_updated = ?
|
|
278
|
+
WHERE version = ?
|
|
279
|
+
''', (release_date, last_updated, version))
|
|
280
|
+
|
|
281
|
+
conn.commit()
|
|
282
|
+
finally:
|
|
283
|
+
conn.close()
|
|
284
|
+
|
|
285
|
+
def add_opera_versions(self, dt_add: list, dt_update: list = None):
|
|
286
|
+
conn = self.get_connection()
|
|
287
|
+
cursor = conn.cursor()
|
|
288
|
+
|
|
289
|
+
try:
|
|
290
|
+
for version, release_date, last_updated in dt_add:
|
|
291
|
+
cursor.execute('''
|
|
292
|
+
INSERT OR REPLACE INTO opera_versions
|
|
293
|
+
(version, release_date, last_updated)
|
|
294
|
+
VALUES (?, ?, ?)
|
|
295
|
+
''', (version, release_date, last_updated))
|
|
296
|
+
|
|
297
|
+
if dt_update:
|
|
298
|
+
for version, release_date, last_updated in dt_update:
|
|
299
|
+
cursor.execute('''
|
|
300
|
+
UPDATE opera_versions
|
|
301
|
+
SET release_date = ?, last_updated = ?
|
|
302
|
+
WHERE version = ?
|
|
303
|
+
''', (release_date, last_updated, version))
|
|
304
|
+
|
|
305
|
+
conn.commit()
|
|
306
|
+
finally:
|
|
307
|
+
conn.close()
|
|
308
|
+
|
|
309
|
+
def add_android_versions(self, dt_add: list, dt_update: list = None):
|
|
310
|
+
conn = self.get_connection()
|
|
311
|
+
cursor = conn.cursor()
|
|
312
|
+
|
|
313
|
+
try:
|
|
314
|
+
for version, release_date, last_updated in dt_add:
|
|
315
|
+
cursor.execute('''
|
|
316
|
+
INSERT OR REPLACE INTO android_versions
|
|
317
|
+
(version, release_date, last_updated)
|
|
318
|
+
VALUES (?, ?, ?)
|
|
319
|
+
''', (version, release_date, last_updated))
|
|
320
|
+
|
|
321
|
+
if dt_update:
|
|
322
|
+
for version, release_date, last_updated in dt_update:
|
|
323
|
+
cursor.execute('''
|
|
324
|
+
UPDATE android_versions
|
|
325
|
+
SET release_date = ?, last_updated = ?
|
|
326
|
+
WHERE version = ?
|
|
327
|
+
''', (release_date, last_updated, version))
|
|
328
|
+
|
|
329
|
+
conn.commit()
|
|
330
|
+
finally:
|
|
331
|
+
conn.close()
|
|
332
|
+
|
|
333
|
+
def add_windows_versions(self, dt_add: list, dt_update: list = None):
|
|
334
|
+
conn = self.get_connection()
|
|
335
|
+
cursor = conn.cursor()
|
|
336
|
+
|
|
337
|
+
try:
|
|
338
|
+
for version, release_date, last_updated in dt_add:
|
|
339
|
+
cursor.execute('''
|
|
340
|
+
INSERT OR REPLACE INTO windows_versions
|
|
341
|
+
(version, release_date, last_updated)
|
|
342
|
+
VALUES (?, ?, ?)
|
|
343
|
+
''', (version, release_date, last_updated))
|
|
344
|
+
|
|
345
|
+
if dt_update:
|
|
346
|
+
for version, release_date, last_updated in dt_update:
|
|
347
|
+
cursor.execute('''
|
|
348
|
+
UPDATE windows_versions
|
|
349
|
+
SET release_date = ?, last_updated = ?
|
|
350
|
+
WHERE version = ?
|
|
351
|
+
''', (release_date, last_updated, version))
|
|
352
|
+
|
|
353
|
+
conn.commit()
|
|
354
|
+
finally:
|
|
355
|
+
conn.close()
|
|
356
|
+
|
|
357
|
+
def add_macos_versions(self, dt_add: list, dt_update: list = None):
|
|
358
|
+
conn = self.get_connection()
|
|
359
|
+
cursor = conn.cursor()
|
|
360
|
+
|
|
361
|
+
try:
|
|
362
|
+
for version, release_date, last_updated in dt_add:
|
|
363
|
+
cursor.execute('''
|
|
364
|
+
INSERT OR REPLACE INTO macos_versions
|
|
365
|
+
(version, release_date, last_updated)
|
|
366
|
+
VALUES (?, ?, ?)
|
|
367
|
+
''', (version, release_date, last_updated))
|
|
368
|
+
|
|
369
|
+
if dt_update:
|
|
370
|
+
for version, release_date, last_updated in dt_update:
|
|
371
|
+
cursor.execute('''
|
|
372
|
+
UPDATE macos_versions
|
|
373
|
+
SET release_date = ?, last_updated = ?
|
|
374
|
+
WHERE version = ?
|
|
375
|
+
''', (release_date, last_updated, version))
|
|
376
|
+
|
|
377
|
+
conn.commit()
|
|
378
|
+
finally:
|
|
379
|
+
conn.close()
|
|
380
|
+
|
|
381
|
+
def add_platforms(self, platforms_data: list):
|
|
382
|
+
conn = self.get_connection()
|
|
383
|
+
cursor = conn.cursor()
|
|
384
|
+
|
|
385
|
+
try:
|
|
386
|
+
cursor.execute("DELETE FROM platforms")
|
|
387
|
+
|
|
388
|
+
for platform, system_info in platforms_data:
|
|
389
|
+
cursor.execute(
|
|
390
|
+
"INSERT OR REPLACE INTO platforms (platform, system_info) VALUES (?, ?)",
|
|
391
|
+
(platform, system_info)
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
conn.commit()
|
|
395
|
+
finally:
|
|
396
|
+
conn.close()
|
|
397
|
+
|
|
398
|
+
def add_version_types(self, version_types_data: list):
|
|
399
|
+
conn = self.get_connection()
|
|
400
|
+
cursor = conn.cursor()
|
|
401
|
+
|
|
402
|
+
try:
|
|
403
|
+
cursor.execute("DELETE FROM version_types")
|
|
404
|
+
|
|
405
|
+
for platform, version_type in version_types_data:
|
|
406
|
+
cursor.execute(
|
|
407
|
+
"INSERT OR REPLACE INTO version_types (platform, version_type) VALUES (?, ?)",
|
|
408
|
+
(platform, version_type)
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
conn.commit()
|
|
412
|
+
finally:
|
|
413
|
+
conn.close()
|