python-gitlab documentationを踏まえて動くサンプルコードを掲載する。
https://python-gitlab.readthedocs.io/en/stable/index.html
install / import
インストール
pip install --upgrade python-gitlab
インポートと初期化
import gitlab
gl = gitlab.Gitlab('https://gitlab.arm.com')
list projects
for project in gl.projects.list():
print(f'* {project.name} [{project.http_url_to_repo}]({project.http_url_to_repo})')
結果
- cnf-reference-arch https://git.gitlab.arm.com/arm-reference-solutions/cnf-reference-arch.git
- dataplane-stack https://git.gitlab.arm.com/arm-reference-solutions/dataplane-stack.git
- fwupd-scripts https://git.gitlab.arm.com/systemready/demos/lvfs-on-systemready-ir/fwupd-scripts.git
- Kvm Unit Tests https://git.gitlab.arm.com/arm-reference-solutions/kvm-unit-tests.git
- freertos https://git.gitlab.arm.com/iot/aws/freertos.git
- Ampere Mt Jade https://git.gitlab.arm.com/systemready/firmware-build/linuxboot/ampere_mt_jade.git
- IPSec MB https://git.gitlab.arm.com/arm-reference-solutions/ipsec-mb.git
- Prebuilt_Images https://git.gitlab.arm.com/systemready/firmware-build/morello/prebuilt_images.git
- storage https://git.gitlab.arm.com/iot/open-iot-sdk/storage.git
- blinky https://git.gitlab.arm.com/iot/open-iot-sdk/examples/blinky.git
- edk2 Platforms https://git.gitlab.arm.com/systemready/firmware-build/morello/edk2-platforms.git
- edk2 https://git.gitlab.arm.com/systemready/firmware-build/morello/edk2.git
- test https://git.gitlab.arm.com/systemready/firmware-build/test.git
- Arm SystemReady ACS https://git.gitlab.arm.com/systemready/acs/arm-systemready.git
- mcu-driver-reference-platforms-for-arm https://git.gitlab.arm.com/iot/open-iot-sdk/mcu-driver-hal/mcu-driver-reference-platforms-for-arm.git
- mcu-driver-hal https://git.gitlab.arm.com/iot/open-iot-sdk/mcu-driver-hal/mcu-driver-hal.git
- toolchain https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git
- sdk https://git.gitlab.arm.com/iot/open-iot-sdk/sdk.git
- systemready-patch https://git.gitlab.arm.com/arm-reference-solutions/systemready-patch.git
- suit-parser https://git.gitlab.arm.com/research/ietf-suit/suit-parser.git
list groups
for group in gl.groups.list():
print(f'* {group.name} [{group.web_url}]({group.web_url})')
結果
- ACS https://gitlab.arm.com/groups/systemready/acs
- Application https://gitlab.arm.com/groups/application
- Arm Reference Solutions https://gitlab.arm.com/groups/arm-reference-solutions
- EWAOL https://gitlab.arm.com/groups/ewaol
- Firmware https://gitlab.arm.com/groups/firmware
- IoT https://gitlab.arm.com/groups/iot
- LVFS on SystemReady IR https://gitlab.arm.com/groups/systemready/demos/lvfs-on-systemready-ir
- Libraries https://gitlab.arm.com/groups/libraries
- LinuxBoot https://gitlab.arm.com/groups/systemready/firmware-build/linuxboot
- Morello https://gitlab.arm.com/groups/systemready/firmware-build/morello
- Open IoT SDK https://gitlab.arm.com/groups/iot/open-iot-sdk
- Research https://gitlab.arm.com/groups/research
- SOAFEE https://gitlab.arm.com/groups/soafee
- SystemReady https://gitlab.arm.com/groups/systemready
- Tests https://gitlab.arm.com/groups/tests
- Tooling https://gitlab.arm.com/groups/tooling
- aws https://gitlab.arm.com/groups/iot/aws
- demos https://gitlab.arm.com/groups/systemready/demos
- examples https://gitlab.arm.com/groups/iot/open-iot-sdk/examples
- firmware-build https://gitlab.arm.com/groups/systemready/firmware-build
list projects in group
group = gl.groups.get('SystemReady')
for project in group.projects.list():
project = gl.projects.get(project.id) # need if lists branches, tree and so on.
print(f'* {project.name} [{project.http_url_to_repo}]({project.http_url_to_repo})')
結果
- systemready-es-sr-template https://git.gitlab.arm.com/systemready/systemready-es-sr-template.git
- linuxboot-resources https://git.gitlab.arm.com/systemready/linuxboot-resources.git
- systemready-scripts https://git.gitlab.arm.com/systemready/systemready-scripts.git
- systemready-template https://git.gitlab.arm.com/systemready/systemready-template.git
- edk2-test-parser https://git.gitlab.arm.com/systemready/edk2-test-parser.git
- edk2-test-manifest https://git.gitlab.arm.com/systemready/edk2-test-manifest.git
- u-boot-tfa-build https://git.gitlab.arm.com/systemready/u-boot-tfa-build.git
list files in project
project = gl.projects.get('systemready/linuxboot-resources')
for item in project.repository_tree(ref='master', recursive=True, all=True):
print(f"* {item['path']} ({item['type']}) {item['mode']}")
結果
- FVP (tree) 040000
- RPi4 (tree) 040000
- RPi4/Code (tree) 040000
- RPi4/DemoMedia (tree) 040000
- RPi4/DemoMedia/Images (tree) 040000
- SBSA-QEMU (tree) 040000
- SBSA-QEMU/Code (tree) 040000
- SBSA-QEMU/Code/scripts (tree) 040000
- SBSA-QEMU/DemoMedia (tree) 040000
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo (tree) 040000
- SBSA-QEMU/DemoMedia/ReplaceUefiShell (tree) 040000
- FVP/README.md (blob) 100644
- README.md (blob) 100644
- RPi4/Code/0001-Platform-RaspberryPi-RPi4-Added-LinuxBoot.patch (blob) 100644
- RPi4/Code/0001-adding-Basic-LinuxBoot-defconfig.patch (blob) 100644
- RPi4/DemoMedia/Images/BootManager.png (blob) 100644
- RPi4/DemoMedia/Images/BootUEFI.png (blob) 100644
- RPi4/DemoMedia/Images/FedoraACPI.png (blob) 100644
- RPi4/DemoMedia/Images/FedoraEFIVars.png (blob) 100644
- RPi4/DemoMedia/Images/FedoraLogin.png (blob) 100644
- RPi4/DemoMedia/Images/FedoraOSInfo.png (blob) 100644
- RPi4/DemoMedia/Images/LinuxBootBootManager1.png (blob) 100644
- RPi4/DemoMedia/Images/LinuxBootBootManager2.png (blob) 100644
- RPi4/DemoMedia/Images/UEFIShell.png (blob) 100644
- RPi4/DemoMedia/Images/WelcomeToFedora.png (blob) 100644
- RPi4/DemoMedia/Images/kexec.png (blob) 100644
- RPi4/DemoMedia/Images/u-root.png (blob) 100644
- RPi4/DemoMedia/RPi4fedora.mov (blob) 100644
- RPi4/README.md (blob) 100644
- SBSA-QEMU/Code/bootMgr.patch (blob) 100644
- SBSA-QEMU/Code/linuxboot.patch (blob) 100644
- SBSA-QEMU/Code/linuxboot_defconfig (blob) 100644
- SBSA-QEMU/Code/scripts/Edk2Buildscript.sh (blob) 100644
- SBSA-QEMU/Code/scripts/Edk2Rebuildscript.sh (blob) 100644
- SBSA-QEMU/Code/scripts/ImageBuildscript.sh (blob) 100755
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo/EmulatorStarting.PNG (blob) 100644
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo/automaticRun.webm (blob) 100644
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo/bootedToACS.PNG (blob) 100644
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo/kexecACSKernel.PNG (blob) 100644
- SBSA-QEMU/DemoMedia/PlatformBootMgrDemo/urootUnitAutomaticallyRunACSKernel.PNG (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/LBKernel1.png (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/LBKernel2.png (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/LinuxbootOnSbsaqemuDemo.webm (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/Stage2Os.png (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/StartingEmulator.png (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/UEFImenu.png (blob) 100644
- SBSA-QEMU/DemoMedia/ReplaceUefiShell/UEFImenu2.png (blob) 100644
- SBSA-QEMU/README.md (blob) 100644
- SBSA-QEMU/longGuide.md (blob) 100644
get file content
project = gl.projects.get('systemready/linuxboot-resources')
text = project.files.raw('README.md', ref='master').decode('utf-8', errors='ignore')