function GlobalConfigFields() return {} end function InstanceConfigFields() return {} end function InstanceConfigEvents() return { ["form-out"] = "change" } end function runcmd( cmd ) local stderr = os.tmpname() local stdout = os.tmpname() local rc = os.execute( cmd .. ' > ' .. stdout .. ' 2> ' .. stderr ) local sefh = io.open( stderr ) local sofh = io.open( stdout ) local stderr = sefh:read( "*all" ) local stdout = sofh:read( "*all" ) sefh:close() sofh:close() return rc, stdout, stderr end function FormOut() local adir = Helix.Core.Server.GetArchDirFileName( "" ) local ddir = Helix.Core.Server.GetDataDirFileName( "" ) -- Convert to Windows-local separators. adir = adir:gsub( "/", "\\" ) ddir = ddir:gsub( "/", "\\" ) local port = Helix.Core.Server.GetVar( "serverport" ) local user = Helix.Core.Server.GetVar( "user" ) local form = Helix.Core.Server.GetVar( "formfile" ) -- Use a batch file to set up Python. This indirection lets -- us set environmental variables and whatever else we might -- need to do outside of the Extension runtime. local cmd = '"' .. adir .. '\\setenv.bat"' .. ' "' .. ddir .. '"' .. ' -p ' .. port .. ' -u ' .. user .. ' perforce ' .. ' "' .. form .. '"' local rc, stdout, stderr = runcmd( cmd ) if rc == nil or string.len( stderr ) > 0 then local msg = "Error running wrapped trigger: " .. stdout .. stderr .. "\n" .. cmd Helix.Core.Server.SetClientMsg( msg ) return false end if string.len( stdout ) > 0 then Helix.Core.Server.SetClientMsg( stdout ) end return true end