P4 Command Blaster ================== **Description:** P4 Command Blaster is a Python script designed to automate interactions with Perforce (P4) version control systems and to upload command outputs to Azure Blob Storage. It handles server trust, P4 login, and executes a range of P4 commands based on user input. Setup and Requirements ---------------------- Before running the script, ensure all dependencies are installed. The required packages are listed in the `requirements.txt` file. Minimum required Python versions: 3.7 Configuration ------------- The script uses a host_config.yaml configuration file for Perforce settings similiar to that (`.p4config`) and environment variables for Azure Blob Storage access. Update the `p4config_path` variable in the script with the path to your P4 configuration file. Usage ----- ``` pip install -r requirements.txt ``` Edit host_config.yaml ``` - name: "Studio1" hosts: - host: "ssl:host1.studio1.com:1999" user: "perforce" - host: "ssl:host2.studio1.com:1999" user: "perforce" - name: "Studio2" hosts: - host: "ssl:host1.studio2.com:1666" user: "user3" - host: "ssl:host2.studio2.com:1999" user: "perforce" ``` ### Linux ``` export AZURE_ACCOUNT_NAME=your_account_name export AZURE_ACCOUNT_KEY=your_account_key ``` ### Windows - CMD ``` set AZURE_ACCOUNT_NAME=your_account_name set AZURE_ACCOUNT_KEY=your_account_key ``` ### Windows - PowerShell ``` $env:AZURE_ACCOUNT_NAME = "your_account_name" $env:AZURE_ACCOUNT_KEY = "your_account_key" ``` # P4 Commands that will Run ``` p4 -ztag info: Provides detailed information about the Perforce server. p4 diskspace: Displays disk space information for the Perforce depots. p4 configure show allservers: Shows the configuration for all servers in a Perforce installation. p4 servers -J: Checks replication status between Perforce master and replica servers. ``` **P4 Commands Executed With --all Flag** In addition to the above commands, the following are executed if the --all flag is used: ``` p4 triggers -o: Outputs the triggers table. p4 extension --list --type extensions: Lists all extensions installed on the Perforce server. p4 protect -o: Outputs the protections table, showing access controls in place. p4 property -n P4.Swarm.URL -l: Lists the properties with the name P4.Swarm.URL. ``` To run the script, use the following command structure: ``` python cmd-blaster.py \[options\] ``` Options: * `-h`, `--help` show this help message and exit * `--all` Run all commands * `--write-to-file` Optionally write output to a file before uploading * `-v`, `--verbose` Enable verbose output * `-s STUDIO`, `--studio STUDIO` Studio name for blob storage path * `-hc HOST_CONFIG`, `--host-config HOST_CONFIG` Path to host configuration file (default: ./host_config.yaml) * `--host HOST` Specific host to run the commands on * `--user USER` Perforce username for login * `--json` Output in JSON format Features -------- * Automated handling of P4 server trust * P4 login with password prompt * Execution of various P4 commands based on user input * Uploading command outputs to Azure Blob Storage * Logging system for monitoring script activity