EdgeX (3) the edges of the open-source computing framework EdgeX Foundry, download the project, write a python program batch download

Foreword


All categories related EdgeX Foundry:
https://blog.csdn.net/freewebsys/category_9437788.html

Original connection of this paper is:
https://blog.csdn.net/freewebsys/article/details/104219390

Bloggers may not be reproduced without the permit.
Bloggers address is: http://blog.csdn.net/freewebsys

1, on the EdgeX


git project Address:
https://github.com/edgexfoundry?utf8=%E2%9C%93&q=go&type=&language=

Search for relevant projects under golang found Super Multi project file.
27, however, some old projects, has not renewed after 2017 2018. And also locked.
Write a text, and then let the python read text data, then execute commands to download or update.

2, using python, batch updates git project


Which edgex-all-go.txt content:

edgex-go
device-sdk-go
edgex-ui-go
device-modbus-go
device-mqtt-go
go-mod-core-contracts
app-functions-sdk-go
go-mod-bootstrap
go-mod-registry
go-mod-messaging
device-camera-go
go-mod-secrets
device-virtual-go
device-rest-go
device-snmp-go
go-mod-configuration

Then update or download by footsteps:

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# https://www.runoob.com/python/python-tutorial.html
# 其他相关的python 基础语法使用
import os
pwd = os.getcwd()
print(pwd)

def git_clone(line):
	tmp_dir = pwd + "/" + line
	print( tmp_dir )
	if os.path.isdir(tmp_dir) :
		shell = 'cd %s/%s && git pull ' % ( pwd , line )
		print(shell)
		output = os.popen(shell)
		print(output.read())
	else:	
		
		shell = 'cd %s && git clone https://github.com/edgexfoundry/%s.git' % ( pwd , line )
		print(shell)
		output = os.popen(shell)
		print(output.read())

# 打开文件,with 自动关闭
with open("edgex-all-go.txt", "r") as fo:
	print( "文件名为: ", fo.name )

	for line in fo.readlines():  #依次读取每行  
		line = line.strip()  #去掉每行头尾空白 
		
		print( "读取的数据为: %s" % (line) )
		git_clone( line )
		

effect:

.......
读取的数据为: device-camera-go
/media/test/NewDisk1/go/src/github.com/edgexfoundry/device-camera-go
cd /media/test/NewDisk1/go/src/github.com/edgexfoundry/device-camera-go && git pull 
已经是最新的。

读取的数据为: go-mod-secrets
/media/test/NewDisk1/go/src/github.com/edgexfoundry/go-mod-secrets
cd /media/test/NewDisk1/go/src/github.com/edgexfoundry/go-mod-secrets && git pull 
已经是最新的。

读取的数据为: device-virtual-go
/media/test/NewDisk1/go/src/github.com/edgexfoundry/device-virtual-go
cd /media/test/NewDisk1/go/src/github.com/edgexfoundry/device-virtual-go && git pull 
已经是最新的。

读取的数据为: device-rest-go
/media/test/NewDisk1/go/src/github.com/edgexfoundry/device-rest-go
cd /media/test/NewDisk1/go/src/github.com/edgexfoundry/device-rest-go && git pull 
已经是最新的。

读取的数据为: device-snmp-go
/media/test/NewDisk1/go/src/github.com/edgexfoundry/device-snmp-go
cd /media/test/NewDisk1/go/src/github.com/edgexfoundry/device-snmp-go && git pull 
已经是最新的。

.........

python really convenient.

3, summary


Open source edge computing framework EdgeX Foundry, projects more.
Sometimes github access is slower, then wrote pace, download in the morning or evening when.
Batch download of golang project. python syntax is super simple, so simple a few provinces to a lot of trouble.
At the same time with a shell syntax too weird, other languages may not be as fast python development. Python still good.

Original connection of this paper is:
https://blog.csdn.net/freewebsys/article/details/104219390

Bloggers address is: https://blog.csdn.net/freewebsys

Published 639 original articles · won praise 260 · Views 2.11 million +

Guess you like

Origin blog.csdn.net/freewebsys/article/details/104219390