current position：Home>Python batch get gitlab project code
Python batch get gitlab project code
2022-08-06 18:32:25【As for why】
More and more companies are now using gitlab to manage their code.There is a problem with gitlab, the free version does not support global code search, which is very troublesome.If you clone all the code to the local, you can easily perform various searches.
gitlab provides api to get projecct list, then you can traverse this list to do
A private token needs to be generated to use the Gitlab API
- Token generation method:
- Token is only visible once when it is generated, please save it
Note: gitlab's api can only obtain information about 100 projecct at most each time.This script has page turning function and can support more than 100 items.
# -*- coding: UTF-8 -*-# Passed the test in Python 3.0# Need to create a new AccessToken in gitlab and fill in gitlabTokenimport sysif sys.version_info < (3, 0):import urllibelse:from urllib.request import urlopenimport jsonimport subprocess, shleximport timeimport osgitlabAddr = '22.214.171.124:8099' #git addressgitlabToken = 'Nzyg92-123456aa4ay__y' #gitlab's token, there is a production temporary token in the gitlab settingsfor index in range(10):url = "http://%s/api/v4/projects?private_token=%s&per_page=100&page=%d&order_by=name" % (gitlabAddr, gitlabToken, index)print(url)if sys.version_info < (3, 0):allProjects = urllib.urlopen(url)else:allProjects = urlopen(url)allProjectsDict = json.loads(allProjects.read().decode(encoding='UTF-8'))if len(allProjectsDict) == 0:breakfor thisProject in allProjectsDict:try:thisProjectURL = thisProject['ssh_url_to_repo']thisProjectPath = thisProject['path_with_namespace']print(thisProjectURL + ' ' + thisProjectPath)if os.path.exists(thisProjectPath):command = shlex.split('git -C "%s" pull' % (thisProjectPath))else:command = shlex.split('git clone %s %s' % (thisProjectURL, thisProjectPath))resultCode = subprocess.Popen(command)time.sleep(0.5)except Exception as e:print("Error on %s: %s" % (thisProjectURL, e.strerror))
author[As for why],Please bring the original link to reprint, thank you.
The sidebar is recommended
- The get/post request tool (apifox/postman/browser) can request through but the java code can't solve the problem
- "Docker Basics: 2. Docker Installation" includes premise description, basic composition of Docker, Docker platform architecture diagram (architecture version), installation steps, Alibaba Cloud image acceleration, eternal HelloWorld, and underlying princi
- Spring Cloud Gateway integrates Nacos and Swagger to aggregate Api documents
- `Algorithmic Knowledge` Average
- Example of using ElasticsearchRestTemplate in SpringBoot, (add, delete, modify, highlight, id, paginate, time range, and multi-condition queries)
- Ubuntu encountered ERROR: configuration failed for package 'rJava' when installing xlsx package
- Openresty+nginx image server configuration, add http_image_filter_module module
- How to make Zuul support WebSocket
- What does this picture represent?
guess what you like
"Docker Basics: 3. Docker Common Commands" includes help startup commands, mirroring commands, and mirroring to create containers, which is the fundamental premise (download a CentOS or ubuntu mirror demo), container commands, and a small summary
Remember to configure the expiration time of @Cacheable (Redis specifies the expiration time of certain Cache Keys)
[Deployment] Deploy the back-end project to the Pagoda Linux cloud server Java SpringBoot
`Algorithm knowledge` Prime numbers
Springcloud gateway gateway+authentication service+token mode, entrance layer authentication unified microservice authentication [design practice]
(5) Backward compatibility problems in compilation
Go native development blog project series (the third)
Blog project (4, initialization)
See three years of CRUD programmers how to solve the database deadlock
Kettle Demand Reappears - 100 million details
- Deep understanding of volatile, Synchronized, and already the underlying implementation principle
- Spring common annotation analysis
- Docker quickly builds a PHP+Nginx+Mysql environment and steps on the pit diary
- Mac's own software - play with focus search
- What is the principle of the second type of dictionary method?
- Implementing a caching mechanism using soft references
- Vue entry page for the first time, how to distinguish between created and activated?
- Things to do with your new mac notebook
- [Java Interview] After 7 years of work, I went to the byte interview and turned around on this question. Could you please tell me your understanding of the time wheel?
- Optimization, genetic algorithm (ga)
- Advanced Guide to Algorithm Competition Recursive Implementation of Permutation Enumeration
- How to use the second type of dictionary method?
- mac Maven error No compiler is provided in this environment. Perhaps you are running on a JRE rat
- [Help] In the vue2 that the vue3 project is connected to as a subsystem, the whole project using el-drawer reports an error?
- Redis basis
- 【Macbook software sharing｜Use skills】Dry goods
- Advanced Guide to Algorithm Competition Recursive Implementation of Exponential Enumeration
- JAVA based - 11 - encapsulated inherited polymorphism - nine five small jean-marie le pen
- Trend Micro Written Test Review (Algorithm Question 2)
- Multilayer Perceptron - MLP
- (3) write their own - YOLOv3 - loss function
- Sketch91: How to set an aligned reference object and align it according to the specified element tutorial
- Target tracking actual combat deepsort+yolov5 (on)
- Tensorflow - recurrent neural network (5) subword text classification
- Linear Algebra and Probability Theory
- Big data "killed": who am I, where am I, and what have I (was) done?
- Study together to build the react + webpack + ts framework!!!!!!(a)
- Java Data Structures and Algorithms Lesson 9 - Sorting
- Hardcore!The internal manual "MySQL Notes" written by the technical director of Ali is really strong
- How Spring solves the circular dependency problem
- What is the goal of quantization coding?
- What are the quantification methods?
- I the first page of the scaffold - AST abstract syntax tree
- What is the core idea of the first type of dictionary coding method, can you give an example?
- iOSUIKit and Swift ｜ Youth Training Notes
- Vue about embedded iframe page?
- Likou 93 - Restoring IP Address [Backtracking Algorithm]
- Why is run-length encoding a better encoding method for computer desktop images?
- What is the Cartesian product type in quantization coding?
- Cache series: cache consistency problem solution