Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python activities issues OSAC 39,40,41,50 #71

Merged
merged 17 commits into from
Nov 12, 2020
Merged
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
25 changes: 21 additions & 4 deletions Activities/Database/UiPath.Database/DatabaseConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
using System.Text;
using UiPath.Database.Properties;

namespace UiPath.Database
{
public class DatabaseConnection : IDisposable
{
private string OracleDriverPattern = "SQORA";
private DbConnection _connection;
private DbCommand _command;
private DbTransaction _transaction;
Expand Down Expand Up @@ -111,13 +113,18 @@ private void SetupCommand(string sql, Dictionary<string, Tuple<object, ArgumentD

_command = _command ?? _connection.CreateCommand();

var ceilVal = (int) Math.Ceiling((double) commandTimeout / 1000);
var ceilVal = (int)Math.Ceiling((double)commandTimeout / 1000);

if (ceilVal != 0)
{
_command.CommandTimeout = ceilVal;
}

}
//Oracle has different implementation for Odbc Stored Procedure calling
if (_connection.GetType() == typeof(OdbcConnection)
petcua1 marked this conversation as resolved.
Show resolved Hide resolved
&& ((OdbcConnection)_connection).Driver.StartsWith(OracleDriverPattern)
&& commandType == CommandType.StoredProcedure)
sql = GetOracleOdbcSqlSPString(sql, parameters.Count);

_command.CommandType = commandType;
_command.CommandText = sql;
_command.Parameters.Clear();
Expand All @@ -132,13 +139,23 @@ private void SetupCommand(string sql, Dictionary<string, Tuple<object, ArgumentD
dbParameter.Direction = WokflowDbParameterToParameterDirection(param.Value.Item2);
if (dbParameter.Direction.HasFlag(ParameterDirection.InputOutput) || dbParameter.Direction.HasFlag(ParameterDirection.Output))
{
dbParameter.Size = -1;
dbParameter.Size = 10000000;
}

dbParameter.Value = param.Value.Item1 ?? DBNull.Value;
_command.Parameters.Add(dbParameter);
}
}
private string GetOracleOdbcSqlSPString(string sql, int parametersCount)
{
if (sql.Trim().Split(' ').Length > 1)
return sql;
string pattern = "CALL {0} ({1})";
string[] parameterString = new string[parametersCount];
for (int i = 0; i < parametersCount; i++)
parameterString[i] = "?";
return string.Format(pattern, sql, string.Join(",", parameterString));
}

private string GetColumnNames(DataTable table)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<comment>activity name</comment>
</data>
<data name="ScriptFileDescription" xml:space="preserve">
<value>Python script file</value>
<value>Full path to Python script file</value>
</data>
<data name="ScriptFileNameDisplayName" xml:space="preserve">
<value>File</value>
Expand Down
5 changes: 0 additions & 5 deletions Activities/Python/UiPath.Python.Activities/PythonScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ namespace UiPath.Python.Activities
[LocalizedDescription(nameof(Resources.PythonScopeDescription))]
public class PythonScope : AsyncTaskNativeActivity
{

[RequiredArgument]
[LocalizedCategory(nameof(Resources.Input))]
[LocalizedDisplayName(nameof(Resources.VersionNameDisplayName))]
[LocalizedDescription(nameof(Resources.VersionDescription))]
petcua1 marked this conversation as resolved.
Show resolved Hide resolved
[DefaultValue(Version.Auto)]
public Version Version { get; set; }

Expand Down
29 changes: 22 additions & 7 deletions Activities/Python/UiPath.Python/EngineProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class EngineProvider
{
private const string PythonHomeEnv = "PYTHONHOME";
private const string PythonExe = "python.exe";
private const string PythonVersionArgument = "--version";

// engines cache
private static object _lock = new object();
Expand All @@ -31,13 +32,10 @@ public static IEngine Get(Version version, string path, bool inProcess = true, T
Trace.TraceInformation($"Found Pyhton path {path}");
}

Autodetect(path, out version);
if (!version.IsValid())
{
Autodetect(path, out version);
if (!version.IsValid())
{
throw new ArgumentException(Resources.DetectVersionException);
}
throw new ArgumentException(Resources.DetectVersionException);
}

// TODO: target&visible are meaningless when running in-process (at least now), maybe it should be split
Expand Down Expand Up @@ -66,9 +64,26 @@ private static void Autodetect(string path, out Version version)
{
throw new FileNotFoundException(Resources.PythonExeNotFoundException, pyExe);
}

version = FileVersionInfo.GetVersionInfo(pyExe).Get();
Process process = new Process();
process.StartInfo = new ProcessStartInfo()
{
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
FileName = pyExe,
Arguments = PythonVersionArgument,
RedirectStandardError = true,
RedirectStandardOutput = true
};
process.Start();
// Now read the value, parse to int and add 1 (from the original script)
string ver = process.StandardError.ReadToEnd();
if(string.IsNullOrEmpty(ver))
ver = process.StandardOutput.ReadToEnd();
process.WaitForExit();
version = ver.GetVersionFromStr();
Trace.TraceInformation($"Autodetected Python version {version}");
}

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 22 additions & 19 deletions Activities/Python/UiPath.Python/Properties/UiPath.Python.fr.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
<xsd:element name="value" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
Expand Down Expand Up @@ -126,4 +126,7 @@
<data name="PythonRuntimeTypeException" xml:space="preserve">
<value>Type/méthode/propriété runtime de Python introuvable : {0}</value>
</data>
</root>
<data name="UnsupportedVersionException" xml:space="preserve">
petcua1 marked this conversation as resolved.
Show resolved Hide resolved
<value/>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<?xml version='1.0' encoding='utf-8'?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -126,4 +126,7 @@
<data name="PythonRuntimeTypeException" xml:space="preserve">
<value>Python ランタイムの型/メソッド/プロパティが見つかりません: {0}</value>
</data>
<data name="UnsupportedVersionException" xml:space="preserve">
petcua1 marked this conversation as resolved.
Show resolved Hide resolved
<value/>
</data>
</root>
3 changes: 3 additions & 0 deletions Activities/Python/UiPath.Python/Properties/UiPath.Python.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@
<data name="PythonRuntimeTypeException" xml:space="preserve">
<value>Python runtime type/method/property not found: {0}</value>
</data>
<data name="UnsupportedVersionException" xml:space="preserve">
<value>Python version {0} is not supported. Supported versions are: {1}</value>
</data>
</root>
41 changes: 22 additions & 19 deletions Activities/Python/UiPath.Python/Properties/UiPath.Python.ru.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version='1.0' encoding='utf-8'?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -59,46 +59,46 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
<xsd:element name="value" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
Expand Down Expand Up @@ -126,4 +126,7 @@
<data name="PythonRuntimeTypeException" xml:space="preserve">
<value>Не найдено свойство/метод/тип среды выполнения Python: {0}</value>
</data>
</root>
<data name="UnsupportedVersionException" xml:space="preserve">
<value/>
</data>
</root>
Loading