public override string[] GetArguments (PythonConfiguration config) { List<string> args = new List<string> (); if (config.Optimize) args.Add ("-O"); if (config.DebugMode) args.Add ("-d"); // Make sure python uses unbuffered files for stdin and stdout // so that we can get updates to the console immediately. args.Add ("-u"); // Add custom configuration arguments if (!String.IsNullOrEmpty (config.PythonOptions)) args.Add (config.PythonOptions); // The -m argument prevents any more argument passing to // python. Therefore, it must be at the end of the list. if (!String.IsNullOrEmpty (config.Module)) { args.Add ("-m"); args.Add (config.Module); } // Append the user runtime options if (!String.IsNullOrEmpty (config.CommandLineParameters)) args.Add (config.CommandLineParameters); return args.ToArray (); }
public override void ApplyChanges() { PythonConfiguration config = CurrentConfiguration as PythonConfiguration; config.Module = widget.DefaultModule; config.Optimize = widget.Optimize; config.Runtime = widget.Runtime; config.PythonOptions = widget.PythonOptions; var paths = new List <string> (widget.PythonPaths); // look for added modules foreach (var path in paths) { if (!config.Runtime.Site.ContainsPath(path)) { Console.WriteLine("Adding path {0}", path); config.Runtime.Site.AddPath(path); } } // look for removed foreach (var path in config.Runtime.Site.Paths) { if (!paths.Contains(path)) { Console.WriteLine("Removing path {0}", path); config.Runtime.Site.RemovePath(path); } } }
public override void LoadConfigData() { PythonConfiguration config = CurrentConfiguration as PythonConfiguration; widget.DefaultModule = config.Module; widget.Optimize = config.Optimize; widget.Runtime = config.Runtime; widget.PythonOptions = config.PythonOptions; widget.PythonPaths = config.Runtime.Site.Paths; }
public override string[] GetArguments (PythonConfiguration config) { var args = new List<string> (); if (!String.IsNullOrEmpty (config.Module)) args.Add (System.IO.Path.ChangeExtension (config.Module, "py")); if (!String.IsNullOrEmpty (config.CommandLineParameters)) args.Add (config.CommandLineParameters); return args.ToArray (); }
public void Compile (PythonProject project, FilePath fileName, PythonConfiguration config, BuildResult result) { if (String.IsNullOrEmpty (fileName)) throw new ArgumentNullException ("fileName"); else if (config == null) throw new ArgumentNullException ("config"); else if (result == null) throw new ArgumentNullException ("result"); else if (Runtime == null) throw new InvalidOperationException ("No supported runtime!"); // Get our relative path within the project if (!fileName.IsChildPathOf (project.BaseDirectory)) { Console.WriteLine ("File is not within our project!"); return; } FilePath relName = fileName.ToRelative (project.BaseDirectory); string outFile = relName.ToAbsolute (config.OutputDirectory); if (!outFile.EndsWith (".py")) return; // Create the destination directory FileInfo fileInfo = new FileInfo (outFile); if (!fileInfo.Directory.Exists) fileInfo.Directory.Create (); // Create and start our process to generate the byte code Process process = BuildCompileProcess (fileName, outFile, config.Optimize); process.Start (); process.WaitForExit (); // Parse errors and warnings string output = process.StandardError.ReadToEnd (); // Extract potential Warnings foreach (Match m in m_WarningRegex.Matches (output)) { string lineNum = m.Groups[m_WarningRegex.GroupNumberFromName ("line")].Value; string message = m.Groups[m_WarningRegex.GroupNumberFromName ("message")].Value; result.AddWarning (fileName, Int32.Parse (lineNum), 0, String.Empty, message); } // Extract potential SyntaxError foreach (Match m in m_ErrorRegex.Matches (output)) { string lineNum = m.Groups[m_ErrorRegex.GroupNumberFromName ("line")].Value; result.AddError (fileName, Int32.Parse (lineNum), 0, String.Empty, "SyntaxError"); } }
public override string[] GetArguments(PythonConfiguration config) { var args = new List <string> (); if (!String.IsNullOrEmpty(config.Module)) { args.Add(System.IO.Path.ChangeExtension(config.Module, "py")); } if (!String.IsNullOrEmpty(config.CommandLineParameters)) { args.Add(config.CommandLineParameters); } return(args.ToArray()); }
public override string[] GetArguments(PythonConfiguration config) { List <string> args = new List <string> (); if (config.Optimize) { args.Add("-O"); } if (config.DebugMode) { args.Add("-d"); } // Make sure python uses unbuffered files for stdin and stdout // so that we can get updates to the console immediately. args.Add("-u"); // Add custom configuration arguments if (!String.IsNullOrEmpty(config.PythonOptions)) { args.Add(config.PythonOptions); } // The -m argument prevents any more argument passing to // python. Therefore, it must be at the end of the list. if (!String.IsNullOrEmpty(config.Module)) { args.Add("-m"); args.Add(config.Module); } // Append the user runtime options if (!String.IsNullOrEmpty(config.CommandLineParameters)) { args.Add(config.CommandLineParameters); } return(args.ToArray()); }
public void Compile(PythonProject project, FilePath fileName, PythonConfiguration config, BuildResult result) { if (String.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } else if (config == null) { throw new ArgumentNullException("config"); } else if (result == null) { throw new ArgumentNullException("result"); } else if (Runtime == null) { throw new InvalidOperationException("No supported runtime!"); } // Get our relative path within the project if (!fileName.IsChildPathOf(project.BaseDirectory)) { Console.WriteLine("File is not within our project!"); return; } FilePath relName = fileName.ToRelative(project.BaseDirectory); string outFile = relName.ToAbsolute(config.OutputDirectory); if (!outFile.EndsWith(".py")) { return; } // Create the destination directory FileInfo fileInfo = new FileInfo(outFile); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } // Create and start our process to generate the byte code Process process = BuildCompileProcess(fileName, outFile, config.Optimize); process.Start(); process.WaitForExit(); // Parse errors and warnings string output = process.StandardError.ReadToEnd(); // Extract potential Warnings foreach (Match m in m_WarningRegex.Matches(output)) { string lineNum = m.Groups[m_WarningRegex.GroupNumberFromName("line")].Value; string message = m.Groups[m_WarningRegex.GroupNumberFromName("message")].Value; result.AddWarning(fileName, Int32.Parse(lineNum), 0, String.Empty, message); } // Extract potential SyntaxError foreach (Match m in m_ErrorRegex.Matches(output)) { string lineNum = m.Groups[m_ErrorRegex.GroupNumberFromName("line")].Value; result.AddError(fileName, Int32.Parse(lineNum), 0, String.Empty, "SyntaxError"); } }
public abstract string[] GetArguments(PythonConfiguration config);