Exemplo n.º 1
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var leftValue  = Left.Interp(environment);
            var rightValue = Right.Interp(environment);

            return(new InterpValue(leftValue.Equals(rightValue)));
        }
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var val = Value.Interp(environment);

            if (val.Type != ValueType.Boolean)
            {
                throw new WrongTypeException(val.Type, ValueType.Boolean);
            }

            if (!val.BoolValue)
            {
                if (Value is InterpEqual)
                {
                    var eq   = Value as InterpEqual;
                    var lval = eq.Left.Interp(environment);
                    var rval = eq.Right.Interp(environment);

                    throw new AssertFailException(Value, lval, rval);
                }
                else
                {
                    throw new AssertFailException(Value);
                }
            }

            return(new InterpValue());
        }
Exemplo n.º 3
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var connVal = Connection.Interp(environment);

            AssertType(connVal.Type, ValueType.SshConnection);

            var localVal = LocalFile.Interp(environment);

            AssertType(localVal.Type, ValueType.String);

            string remoteName = string.Empty;

            if (RemoteFile == null)
            {
                remoteName = Path.GetFileName(localVal.StringValue);
            }
            else
            {
                var remoteVal = RemoteFile.Interp(environment);
                AssertType(remoteVal.Type, ValueType.String);

                remoteName = remoteVal.StringValue;
            }

            using (var localStream = File.OpenRead(localVal.StringValue))
                connVal.SshValue.ScpClient.Upload(localStream, "./" + connVal.SshValue.DirName + "/" + remoteName);

            return(new InterpValue());
        }
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var val = Value.Interp(environment);

            environment[Identifier] = val;

            return(new InterpValue());
        }
Exemplo n.º 5
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var val = Value.Interp(environment);

            AssertType(val.Type, ValueType.Boolean);

            return(new InterpValue(!val.BoolValue));
        }
Exemplo n.º 6
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var tval = Target.Interp(environment);

            AssertType(tval.Type, ValueType.Process);

            return(new InterpValue(tval.ProcessValue.Kill()));
        }
Exemplo n.º 7
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var filename = Filename.Interp(environment);

            AssertType(filename.Type, ValueType.String);

            var text = File.ReadAllText(filename.StringValue);

            return(new InterpValue(text));
        }
Exemplo n.º 8
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            InterpValue last = new InterpValue();

            foreach (var val in Values)
            {
                last = val.Interp(environment);
            }

            return(last);
        }
Exemplo n.º 9
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var proc = Value.Interp(environment);

            if (proc.Type != ValueType.Process)
            {
                throw new WrongTypeException(proc.Type, ValueType.Process);
            }

            return(new InterpValue(proc.ProcessValue.Output));
        }
Exemplo n.º 10
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var filenameVal = Filename.Interp(environment);

            AssertType(filenameVal.Type, ValueType.String);

            var textVal = Text.Interp(environment);

            AssertType(textVal.Type, ValueType.String);

            File.WriteAllText(filenameVal.StringValue, textVal.StringValue);
            return(new InterpValue());
        }
Exemplo n.º 11
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var connVal = Connection.Interp(environment);

            AssertType(connVal.Type, ValueType.SshConnection);

            var commandVal = Command.Interp(environment);

            AssertType(commandVal.Type, ValueType.String);

            var command = connVal.SshValue.SshClient.CreateCommand(connVal.SshValue.Prepend + commandVal.StringValue);

            return(new InterpValue(new RemoteProcessWrapper(command)));
        }
Exemplo n.º 12
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var value = Value.Interp(environment);

            if (value.Type != ValueType.String)
            {
                throw new WrongTypeException(value.Type, ValueType.String);
            }

            var p = StartShell(value.StringValue);

            p.WaitForExit();

            return(new InterpValue());
        }
Exemplo n.º 13
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var glob = Value.Interp(environment);

            AssertType(glob.Type, ValueType.String);

            var dirInfo = new DirectoryInfo(Environment.CurrentDirectory);

            foreach (var file in dirInfo.EnumerateFiles(glob.StringValue))
            {
                file.Delete();
            }

            return(new InterpValue());
        }
