equal
deleted
inserted
replaced
20 # |
20 # |
21 # You should have received a copy of the GNU General Public License |
21 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
|
25 |
|
26 from __future__ import print_function |
25 from types import * |
27 from types import * |
26 |
28 |
27 # Translation between IEC types and Can Open types |
29 # Translation between IEC types and Can Open types |
28 IECToCOType = { |
30 IECToCOType = { |
29 "BOOL": 0x01, |
31 "BOOL": 0x01, |
695 import os |
697 import os |
696 import sys |
698 import sys |
697 import getopt |
699 import getopt |
698 |
700 |
699 def usage(): |
701 def usage(): |
700 print """ |
702 print(""" |
701 Usage of config_utils.py test : |
703 Usage of config_utils.py test : |
702 |
704 |
703 %s [options] |
705 %s [options] |
704 |
706 |
705 Options: |
707 Options: |
708 |
710 |
709 --reset (-r) |
711 --reset (-r) |
710 Reset the reference result of config_utils test. |
712 Reset the reference result of config_utils test. |
711 Use with caution. Be sure that config_utils |
713 Use with caution. Be sure that config_utils |
712 is currently working properly. |
714 is currently working properly. |
713 """ % sys.argv[0] |
715 """ % sys.argv[0]) |
714 |
716 |
715 # Boolean that indicate if reference result must be redefined |
717 # Boolean that indicate if reference result must be redefined |
716 reset = False |
718 reset = False |
717 |
719 |
718 # Extract command options |
720 # Extract command options |
762 |
764 |
763 # Generate MasterNode configuration |
765 # Generate MasterNode configuration |
764 try: |
766 try: |
765 masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
767 masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
766 except ValueError, message: |
768 except ValueError, message: |
767 print "%s\nTest Failed!" % message |
769 print("%s\nTest Failed!" % message) |
768 sys.exit() |
770 sys.exit() |
769 |
771 |
770 import pprint |
772 import pprint |
771 # Get Text corresponding to MasterNode |
773 # Get Text corresponding to MasterNode |
772 result_node = masternode.PrintString() |
774 result_node = masternode.PrintString() |
778 # Write Text into reference result file |
780 # Write Text into reference result file |
779 testfile = open("test_config/result.txt", "w") |
781 testfile = open("test_config/result.txt", "w") |
780 testfile.write(result) |
782 testfile.write(result) |
781 testfile.close() |
783 testfile.close() |
782 |
784 |
783 print "Reset Successful!" |
785 print("Reset Successful!") |
784 else: |
786 else: |
785 import os |
787 import os |
786 |
788 |
787 testfile = open("test_config/result_tmp.txt", "w") |
789 testfile = open("test_config/result_tmp.txt", "w") |
788 testfile.write(result) |
790 testfile.write(result) |