Beispiel #1
0
GitCloneLogger = None
conn = None

try:

    # Will only run if this file is called as primary file
    if __name__ == '__main__':

        # Start Main execution here:
        ProcessParams(sys.argv)

        # Initialize Logging:
        GitCloneLogger = InitGitCloneLogging()

        GitCloneLogger.info("Starting GitRepoCloner.py script at " +
                            genfunc.GetCurrentDateTime() + ".")
        GitCloneLogger.info("")
        GitCloneLogger.info("Parameters = " + str(sys.argv))

        # Create a SQL connection to SQLite database
        GitCloneLogger.info("Connecting to SQLite Database " + config.database)
        conn = config.create_sqlite_connection(config.database)
        GitCloneLogger.info("Connected to SQLite Database " + config.database)
        cur = conn.cursor()

        SqlString = 'SELECT RepoUrl, ProjectName FROM Repos;'
        GitCloneLogger.info("Sql = " + SqlString)
        GitCloneLogger.info("Executing SQL")
        cur.execute(SqlString)

        GitCloneLogger.info("Fetching Rows")
Beispiel #2
0
# Main Script Execution
# ************************************

# Will only run if this file is called as primary file 
if __name__ == '__main__':
  
  # Intialize variables:
  JsonResponse = ""

	# Initialize Logging:
  GetADOGitProjectsLogger = InitScriptLogging()

  # Proccess Parameters
  ProcessParams(sys.argv)

  GetADOGitProjectsLogger.info("Starting  GetADOGitProjects script at " + genfunc.GetCurrentDateTime() + ".")
  # Show parameters - mask PAT
  GetADOGitProjectsLogger.info("Parameters = " + str(sys.argv[0]) + " " + str(sys.argv[1]) + " " + str(sys.argv[2]) + " **********")
  
  try:

    # Call Azure DevOps Rest API
    print("Call ADo REST API to get list of Git Repos in Project " + config.AdoProject)
    config.RestAPiUrl = config.AdoBase + config.AdoProject + config.AdoRestUrl
    GetADOGitProjectsLogger.info("RestAPiUrl = " + config.RestAPiUrl)

    try:
      GetJSONFromURL(config.RestAPiUrl)
      JsonResponse = GetJSONFromURL(config.RestAPiUrl)
      JsonData = json.loads(JsonResponse.data.decode('utf-8-sig'))
Beispiel #3
0
    # Note: Choose to use either File Logging or Console Logging.
	  # Initialize File Logging:
    MyScriptLogger = InitScriptFileLogging(MyScript, config.LogPath, config.LogFile, config.LogLevel)
    
    # INitialize Console Logging:
    MyScriptLogger = genfunc.InitScriptConsoleLogging(MyScript, config.LogLevel)

    # Proccess Parameters
    ProcessParams(sys.argv)

	  # Do Something
    MyScriptLogger.info("Doing Something")


  except Exception as e:
    MyScriptLogger.info("MyScript script Ended at " + genfunc.GetCurrentDateTime() + ".")
    MyScriptLogger.error("Execution failed.")
    MyScriptLogger.error("Exception Information: ")
    MyScriptLogger.error(sys.exc_info()[0])
    MyScriptLogger.error(sys.exc_info()[1])
    MyScriptLogger.error(sys.exc_info()[2])
    MyScriptLogger.error("")
    MyScriptLogger.error("MyScript.py completed unsuccessfully at " + genfunc.GetCurrentDateTime() + ".")
    config.HasError = True
    sys.exit(1)


  if not config.HasError:
    # All Went well - exiting!
    MyScriptLogger.info("MyScript script Ended at " + genfunc.GetCurrentDateTime() + ".")
    MyScriptLogger.info("")
Beispiel #4
0
# Will only run if this file is called as primary file 
if __name__ == '__main__':

  # Intialize variables:
  JsonResponse = ""

	# Initialize Logging:
  GetOpenAPIJsonLogger = InitGetOpenAPIJsonLogging()

  # Proccess Parameters
  ProcessParams(sys.argv)

  try:

    GetOpenAPIJsonLogger.info("Starting  GetOpenAPIJson script at " + genfunc.GetCurrentDateTime() + ".")
    GetOpenAPIJsonLogger.info("Parameters = " + str(sys.argv))

    # Create new info dictionary to update the JSON data with
    NewInfoDict = {'swagger':'2.0','info':{'title': config.ApiName, 'version': '1.0', 'termsOfService': 'http://mycompany.com', 'license': {'name': 'My Company License'}}}
    GetOpenAPIJsonLogger.info("NewInfoDict = " + str(NewInfoDict))

	  # Get JSON File/Data from URL
    GetOpenAPIJsonLogger.info("Url = " +  config.JsonURL)

    try:
      # Check if URL Passed is HTTP URL or File Path:
      isHttp = config.JsonURL.startswith('http')
      if isHttp:
        GetOpenAPIJsonLogger.info("Trying to get JSON from URL")
        JsonResponse = jsonfunc.GetJSONFromURL(GetOpenAPIJsonLogger, config.HasError, config.JsonURL)
Beispiel #5
0
# Will only run if this file is called as primary file 
if __name__ == '__main__':
  
  ProcessParams(sys.argv)
  
  # Initialize Logging:
  WinServiceAdminLogger = InitWinServiceAdminLogging()

  WinServiceAdminLogger.info("")
  WinServiceAdminLogger.info("Parameters = " + str(sys.argv))
  #WinServiceAdminLogger.debug("RSK Debug> In main - Parameters = " + config.Command + " " + config.Service + " " + config.Server + " " + config.ServiceLocation)
  WinServiceAdminLogger.info("")
  WinServiceAdminLogger.info("LogFile = " + os.path.join(config.LogPath, config.LogFile))
  WinServiceAdminLogger.info("")
  WinServiceAdminLogger.info("Starting WinServiceAdmin.py script at " + genfunc.GetCurrentDateTime() + ".")
  WinServiceAdminLogger.info("")
  WinServiceAdminLogger.info("Running as user: "******"")

  try:
    # Start Main execution here:
    WinServiceAdminLogger.info("Starting WinServiceAdmin.")

    # *** Verify command is one of the valid commands (stop/start/status) *********************
    #config.Command = 'restart'
    WinServiceAdminLogger.info("Passed Command = " + config.Command)

    WinServiceAdminLogger.info("Valid Commands = " + str(config.ValidCommands))
    WinServiceAdminLogger.info("Check if " + config.Command + " is in the ValidCommands list")