|
19 | 19 | print("[Auto-Photoshop-SD] Attempting auto-update...")
|
20 | 20 |
|
21 | 21 | try:
|
| 22 | + checkout_result = run( |
| 23 | + f'"{git}" -C "{REPO_LOCATION}" checkout {extension_branch}', |
| 24 | + "[Auto-Photoshop-SD] switch branch to extension branch.", |
| 25 | + ) |
| 26 | + print("checkout_result:", checkout_result) |
22 | 27 |
|
23 |
| - checkout_result = run(f'"{git}" -C "{REPO_LOCATION}" checkout {extension_branch}', "[Auto-Photoshop-SD] switch branch to extension branch.") |
24 |
| - print("checkout_result:",checkout_result) |
| 28 | + branch_result = run( |
| 29 | + f'"{git}" -C "{REPO_LOCATION}" branch', |
| 30 | + "[Auto-Photoshop-SD] Current Branch.", |
| 31 | + ) |
| 32 | + print("branch_result:", branch_result) |
25 | 33 |
|
26 |
| - branch_result = run(f'"{git}" -C "{REPO_LOCATION}" branch', "[Auto-Photoshop-SD] Current Branch.") |
27 |
| - print("branch_result:",branch_result) |
| 34 | + fetch_result = run( |
| 35 | + f'"{git}" -C "{REPO_LOCATION}" fetch', "[Auto-Photoshop-SD] Fetch upstream." |
| 36 | + ) |
| 37 | + print("fetch_result:", fetch_result) |
28 | 38 |
|
29 |
| - fetch_result = run(f'"{git}" -C "{REPO_LOCATION}" fetch', "[Auto-Photoshop-SD] Fetch upstream.") |
30 |
| - print("fetch_result:",fetch_result) |
31 |
| - |
32 |
| - pull_result = run(f'"{git}" -C "{REPO_LOCATION}" pull', "[Auto-Photoshop-SD] Pull upstream.") |
33 |
| - print("pull_result:",pull_result) |
| 39 | + pull_result = run( |
| 40 | + f'"{git}" -C "{REPO_LOCATION}" pull', "[Auto-Photoshop-SD] Pull upstream." |
| 41 | + ) |
| 42 | + print("pull_result:", pull_result) |
34 | 43 |
|
35 | 44 | except Exception as e:
|
36 | 45 | print("[Auto-Photoshop-SD] Auto-update failed:")
|
|
39 | 48 |
|
40 | 49 |
|
41 | 50 | # print("Auto-Photoshop-SD plugin is installing")
|
| 51 | +import pkg_resources |
| 52 | + |
| 53 | + |
| 54 | +def install_or_update_package(package_name, package_version): |
| 55 | + if not launch.is_installed(package_name): |
| 56 | + launch.run_pip( |
| 57 | + f"install {package_name}=={package_version}", |
| 58 | + "requirements for Auto-Photoshop Image Search", |
| 59 | + ) |
| 60 | + else: # it's installed but we need to check for update |
| 61 | + version = pkg_resources.get_distribution(package_name).version |
| 62 | + if version != package_version: |
| 63 | + print( |
| 64 | + f"{package_name} version: {version} will update to version: {package_version}" |
| 65 | + ) |
| 66 | + launch.run_pip( |
| 67 | + f"install {package_name}=={package_version}", |
| 68 | + "update requirements for Auto-Photoshop Image Search", |
| 69 | + ) |
| 70 | + |
42 | 71 |
|
43 |
| -package_name = 'duckduckgo_search' |
44 |
| -package_version= '3.9.9' |
45 |
| -if not launch.is_installed(package_name): |
46 |
| - launch.run_pip(f"install {package_name}=={package_version}", "requirements for Auto-Photoshop Image Search") |
47 |
| -else:# it's installed but we need to check for update |
48 |
| - import pkg_resources |
49 |
| - |
50 |
| - version = pkg_resources.get_distribution(package_name).version |
51 |
| - if(version != package_version): |
52 |
| - print(f'{package_name} version: {version} will update to version: {package_version}') |
53 |
| - launch.run_pip(f"install {package_name}=={package_version}", "update requirements for Auto-Photoshop Image Search") |
| 72 | +# Now we can use this function to install or update the packages |
| 73 | +install_or_update_package("duckduckgo_search", "3.9.9") |
| 74 | +install_or_update_package("httpx", "0.24.1") |
0 commit comments