You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
5 years ago
|
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
#==================
|
||
|
# Author: Alvis Zhao
|
||
|
# Date: 2020-08-14 15:27:05
|
||
|
# LastEditTime: 2020-08-14 15:27:57
|
||
|
# Description: 批量上传deb包到内网nexus源
|
||
|
#==================
|
||
|
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
def showUsage():
|
||
|
print("Usage:")
|
||
|
print(" python upload-apt.py dir-to-upload")
|
||
|
|
||
|
USERNAME="uploader"
|
||
|
PASSWORD="uploader"
|
||
|
URL="http://nexus3.developer.com/service/rest/v1/components?repository=bionic"
|
||
|
|
||
|
def main():
|
||
|
if len(sys.argv) < 2:
|
||
|
print("用法错误!")
|
||
|
showUsage()
|
||
|
return
|
||
|
|
||
|
uploadDir=sys.argv[1]
|
||
|
if not os.path.isdir(uploadDir):
|
||
|
print("用法错误!")
|
||
|
showUsage()
|
||
|
return
|
||
|
|
||
|
fileList=os.listdir(uploadDir)
|
||
|
for file in fileList:
|
||
|
filepath = uploadDir + os.sep + file
|
||
|
print(filepath)
|
||
|
cmd = "curl POST -u " + USERNAME + ":" + PASSWORD + " " + URL + ' -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "apt.asset=@' + filepath + '"'
|
||
|
os.popen(cmd)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|