Exemple #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());
        }
        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());
        }
        public override InterpValue Interp(InterpEnvironment environment)
        {
            var val = Value.Interp(environment);

            AssertType(val.Type, ValueType.Boolean);

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

            AssertType(tval.Type, ValueType.Process);

            return(new InterpValue(tval.ProcessValue.Kill()));
        }
        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));
        }
        public override InterpValue Interp(InterpEnvironment environment)
        {
            InterpValue last = new InterpValue();

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

            return(last);
        }
Exemple #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));
        }
        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());
        }
Exemple #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)));
        }
Exemple #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());
        }
        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());
        }
Exemple #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);
        }
Exemple #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());
        }
Exemple #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))));
        }
Exemple #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)));
            }
        }
Exemple #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());
        }
        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)));
        }
 public override InterpValue Interp(InterpEnvironment environment)
 {
     return(new InterpValue(Value));
 }
 public abstract InterpValue Interp(InterpEnvironment environment);
Exemple #22
0
 public override InterpValue Interp(InterpEnvironment environment)
 {
     return(environment[Identifier]);
 }