Giter Site home page Giter Site logo

openserver's Introduction

PyPI SCM Compliance Runs on Windows

OpenServer

Code for running Petroleum Experts OpenServer API commands in Python. More general information about this API protocol can be found on Petroleum Experts' site.

Please have a look at the CONTRIBUTING.MD file if you want to contribute.

Python

Getting started

Install the required package:

pip install openserver

Example in Python

There are two ways of using the functions, either by importing a class called OpenServer or by importing all modules. The first is the most "pythonic" way which can be used to disconnect from the license server. The latter is easier for those converting from visual basic style coding environment.

The following code will import the OpenServer module, start Prosper, open a Prosper file named well_2 on C-drive and adding a comment into the comment section in Prosper.

by using the class

from openserver import OpenServer

c = OpenServer()
c.connect()

c.DoCmd('PROSPER.START()')
c.DoCmd('PROSPER.OPENFILE("C:\\well_2.OUT")')
c.DoSet('PROSPER.SIN.SUM.Comments', 'Testing OpenServer from Python')

c.disconnect()

or

from openserver import OpenServer

with OpenServer() as c:
    c.DoCmd('PROSPER.START()')
    c.DoCmd('PROSPER.OPENFILE("C:\\well_2.OUT")')
    c.DoSet('PROSPER.SIN.SUM.Comments', 'Testing OpenServer from Python')

by importing all modules

from openserver import *

DoCmd('PROSPER.START()')
DoCmd('PROSPER.OPENFILE("C:\\well_2.OUT")')
DoSet('PROSPER.SIN.SUM.Comments', 'Testing OpenServer from Python')

openserver's People

Contributors

knudsvik avatar mtrevoux avatar smolvik1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openserver's Issues

Array fixes

  • DoGet function should run also when asking for parts of an array, i.e. following included in the access string: [1,3,4] to get first, third and fourth item returned as an array. Now only the full array [$] is catered for. Are multi-dimension arrays handled?

  • DoSet should handle numpy arrays as input. Needs to be re-written to "val1|val2|val3" when passed to OpenServer API.

  • Document how arrays are treated, e.g. in docstrings of DoGet and DoSet.

Implement parsing of results returned by DoCmd[$]

Merouane Hamdani 03.06.20:
Not sure if anyone has experienced that but the output of the DoGet is bit funny in my view ... it outputs a string that needs to be splitted and parced ... attached is a simple example where I do make some IPR's sensitivites (nb... I am choosing to querry the DoGet with the "$" as it s a way too fast compared to a normal loop)

Add function testing

Anything that can be tested? Would need the "PX32.OpenServer.1" reference for most functions.. may put a prosper file in resources section to test functions on?

PCP changes on artificial lift input data

Hi!

I'm trying to modify an template file of a PCP well in prosper, and i need to change this variables that are in a pick list.
1
I'm trying to use DoSet with its access string (os.SetValue('PROSPER.SIN.PCP.DesPump','1')), and everything apparently is fine, i use DoGet to obtain the variable (GetValue('PROSPER.SIN.PCP.DesPump')) and the change is done, but then, when i save the .out (DoCommand('PROSPER.SAVEFILE("path")')) and i open that file, the change is not done and it uses the options by default (template).
image
Then i went to the prosper functions and i found this functions that work for ESP to change information about AL input data (specifically pick list), do you know if there are functions like that to PCP?, or if there is currently a way to do it?
image

DoGAPFunc

Hello guys!

Thank you very much for this library, it's very handy for Prosper automatization.
Can you create some additional function (DoGAPFunc) as it has been implemented on VBA?
This function will be helpful for GAP automatization.
For instance: we want to import VLP curves to GAP which was generated by each Prosper model.

Thanks a lot,
Ilya Kvitachenko

docstrings: openserver access strings

Add more information in the DoCmd, DoGet and DoSet docstrings on how to get hold of access strings (ctrl+right click in the applications). Also check if docstrings can be made available outside the class methods.

Additional wildcards handling

Facilitate for returning arrays when wildcards are submitted (chp. 3.6 of OpenServer manual):

  • Underscore (_)
  • @ Sign and *
  • @ Sign and ?
  • @ Sign and #
  • @ Sign and !

DoSet failling when no arguments needed

Some DoSet commands are failling when no arguments is provided
image

passing a command like this fails:
c.DoSet('PROSPER.ANL.SYS.Sens.SensDB.Clear')

Workaround was to past an empty string as a value, however that should be defaulted and DoSet should never fail because of that

WIN32.COM issues

Hi,

Thank you very much for the library that you created.

Today I found the following error message when I tried to connect to OpenServer. Is there any changes on the dependencies that creating this error? Sorry, I am not really familiar with this issue.

com_error Traceback (most recent call last)
~\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
88 try:
---> 89 IDispatch = pythoncom.connect(IDispatch)
90 except pythoncom.ole_error:

com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

com_error Traceback (most recent call last)
in
3 myConnection = osconnection()
4 myConnection.setVerbose(verbose_output)
----> 5 myConnection.Connect()

~\openserver\osconnection.py in Connect(self)
27 if connected == 0 :
28 global server
---> 29 server = win32com.client.Dispatch("PX32.OpenServer.1")
30 if verbose == True : print ("Establising connection")
31 connected = 1

~\Anaconda3\lib\site-packages\win32com\client_init_.py in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
93 """
94 assert UnicodeToString is None, "this is deprecated and will go away"
---> 95 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
96 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
97

~\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
112 else:
113 userName = str(userName)
--> 114 return (_GetGoodDispatch(IDispatch, clsctx), userName)
115
116 def _GetDescInvokeType(entry, invoke_type):

~\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
89 IDispatch = pythoncom.connect(IDispatch)
90 except pythoncom.ole_error:
---> 91 IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
92 else:
93 # may already be a wrapped class.

com_error: (-2147221164, 'Class not registered', None, None)

Regards,

Feldy

Application start command fails

I am using Python 3.7.1 and running the commands in Jupyter Notebook.

MicrosoftTeams-image

DoCmd() func is working when having the application open (manually).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.