Exemplo n.º 14
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            InterpValue val = null;

            var plat = Environment.OSVersion.Platform;

            if (plat == PlatformID.Unix)
            {
                val = Unix.Interp(environment);
            }
            else
            {
                val = Windows.Interp(environment);
            }

            return(val);
        }
Exemplo n.º 15
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var conn = Value.Interp(environment);

            AssertType(conn.Type, ValueType.SshConnection);

            bool cleanup = true;

            if (Cleanup != null)
            {
                var cleanupVal = Cleanup.Interp(environment);
                AssertType(cleanupVal.Type, ValueType.Boolean);

                cleanup = cleanupVal.BoolValue;
            }

            conn.SshValue.Disconnect(cleanup);

            return(new InterpValue());
        }
Exemplo n.º 16
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var name = Name.Interp(environment);

            if (name.Type != ValueType.String)
            {
                throw new WrongTypeException(name.Type, ValueType.String);
            }

            string procName = null;

            if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix)
            {
                procName = name.StringValue + ".exe";
            }
            else
            {
                procName = name.StringValue;
            }

            var startInfo = new ProcessStartInfo(procName)
            {
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false,
            };

            if (Args != null)
            {
                var args = Args.Interp(environment);
                if (args.Type != ValueType.String)
                {
                    throw new WrongTypeException(args.Type, ValueType.String);
                }

                startInfo.Arguments = args.StringValue;
            }

            return(new InterpValue(
                       new LocalProcessWrapper(Process.Start(startInfo))));
        }
Exemplo n.º 17
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var amVal = Amount.Interp(environment);

            AssertType(amVal.Type, ValueType.Integer);

            var stringVal = Value.Interp(environment);

            AssertType(stringVal.Type, ValueType.String);

            var lines = stringVal.StringValue.Split('\n');

            if (lines.Count() <= amVal.IntValue)
            {
                return(new InterpValue(string.Empty));
            }
            else
            {
                return(new InterpValue(lines.Skip(amVal.IntValue).Aggregate((l, r) => l + "\n" + r)));
            }
        }
Exemplo n.º 18
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var evaled = new List <InterpValue>();

            foreach (var child in Children)
            {
                var res = child.Interp(environment);
                if (res.Type != ValueType.Process)
                {
                    throw new WrongTypeException(res.Type, ValueType.Process);
                }

                evaled.Add(res);
            }

            foreach (var val in evaled)
            {
                val.ProcessValue.Wait();
            }

            return(new InterpValue());
        }
Exemplo n.º 19
0
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var addrVal = Address.Interp(environment);

            AssertType(addrVal.Type, ValueType.String);

            string prepend = string.Empty;

            if (Prepend != null)
            {
                var prependVal = Prepend.Interp(environment);
                AssertType(prependVal.Type, ValueType.String);

                prepend = prependVal.StringValue;
            }

            AuthInfo auth;

            if (m_authManager.HasInfo(addrVal.StringValue))
            {
                auth = m_authManager[addrVal.StringValue];
            }
            else
            {
                // mode check
                // prompt
                var ret = m_authManager.Prompt(addrVal.StringValue);
                if (ret == null || !ret.HasValue)
                {
                    throw new Exception("Bad ssh thing");
                }

                auth = ret.Value;
            }

            var info = new ConnectionInfo(addrVal.StringValue, auth.Username, new PasswordAuthenticationMethod(auth.Username, auth.Password));

            return(new InterpValue(new ConnectionWrapper(info, prepend)));
        }
Exemplo n.º 20
0
 public override InterpValue Interp(InterpEnvironment environment)
 {
     return(new InterpValue(Value));
 }
Exemplo n.º 21
0
 public abstract InterpValue Interp(InterpEnvironment environment);
Exemplo n.º 22
0
 public override InterpValue Interp(InterpEnvironment environment)
 {
     return(environment[Identifier]);
 }