Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
dh-04 committed Dec 2, 2020
1 parent 8870c99 commit d7991ce
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions pip.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
timeout=8000
trusted-host = pypi.tuna.tsinghua.edu.cn
2 changes: 1 addition & 1 deletion platformio_support_package.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
yaml_version: 1
pkg_version: 5.0.3.3
pkg_version: 5.0.3.4
pkg_vendor: RealThread
pkg_type: ThirdParty_Support_Packages
name: PlatformIO
Expand Down
38 changes: 31 additions & 7 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ def __init__(self):
self.platformio_path = self.home_path.joinpath(".platformio")
self.python_path = self.current_folder.joinpath("python377x64/python.exe")
self.get_platformio_script_path = self.current_folder.joinpath("python377x64/get-platformio.py")
self.is_pip_config_exists = False
self.pip_config_dir_path = self.home_path.joinpath("pip")
if self.home_path.joinpath("pip/pip.ini").exists():
self.is_pip_config_exists = True

def modify_pip_source(self):
if self.is_pip_config_exists:
shutil.move(str(self.home_path.joinpath("pip/pip.ini")), str(self.home_path.joinpath("pip/pip.ini.backup")))
self.cp_fr_list(["pip.ini"], self.current_folder, self.pip_config_dir_path)

def recover_pip_source(self):
os.remove(self.pip_config_dir_path.joinpath("pip.ini"))
if self.is_pip_config_exists:
shutil.move(str(self.home_path.joinpath("pip/pip.ini.backup")), str(self.home_path.joinpath("pip/pip.ini")))

def rm_fr_list(self, item_list, dst_path):
for item_path in item_list:
Expand Down Expand Up @@ -79,7 +93,6 @@ def copy_platformio_packages(self):
self.current_folder.joinpath(".platformio/platforms"),
self.platformio_path.joinpath("platforms"))
print(self.current_folder.joinpath(".platformio"))
print(os.listdir(self.current_folder.joinpath(".platformio")))
other_file_and_folders = os.listdir(self.current_folder.joinpath(".platformio"))
other_file_and_folders.remove("platforms")
other_file_and_folders.remove("packages")
Expand All @@ -98,14 +111,25 @@ def install_platformio(self):
def make_platformio(self):
self.copy_platformio_packages()
self.install_platformio()
if len(sys.argv)>1:


if len(sys.argv) > 2:
rt_studio_version = sys.argv[1]
print("rt_studio_version: "+str(rt_studio_version))
if "global" in str(sys.argv[2]).lower():
is_studio_global_version = True
else:
is_studio_global_version = False
print("rt_studio_version: " + str(rt_studio_version))
if rt_studio_version >= "2.0.0":
builder = PlatformioBuilder()
builder.make_platformio()
if is_studio_global_version:
builder = PlatformioBuilder()
builder.make_platformio()
else:
builder = PlatformioBuilder()
builder.modify_pip_source()
builder.make_platformio()
builder.recover_pip_source()
else:
print("RT-Thread Studio version is not match")
else:
print("Info:")
print("Please add RT-Thread Studio version number as parameter")
print("Info:Please add RT-Thread Studio version number as parameter")

0 comments on commit d7991ce

Please sign in to comment.