Exemple #1
0
        private static string ExecuteTest(LightServer ls, string connect, string comp)
        {
            string cmd = connect + " ls '" + cygify(comp) + "'";
            string err = "";
            string std = "";

            using (Process proc = new Process())
            {
                proc.StartInfo.FileName               = ssh;
                proc.StartInfo.CreateNoWindow         = true;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardError  = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.Arguments              = cmd;
                proc.Start();

                err = proc.StandardError.ReadToEnd();
                std = proc.StandardOutput.ReadToEnd();

                proc.WaitForExit(3000);
            }

            if (!string.IsNullOrEmpty(err))
            {
                return(err);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
    /**
     * LIGHT SERVER SERIALIZATION
     **/

    public static void Put(this NetDataWriter writer, LightServer light)
    {
        writer.Put(light.range);
        writer.Put(light.color);
        writer.Put(light.intensity);

        writer.Put(light.shadowStrength);
        writer.Put(light.shadowBias);
        writer.Put(light.shadowNormalBias);
        writer.Put(light.shadowNearPlane);
    }
        public LightConnection(LightServer <T> server, Socket socket)
        {
            Id     = Guid.NewGuid();
            Server = server;
            Socket = socket;

            using (var packet = new T())
                Packetizer = packet.CreatePacketizer();

            StartSendLoop();
        }
Exemple #4
0
        private static void TestConnection(object c)
        {
            int         i  = (int)c;
            LightServer ls = serversToTest[i];

            try
            {
                string server  = string.IsNullOrEmpty(ls.IP) ? ls.Name : ls.IP;
                string connect = DefineConnection(ls.Username, server);
                string err     = ExecuteTest(ls, connect, comp);

                if (!string.IsNullOrEmpty(err))
                {
                    //Console.ForegroundColor = ConsoleColor.Yellow;
                    //Console.WriteLine("not on " + ls.Name);
                    //Console.WriteLine(err);
                    //Console.ResetColor();
                }
                else
                {
                    TestHash(ls, server);
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
            finally
            {
                if (Interlocked.Decrement(ref threadCnt) == 0)
                {
                    signal.Set();
                }
            }
        }
Exemple #5
0
        private static void TestHash(LightServer ls, string server)
        {
            string transferTo = Path.Combine(Directory.GetCurrentDirectory(), ls.Name);

            if (Directory.Exists(transferTo))
            {
                Directory.Delete(transferTo, true);
            }

            string fromRemote = Path.Combine(transferTo, currentComp.Component);

            Directory.CreateDirectory(transferTo);

            string connect = DefineConnection(ls.Username, server);
            string cmd     = connect + ":'" + cygify(comp) + "' '" + cygify(fromRemote) + "'";

            string err = ExecuteSCP(cmd);

            if (!string.IsNullOrEmpty(err))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ls.Name + " - " + err);
            }

            if (File.Exists(fromRemote))
            {
                string remoteHash = BTHash.HashMethods.GetFileHash(fromRemote);
                string sourceHash = "";
                File.Delete(fromRemote);

                string srcUrl = currentComp.SVNPath;
                if (!srcUrl.ToUpper().EndsWith(currentComp.Component.ToUpper()))
                {
                    if (!srcUrl.EndsWith("/"))
                    {
                        srcUrl += "/";
                    }

                    srcUrl += currentComp.Component;
                }

                string svnCmd = "export \"" + srcUrl + "\" -r " + currentComp.Version;
                //Console.WriteLine("Running " + svnCmd);

                using (Process proc = new Process())
                {
                    try
                    {
                        proc.StartInfo.FileName               = "svn.exe";
                        proc.StartInfo.WorkingDirectory       = transferTo;
                        proc.StartInfo.CreateNoWindow         = true;
                        proc.StartInfo.UseShellExecute        = false;
                        proc.StartInfo.RedirectStandardError  = true;
                        proc.StartInfo.RedirectStandardOutput = true;
                        proc.StartInfo.Arguments              = svnCmd;
                        proc.Start();

                        string svnErr = proc.StandardError.ReadToEnd();
                        string svnStd = proc.StandardOutput.ReadToEnd();

                        proc.WaitForExit();

                        if (!string.IsNullOrEmpty(svnErr))
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine(svnErr);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(ex.Message);
                    }

                    if (File.Exists(fromRemote))
                    {
                        sourceHash = BTHash.HashMethods.GetFileHash(fromRemote);
                        File.Delete(fromRemote);
                    }
                }

                if (sourceHash == remoteHash)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("match on " + ls.Name);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("mismatch on " + ls.Name);
                }

                Console.ResetColor();
            }
        }