#!/usr/bin/env python3 # -*- coding: utf-8 -*- #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ """ Usage: jobs-cmd-filter command pre-user-jobs "/p4/common/bin/triggers/JobsCmdFilter.py %args%" This script is designed to run as a jobs command filter trigger on the server. It ensures that multiple wildcards are not specified in any search string (which can cause the server to perform excessive processing and impact performance) """ # Python 2.7/3.3 compatibility. from __future__ import print_function import sys import re class JobsCmdFilter: """ Filters out known issues with jobs search parameters""" def __init__(self, *argv): """ Initialization. Process command line argument and initialize logging. """ self.args = argv def run(self): """Runs trigger""" wildcard_pattern = re.compile("^\*+$|'\*+'|\*\*+|=\*'|=\*$") for arg in self.args: if wildcard_pattern.search(arg): print("Please do not specify bare wildcard patterns (*) in a jobs search parameter") return(1) return 0 if __name__ == '__main__': """ Main Program""" trigger = JobsCmdFilter(*sys.argv[1:]) sys.exit(trigger.run())
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 27246 | Jessie Fernandez | Branch for Jessie Fernandez | ||
//guest/perforce_software/sdp/dev/Unsupported/Samples/triggers/JobsCmdFilter.py | |||||
#2 | 26681 | Robert Cowham |
Removing Deprecated folder - if people want it they can look at past history! All functions have been replaced with standard functionality such as built in LDAP, or default change type. Documentation added for the contents of Unsupported folder. Changes to scripts/triggers are usually to insert tags for inclusion in ASCII Doctor docs. |
||
#1 | 26652 | Robert Cowham |
This is Tom's change: Introduced new 'Unsupported' directory to clarify that some files in the SDP are not officially supported. These files are samples for illustration, to provide examples, or are deprecated but not yet ready for removal from the package. The Maintenance and many SDP triggers have been moved under here, along with other SDP scripts and triggers. Added comments to p4_vars indicating that it should not be edited directly. Added reference to an optional site_global_vars file that, if it exists, will be sourced to provide global user settings without needing to edit p4_vars. As an exception to the refactoring, the totalusers.py Maintenance script will be moved to indicate that it is supported. Removed settings to support long-sunset P4Web from supported structure. Structure under new .../Unsupported folder is: Samples/bin Sample scripts. Samples/triggers Sample trigger scripts. Samples/triggers/tests Sample trigger script tests. Samples/broker Sample broker filter scripts. Deprecated/triggers Deprecated triggers. To Do in a subsequent change: Make corresponding doc changes. |
||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/JobsCmdFilter.py | |||||
#2 | 18687 | Russell C. Jackson (Rusty) | Merge main to dev. | ||
#1 | 18529 | Russell C. Jackson (Rusty) | Merge up before copy down. | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/triggers/JobsCmdFilter.py | |||||
#1 | 18204 | Robert Cowham | New trigger to filter jobs commands plus test harness |