python项目不由SSRS用户运行,但在我的用户上运行良好

时间:2011-10-30 07:32:26

标签: c# python reporting-services

我开发了一个ssrs数据源扩展(c#.NET 4.0) 它适用于我的报表设计器,但无法在服务器上执行相同操作。 错误发生在IDbConnection的open()实现中。 我的open用数据填充数据库表 然后创建一个批处理文件,该文件运行分析表的python组件,并将结果放在另一个数据库表中。 填表的第一部分运行良好。 然后创建批次。它正在运行,并且在python代码中的某些时候它崩溃了,我无法捕获任何异常(根本不是python专家,使用它因为它是开放源代码完全符合我的需要) 这是在.NET端创建和运行批处理文件的方法:

static void mybatchexecution(int uniqueiteration)
{
    string batchfilename = @"C:\CoverageTemp\Coverage_" + uniqueiteration+".bat";
    StreamWriter sw = new StreamWriter(batchfilename);
    string batchcmd = @"F:\Python27\python.exe F:\CoverageProject\CoverageGrowth.py " + uniqueiteration;
    sw.WriteLine(batchcmd);
    sw.Close();
    try
    {
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = batchfilename;
        startInfo.RedirectStandardError = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.LoadUserProfile = true;
        //this i already tried
        //startInfo.UserName = @"domain\user";
        //SecureString passWordObj = new SecureString();
        //foreach (Char C in "pass".ToCharArray())
        //    passWordObj.AppendChar(C);
        //startInfo.Password = passWordObj;
        startInfo.CreateNoWindow = true;
        startInfo.UseShellExecute = false;
        Process childProcess = new Process();
        childProcess.StartInfo = startInfo;
        childProcess.Start();
        string t=childProcess.StandardOutput.ReadToEnd();
        childProcess.WaitForExit();
        string logfile=@"c:\trylogfile.txt";
        StreamWriter mylogwriter = new StreamWriter(logfile);
        mylogwriter.WriteLine(t);
        mylogwriter.WriteLine(childProcess.ExitCode);
        mylogwriter.Close();
    }
    catch (Exception e)
    {
        string logfilename = @"C:\catchlogfile.txt";
        StreamWriter logwriter = new StreamWriter(logfilename);
        logwriter.WriteLine(e.Message);
        logwriter.WriteLine(e.StackTrace);
        Exception et = e.InnerException;
        while (et != null)
        {
            logwriter.WriteLine(et.Message);
            logwriter.WriteLine(et.StackTrace);
            et = et.InnerException;
        }
        logwriter.Close();
    }
}

这是在python端运行的:

import sys, os;
if os.path.join(sys.path[0][:sys.path[0].rfind(os.sep)], '../..') not in sys.path:
sys.path.append(os.path.join(sys.path[0][:sys.path[0].rfind(os.sep)], '../..'))
import pythonequations
import string
import pyodbc
import string
import exceptions
import traceback 
import os
tb = "No error" 
try:
read data from database into mytext 
equation = pythonequations.Equations2D.Exponential.Hocket_Sherby2D() #
equation.fittingTarget = 'SSQABS' 
equation.ConvertTextToData(mytext, 1) 
print "before init"
equation.Initialize() # now that the equation has data, set up the cache
print "before set initial parameters"
equation.SetGAParametersAndGuessInitialCoefficientsIfNeeded()   
     print "before fit"
equation.FitToCacheData() 
print "before errors calculation"
equation.CalculateErrors() 
except (Baseexception,Exception), e:
     tb = traceback.format_exc() ,r
     outfile = open("coveragelogfile","w")
     outfile.write(tb)
     outfile.close()    
else:   
put result in database
finally:
cnxn.close() 

pythonequations是一个开源模块,它使用numpy和scipy,并在mingw g ++上编译。

我总是在reportserver日志中收到错误:

An error occurred during client rendering.
An error has occurred during report processing. (rsProcessingAborted)
An internal error occurred on the report server. See the error log for more details.     (rsInternalError) 

使用TRYLOGFILE.txt显示:

"
before init
before set initial parameters

1
"

python尝试除了没有捕获任何东西。 SSRS在具有管理员权限的用户下运行 烦人的部分是我可以在每次失败后自己运行批处理文件并且它可以工作 对于登录到服务器的其他开发人员也是如此。 值得一提的是,在每个新用户的第一次运行中,mingw正好在python似乎打破的位置进行编译。在第一次运行后,它从不显示此编译消息,mingw在c:\ mingw中的服务器上。

感谢迄今为止幸存的勇士

0 个答案:

没有答案