frepple_python.py :  » ERP » frePPLe » frepple-0.8.0 » contrib » scripting » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » ERP » frePPLe 
frePPLe » frepple 0.8.0 » contrib » scripting » frepple_python.py
#!/usr/bin/python
#  file     : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/tags/0.8.0/contrib/scripting/frepple_python.py $
#  revision : $LastChangedRevision: 924 $  $LastChangedBy: jdetaeye $
#  date     : $LastChangedDate: 2009-02-21 16:37:58 +0100 (Sat, 21 Feb 2009) $

import frepple
import os



try:
  print "Initializing:"
  frepple.FreppleInitialize()
  print " OK"
  print "Reading base data:"
  frepple.FreppleReadXMLData('<?xml version="1.0" encoding="UTF-8" ?> \
    <plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \
      <name>actual plan</name> \
      <description>anything goes</description> \
      <current>2007-01-01T00:00:01</current> \
      <operations> \
        <operation name="make end item" xsi:type="operation_fixed_time"> \
          <duration>P1D</duration> \
        </operation> \
      </operations> \
      <items> \
        <item name="end item"> \
          <operation name="delivery end item" xsi:type="operation_fixed_time"> \
            <duration>P1D</duration> \
          </operation> \
        </item> \
      </items> \
      <buffers> \
        <buffer name="end item"> \
          <producing name="make end item"/> \
          <item name="end item"/> \
        </buffer> \
      </buffers> \
      <resources> \
        <resource name="resource"> \
          <maximum name="capacity" xsi:type="calendar_double"> \
            <buckets> \
              <bucket start="2007-01-01T00:00:01" value="1"/> \
            </buckets> \
          </maximum> \
          <loads> \
            <load> \
              <operation name="make end item" /> \
            </load> \
          </loads> \
        </resource> \
      </resources> \
      <flows> \
        <flow xsi:type="flow_start"> \
          <operation name="delivery end item"/> \
          <buffer name="end item"/> \
          <quantity>-1</quantity> \
        </flow> \
        <flow xsi:type="flow_end"> \
          <operation name="make end item"/> \
          <buffer name="end item"/> \
          <quantity>1</quantity> \
        </flow> \
      </flows> \
      <demands> \
        <demand name="order 1"> \
          <quantity>10</quantity> \
          <due>2007-01-04T09:00:00</due> \
          <priority>1</priority> \
          <item name="end item"/> \
        </demand> \
      </demands> \
    </plan> ', True, False)
  print " OK"

  print "Adding an item:"
  frepple.FreppleReadXMLData('<?xml version="1.0" encoding="UTF-8" ?> \
    <plan xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> \
      <items> \
        <item name="new item"/> \
      </items> \
    </plan>', 1, 0)
  print " OK"

  print "Saving frepple model to a file:"
  frepple.FreppleSaveFile("turbo.python.xml")
  print " OK"

  print "Passing invalid XML data to frepple:"
  frepple.FreppleReadXMLData('<?xml version="1.0" encoding="UTF-8" ?> \
    <plan xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> \
      <xxdescription>dummy</xxdescription> \
    </plan> ', 1, 0)
  print " OK"

  print "End of frepple commands"
except RuntimeError, inst:
  print "Runtime exception caught: " + str(inst)
except:
  print "Caught an unknown exception"
else:
  print "All commands passed without error"

print "Exiting..."
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.