Skip to content

Commit bf7792a

Browse files
committed
added updating submodules to setup.py
1 parent 48201f1 commit bf7792a

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

.idea/vcs.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup.py

+39-26
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,52 @@
11
"""Creates a desktop shortcut that can run Auto Maple from anywhere."""
22

33
import os
4+
import git
45
import argparse
56
import win32com.client as client
67

78

8-
parser = argparse.ArgumentParser()
9-
parser.add_argument('--stay', action='store_true')
10-
args = parser.parse_args()
9+
def create_desktop_shortcut():
10+
"""Creates and saves a desktop shortcut using absolute paths"""
11+
print('\n[~] Creating a desktop shortcut for Auto Maple:')
12+
CWD = os.getcwd()
13+
TARGET = os.path.join(os.environ['WINDIR'], 'System32', 'cmd.exe')
14+
PATH = os.path.join(os.environ['USERPROFILE'], 'Desktop', 'Auto Maple.lnk')
15+
flag = "/c"
16+
if args.stay:
17+
flag = "/k"
18+
print(" - Leaving command prompt open after program finishes")
1119

12-
# Create and save the shortcut using absolute paths
13-
print('[~] Creating a desktop shortcut for Auto Maple:')
14-
CWD = os.getcwd()
15-
TARGET = os.path.join(os.environ['WINDIR'], 'System32', 'cmd.exe')
16-
PATH = os.path.join(os.environ['USERPROFILE'], 'Desktop', 'Auto Maple.lnk')
17-
flag = "/c"
18-
if args.stay:
19-
flag = "/k"
20-
print(" ~ Leaving command prompt open after program finishes")
20+
shell = client.Dispatch('WScript.Shell')
21+
shortcut = shell.CreateShortCut(PATH)
22+
shortcut.Targetpath = TARGET
23+
shortcut.Arguments = flag + f' \"cd {CWD} & python main.py\"'
24+
shortcut.IconLocation = os.path.join(CWD, 'assets', 'icon.ico')
25+
shortcut.save()
2126

22-
shell = client.Dispatch('WScript.Shell')
23-
shortcut = shell.CreateShortCut(PATH)
24-
shortcut.Targetpath = TARGET
25-
shortcut.Arguments = flag + f' \"cd {CWD} & python main.py\"'
26-
shortcut.IconLocation = os.path.join(CWD, 'assets', 'icon.ico')
27-
shortcut.save()
27+
# Enable "run as administrator"
28+
with open(PATH, 'rb') as lnk:
29+
arr = bytearray(lnk.read())
2830

29-
# Enable "run as administrator"
30-
with open(PATH, 'rb') as lnk:
31-
arr = bytearray(lnk.read())
31+
arr[0x15] = arr[0x15] | 0x20 # Set the 6th bit of 21st byte to 1
3232

33-
arr[0x15] = arr[0x15] | 0x20 # Set the 6th bit of 21st byte to 1
33+
with open(PATH, 'wb') as lnk:
34+
lnk.write(arr)
35+
print(' - Enabled the "Run as Administrator" option')
36+
print(' ~ Successfully created Auto Maple shortcut')
3437

35-
with open(PATH, 'wb') as lnk:
36-
lnk.write(arr)
37-
print(' ~ Enabled the "Run as Administrator" option')
3838

39-
print('[~] Successfully created Auto Maple shortcut')
39+
def update_submodules():
40+
print('\n[~] Updating submodules:')
41+
repo = git.Repo()
42+
repo.git.submodule('update', '--init', '--recursive')
43+
print(' ~ Finished updating submodules')
44+
45+
46+
if __name__ == '__main__':
47+
parser = argparse.ArgumentParser()
48+
parser.add_argument('--stay', action='store_true')
49+
args = parser.parse_args()
50+
51+
create_desktop_shortcut()
52+
update_submodules()

0 commit comments

Comments
 (0)