Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkenneth.skovhede@gmail.com <kenneth.skovhede@gmail.com@59da171f-624f-0410-aa54-27559c288bec>2009-06-14 18:49:56 +0400
committerkenneth.skovhede@gmail.com <kenneth.skovhede@gmail.com@59da171f-624f-0410-aa54-27559c288bec>2009-06-14 18:49:56 +0400
commit22ea173dc7b81c7014c3c66f52656586312ce7fb (patch)
tree6ad012bb97b23c7a606f533c0b335fa5aecac15e
parent793d3c43107b4dcec1242e871a917ddb3c72e6d5 (diff)
Added missing files, merge from r190.1.0-final
git-svn-id: https://duplicati.googlecode.com/svn/tags/1.0 Final@193 59da171f-624f-0410-aa54-27559c288bec
-rw-r--r--Duplicati/Library/SharpExpect/Duplicati.Library.SharpExpect.csproj47
-rw-r--r--Duplicati/Library/SharpExpect/Properties/AssemblyInfo.cs54
-rw-r--r--Duplicati/Library/SharpExpect/SharpExpectProcess.cs152
3 files changed, 253 insertions, 0 deletions
diff --git a/Duplicati/Library/SharpExpect/Duplicati.Library.SharpExpect.csproj b/Duplicati/Library/SharpExpect/Duplicati.Library.SharpExpect.csproj
new file mode 100644
index 000000000..0fc1090a5
--- /dev/null
+++ b/Duplicati/Library/SharpExpect/Duplicati.Library.SharpExpect.csproj
@@ -0,0 +1,47 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3526D1E7-64D1-4659-918C-5FC18FBD0905}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Duplicati.Library.SharpExpect</RootNamespace>
+ <AssemblyName>Duplicati.Library.SharpExpect</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="SharpExpectProcess.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/Duplicati/Library/SharpExpect/Properties/AssemblyInfo.cs b/Duplicati/Library/SharpExpect/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..72ad8ab00
--- /dev/null
+++ b/Duplicati/Library/SharpExpect/Properties/AssemblyInfo.cs
@@ -0,0 +1,54 @@
+#region Disclaimer / License
+// Copyright (C) 2009, Kenneth Skovhede
+// http://www.hexad.dk, opensource@hexad.dk
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#endregion
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Duplicati.Library.SharpExpect")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("GEOGRAF A/S")]
+[assembly: AssemblyProduct("Duplicati.Library.SharpExpect")]
+[assembly: AssemblyCopyright("Copyright © GEOGRAF A/S 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("786d822a-f3fa-402a-a0dc-0e30f88937ea")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.183")]
+[assembly: AssemblyFileVersion("1.0.0.183")]
diff --git a/Duplicati/Library/SharpExpect/SharpExpectProcess.cs b/Duplicati/Library/SharpExpect/SharpExpectProcess.cs
new file mode 100644
index 000000000..7371bf8f5
--- /dev/null
+++ b/Duplicati/Library/SharpExpect/SharpExpectProcess.cs
@@ -0,0 +1,152 @@
+#region Disclaimer / License
+// Copyright (C) 2009, Kenneth Skovhede
+// http://www.hexad.dk, opensource@hexad.dk
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Duplicati.Library.SharpExpect
+{
+ public class SharpExpectProcess
+ {
+ private System.Diagnostics.Process m_process;
+ private object m_lock = new object();
+ private System.Threading.Thread m_stdOutReader;
+ private System.Threading.Thread m_stdErrReader;
+ private Queue<string> m_stdOut = new Queue<string>();
+ private Queue<string> m_stdErr = new Queue<string>();
+ private System.Threading.AutoResetEvent m_event = new System.Threading.AutoResetEvent(false);
+
+ public SharpExpectProcess(System.Diagnostics.Process process)
+ {
+ m_process = process;
+
+ if (m_process.StartInfo.RedirectStandardError)
+ {
+ m_stdErrReader = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(StreamReader));
+ m_stdErrReader.Start(m_process.StandardError);
+ }
+
+ if (m_process.StartInfo.RedirectStandardOutput)
+ {
+ m_stdOutReader = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(StreamReader));
+ m_stdOutReader.Start(m_process.StandardOutput);
+ }
+ }
+
+ public string GetNextOutputLine(int millisecondsTimeout)
+ {
+ //Is output buffered?
+ lock (m_lock)
+ {
+ if (m_stdOut.Count > 0)
+ return m_stdOut.Dequeue();
+
+ if (m_stdErr.Count > 0)
+ return m_stdErr.Dequeue();
+ }
+
+ if (millisecondsTimeout > 0)
+ {
+ m_event.WaitOne(millisecondsTimeout);
+ return GetNextOutputLine(0);
+ }
+ else
+ return null;
+ }
+
+ public int Expect(int millisecondsTimeout, params string[] possibilities)
+ {
+ List<KeyValuePair<System.Text.RegularExpressions.Regex, int>> lst = new List<KeyValuePair<System.Text.RegularExpressions.Regex, int>>();
+ for (int i = 0; i < possibilities.Length; i++)
+ if (!string.IsNullOrEmpty(possibilities[i]))
+ lst.Add(new KeyValuePair<System.Text.RegularExpressions.Regex, int>(new System.Text.RegularExpressions.Regex(possibilities[i]), i));
+
+ return Expect<int>(millisecondsTimeout, lst);
+ }
+
+ public T Expect<T>(int millisecondsTimeout, List<KeyValuePair<string, T>> possibilities)
+ {
+ List<KeyValuePair<System.Text.RegularExpressions.Regex, T>> lst = new List<KeyValuePair<System.Text.RegularExpressions.Regex, T>>();
+ for (int i = 0; i < possibilities.Count; i++)
+ if (!string.IsNullOrEmpty(possibilities[i].Key))
+ lst.Add(new KeyValuePair<System.Text.RegularExpressions.Regex, T>(new System.Text.RegularExpressions.Regex(possibilities[i].Key), possibilities[i].Value));
+
+ return Expect<T>(millisecondsTimeout, possibilities);
+ }
+
+ public T Expect<T>(int millisecondsTimeout, List<KeyValuePair<System.Text.RegularExpressions.Regex ,T>> possibilities)
+ {
+ if (possibilities == null || possibilities.Count == 0)
+ return default(T);
+
+ string line = GetNextOutputLine(millisecondsTimeout);
+ if (line == null)
+ return default(T);
+
+ foreach (KeyValuePair<System.Text.RegularExpressions.Regex, T> expr in possibilities)
+ if (expr.Key.Match(line).Success)
+ return expr.Value;
+
+ return default(T);
+ }
+
+ public void Sendline(string line)
+ {
+ m_process.StandardInput.WriteLine(line);
+ }
+
+ private void StreamReader(object input)
+ {
+ char[] buf = new char[1024];
+ System.IO.StreamReader sr = (System.IO.StreamReader)input;
+ Queue<string> queue = sr == m_process.StandardError ? m_stdErr : m_stdOut;
+
+ while (!m_process.HasExited)
+ {
+ int r = sr.Read(buf, 0, buf.Length);
+ if (r > 0)
+ {
+ lock (m_lock)
+ {
+ queue.Enqueue(new string(buf, 0, r));
+ m_event.Set();
+ }
+ }
+ }
+ }
+
+ public System.Diagnostics.Process Process { get { return m_process; } }
+
+
+ public static SharpExpectProcess Spawn(string FileName, string Arguments)
+ {
+ System.Diagnostics.ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo(FileName, Arguments);
+ pi.RedirectStandardError = true;
+ pi.RedirectStandardOutput = true;
+ pi.RedirectStandardInput = true;
+ return Spawn(pi);
+ }
+
+ public static SharpExpectProcess Spawn(System.Diagnostics.ProcessStartInfo startInfo)
+ {
+ return new SharpExpectProcess(System.Diagnostics.Process.Start(startInfo));
+ }
+ }
+}