repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
Nexenta/cinder
cinder/zonemanager/drivers/brocade/brcd_fc_zone_connector_factory.py
13
3195
# (c) Copyright 2015 Brocade Communications Systems Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # """ Brocade Zone Connector Factory is responsible to dynamically create the connection object based on the configuration """ from oslo_log import log as logging from oslo_utils import importutils from cinder.zonemanager.drivers.brocade import fc_zone_constants LOG = logging.getLogger(__name__) class BrcdFCZoneFactory(object): def __init__(self): self.sb_conn_map = {} def get_connector(self, fabric, sb_connector): """Returns Device Connector. Factory method to create and return correct SB connector object based on the protocol """ fabric_ip = fabric.safe_get('fc_fabric_address') client = self.sb_conn_map.get(fabric_ip) if not client: fabric_user = fabric.safe_get('fc_fabric_user') fabric_pwd = fabric.safe_get('fc_fabric_password') fabric_port = fabric.safe_get('fc_fabric_port') fc_vfid = fabric.safe_get('fc_virtual_fabric_id') fabric_ssh_cert_path = fabric.safe_get('fc_fabric_ssh_cert_path') LOG.debug("Client not found. Creating connection client for" " %(ip)s with %(connector)s protocol " "for the user %(user)s at port %(port)s.", {'ip': fabric_ip, 'connector': sb_connector, 'user': fabric_user, 'port': fabric_port, 'vf_id': fc_vfid}) if sb_connector.lower() in (fc_zone_constants.HTTP, fc_zone_constants.HTTPS): client = importutils.import_object( "cinder.zonemanager.drivers.brocade." "brcd_http_fc_zone_client.BrcdHTTPFCZoneClient", ipaddress=fabric_ip, username=fabric_user, password=fabric_pwd, port=fabric_port, vfid=fc_vfid, protocol=sb_connector ) else: client = importutils.import_object( "cinder.zonemanager.drivers.brocade." "brcd_fc_zone_client_cli.BrcdFCZoneClientCLI", ipaddress=fabric_ip, username=fabric_user, password=fabric_pwd, key=fabric_ssh_cert_path, port=fabric_port ) self.sb_conn_map.update({fabric_ip: client}) return client
apache-2.0
[ 3, 259, 334, 67, 9, 1898, 6900, 699, 293, 9490, 18686, 15285, 3277, 14, 199, 3, 259, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 34, 293, 9490, 22518, 13482, 2406, 23616, 365, 17845, 370, 18774, 1218, 314, 199, 2105, 909, 4079, 641, 314, 2897, 199, 624, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 199, 504, 13069, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 492, 10821, 63, 2619, 63, 5559, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 699, 1195, 68, 4161, 11860, 2927, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9264, 63, 1631, 63, 1130, 275, 1052, 339, 347, 664, 63, 11815, 8, 277, 12, 2630, 12, 20088, 63, 11815, 304, 267, 408, 3407, 12272, 13482, 2406, 14, 398, 23616, 1083, 370, 1218, 436, 372, 267, 3211, 26811, 13252, 909, 4079, 641, 314, 4113, 267, 408, 398, 2630, 63, 711, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 1562, 358, 267, 1890, 275, 291, 14, 9264, 63, 1631, 63, 1130, 14, 362, 8, 4991, 63, 711, 9, 398, 340, 440, 1890, 26, 953, 2630, 63, 751, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 751, 358, 288, 2630, 63, 14258, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 2060, 358, 288, 2630, 63, 719, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 719, 358, 288, 10821, 63, 86, 9430, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 2065, 63, 4991, 63, 344, 358, 288, 2630, 63, 5510, 63, 4736, 63, 515, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 5510, 63, 4736, 63, 515, 358, 953, 5051, 14, 1757, 480, 3041, 440, 1911, 14, 20507, 1950, 1890, 367, 2, 1993, 298, 2818, 711, 9, 83, 543, 2818, 11815, 9, 83, 4113, 298, 1993, 298, 509, 314, 922, 2818, 751, 9, 83, 737, 1844, 2818, 719, 9, 83, 4765, 1993, 791, 711, 356, 2630, 63, 711, 12, 2432, 283, 11815, 356, 20088, 63, 11815, 12, 2432, 283, 751, 356, 2630, 63, 751, 12, 2432, 283, 719, 356, 2630, 63, 719, 12, 2432, 283, 19963, 63, 344, 356, 10821, 63, 86, 9430, 1552, 953, 340, 20088, 63, 11815, 14, 2325, 342, 315, 334, 3003, 63, 2619, 63, 5559, 14, 2856, 12, 3147, 10821, 63, 2619, 63, 5559, 14, 14921, 304, 355, 1890, 275, 492, 1208, 14, 646, 63, 785, 8, 490, 298, 12372, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 2122, 490, 298, 66, 1195, 68, 63, 1014, 63, 3003, 63, 2619, 63, 1258, 14, 34, 1195, 68, 2856, 4161, 11860, 3041, 401, 490, 20617, 29, 4991, 63, 711, 12, 490, 3434, 29, 4991, 63, 751, 12, 490, 2505, 29, 4991, 63, 14258, 12, 490, 1844, 29, 4991, 63, 719, 12, 490, 373, 9430, 29, 3003, 63, 86, 9430, 12, 490, 4113, 29, 9264, 63, 11815, 355, 776, 288, 587, 26, 355, 1890, 275, 492, 1208, 14, 646, 63, 785, 8, 490, 298, 12372, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 2122, 490, 298, 66, 1195, 68, 63, 3003, 63, 2619, 63, 1258, 63, 2764, 14, 34, 1195, 68, 4161, 11860, 3041, 7802, 401, 490, 20617, 29, 4991, 63, 711, 12, 490, 3434, 29, 4991, 63, 751, 12, 490, 2505, 29, 4991, 63, 14258, 12, 490, 790, 29, 4991, 63, 5510, 63, 4736, 63, 515, 12, 490, 1844, 29, 4991, 63, 719, 355, 776, 288, 291, 14, 9264, 63, 1631, 63, 1130, 14, 873, 2561, 4991, 63, 711, 26, 1890, 1552, 267, 372, 1890, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 259, 334, 67, 9, 1898, 6900, 699, 293, 9490, 18686, 15285, 3277, 14, 199, 3, 259, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 34, 293, 9490, 22518, 13482, 2406, 23616, 365, 17845, 370, 18774, 1218, 314, 199, 2105, 909, 4079, 641, 314, 2897, 199, 624, 199, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 199, 504, 13069, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 492, 10821, 63, 2619, 63, 5559, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 699, 1195, 68, 4161, 11860, 2927, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 9264, 63, 1631, 63, 1130, 275, 1052, 339, 347, 664, 63, 11815, 8, 277, 12, 2630, 12, 20088, 63, 11815, 304, 267, 408, 3407, 12272, 13482, 2406, 14, 398, 23616, 1083, 370, 1218, 436, 372, 267, 3211, 26811, 13252, 909, 4079, 641, 314, 4113, 267, 408, 398, 2630, 63, 711, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 1562, 358, 267, 1890, 275, 291, 14, 9264, 63, 1631, 63, 1130, 14, 362, 8, 4991, 63, 711, 9, 398, 340, 440, 1890, 26, 953, 2630, 63, 751, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 751, 358, 288, 2630, 63, 14258, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 2060, 358, 288, 2630, 63, 719, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 719, 358, 288, 10821, 63, 86, 9430, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 2065, 63, 4991, 63, 344, 358, 288, 2630, 63, 5510, 63, 4736, 63, 515, 275, 2630, 14, 3489, 63, 362, 360, 3003, 63, 4991, 63, 5510, 63, 4736, 63, 515, 358, 953, 5051, 14, 1757, 480, 3041, 440, 1911, 14, 20507, 1950, 1890, 367, 2, 1993, 298, 2818, 711, 9, 83, 543, 2818, 11815, 9, 83, 4113, 298, 1993, 298, 509, 314, 922, 2818, 751, 9, 83, 737, 1844, 2818, 719, 9, 83, 4765, 1993, 791, 711, 356, 2630, 63, 711, 12, 2432, 283, 11815, 356, 20088, 63, 11815, 12, 2432, 283, 751, 356, 2630, 63, 751, 12, 2432, 283, 719, 356, 2630, 63, 719, 12, 2432, 283, 19963, 63, 344, 356, 10821, 63, 86, 9430, 1552, 953, 340, 20088, 63, 11815, 14, 2325, 342, 315, 334, 3003, 63, 2619, 63, 5559, 14, 2856, 12, 3147, 10821, 63, 2619, 63, 5559, 14, 14921, 304, 355, 1890, 275, 492, 1208, 14, 646, 63, 785, 8, 490, 298, 12372, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 2122, 490, 298, 66, 1195, 68, 63, 1014, 63, 3003, 63, 2619, 63, 1258, 14, 34, 1195, 68, 2856, 4161, 11860, 3041, 401, 490, 20617, 29, 4991, 63, 711, 12, 490, 3434, 29, 4991, 63, 751, 12, 490, 2505, 29, 4991, 63, 14258, 12, 490, 1844, 29, 4991, 63, 719, 12, 490, 373, 9430, 29, 3003, 63, 86, 9430, 12, 490, 4113, 29, 9264, 63, 11815, 355, 776, 288, 587, 26, 355, 1890, 275, 492, 1208, 14, 646, 63, 785, 8, 490, 298, 12372, 14, 2619, 2609, 14, 13337, 14, 20670, 9490, 2122, 490, 298, 66, 1195, 68, 63, 3003, 63, 2619, 63, 1258, 63, 2764, 14, 34, 1195, 68, 4161, 11860, 3041, 7802, 401, 490, 20617, 29, 4991, 63, 711, 12, 490, 3434, 29, 4991, 63, 751, 12, 490, 2505, 29, 4991, 63, 14258, 12, 490, 790, 29, 4991, 63, 5510, 63, 4736, 63, 515, 12, 490, 1844, 29, 4991, 63, 719, 355, 776, 288, 291, 14, 9264, 63, 1631, 63, 1130, 14, 873, 2561, 4991, 63, 711, 26, 1890, 1552, 267, 372, 1890, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ProfessionalIT/professionalit-webiste
sdk/google_appengine/lib/django-1.2/django/core/files/uploadhandler.py
236
7028
""" Base file upload handler classes, and the built-in concrete subclasses """ try: from cStringIO import StringIO except ImportError: from StringIO import StringIO from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.uploadedfile import TemporaryUploadedFile, InMemoryUploadedFile from django.utils import importlib __all__ = ['UploadFileException','StopUpload', 'SkipFile', 'FileUploadHandler', 'TemporaryFileUploadHandler', 'MemoryFileUploadHandler', 'load_handler', 'StopFutureHandlers'] class UploadFileException(Exception): """ Any error having to do with uploading files. """ pass class StopUpload(UploadFileException): """ This exception is raised when an upload must abort. """ def __init__(self, connection_reset=False): """ If ``connection_reset`` is ``True``, Django knows will halt the upload without consuming the rest of the upload. This will cause the browser to show a "connection reset" error. """ self.connection_reset = connection_reset def __unicode__(self): if self.connection_reset: return u'StopUpload: Halt current upload.' else: return u'StopUpload: Consume request data, then halt.' class SkipFile(UploadFileException): """ This exception is raised by an upload handler that wants to skip a given file. """ pass class StopFutureHandlers(UploadFileException): """ Upload handers that have handled a file and do not want future handlers to run should raise this exception instead of returning None. """ pass class FileUploadHandler(object): """ Base class for streaming upload handlers. """ chunk_size = 64 * 2 ** 10 #: The default chunk size is 64 KB. def __init__(self, request=None): self.file_name = None self.content_type = None self.content_length = None self.charset = None self.request = request def handle_raw_input(self, input_data, META, content_length, boundary, encoding=None): """ Handle the raw input from the client. Parameters: :input_data: An object that supports reading via .read(). :META: ``request.META``. :content_length: The (integer) value of the Content-Length header from the client. :boundary: The boundary from the Content-Type header. Be sure to prepend two '--'. """ pass def new_file(self, field_name, file_name, content_type, content_length, charset=None): """ Signal that a new file has been started. Warning: As with any data from the client, you should not trust content_length (and sometimes won't even get it). """ self.field_name = field_name self.file_name = file_name self.content_type = content_type self.content_length = content_length self.charset = charset def receive_data_chunk(self, raw_data, start): """ Receive data from the streamed upload parser. ``start`` is the position in the file of the chunk. """ raise NotImplementedError() def file_complete(self, file_size): """ Signal that a file has completed. File size corresponds to the actual size accumulated by all the chunks. Subclasses should return a valid ``UploadedFile`` object. """ raise NotImplementedError() def upload_complete(self): """ Signal that the upload is complete. Subclasses should perform cleanup that is necessary for this handler. """ pass class TemporaryFileUploadHandler(FileUploadHandler): """ Upload handler that streams data into a temporary file. """ def __init__(self, *args, **kwargs): super(TemporaryFileUploadHandler, self).__init__(*args, **kwargs) def new_file(self, file_name, *args, **kwargs): """ Create the file object to append to as data is coming in. """ super(TemporaryFileUploadHandler, self).new_file(file_name, *args, **kwargs) self.file = TemporaryUploadedFile(self.file_name, self.content_type, 0, self.charset) def receive_data_chunk(self, raw_data, start): self.file.write(raw_data) def file_complete(self, file_size): self.file.seek(0) self.file.size = file_size return self.file class MemoryFileUploadHandler(FileUploadHandler): """ File upload handler to stream uploads into memory (used for small files). """ def handle_raw_input(self, input_data, META, content_length, boundary, encoding=None): """ Use the content_length to signal whether or not this handler should be in use. """ # Check the content-length header to see if we should # If the post is too large, we cannot use the Memory handler. if content_length > settings.FILE_UPLOAD_MAX_MEMORY_SIZE: self.activated = False else: self.activated = True def new_file(self, *args, **kwargs): super(MemoryFileUploadHandler, self).new_file(*args, **kwargs) if self.activated: self.file = StringIO() raise StopFutureHandlers() def receive_data_chunk(self, raw_data, start): """ Add the data to the StringIO file. """ if self.activated: self.file.write(raw_data) else: return raw_data def file_complete(self, file_size): """ Return a file object if we're activated. """ if not self.activated: return self.file.seek(0) return InMemoryUploadedFile( file = self.file, field_name = self.field_name, name = self.file_name, content_type = self.content_type, size = file_size, charset = self.charset ) def load_handler(path, *args, **kwargs): """ Given a path to a handler, return an instance of that handler. E.g.:: >>> load_handler('django.core.files.uploadhandler.TemporaryFileUploadHandler', request) <TemporaryFileUploadHandler object at 0x...> """ i = path.rfind('.') module, attr = path[:i], path[i+1:] try: mod = importlib.import_module(module) except ImportError, e: raise ImproperlyConfigured('Error importing upload handler module %s: "%s"' % (module, e)) except ValueError, e: raise ImproperlyConfigured('Error importing upload handler module. Is FILE_UPLOAD_HANDLERS a correctly defined list or tuple?') try: cls = getattr(mod, attr) except AttributeError: raise ImproperlyConfigured('Module "%s" does not define a "%s" upload handler backend' % (module, attr)) return cls(*args, **kwargs)
lgpl-3.0
[ 624, 199, 1563, 570, 5802, 3016, 3992, 12, 436, 314, 6137, 13, 262, 13801, 9180, 199, 624, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 21791, 24665, 12, 1010, 8628, 24665, 199, 504, 1639, 14, 1208, 492, 14802, 199, 199, 363, 452, 363, 275, 788, 10301, 1173, 1726, 1673, 6293, 10301, 297, 283, 7738, 1173, 297, 283, 1173, 10301, 2461, 297, 1779, 283, 13271, 10301, 2461, 297, 283, 8628, 1173, 10301, 2461, 297, 1779, 283, 912, 63, 2232, 297, 283, 6293, 14224, 25096, 418, 199, 199, 533, 19149, 1173, 1726, 8, 1726, 304, 272, 408, 272, 6184, 1125, 9445, 370, 886, 543, 24349, 1584, 14, 272, 408, 272, 986, 199, 199, 533, 8015, 10301, 8, 10301, 1173, 1726, 304, 272, 408, 272, 961, 1919, 365, 4915, 1380, 376, 5802, 1471, 12004, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1950, 63, 3958, 29, 797, 304, 267, 408, 267, 982, 1124, 2105, 63, 3958, 1040, 365, 1124, 549, 4542, 5634, 19428, 911, 394, 4478, 314, 5802, 267, 1928, 406, 26745, 314, 4618, 402, 314, 5802, 14, 961, 911, 7675, 314, 7042, 370, 267, 2498, 282, 298, 2105, 5305, 2, 1125, 14, 267, 408, 267, 291, 14, 2105, 63, 3958, 275, 1950, 63, 3958, 339, 347, 636, 2975, 721, 277, 304, 267, 340, 291, 14, 2105, 63, 3958, 26, 288, 372, 399, 7, 6293, 10301, 26, 869, 4478, 1453, 5802, 3530, 267, 587, 26, 288, 372, 399, 7, 6293, 10301, 26, 1448, 3639, 1056, 666, 12, 2066, 394, 4478, 3530, 199, 199, 533, 8232, 1173, 8, 10301, 1173, 1726, 304, 272, 408, 272, 961, 1919, 365, 4915, 701, 376, 5802, 3016, 626, 15061, 370, 3372, 282, 1627, 570, 14, 272, 408, 272, 986, 199, 199, 533, 8015, 14224, 25096, 8, 10301, 1173, 1726, 304, 272, 408, 272, 19149, 394, 290, 7735, 626, 1172, 8860, 282, 570, 436, 886, 440, 2934, 6466, 8297, 370, 272, 1255, 1077, 746, 642, 1919, 3140, 402, 8152, 488, 14, 272, 408, 272, 986, 199, 199, 533, 3814, 10301, 2461, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 18490, 5802, 8297, 14, 272, 408, 272, 3728, 63, 890, 275, 5049, 627, 499, 1011, 1616, 6079, 710, 849, 3728, 1568, 365, 5049, 27638, 14, 339, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 304, 267, 291, 14, 493, 63, 354, 275, 488, 267, 291, 14, 1317, 63, 466, 275, 488, 267, 291, 14, 1317, 63, 1267, 275, 488, 267, 291, 14, 6043, 275, 488, 267, 291, 14, 1069, 275, 1056, 339, 347, 2429, 63, 1773, 63, 1210, 8, 277, 12, 1324, 63, 576, 12, 603, 15808, 12, 1564, 63, 1267, 12, 8424, 12, 2644, 29, 403, 304, 267, 408, 267, 8690, 314, 3066, 1324, 687, 314, 1890, 14, 398, 3897, 26, 953, 520, 1210, 63, 576, 26, 355, 1626, 909, 626, 5171, 7664, 4799, 1275, 739, 1252, 288, 520, 10614, 26, 355, 1124, 1069, 14, 10614, 4345, 288, 520, 1317, 63, 1267, 26, 355, 710, 334, 4115, 9, 574, 402, 314, 6646, 13, 4625, 1406, 687, 314, 355, 1890, 14, 288, 520, 9891, 26, 710, 8424, 687, 314, 6646, 13, 804, 1406, 14, 6423, 3238, 370, 355, 18213, 2877, 2850, 1370, 267, 408, 267, 986, 339, 347, 892, 63, 493, 8, 277, 12, 901, 63, 354, 12, 570, 63, 354, 12, 1564, 63, 466, 12, 1564, 63, 1267, 12, 5960, 29, 403, 304, 267, 408, 267, 18288, 626, 282, 892, 570, 965, 2757, 8239, 14, 398, 15902, 26, 3709, 543, 1263, 666, 687, 314, 1890, 12, 1265, 1077, 440, 16822, 267, 1564, 63, 1267, 334, 460, 15026, 7859, 1133, 2755, 664, 652, 680, 267, 408, 267, 291, 14, 698, 63, 354, 275, 901, 63, 354, 267, 291, 14, 493, 63, 354, 275, 570, 63, 354, 267, 291, 14, 1317, 63, 466, 275, 1564, 63, 466, 267, 291, 14, 1317, 63, 1267, 275, 1564, 63, 1267, 267, 291, 14, 6043, 275, 5960, 339, 347, 9128, 63, 576, 63, 4604, 8, 277, 12, 3066, 63, 576, 12, 1343, 304, 267, 408, 267, 799, 5251, 666, 687, 314, 410, 19308, 68, 5802, 1798, 14, 1124, 928, 1040, 365, 314, 3421, 267, 315, 314, 570, 402, 314, 3728, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 570, 63, 4883, 8, 277, 12, 570, 63, 890, 304, 267, 408, 267, 18288, 626, 282, 570, 965, 9709, 14, 3814, 1568, 13718, 370, 314, 3503, 267, 1568, 29845, 701, 1006, 314, 8291, 14, 398, 20196, 1077, 372, 282, 1686, 1124, 24665, 1040, 909, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 5802, 63, 4883, 8, 277, 304, 267, 408, 267, 18288, 626, 314, 5802, 365, 4890, 14, 20196, 1077, 5147, 9058, 267, 626, 365, 5784, 367, 642, 3016, 14, 267, 408, 267, 986, 199, 199, 533, 21791, 1173, 10301, 2461, 8, 1173, 10301, 2461, 304, 272, 408, 272, 19149, 3016, 626, 13788, 666, 1901, 282, 7937, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 13271, 10301, 2461, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 892, 63, 493, 8, 277, 12, 570, 63, 354, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 2790, 314, 570, 909, 370, 5666, 370, 465, 666, 365, 17262, 315, 14, 267, 408, 267, 1613, 8, 13271, 10301, 2461, 12, 291, 680, 1222, 63, 493, 8, 493, 63, 354, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 493, 275, 21791, 24665, 8, 277, 14, 493, 63, 354, 12, 291, 14, 1317, 63, 466, 12, 378, 12, 291, 14, 6043, 9, 339, 347, 9128, 63, 576, 63, 4604, 8, 277, 12, 3066, 63, 576, 12, 1343, 304, 267, 291, 14, 493, 14, 952, 8, 1773, 63, 576, 9, 339, 347, 570, 63, 4883, 8, 277, 12, 570, 63, 890, 304, 267, 291, 14, 493, 14, 5507, 8, 16, 9, 267, 291, 14, 493, 14, 890, 275, 570, 63, 890, 267, 372, 291, 14 ]
[ 199, 1563, 570, 5802, 3016, 3992, 12, 436, 314, 6137, 13, 262, 13801, 9180, 199, 624, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 21791, 24665, 12, 1010, 8628, 24665, 199, 504, 1639, 14, 1208, 492, 14802, 199, 199, 363, 452, 363, 275, 788, 10301, 1173, 1726, 1673, 6293, 10301, 297, 283, 7738, 1173, 297, 283, 1173, 10301, 2461, 297, 1779, 283, 13271, 10301, 2461, 297, 283, 8628, 1173, 10301, 2461, 297, 1779, 283, 912, 63, 2232, 297, 283, 6293, 14224, 25096, 418, 199, 199, 533, 19149, 1173, 1726, 8, 1726, 304, 272, 408, 272, 6184, 1125, 9445, 370, 886, 543, 24349, 1584, 14, 272, 408, 272, 986, 199, 199, 533, 8015, 10301, 8, 10301, 1173, 1726, 304, 272, 408, 272, 961, 1919, 365, 4915, 1380, 376, 5802, 1471, 12004, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1950, 63, 3958, 29, 797, 304, 267, 408, 267, 982, 1124, 2105, 63, 3958, 1040, 365, 1124, 549, 4542, 5634, 19428, 911, 394, 4478, 314, 5802, 267, 1928, 406, 26745, 314, 4618, 402, 314, 5802, 14, 961, 911, 7675, 314, 7042, 370, 267, 2498, 282, 298, 2105, 5305, 2, 1125, 14, 267, 408, 267, 291, 14, 2105, 63, 3958, 275, 1950, 63, 3958, 339, 347, 636, 2975, 721, 277, 304, 267, 340, 291, 14, 2105, 63, 3958, 26, 288, 372, 399, 7, 6293, 10301, 26, 869, 4478, 1453, 5802, 3530, 267, 587, 26, 288, 372, 399, 7, 6293, 10301, 26, 1448, 3639, 1056, 666, 12, 2066, 394, 4478, 3530, 199, 199, 533, 8232, 1173, 8, 10301, 1173, 1726, 304, 272, 408, 272, 961, 1919, 365, 4915, 701, 376, 5802, 3016, 626, 15061, 370, 3372, 282, 1627, 570, 14, 272, 408, 272, 986, 199, 199, 533, 8015, 14224, 25096, 8, 10301, 1173, 1726, 304, 272, 408, 272, 19149, 394, 290, 7735, 626, 1172, 8860, 282, 570, 436, 886, 440, 2934, 6466, 8297, 370, 272, 1255, 1077, 746, 642, 1919, 3140, 402, 8152, 488, 14, 272, 408, 272, 986, 199, 199, 533, 3814, 10301, 2461, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 18490, 5802, 8297, 14, 272, 408, 272, 3728, 63, 890, 275, 5049, 627, 499, 1011, 1616, 6079, 710, 849, 3728, 1568, 365, 5049, 27638, 14, 339, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 304, 267, 291, 14, 493, 63, 354, 275, 488, 267, 291, 14, 1317, 63, 466, 275, 488, 267, 291, 14, 1317, 63, 1267, 275, 488, 267, 291, 14, 6043, 275, 488, 267, 291, 14, 1069, 275, 1056, 339, 347, 2429, 63, 1773, 63, 1210, 8, 277, 12, 1324, 63, 576, 12, 603, 15808, 12, 1564, 63, 1267, 12, 8424, 12, 2644, 29, 403, 304, 267, 408, 267, 8690, 314, 3066, 1324, 687, 314, 1890, 14, 398, 3897, 26, 953, 520, 1210, 63, 576, 26, 355, 1626, 909, 626, 5171, 7664, 4799, 1275, 739, 1252, 288, 520, 10614, 26, 355, 1124, 1069, 14, 10614, 4345, 288, 520, 1317, 63, 1267, 26, 355, 710, 334, 4115, 9, 574, 402, 314, 6646, 13, 4625, 1406, 687, 314, 355, 1890, 14, 288, 520, 9891, 26, 710, 8424, 687, 314, 6646, 13, 804, 1406, 14, 6423, 3238, 370, 355, 18213, 2877, 2850, 1370, 267, 408, 267, 986, 339, 347, 892, 63, 493, 8, 277, 12, 901, 63, 354, 12, 570, 63, 354, 12, 1564, 63, 466, 12, 1564, 63, 1267, 12, 5960, 29, 403, 304, 267, 408, 267, 18288, 626, 282, 892, 570, 965, 2757, 8239, 14, 398, 15902, 26, 3709, 543, 1263, 666, 687, 314, 1890, 12, 1265, 1077, 440, 16822, 267, 1564, 63, 1267, 334, 460, 15026, 7859, 1133, 2755, 664, 652, 680, 267, 408, 267, 291, 14, 698, 63, 354, 275, 901, 63, 354, 267, 291, 14, 493, 63, 354, 275, 570, 63, 354, 267, 291, 14, 1317, 63, 466, 275, 1564, 63, 466, 267, 291, 14, 1317, 63, 1267, 275, 1564, 63, 1267, 267, 291, 14, 6043, 275, 5960, 339, 347, 9128, 63, 576, 63, 4604, 8, 277, 12, 3066, 63, 576, 12, 1343, 304, 267, 408, 267, 799, 5251, 666, 687, 314, 410, 19308, 68, 5802, 1798, 14, 1124, 928, 1040, 365, 314, 3421, 267, 315, 314, 570, 402, 314, 3728, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 570, 63, 4883, 8, 277, 12, 570, 63, 890, 304, 267, 408, 267, 18288, 626, 282, 570, 965, 9709, 14, 3814, 1568, 13718, 370, 314, 3503, 267, 1568, 29845, 701, 1006, 314, 8291, 14, 398, 20196, 1077, 372, 282, 1686, 1124, 24665, 1040, 909, 14, 267, 408, 267, 746, 4279, 342, 339, 347, 5802, 63, 4883, 8, 277, 304, 267, 408, 267, 18288, 626, 314, 5802, 365, 4890, 14, 20196, 1077, 5147, 9058, 267, 626, 365, 5784, 367, 642, 3016, 14, 267, 408, 267, 986, 199, 199, 533, 21791, 1173, 10301, 2461, 8, 1173, 10301, 2461, 304, 272, 408, 272, 19149, 3016, 626, 13788, 666, 1901, 282, 7937, 570, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 13271, 10301, 2461, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 892, 63, 493, 8, 277, 12, 570, 63, 354, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 2790, 314, 570, 909, 370, 5666, 370, 465, 666, 365, 17262, 315, 14, 267, 408, 267, 1613, 8, 13271, 10301, 2461, 12, 291, 680, 1222, 63, 493, 8, 493, 63, 354, 12, 627, 589, 12, 1011, 958, 9, 267, 291, 14, 493, 275, 21791, 24665, 8, 277, 14, 493, 63, 354, 12, 291, 14, 1317, 63, 466, 12, 378, 12, 291, 14, 6043, 9, 339, 347, 9128, 63, 576, 63, 4604, 8, 277, 12, 3066, 63, 576, 12, 1343, 304, 267, 291, 14, 493, 14, 952, 8, 1773, 63, 576, 9, 339, 347, 570, 63, 4883, 8, 277, 12, 570, 63, 890, 304, 267, 291, 14, 493, 14, 5507, 8, 16, 9, 267, 291, 14, 493,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
georgemarshall/django
tests/db_functions/math/test_cos.py
57
2271
import math from decimal import Decimal from django.db.models import DecimalField from django.db.models.functions import Cos from django.test import TestCase from django.test.utils import register_lookup from ..models import DecimalModel, FloatModel, IntegerModel class CosTests(TestCase): def test_null(self): IntegerModel.objects.create() obj = IntegerModel.objects.annotate(null_cos=Cos('normal')).first() self.assertIsNone(obj.null_cos) def test_decimal(self): DecimalModel.objects.create(n1=Decimal('-12.9'), n2=Decimal('0.6')) obj = DecimalModel.objects.annotate(n1_cos=Cos('n1'), n2_cos=Cos('n2')).first() self.assertIsInstance(obj.n1_cos, Decimal) self.assertIsInstance(obj.n2_cos, Decimal) self.assertAlmostEqual(obj.n1_cos, Decimal(math.cos(obj.n1))) self.assertAlmostEqual(obj.n2_cos, Decimal(math.cos(obj.n2))) def test_float(self): FloatModel.objects.create(f1=-27.5, f2=0.33) obj = FloatModel.objects.annotate(f1_cos=Cos('f1'), f2_cos=Cos('f2')).first() self.assertIsInstance(obj.f1_cos, float) self.assertIsInstance(obj.f2_cos, float) self.assertAlmostEqual(obj.f1_cos, math.cos(obj.f1)) self.assertAlmostEqual(obj.f2_cos, math.cos(obj.f2)) def test_integer(self): IntegerModel.objects.create(small=-20, normal=15, big=-1) obj = IntegerModel.objects.annotate( small_cos=Cos('small'), normal_cos=Cos('normal'), big_cos=Cos('big'), ).first() self.assertIsInstance(obj.small_cos, float) self.assertIsInstance(obj.normal_cos, float) self.assertIsInstance(obj.big_cos, float) self.assertAlmostEqual(obj.small_cos, math.cos(obj.small)) self.assertAlmostEqual(obj.normal_cos, math.cos(obj.normal)) self.assertAlmostEqual(obj.big_cos, math.cos(obj.big)) def test_transform(self): with register_lookup(DecimalField, Cos): DecimalModel.objects.create(n1=Decimal('-8.0'), n2=Decimal('0')) DecimalModel.objects.create(n1=Decimal('3.14'), n2=Decimal('0')) obj = DecimalModel.objects.filter(n1__cos__gt=-0.2).get() self.assertEqual(obj.n1, Decimal('-8.0'))
bsd-3-clause
[ 646, 3473, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 14, 697, 14, 992, 492, 6345, 792, 199, 504, 1639, 14, 697, 14, 992, 14, 5777, 492, 445, 736, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 2274, 63, 3892, 199, 199, 504, 2508, 992, 492, 6345, 1685, 12, 11140, 1685, 12, 7225, 1685, 421, 199, 533, 445, 736, 2925, 8, 1746, 304, 339, 347, 511, 63, 2307, 8, 277, 304, 267, 7225, 1685, 14, 1462, 14, 981, 342, 267, 1559, 275, 7225, 1685, 14, 1462, 14, 10898, 8, 2307, 63, 5197, 29, 26253, 360, 3302, 11103, 2246, 342, 267, 291, 14, 7702, 8, 1113, 14, 2307, 63, 5197, 9, 339, 347, 511, 63, 6355, 8, 277, 304, 267, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 3654, 713, 14, 25, 659, 302, 18, 29, 6745, 360, 16, 14, 22, 1333, 267, 1559, 275, 6345, 1685, 14, 1462, 14, 10898, 8, 78, 17, 63, 5197, 29, 26253, 360, 78, 17, 659, 302, 18, 63, 5197, 29, 26253, 360, 78, 18, 11103, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 78, 17, 63, 5197, 12, 6345, 9, 267, 291, 14, 6926, 8, 1113, 14, 78, 18, 63, 5197, 12, 6345, 9, 267, 291, 14, 7904, 8, 1113, 14, 78, 17, 63, 5197, 12, 6345, 8, 3442, 14, 5197, 8, 1113, 14, 78, 17, 1724, 267, 291, 14, 7904, 8, 1113, 14, 78, 18, 63, 5197, 12, 6345, 8, 3442, 14, 5197, 8, 1113, 14, 78, 18, 1724, 339, 347, 511, 63, 1609, 8, 277, 304, 267, 11140, 1685, 14, 1462, 14, 981, 8, 70, 17, 4022, 1465, 14, 21, 12, 289, 18, 29, 16, 14, 1153, 9, 267, 1559, 275, 11140, 1685, 14, 1462, 14, 10898, 8, 70, 17, 63, 5197, 29, 26253, 360, 70, 17, 659, 289, 18, 63, 5197, 29, 26253, 360, 70, 18, 11103, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 70, 17, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 70, 18, 63, 5197, 12, 2069, 9, 267, 291, 14, 7904, 8, 1113, 14, 70, 17, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 70, 17, 430, 267, 291, 14, 7904, 8, 1113, 14, 70, 18, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 70, 18, 430, 339, 347, 511, 63, 4115, 8, 277, 304, 267, 7225, 1685, 14, 1462, 14, 981, 8, 7241, 4022, 1165, 12, 3293, 29, 1046, 12, 7282, 4022, 17, 9, 267, 1559, 275, 7225, 1685, 14, 1462, 14, 10898, 8, 288, 7425, 63, 5197, 29, 26253, 360, 7241, 659, 288, 3293, 63, 5197, 29, 26253, 360, 3302, 659, 288, 7282, 63, 5197, 29, 26253, 360, 5076, 659, 267, 7092, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 7241, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 3302, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 5076, 63, 5197, 12, 2069, 9, 267, 291, 14, 7904, 8, 1113, 14, 7241, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 7241, 430, 267, 291, 14, 7904, 8, 1113, 14, 3302, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 3302, 430, 267, 291, 14, 7904, 8, 1113, 14, 5076, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 5076, 430, 339, 347, 511, 63, 4711, 8, 277, 304, 267, 543, 2274, 63, 3892, 8, 15975, 12, 445, 736, 304, 288, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 3654, 24, 14, 16, 659, 302, 18, 29, 6745, 360, 16, 1333, 288, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 360, 19, 14, 1079, 659, 302, 18, 29, 6745, 360, 16, 1333, 288, 1559, 275, 6345, 1685, 14, 1462, 14, 1541, 8, 78, 17, 363, 5197, 363, 3308, 4022, 16, 14, 18, 680, 362, 342, 288, 291, 14, 629, 8, 1113, 14, 78, 17, 12, 6345, 3654, 24, 14, 16, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3473, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 14, 697, 14, 992, 492, 6345, 792, 199, 504, 1639, 14, 697, 14, 992, 14, 5777, 492, 445, 736, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 2274, 63, 3892, 199, 199, 504, 2508, 992, 492, 6345, 1685, 12, 11140, 1685, 12, 7225, 1685, 421, 199, 533, 445, 736, 2925, 8, 1746, 304, 339, 347, 511, 63, 2307, 8, 277, 304, 267, 7225, 1685, 14, 1462, 14, 981, 342, 267, 1559, 275, 7225, 1685, 14, 1462, 14, 10898, 8, 2307, 63, 5197, 29, 26253, 360, 3302, 11103, 2246, 342, 267, 291, 14, 7702, 8, 1113, 14, 2307, 63, 5197, 9, 339, 347, 511, 63, 6355, 8, 277, 304, 267, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 3654, 713, 14, 25, 659, 302, 18, 29, 6745, 360, 16, 14, 22, 1333, 267, 1559, 275, 6345, 1685, 14, 1462, 14, 10898, 8, 78, 17, 63, 5197, 29, 26253, 360, 78, 17, 659, 302, 18, 63, 5197, 29, 26253, 360, 78, 18, 11103, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 78, 17, 63, 5197, 12, 6345, 9, 267, 291, 14, 6926, 8, 1113, 14, 78, 18, 63, 5197, 12, 6345, 9, 267, 291, 14, 7904, 8, 1113, 14, 78, 17, 63, 5197, 12, 6345, 8, 3442, 14, 5197, 8, 1113, 14, 78, 17, 1724, 267, 291, 14, 7904, 8, 1113, 14, 78, 18, 63, 5197, 12, 6345, 8, 3442, 14, 5197, 8, 1113, 14, 78, 18, 1724, 339, 347, 511, 63, 1609, 8, 277, 304, 267, 11140, 1685, 14, 1462, 14, 981, 8, 70, 17, 4022, 1465, 14, 21, 12, 289, 18, 29, 16, 14, 1153, 9, 267, 1559, 275, 11140, 1685, 14, 1462, 14, 10898, 8, 70, 17, 63, 5197, 29, 26253, 360, 70, 17, 659, 289, 18, 63, 5197, 29, 26253, 360, 70, 18, 11103, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 70, 17, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 70, 18, 63, 5197, 12, 2069, 9, 267, 291, 14, 7904, 8, 1113, 14, 70, 17, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 70, 17, 430, 267, 291, 14, 7904, 8, 1113, 14, 70, 18, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 70, 18, 430, 339, 347, 511, 63, 4115, 8, 277, 304, 267, 7225, 1685, 14, 1462, 14, 981, 8, 7241, 4022, 1165, 12, 3293, 29, 1046, 12, 7282, 4022, 17, 9, 267, 1559, 275, 7225, 1685, 14, 1462, 14, 10898, 8, 288, 7425, 63, 5197, 29, 26253, 360, 7241, 659, 288, 3293, 63, 5197, 29, 26253, 360, 3302, 659, 288, 7282, 63, 5197, 29, 26253, 360, 5076, 659, 267, 7092, 2246, 342, 267, 291, 14, 6926, 8, 1113, 14, 7241, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 3302, 63, 5197, 12, 2069, 9, 267, 291, 14, 6926, 8, 1113, 14, 5076, 63, 5197, 12, 2069, 9, 267, 291, 14, 7904, 8, 1113, 14, 7241, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 7241, 430, 267, 291, 14, 7904, 8, 1113, 14, 3302, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 3302, 430, 267, 291, 14, 7904, 8, 1113, 14, 5076, 63, 5197, 12, 3473, 14, 5197, 8, 1113, 14, 5076, 430, 339, 347, 511, 63, 4711, 8, 277, 304, 267, 543, 2274, 63, 3892, 8, 15975, 12, 445, 736, 304, 288, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 3654, 24, 14, 16, 659, 302, 18, 29, 6745, 360, 16, 1333, 288, 6345, 1685, 14, 1462, 14, 981, 8, 78, 17, 29, 6745, 360, 19, 14, 1079, 659, 302, 18, 29, 6745, 360, 16, 1333, 288, 1559, 275, 6345, 1685, 14, 1462, 14, 1541, 8, 78, 17, 363, 5197, 363, 3308, 4022, 16, 14, 18, 680, 362, 342, 288, 291, 14, 629, 8, 1113, 14, 78, 17, 12, 6345, 3654, 24, 14, 16, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
spirosmastorakis/ndnSIM2-refactored
bindings/modulegen__gcc_ILP32.py
46
17626
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers from pybindgen.typehandlers.smart_ptr import StdSharedPtr from ns3_ptr import Ns3PtrMemoryPolicy import pybindgen.settings import warnings import sys def module_init(): root_module = Module('ns.ndnSIM', cpp_namespace='::ns3') return root_module def register_types(module): module.add_class('ObjectBase', allow_subclassing=True, import_from_module='ns.core') module.add_class('SimpleRefCount', automatic_type_narrowing=True, import_from_module='ns.core', template_parameters=['ns3::Object', 'ns3::ObjectBase', 'ns3::ObjectDeleter'], parent=module['ns3::ObjectBase'], memory_policy=cppclass.ReferenceCountingMethodsPolicy(incref_method='Ref', decref_method='Unref', peekref_method='GetReferenceCount')) module.add_class('Object', import_from_module='ns.core', parent=module['ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >']) module.add_class('TypeId', import_from_module='ns.core') module.add_class('AttributeValue', import_from_module='ns.core') module.add_class('NodeContainer', import_from_module='ns.network') module.add_class('Node', import_from_module='ns.network', parent=module['ns3::Object']) module.add_class('ApplicationContainer', import_from_module='ns.network') def reg_ndn(module): module.add_class('StackHelper') module.add_class('FibHelper') module.add_class('StrategyChoiceHelper') module.add_class('AppHelper') module.add_class('GlobalRoutingHelper') module.add_class('L3Protocol', parent=module.get_root()['ns3::Object']) module.add_class('Name') module.add_class('Interest') module.add_class('Data') module.add_class('Face', memory_policy=StdSharedPtr('ns3::ndn::Face')) module.add_class('FaceContainer', memory_policy=Ns3PtrMemoryPolicy('::ns3::ndn::FaceContainer')) def reg_name(module): module.add_class('Component') reg_name(module.add_cpp_namespace('name')) def reg_nfd(module): module.add_class('Forwarder', memory_policy=StdSharedPtr('::ns3::ndn::nfd::Forwarder'), is_singleton=True) module.add_class('Fib') module.add_class('Pit') module.add_class('Cs') def reg_fib(module): module.add_class('Entry')#, memory_policy=StdSharedPtr('ns3::ndn::nfd::fib::Entry')) module.add_class('NextHop') module.add_class('NextHopList') reg_fib(module.add_cpp_namespace('fib')) def reg_pit(module): module.add_class('Entry')#, memory_policy=StdSharedPtr('ns3::ndn::nfd::pit::Entry')) reg_pit(module.add_cpp_namespace('pit')) def reg_cs(module): module.add_class('Entry')#, memory_policy=StdSharedPtr('ns3::ndn::nfd::cs::Entry')) reg_cs(module.add_cpp_namespace('cs')) reg_nfd(module.add_cpp_namespace('nfd')) reg_ndn(module.add_cpp_namespace('ndn')) def register_methods(root_module): reg_other_modules(root_module) def reg_stackhelper(cls): cls.add_constructor([]) cls.add_method('Install', 'ns3::Ptr<ns3::ndn::FaceContainer>', [param('ns3::Ptr<ns3::Node>', 'node')], is_const=True) cls.add_method('Install', 'ns3::Ptr<ns3::ndn::FaceContainer>', [param('std::string const&', 'nodeName')], is_const=True) cls.add_method('Install', 'ns3::Ptr<ns3::ndn::FaceContainer>', [param('const ns3::NodeContainer&', 'c')], is_const=True) cls.add_method('InstallAll', 'ns3::Ptr<ns3::ndn::FaceContainer>', [], is_const=True) cls.add_method('SetDefaultRoutes', retval('void'), [param('bool', 'isEnabled', default_value='true')], is_const=True) cls.add_method('SetStackAttributes', retval('void'), [param('const std::string&', 'attr1', default_value='""'), param('const std::string&', 'value1', default_value='""'), param('const std::string&', 'attr2', default_value='""'), param('const std::string&', 'value2', default_value='""'), param('const std::string&', 'attr3', default_value='""'), param('const std::string&', 'value3', default_value='""'), param('const std::string&', 'attr4', default_value='""'), param('const std::string&', 'value4', default_value='""')]) cls.add_method('setCsSize', retval('void'), [param('size_t', 'maxSize')]) cls.add_method('SetOldContentStore', retval('void'), [param('const std::string&', 'contentStoreClass'), param('const std::string&', 'attr1', default_value='""'), param('const std::string&', 'value1', default_value='""'), param('const std::string&', 'attr2', default_value='""'), param('const std::string&', 'value2', default_value='""'), param('const std::string&', 'attr3', default_value='""'), param('const std::string&', 'value3', default_value='""'), param('const std::string&', 'attr4', default_value='""'), param('const std::string&', 'value4', default_value='""')]) reg_stackhelper(root_module['ns3::ndn::StackHelper']) def reg_fibhelper(cls): cls.add_method('AddRoute', retval('void'), [ param('const std::string&', 'nodeName'), param('const std::string&', 'prefix'), param('uint32_t', 'faceId'), param('int32_t', 'metric'), ], is_const=True, is_static=True) cls.add_method('AddRoute', retval('void'), [ param('ns3::Ptr<ns3::Node>', 'node'), param('const ns3::ndn::Name&', 'prefix'), param('uint32_t', 'faceId'), param('int32_t', 'metric') ], is_const=True, is_static=True) cls.add_method('AddRoute', retval('void'), [ param('ns3::Ptr<ns3::Node>', 'node'), param('const ns3::ndn::Name&', 'prefix'), param('std::shared_ptr<ns3::ndn::Face>', 'face'), param('int32_t', 'metric'), ], is_const=True, is_static=True) cls.add_method('AddRoute', retval('void'), [ param('ns3::Ptr<ns3::Node>', 'node'), param('const ns3::ndn::Name&', 'prefix'), param('ns3::Ptr<ns3::Node>', 'otherNode'), param('int32_t', 'metric'), ], is_const=True, is_static=True) cls.add_method('AddRoute', retval('void'), [ param('const std::string&', 'nodeName'), param('const std::string&', 'prefix'), param('const std::string&', 'otherNodeName'), param('int32_t', 'metric'), ], is_const=True, is_static=True) reg_fibhelper(root_module['ns3::ndn::FibHelper']) def reg_strategychoicehelper(cls): cls.add_method('Install', retval('void'), [param('ns3::Ptr<ns3::Node>', 'node'), param('const const std::string&', 'name'), param('const const std::string&', 'strategy')], is_const=True, is_static=True) cls.add_method('Install', retval('void'), [param('const ns3::NodeContainer&', 'c'), param('const const std::string&', 'name'), param('const const std::string&', 'strategy')], is_const=True, is_static=True) cls.add_method('InstallAll', retval('void'), [param('const std::string&', 'name'), param('const std::string&', 'strategy')], is_const=True, is_static=True) reg_strategychoicehelper(root_module['ns3::ndn::StrategyChoiceHelper']) def reg_apphelper(cls): cls.add_constructor([param('const std::string&', 'prefix')]) cls.add_method('SetPrefix', 'void', [param('const std::string&', 'prefix')]) cls.add_method('SetAttribute', 'void', [param('std::string', 'name'), param('const ns3::AttributeValue&', 'value')]) cls.add_method('Install', 'ns3::ApplicationContainer', [param('ns3::NodeContainer', 'c')]) cls.add_method('Install', 'ns3::ApplicationContainer', [param('ns3::Ptr<ns3::Node>', 'node')]) cls.add_method('Install', 'ns3::ApplicationContainer', [param('std::string', 'nodeName')]) reg_apphelper(root_module['ns3::ndn::AppHelper']) def reg_GlobalRoutingHelper(cls): cls.add_constructor([]) cls.add_method('Install', 'void', [param('ns3::Ptr<ns3::Node>', 'node')]) cls.add_method('Install', 'void', [param('const ns3::NodeContainer&', 'nodes')]) cls.add_method('InstallAll', 'void', []) cls.add_method('AddOrigin', 'void', [param('const std::string&', 'prefix'), param('ns3::Ptr<ns3::Node>', 'node')]) cls.add_method('AddOrigin', 'void', [param('const std::string&', 'prefix'), param('const std::string&', 'nodeName')]) cls.add_method('AddOrigins', 'void', [param('const std::string&', 'prefix'), param('const ns3::NodeContainer&', 'nodes')]) cls.add_method('AddOriginsForAll', 'void', []) cls.add_method('CalculateRoutes', 'void', []) cls.add_method('CalculateAllPossibleRoutes', 'void', []) reg_GlobalRoutingHelper(root_module['ns3::ndn::GlobalRoutingHelper']) def reg_Name(root_module, cls): cls.implicitly_converts_to(root_module['ns3::ndn::Interest']) cls.add_output_stream_operator() for op in ['==', '!=', '<', '<=', '>', '>=']: cls.add_binary_comparison_operator(op) cls.add_container_traits(retval('const ns3::ndn::name::Component&'), begin_method='begin', end_method='end', iterator_type='const_iterator') cls.add_constructor([]) cls.add_constructor([param('const ns3::ndn::Name&', 'other')]) cls.add_constructor([param('const std::string&', 'url')]) cls.add_method('append', 'ns3::ndn::Name &', [param('const ns3::ndn::name::Component&', 'comp')]) cls.add_method('get', 'const ns3::ndn::name::Component&', [param('int', 'index')], is_const=True) cls.add_method('getPrefix', 'ns3::ndn::Name', [param('size_t', 'len')], is_const=True) cls.add_method('size', 'size_t', [], is_const=True) cls.add_method('toUri', retval('std::string'), [], is_const=True) reg_Name(root_module, root_module['ns3::ndn::Name']) def reg_NameComponent(cls): cls.add_output_stream_operator() for op in ['==', '!=', '<', '<=', '>', '>=']: cls.add_binary_comparison_operator(op) cls.add_constructor([param('const ns3::ndn::name::Component&', 'arg0')]) cls.add_constructor([]) cls.add_method('fromNumber', 'ns3::ndn::name::Component', [param('uint64_t', 'number')]) cls.add_method('fromNumberWithMarker', 'ns3::ndn::name::Component', [param('uint64_t', 'number'), param('unsigned char', 'marker')]) cls.add_method('fromEscapedString', 'ns3::ndn::name::Component', [param('const std::string&', 'uri')]) reg_NameComponent(root_module['ns3::ndn::name::Component']) def reg_Interest(cls): cls.add_output_stream_operator() cls.add_constructor([param('const ns3::ndn::Interest&', 'interest')]) cls.add_constructor([]) reg_Interest(root_module['ns3::ndn::Interest']) def reg_Data(cls): cls.add_output_stream_operator() cls.add_constructor([param('const ns3::ndn::Data&', 'data')]) cls.add_constructor([]) reg_Data(root_module['ns3::ndn::Data']) ######################################################################################### ## Interface to NFD ######################################################################################### def register_L3Protocol(cls): cls.add_method('getL3Protocol', 'ns3::Ptr<ns3::ndn::L3Protocol>', [param('ns3::Ptr<ns3::Object>', 'node')], is_static=True) cls.add_method('getForwarder', 'std::shared_ptr<ns3::ndn::nfd::Forwarder>', []) register_L3Protocol(root_module['ns3::ndn::L3Protocol']) def reg_Face(cls): cls.add_output_stream_operator() cls.add_method('getId', retval('int64_t'), [], is_const=True) reg_Face(root_module['ns3::ndn::Face']) def reg_NfdForwarder(cls): cls.add_method('getFib', retval('const ns3::ndn::nfd::Fib&', caller_manages_return=False), [], is_const=True) cls.add_method('getPit', retval('const ns3::ndn::nfd::Pit&', caller_manages_return=False), [], is_const=True) cls.add_method('getCs', retval('const ns3::ndn::nfd::Cs&', caller_manages_return=False), [], is_const=True) reg_NfdForwarder(root_module['ns3::ndn::nfd::Forwarder']) ############# #### FIB #### def reg_NfdFib(root_module, cls): cls.add_method('size', retval('size_t'), [], is_const=True) cls.add_container_traits(retval('const ns3::ndn::nfd::fib::Entry&', caller_manages_return=False), begin_method='begin', end_method='end', iterator_type='const_iterator') # The following is not supported # cls.add_method('findLongestPrefixMatch', retval('std::shared_ptr<ns3::ndn::nfd::fib::Entry>'), # [param('const ns3::ndn::Name&', 'prefix')], is_const=True) # cls.add_method('findExactMatch', retval('std::shared_ptr<ns3::ndn::nfd::fib::Entry>'), # [param('const ns3::ndn::Name&', 'prefix')], is_const=True) # cls.add_method('findLongestPrefixMatch', retval('shared_ptr<ns3::ndn::nfd::fib::Entry>'), # [param('const pit::Entry&', 'pitEntry')], is_const=True) # cls.add_method('findLongestPrefixMatch', retval('shared_ptr<ns3::ndn::nfd::fib::Entry>'), # [param('const measurements::Entry&', 'measurementsEntry')], is_const=True) # cls.add_method('insert', retval('std::pair<std::shared_ptr<ns3::ndn::nfd::fib::Entry>, bool>'), [param('const ns3::ndn::Name&', 'prefix')]) cls.add_method('erase', retval('void'), [param('const ns3::ndn::Name&', 'prefix')]) cls.add_method('erase', retval('void'), [param('const ns3::ndn::nfd::fib::Entry&', 'entry')]) cls.add_method('removeNextHopFromAllEntries', retval('void'), [param('std::shared_ptr<ns3::ndn::Face>', 'face')]) def reg_Entry(cls): cls.add_method('getPrefix', 'const ns3::ndn::Name&', [], is_const=True) cls.add_method('getNextHops', retval('const ns3::ndn::nfd::fib::NextHopList&', caller_manages_return=False), [], is_const=True) cls.add_method('hasNextHops', 'bool', [], is_const=True) reg_Entry(root_module['ns3::ndn::nfd::fib::Entry']) def reg_NextHop(cls): cls.add_constructor([param('std::shared_ptr<ns3::ndn::Face>', 'face')]) cls.add_method('getFace', 'std::shared_ptr<ns3::ndn::Face>', [], is_const=True) cls.add_method('setCost', 'void', [param('uint64_t', 'cost')]) cls.add_method('getCost', 'uint64_t', [], is_const=True) reg_NextHop(root_module['ns3::ndn::nfd::fib::NextHop']) def reg_NextHopList(cls): cls.add_method('size', retval('size_t'), [], is_const=True) cls.add_container_traits(retval('const ns3::ndn::nfd::fib::NextHop&', caller_manages_return=False), begin_method='begin', end_method='end', iterator_type='const_iterator') reg_NextHopList(root_module['ns3::ndn::nfd::fib::NextHopList']) reg_NfdFib(root_module, root_module['ns3::ndn::nfd::Fib']) #### FIB #### ############# ############# #### PIT #### def reg_NfdPit(root_module, cls): cls.add_method('size', retval('size_t'), [], is_const=True) cls.add_container_traits(retval('const ns3::ndn::nfd::pit::Entry&', caller_manages_return=False), begin_method='begin', end_method='end', iterator_type='const_iterator') def reg_Entry(cls): cls.add_method('getInterest', retval('const ns3::ndn::Interest&'), [], is_const=True) cls.add_method('getName', retval('const ns3::ndn::Name&'), [], is_const=True) reg_Entry(root_module['ns3::ndn::nfd::pit::Entry']) reg_NfdPit(root_module, root_module['ns3::ndn::nfd::Pit']) #### PIT #### ############# ############# #### CS #### def reg_NfdCs(root_module, cls): cls.add_method('size', retval('size_t'), [], is_const=True) cls.add_container_traits(retval('const ns3::ndn::nfd::cs::Entry&', caller_manages_return=False), begin_method='begin', end_method='end', iterator_type='const_iterator') def reg_Entry(cls): cls.add_method('getName', retval('const ns3::ndn::Name&'), [], is_const=True) reg_Entry(root_module['ns3::ndn::nfd::cs::Entry']) reg_NfdCs(root_module, root_module['ns3::ndn::nfd::Cs']) #### CS #### ############# def reg_other_modules(root_module): def reg_ApplicationContainer(cls): cls.add_constructor([]) cls.add_constructor([param('ns3::ApplicationContainer', 'container')]) reg_ApplicationContainer(root_module['ns3::ApplicationContainer']) def register_functions(root_module): return def main(): out = FileCodeSink(sys.stdout) root_module = module_init() register_types(root_module) register_methods(root_module) register_functions(root_module) root_module.generate(out) if __name__ == '__main__': main()
gpl-3.0
[ 504, 1134, 31297, 492, 5673, 12, 3814, 3034, 17111, 12, 1215, 12, 9151, 12, 7246, 533, 12, 14330, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 7853, 63, 4695, 492, 20992, 12197, 2115, 199, 199, 504, 700, 19, 63, 4695, 492, 653, 83, 19, 2115, 8628, 4845, 199, 199, 646, 1134, 31297, 14, 1751, 199, 646, 3598, 199, 199, 646, 984, 199, 199, 318, 859, 63, 826, 837, 272, 1738, 63, 578, 275, 5673, 360, 561, 14, 977, 78, 16590, 297, 7246, 63, 3251, 18749, 26, 561, 19, 358, 272, 372, 1738, 63, 578, 199, 199, 318, 2274, 63, 1313, 8, 578, 304, 272, 859, 14, 525, 63, 533, 360, 8141, 297, 2040, 63, 27904, 29, 549, 12, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 297, 2151, 1978, 63, 3214, 2968, 561, 19, 447, 1692, 297, 283, 561, 19, 447, 8141, 297, 283, 561, 19, 447, 13820, 995, 2151, 1676, 29, 578, 459, 561, 19, 447, 8141, 995, 2151, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 859, 14, 525, 63, 533, 360, 1692, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 297, 1676, 29, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 1692, 12, 700, 19, 447, 8141, 12, 700, 19, 447, 13820, 12734, 339, 859, 14, 525, 63, 533, 360, 2568, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 272, 859, 14, 525, 63, 533, 360, 4016, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 339, 859, 14, 525, 63, 533, 360, 8676, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 358, 272, 859, 14, 525, 63, 533, 360, 1716, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 297, 1676, 29, 578, 459, 561, 19, 447, 1692, 1105, 272, 859, 14, 525, 63, 533, 360, 5039, 4076, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 358, 339, 347, 1295, 63, 977, 78, 8, 578, 304, 267, 859, 14, 525, 63, 533, 360, 4851, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 38, 1892, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 16199, 9054, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 2640, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 7025, 32529, 358, 398, 859, 14, 525, 63, 533, 360, 44, 19, 3658, 297, 1676, 29, 578, 14, 362, 63, 1231, 12047, 561, 19, 447, 1692, 1105, 398, 859, 14, 525, 63, 533, 360, 985, 358, 267, 859, 14, 525, 63, 533, 360, 8309, 3911, 358, 267, 859, 14, 525, 63, 533, 360, 1451, 358, 267, 859, 14, 525, 63, 533, 360, 13414, 297, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 13414, 1333, 267, 859, 14, 525, 63, 533, 360, 13414, 4076, 297, 4402, 63, 3185, 29, 2438, 19, 2115, 8628, 4845, 29539, 561, 19, 447, 977, 78, 447, 13414, 4076, 1333, 398, 347, 1295, 63, 354, 8, 578, 304, 288, 859, 14, 525, 63, 533, 360, 7004, 358, 267, 1295, 63, 354, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 354, 1333, 398, 347, 1295, 63, 78, 2592, 8, 578, 304, 288, 859, 14, 525, 63, 533, 360, 1858, 26829, 297, 4402, 63, 3185, 29, 11976, 12197, 2115, 29539, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 1858, 26829, 659, 365, 63, 24675, 29, 549, 9, 288, 859, 14, 525, 63, 533, 360, 38, 1892, 358, 288, 859, 14, 525, 63, 533, 360, 48, 390, 358, 288, 859, 14, 525, 63, 533, 360, 13912, 358, 953, 347, 1295, 63, 329, 66, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 329, 66, 447, 3900, 1333, 355, 859, 14, 525, 63, 533, 360, 5765, 13378, 358, 355, 859, 14, 525, 63, 533, 360, 5765, 13378, 1296, 358, 288, 1295, 63, 329, 66, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 329, 66, 1333, 953, 347, 1295, 63, 80, 390, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 80, 390, 447, 3900, 1333, 288, 1295, 63, 80, 390, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 80, 390, 1333, 953, 347, 1295, 63, 1259, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 1259, 447, 3900, 1333, 288, 1295, 63, 1259, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 1259, 1333, 398, 1295, 63, 78, 2592, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 78, 2592, 1333, 272, 1295, 63, 977, 78, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 977, 78, 1333, 199, 199, 318, 2274, 63, 2474, 8, 1231, 63, 578, 304, 272, 1295, 63, 1848, 63, 3112, 8, 1231, 63, 578, 9, 339, 347, 1295, 63, 2340, 3676, 8, 1886, 304, 267, 843, 14, 525, 63, 1880, 4157, 398, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 561, 19, 447, 2115, 28, 561, 19, 447, 1716, 4206, 283, 932, 2665, 365, 63, 1297, 29, 549, 9, 267, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 1516, 447, 875, 950, 16749, 283, 13777, 2665, 365, 63, 1297, 29, 549, 9, 267, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 1297, 700, 19, 447, 8676, 16749, 283, 67 ]
[ 1134, 31297, 492, 5673, 12, 3814, 3034, 17111, 12, 1215, 12, 9151, 12, 7246, 533, 12, 14330, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 7853, 63, 4695, 492, 20992, 12197, 2115, 199, 199, 504, 700, 19, 63, 4695, 492, 653, 83, 19, 2115, 8628, 4845, 199, 199, 646, 1134, 31297, 14, 1751, 199, 646, 3598, 199, 199, 646, 984, 199, 199, 318, 859, 63, 826, 837, 272, 1738, 63, 578, 275, 5673, 360, 561, 14, 977, 78, 16590, 297, 7246, 63, 3251, 18749, 26, 561, 19, 358, 272, 372, 1738, 63, 578, 199, 199, 318, 2274, 63, 1313, 8, 578, 304, 272, 859, 14, 525, 63, 533, 360, 8141, 297, 2040, 63, 27904, 29, 549, 12, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 272, 859, 14, 525, 63, 533, 360, 4447, 297, 4834, 63, 466, 63, 18372, 29, 549, 12, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 297, 2151, 1978, 63, 3214, 2968, 561, 19, 447, 1692, 297, 283, 561, 19, 447, 8141, 297, 283, 561, 19, 447, 13820, 995, 2151, 1676, 29, 578, 459, 561, 19, 447, 8141, 995, 2151, 4402, 63, 3185, 29, 20302, 14, 20368, 8, 19417, 63, 765, 534, 2891, 297, 19949, 63, 765, 534, 20259, 297, 20375, 63, 765, 534, 20310, 1333, 272, 859, 14, 525, 63, 533, 360, 1692, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 297, 1676, 29, 578, 459, 561, 19, 447, 4447, 28, 700, 19, 447, 1692, 12, 700, 19, 447, 8141, 12, 700, 19, 447, 13820, 12734, 339, 859, 14, 525, 63, 533, 360, 2568, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 272, 859, 14, 525, 63, 533, 360, 4016, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1018, 358, 339, 859, 14, 525, 63, 533, 360, 8676, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 358, 272, 859, 14, 525, 63, 533, 360, 1716, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 297, 1676, 29, 578, 459, 561, 19, 447, 1692, 1105, 272, 859, 14, 525, 63, 533, 360, 5039, 4076, 297, 492, 63, 504, 63, 578, 534, 561, 14, 1200, 358, 339, 347, 1295, 63, 977, 78, 8, 578, 304, 267, 859, 14, 525, 63, 533, 360, 4851, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 38, 1892, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 16199, 9054, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 2640, 4433, 358, 267, 859, 14, 525, 63, 533, 360, 7025, 32529, 358, 398, 859, 14, 525, 63, 533, 360, 44, 19, 3658, 297, 1676, 29, 578, 14, 362, 63, 1231, 12047, 561, 19, 447, 1692, 1105, 398, 859, 14, 525, 63, 533, 360, 985, 358, 267, 859, 14, 525, 63, 533, 360, 8309, 3911, 358, 267, 859, 14, 525, 63, 533, 360, 1451, 358, 267, 859, 14, 525, 63, 533, 360, 13414, 297, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 13414, 1333, 267, 859, 14, 525, 63, 533, 360, 13414, 4076, 297, 4402, 63, 3185, 29, 2438, 19, 2115, 8628, 4845, 29539, 561, 19, 447, 977, 78, 447, 13414, 4076, 1333, 398, 347, 1295, 63, 354, 8, 578, 304, 288, 859, 14, 525, 63, 533, 360, 7004, 358, 267, 1295, 63, 354, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 354, 1333, 398, 347, 1295, 63, 78, 2592, 8, 578, 304, 288, 859, 14, 525, 63, 533, 360, 1858, 26829, 297, 4402, 63, 3185, 29, 11976, 12197, 2115, 29539, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 1858, 26829, 659, 365, 63, 24675, 29, 549, 9, 288, 859, 14, 525, 63, 533, 360, 38, 1892, 358, 288, 859, 14, 525, 63, 533, 360, 48, 390, 358, 288, 859, 14, 525, 63, 533, 360, 13912, 358, 953, 347, 1295, 63, 329, 66, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 329, 66, 447, 3900, 1333, 355, 859, 14, 525, 63, 533, 360, 5765, 13378, 358, 355, 859, 14, 525, 63, 533, 360, 5765, 13378, 1296, 358, 288, 1295, 63, 329, 66, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 329, 66, 1333, 953, 347, 1295, 63, 80, 390, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 80, 390, 447, 3900, 1333, 288, 1295, 63, 80, 390, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 80, 390, 1333, 953, 347, 1295, 63, 1259, 8, 578, 304, 355, 859, 14, 525, 63, 533, 360, 3900, 358, 3, 12, 4402, 63, 3185, 29, 11976, 12197, 2115, 360, 561, 19, 447, 977, 78, 447, 78, 2592, 447, 1259, 447, 3900, 1333, 288, 1295, 63, 1259, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 1259, 1333, 398, 1295, 63, 78, 2592, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 78, 2592, 1333, 272, 1295, 63, 977, 78, 8, 578, 14, 525, 63, 5910, 63, 3251, 360, 977, 78, 1333, 199, 199, 318, 2274, 63, 2474, 8, 1231, 63, 578, 304, 272, 1295, 63, 1848, 63, 3112, 8, 1231, 63, 578, 9, 339, 347, 1295, 63, 2340, 3676, 8, 1886, 304, 267, 843, 14, 525, 63, 1880, 4157, 398, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 561, 19, 447, 2115, 28, 561, 19, 447, 1716, 4206, 283, 932, 2665, 365, 63, 1297, 29, 549, 9, 267, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 1516, 447, 875, 950, 16749, 283, 13777, 2665, 365, 63, 1297, 29, 549, 9, 267, 843, 14, 525, 63, 765, 360, 8154, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 977, 78, 447, 13414, 4076, 4206, 359, 635, 360, 1297, 700, 19, 447, 8676, 16749, 283, 67, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
revanthkolli/osf.io
tests/test_metadata.py
27
1207
# -*- coding: utf-8 -*- '''Unit tests for models and their factories.''' import unittest from nose.tools import * # PEP8 asserts from framework.forms.utils import process_payload from website.project.model import MetaSchema from website.project.model import ensure_schemas from website.project.metadata.schemas import OSF_META_SCHEMAS from tests.base import OsfTestCase class TestMetaData(OsfTestCase): def test_ensure_schemas(self): # Should be zero MetaSchema records to begin with assert_equal( MetaSchema.find().count(), 0 ) ensure_schemas() assert_equal( MetaSchema.find().count(), len(OSF_META_SCHEMAS) ) def test_process(self): processed = process_payload({'foo': 'bar&baz'}) assert_equal(processed['foo'], 'bar%26baz') def test_process_list(self): processed = process_payload({'foo': ['bar', 'baz&bob']}) assert_equal(processed['foo'][1], 'baz%26bob') def test_process_whitespace(self): processed = process_payload({'foo': 'bar baz'}) assert_equal(processed['foo'], 'bar baz') if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 5072, 2295, 367, 1709, 436, 3932, 22115, 10595, 199, 646, 2882, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 13663, 24, 702, 83, 199, 199, 504, 10059, 14, 3351, 14, 1208, 492, 2112, 63, 4749, 199, 199, 504, 10691, 14, 1715, 14, 1238, 492, 6288, 6700, 199, 504, 10691, 14, 1715, 14, 1238, 492, 4868, 63, 9482, 199, 504, 10691, 14, 1715, 14, 2343, 14, 9482, 492, 4403, 38, 63, 10614, 63, 17859, 1179, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 421, 199, 533, 1379, 25285, 8, 47, 7646, 1746, 304, 339, 347, 511, 63, 7505, 63, 9482, 8, 277, 304, 398, 327, 7719, 506, 4697, 6288, 6700, 5767, 370, 5386, 543, 267, 702, 63, 1452, 8, 288, 6288, 6700, 14, 1623, 1252, 835, 1062, 288, 378, 267, 776, 398, 4868, 63, 9482, 342, 398, 702, 63, 1452, 8, 288, 6288, 6700, 14, 1623, 1252, 835, 1062, 288, 822, 8, 3100, 38, 63, 10614, 63, 17859, 1179, 9, 267, 776, 339, 347, 511, 63, 1412, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 283, 1700, 6, 6185, 3071, 267, 702, 63, 1452, 8, 7292, 459, 1421, 995, 283, 1700, 5, 1479, 6185, 358, 339, 347, 511, 63, 1412, 63, 513, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 788, 1700, 297, 283, 6185, 6, 7913, 13678, 267, 702, 63, 1452, 8, 7292, 459, 1421, 3488, 17, 467, 283, 6185, 5, 1479, 7913, 358, 339, 347, 511, 63, 1412, 63, 8506, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 283, 1700, 15507, 3071, 267, 702, 63, 1452, 8, 7292, 459, 1421, 995, 283, 1700, 15507, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 5072, 2295, 367, 1709, 436, 3932, 22115, 10595, 199, 646, 2882, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 13663, 24, 702, 83, 199, 199, 504, 10059, 14, 3351, 14, 1208, 492, 2112, 63, 4749, 199, 199, 504, 10691, 14, 1715, 14, 1238, 492, 6288, 6700, 199, 504, 10691, 14, 1715, 14, 1238, 492, 4868, 63, 9482, 199, 504, 10691, 14, 1715, 14, 2343, 14, 9482, 492, 4403, 38, 63, 10614, 63, 17859, 1179, 199, 199, 504, 2295, 14, 1095, 492, 593, 7646, 1746, 421, 199, 533, 1379, 25285, 8, 47, 7646, 1746, 304, 339, 347, 511, 63, 7505, 63, 9482, 8, 277, 304, 398, 327, 7719, 506, 4697, 6288, 6700, 5767, 370, 5386, 543, 267, 702, 63, 1452, 8, 288, 6288, 6700, 14, 1623, 1252, 835, 1062, 288, 378, 267, 776, 398, 4868, 63, 9482, 342, 398, 702, 63, 1452, 8, 288, 6288, 6700, 14, 1623, 1252, 835, 1062, 288, 822, 8, 3100, 38, 63, 10614, 63, 17859, 1179, 9, 267, 776, 339, 347, 511, 63, 1412, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 283, 1700, 6, 6185, 3071, 267, 702, 63, 1452, 8, 7292, 459, 1421, 995, 283, 1700, 5, 1479, 6185, 358, 339, 347, 511, 63, 1412, 63, 513, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 788, 1700, 297, 283, 6185, 6, 7913, 13678, 267, 702, 63, 1452, 8, 7292, 459, 1421, 3488, 17, 467, 283, 6185, 5, 1479, 7913, 358, 339, 347, 511, 63, 1412, 63, 8506, 8, 277, 304, 267, 7686, 275, 2112, 63, 4749, 3252, 1421, 356, 283, 1700, 15507, 3071, 267, 702, 63, 1452, 8, 7292, 459, 1421, 995, 283, 1700, 15507, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bugsnag/bugsnag-python
bugsnag/sessiontracker.py
1
4934
from copy import deepcopy from uuid import uuid4 from time import strftime, gmtime from threading import Lock, Timer from typing import List, Dict, Callable import atexit try: from contextvars import ContextVar _session_info = ContextVar('bugsnag-session', default={}) # type: ignore except ImportError: from bugsnag.utils import ThreadContextVar # flake8: noqa _session_info = ThreadContextVar('bugsnag-session', default={}) # type: ignore from bugsnag.utils import package_version, FilterDict, SanitizingJSONEncoder from bugsnag.event import Event __all__ = [] # type: List[str] class SessionTracker: MAXIMUM_SESSION_COUNT = 100 SESSION_PAYLOAD_VERSION = "1.0" """ Session tracking class for Bugsnag """ def __init__(self, configuration): self.session_counts = {} # type: Dict[str, int] self.config = configuration self.mutex = Lock() self.auto_sessions = False self.delivery_thread = None def start_session(self): if not self.auto_sessions and self.config.auto_capture_sessions: self.auto_sessions = True self.__start_delivery() start_time = strftime('%Y-%m-%dT%H:%M:00', gmtime()) new_session = { 'id': uuid4().hex, 'startedAt': start_time, 'events': { 'handled': 0, 'unhandled': 0 } } _session_info.set(new_session) self.__queue_session(start_time) def send_sessions(self): self.mutex.acquire() try: sessions = [] for min_time, count in self.session_counts.items(): sessions.append({ 'startedAt': min_time, 'sessionsStarted': count }) self.session_counts = {} finally: self.mutex.release() self.__deliver(sessions) def __start_delivery(self): if self.delivery_thread is None: def deliver(): self.send_sessions() self.delivery_thread = Timer(30.0, deliver) self.delivery_thread.daemon = True self.delivery_thread.start() self.delivery_thread = Timer(30.0, deliver) self.delivery_thread.daemon = True self.delivery_thread.start() def cleanup(): if self.delivery_thread is not None: self.delivery_thread.cancel() self.send_sessions() atexit.register(cleanup) def __queue_session(self, start_time: str): self.mutex.acquire() try: if start_time not in self.session_counts: self.session_counts[start_time] = 0 self.session_counts[start_time] += 1 finally: self.mutex.release() def __deliver(self, sessions: List[Dict]): if not sessions: self.config.logger.debug("No sessions to deliver") return if not self.config.api_key: self.config.logger.debug( "Not delivering due to an invalid api_key" ) return if not self.config.should_notify(): self.config.logger.debug("Not delivering due to release_stages") return notifier_version = package_version('bugsnag') or 'unknown' payload = { 'notifier': { 'name': Event.NOTIFIER_NAME, 'url': Event.NOTIFIER_URL, 'version': notifier_version }, 'device': FilterDict({ 'hostname': self.config.hostname, 'runtimeVersions': self.config.runtime_versions }), 'app': { 'releaseStage': self.config.release_stage, 'version': self.config.app_version }, 'sessionCounts': sessions } try: encoder = SanitizingJSONEncoder( self.config.logger, separators=(',', ':'), keyword_filters=self.config.params_filters ) encoded_payload = encoder.encode(payload) self.config.delivery.deliver_sessions(self.config, encoded_payload) except Exception as e: self.config.logger.exception('Sending sessions failed %s', e) class SessionMiddleware: """ Session middleware ensures that a session is appended to the event. """ def __init__(self, bugsnag: Callable[[Event], Callable]): self.bugsnag = bugsnag def __call__(self, event: Event): session = _session_info.get() if session: if event.unhandled: session['events']['unhandled'] += 1 else: session['events']['handled'] += 1 event.session = deepcopy(session) self.bugsnag(event)
mit
[ 504, 1331, 492, 14800, 199, 504, 5377, 492, 5377, 20, 199, 504, 900, 492, 14053, 12, 486, 8180, 199, 504, 5796, 492, 15536, 12, 22287, 199, 504, 14090, 492, 3820, 12, 7448, 12, 16975, 199, 646, 19840, 199, 199, 893, 26, 272, 687, 1067, 2936, 492, 9470, 5894, 272, 485, 1730, 63, 815, 275, 9470, 5894, 360, 13017, 78, 643, 13, 1730, 297, 849, 21146, 221, 327, 730, 26, 3686, 199, 2590, 3545, 26, 272, 687, 18227, 78, 643, 14, 1208, 492, 11086, 2998, 5894, 272, 327, 27510, 24, 26, 8151, 272, 485, 1730, 63, 815, 275, 11086, 2998, 5894, 360, 13017, 78, 643, 13, 1730, 297, 849, 21146, 221, 327, 730, 26, 3686, 199, 199, 504, 18227, 78, 643, 14, 1208, 492, 2559, 63, 1023, 12, 9388, 2141, 12, 428, 9385, 20135, 23069, 199, 504, 18227, 78, 643, 14, 1430, 492, 6763, 421, 199, 363, 452, 363, 275, 942, 221, 327, 730, 26, 3820, 59, 495, 61, 421, 199, 533, 8596, 13652, 26, 339, 9141, 27078, 63, 12763, 63, 8760, 275, 2948, 272, 428, 9577, 63, 24647, 63, 4612, 275, 298, 17, 14, 16, 2, 339, 408, 272, 8596, 15161, 1021, 367, 4779, 458, 78, 643, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2897, 304, 267, 291, 14, 1730, 63, 6851, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 1109, 61, 267, 291, 14, 888, 275, 2897, 267, 291, 14, 19078, 275, 15536, 342, 267, 291, 14, 2495, 63, 11676, 275, 756, 267, 291, 14, 14564, 63, 2671, 275, 488, 339, 347, 1343, 63, 1730, 8, 277, 304, 267, 340, 440, 291, 14, 2495, 63, 11676, 436, 291, 14, 888, 14, 2495, 63, 12685, 63, 11676, 26, 288, 291, 14, 2495, 63, 11676, 275, 715, 288, 291, 855, 928, 63, 14564, 342, 267, 1343, 63, 521, 275, 14053, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 26, 383, 297, 486, 8180, 1012, 267, 892, 63, 1730, 275, 469, 288, 283, 344, 356, 5377, 20, 1252, 4097, 12, 288, 283, 8924, 1271, 356, 1343, 63, 521, 12, 288, 283, 4368, 356, 469, 355, 283, 11217, 356, 378, 12, 355, 283, 23648, 356, 378, 288, 789, 267, 789, 267, 485, 1730, 63, 815, 14, 409, 8, 1222, 63, 1730, 9, 267, 291, 855, 1825, 63, 1730, 8, 928, 63, 521, 9, 339, 347, 3222, 63, 11676, 8, 277, 304, 267, 291, 14, 19078, 14, 8174, 342, 267, 862, 26, 288, 12184, 275, 942, 288, 367, 1748, 63, 521, 12, 2338, 315, 291, 14, 1730, 63, 6851, 14, 1744, 837, 355, 12184, 14, 740, 2561, 490, 283, 8924, 1271, 356, 1748, 63, 521, 12, 490, 283, 11676, 21031, 356, 2338, 355, 3828, 288, 291, 14, 1730, 63, 6851, 275, 1052, 267, 3753, 26, 288, 291, 14, 19078, 14, 3221, 342, 267, 291, 855, 31584, 8, 11676, 9, 339, 347, 636, 928, 63, 14564, 8, 277, 304, 267, 340, 291, 14, 14564, 63, 2671, 365, 488, 26, 288, 347, 28503, 837, 355, 291, 14, 2254, 63, 11676, 342, 355, 291, 14, 14564, 63, 2671, 275, 22287, 8, 1216, 14, 16, 12, 28503, 9, 355, 291, 14, 14564, 63, 2671, 14, 10824, 275, 715, 355, 291, 14, 14564, 63, 2671, 14, 928, 342, 953, 291, 14, 14564, 63, 2671, 275, 22287, 8, 1216, 14, 16, 12, 28503, 9, 288, 291, 14, 14564, 63, 2671, 14, 10824, 275, 715, 288, 291, 14, 14564, 63, 2671, 14, 928, 342, 953, 347, 9058, 837, 355, 340, 291, 14, 14564, 63, 2671, 365, 440, 488, 26, 490, 291, 14, 14564, 63, 2671, 14, 6406, 342, 355, 291, 14, 2254, 63, 11676, 342, 953, 19840, 14, 2683, 8, 7661, 9, 339, 347, 636, 1825, 63, 1730, 8, 277, 12, 1343, 63, 521, 26, 620, 304, 267, 291, 14, 19078, 14, 8174, 342, 267, 862, 26, 288, 340, 1343, 63, 521, 440, 315, 291, 14, 1730, 63, 6851, 26, 355, 291, 14, 1730, 63, 6851, 59, 928, 63, 521, 61, 275, 378, 288, 291, 14, 1730, 63, 6851, 59, 928, 63, 521, 61, 847, 413, 267, 3753, 26, 288, 291, 14, 19078, 14, 3221, 342, 339, 347, 636, 31584, 8, 277, 12, 12184, 26, 3820, 59, 2141, 4682, 267, 340, 440, 12184, 26, 288, 291, 14, 888, 14, 2921, 14, 1757, 480, 1944, 12184, 370, 28503, 531, 288, 372, 398, 340, 440, 291, 14, 888, 14, 1246, 63, 498, 26, 288, 291, 14, 888, 14, 2921, 14, 1757, 8, 355, 298, 1763, 28503, 316, 7037, 370, 376, 3866, 2986, 63, 498, 2, 288, 776, 288, 372, 398, 340, 440, 291, 14, 888, 14, 5626, 63, 6814, 837, 288, 291, 14, 888, 14, 2921, 14, 1757, 480, 1763, 28503, 316, 7037, 370, 4683, 63, 30646, 531, 288, 372, 398, 30154, 63, 1023, 275, 2559, 63, 1023, 360, 13017, 78, 643, 358, 503, 283, 5187, 7, 398, 4886, 275, 469, 288, 283, 18031, 356, 469, 355, 283, 354, 356, 6763, 14, 4609, 16910, 63, 2339, 12, 355, 283, 633, 356, 6763, 14, 4609, 16910, 63, 2632, 12, 355, 283, 1023, 356, 30154, 63, 1023, 288, 1660, 288, 283, 1782, 356, 9388, 2141, 2561, 355, 283, 4269, 356, 291, 14, 888, 14, 4269, 12, 355, 283, 7726, 21167, 356, 291, 14, 888, 14, 7726, 63, 6234, 288, 9998, 288, 283, 571, 356, 469, 355, 283, 3221, 21052, 356, 291, 14, 888, 14, 3221, 63, 8614, 12, 355, 283, 1023, 356, 291, 14, 888, 14, 571, 63, 1023, 288, 1660, 288, 283, 1730, 23209, 356, 12184, 267, 789, 398, 862, 26, 288, 10295, 275, 428, 9385, 20135, 23069, 8, 355, 291, 14, 888, 14, 2921, 12, 355, 17658, 2687, 23324, 7596, 659, 355, 4252, 63, 4273, 29, 277, 14, 888, 14, 1162, 63, 4273, 288, 776, 953, 5737, 63, 4749, 275, 10295, 14, 2143, 8, 4749, 9, 288, 291, 14, 888, 14, 14564, 14, 31584, 63, 11676, 8, 277, 14, 888, 12, 5737, 63, 4749, 9, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 888, 14, 2921, 14, 1971, 360, 27219, 12184, 3405, 450, 83, 297, 325, 9, 421, 199, 533, 8596, 6608, 26, 272, 408, 272, 8596, 10816, 15620, 626, 282, 2351, 365, 11544, 370, 314, 1566, 14, 272, 408 ]
[ 1331, 492, 14800, 199, 504, 5377, 492, 5377, 20, 199, 504, 900, 492, 14053, 12, 486, 8180, 199, 504, 5796, 492, 15536, 12, 22287, 199, 504, 14090, 492, 3820, 12, 7448, 12, 16975, 199, 646, 19840, 199, 199, 893, 26, 272, 687, 1067, 2936, 492, 9470, 5894, 272, 485, 1730, 63, 815, 275, 9470, 5894, 360, 13017, 78, 643, 13, 1730, 297, 849, 21146, 221, 327, 730, 26, 3686, 199, 2590, 3545, 26, 272, 687, 18227, 78, 643, 14, 1208, 492, 11086, 2998, 5894, 272, 327, 27510, 24, 26, 8151, 272, 485, 1730, 63, 815, 275, 11086, 2998, 5894, 360, 13017, 78, 643, 13, 1730, 297, 849, 21146, 221, 327, 730, 26, 3686, 199, 199, 504, 18227, 78, 643, 14, 1208, 492, 2559, 63, 1023, 12, 9388, 2141, 12, 428, 9385, 20135, 23069, 199, 504, 18227, 78, 643, 14, 1430, 492, 6763, 421, 199, 363, 452, 363, 275, 942, 221, 327, 730, 26, 3820, 59, 495, 61, 421, 199, 533, 8596, 13652, 26, 339, 9141, 27078, 63, 12763, 63, 8760, 275, 2948, 272, 428, 9577, 63, 24647, 63, 4612, 275, 298, 17, 14, 16, 2, 339, 408, 272, 8596, 15161, 1021, 367, 4779, 458, 78, 643, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2897, 304, 267, 291, 14, 1730, 63, 6851, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 1109, 61, 267, 291, 14, 888, 275, 2897, 267, 291, 14, 19078, 275, 15536, 342, 267, 291, 14, 2495, 63, 11676, 275, 756, 267, 291, 14, 14564, 63, 2671, 275, 488, 339, 347, 1343, 63, 1730, 8, 277, 304, 267, 340, 440, 291, 14, 2495, 63, 11676, 436, 291, 14, 888, 14, 2495, 63, 12685, 63, 11676, 26, 288, 291, 14, 2495, 63, 11676, 275, 715, 288, 291, 855, 928, 63, 14564, 342, 267, 1343, 63, 521, 275, 14053, 3508, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 26, 383, 297, 486, 8180, 1012, 267, 892, 63, 1730, 275, 469, 288, 283, 344, 356, 5377, 20, 1252, 4097, 12, 288, 283, 8924, 1271, 356, 1343, 63, 521, 12, 288, 283, 4368, 356, 469, 355, 283, 11217, 356, 378, 12, 355, 283, 23648, 356, 378, 288, 789, 267, 789, 267, 485, 1730, 63, 815, 14, 409, 8, 1222, 63, 1730, 9, 267, 291, 855, 1825, 63, 1730, 8, 928, 63, 521, 9, 339, 347, 3222, 63, 11676, 8, 277, 304, 267, 291, 14, 19078, 14, 8174, 342, 267, 862, 26, 288, 12184, 275, 942, 288, 367, 1748, 63, 521, 12, 2338, 315, 291, 14, 1730, 63, 6851, 14, 1744, 837, 355, 12184, 14, 740, 2561, 490, 283, 8924, 1271, 356, 1748, 63, 521, 12, 490, 283, 11676, 21031, 356, 2338, 355, 3828, 288, 291, 14, 1730, 63, 6851, 275, 1052, 267, 3753, 26, 288, 291, 14, 19078, 14, 3221, 342, 267, 291, 855, 31584, 8, 11676, 9, 339, 347, 636, 928, 63, 14564, 8, 277, 304, 267, 340, 291, 14, 14564, 63, 2671, 365, 488, 26, 288, 347, 28503, 837, 355, 291, 14, 2254, 63, 11676, 342, 355, 291, 14, 14564, 63, 2671, 275, 22287, 8, 1216, 14, 16, 12, 28503, 9, 355, 291, 14, 14564, 63, 2671, 14, 10824, 275, 715, 355, 291, 14, 14564, 63, 2671, 14, 928, 342, 953, 291, 14, 14564, 63, 2671, 275, 22287, 8, 1216, 14, 16, 12, 28503, 9, 288, 291, 14, 14564, 63, 2671, 14, 10824, 275, 715, 288, 291, 14, 14564, 63, 2671, 14, 928, 342, 953, 347, 9058, 837, 355, 340, 291, 14, 14564, 63, 2671, 365, 440, 488, 26, 490, 291, 14, 14564, 63, 2671, 14, 6406, 342, 355, 291, 14, 2254, 63, 11676, 342, 953, 19840, 14, 2683, 8, 7661, 9, 339, 347, 636, 1825, 63, 1730, 8, 277, 12, 1343, 63, 521, 26, 620, 304, 267, 291, 14, 19078, 14, 8174, 342, 267, 862, 26, 288, 340, 1343, 63, 521, 440, 315, 291, 14, 1730, 63, 6851, 26, 355, 291, 14, 1730, 63, 6851, 59, 928, 63, 521, 61, 275, 378, 288, 291, 14, 1730, 63, 6851, 59, 928, 63, 521, 61, 847, 413, 267, 3753, 26, 288, 291, 14, 19078, 14, 3221, 342, 339, 347, 636, 31584, 8, 277, 12, 12184, 26, 3820, 59, 2141, 4682, 267, 340, 440, 12184, 26, 288, 291, 14, 888, 14, 2921, 14, 1757, 480, 1944, 12184, 370, 28503, 531, 288, 372, 398, 340, 440, 291, 14, 888, 14, 1246, 63, 498, 26, 288, 291, 14, 888, 14, 2921, 14, 1757, 8, 355, 298, 1763, 28503, 316, 7037, 370, 376, 3866, 2986, 63, 498, 2, 288, 776, 288, 372, 398, 340, 440, 291, 14, 888, 14, 5626, 63, 6814, 837, 288, 291, 14, 888, 14, 2921, 14, 1757, 480, 1763, 28503, 316, 7037, 370, 4683, 63, 30646, 531, 288, 372, 398, 30154, 63, 1023, 275, 2559, 63, 1023, 360, 13017, 78, 643, 358, 503, 283, 5187, 7, 398, 4886, 275, 469, 288, 283, 18031, 356, 469, 355, 283, 354, 356, 6763, 14, 4609, 16910, 63, 2339, 12, 355, 283, 633, 356, 6763, 14, 4609, 16910, 63, 2632, 12, 355, 283, 1023, 356, 30154, 63, 1023, 288, 1660, 288, 283, 1782, 356, 9388, 2141, 2561, 355, 283, 4269, 356, 291, 14, 888, 14, 4269, 12, 355, 283, 7726, 21167, 356, 291, 14, 888, 14, 7726, 63, 6234, 288, 9998, 288, 283, 571, 356, 469, 355, 283, 3221, 21052, 356, 291, 14, 888, 14, 3221, 63, 8614, 12, 355, 283, 1023, 356, 291, 14, 888, 14, 571, 63, 1023, 288, 1660, 288, 283, 1730, 23209, 356, 12184, 267, 789, 398, 862, 26, 288, 10295, 275, 428, 9385, 20135, 23069, 8, 355, 291, 14, 888, 14, 2921, 12, 355, 17658, 2687, 23324, 7596, 659, 355, 4252, 63, 4273, 29, 277, 14, 888, 14, 1162, 63, 4273, 288, 776, 953, 5737, 63, 4749, 275, 10295, 14, 2143, 8, 4749, 9, 288, 291, 14, 888, 14, 14564, 14, 31584, 63, 11676, 8, 277, 14, 888, 12, 5737, 63, 4749, 9, 267, 871, 2186, 465, 325, 26, 288, 291, 14, 888, 14, 2921, 14, 1971, 360, 27219, 12184, 3405, 450, 83, 297, 325, 9, 421, 199, 533, 8596, 6608, 26, 272, 408, 272, 8596, 10816, 15620, 626, 282, 2351, 365, 11544, 370, 314, 1566, 14, 272, 408, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
masters3d/coursebuilder-masters3d
modules/dashboard/question_group_editor.py
4
8077
# Copyright 2013 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Classes supporting creation and editing of question_groups.""" __author__ = 'John Orr (jorr@google.com)' import question_editor from unit_lesson_editor import CourseOutlineRights from common import schema_fields from controllers.utils import BaseRESTHandler from controllers.utils import XsrfTokenManager from models import transforms from models.models import QuestionDAO from models.models import QuestionGroupDAO from models.models import QuestionGroupDTO class QuestionGroupManagerAndEditor(question_editor.BaseDatastoreAssetEditor): """An editor for editing and managing question_groups.""" def get_template_values(self, key): template_values = {} template_values['page_title'] = self.format_title('Edit Question Group') template_values['main_content'] = self.get_form( QuestionGroupRESTHandler, key) return template_values def get_add_question_group(self): self.render_page(self.get_template_values('')) def get_edit_question_group(self): self.render_page(self.get_template_values(self.request.get('key'))) class QuestionGroupRESTHandler(BaseRESTHandler): """REST handler for editing question_groups.""" URI = '/rest/question_group' REQUIRED_MODULES = [ 'gcb-rte', 'inputex-hidden', 'inputex-select', 'inputex-string', 'inputex-list'] EXTRA_JS_FILES = [] XSRF_TOKEN = 'question-group-edit' SCHEMA_VERSION = '1.5' @classmethod def get_schema(cls): """Return the InputEx schema for the question group editor.""" question_group = schema_fields.FieldRegistry( 'Question Group', description='question_group') question_group.add_property(schema_fields.SchemaField( 'version', '', 'string', optional=True, hidden=True)) question_group.add_property(schema_fields.SchemaField( 'description', 'Description', 'string', optional=True)) question_group.add_property(schema_fields.SchemaField( 'introduction', 'Introduction', 'html', optional=True)) item_type = schema_fields.FieldRegistry( 'Item', extra_schema_dict_values={'className': 'question-group-item'}) item_type.add_property(schema_fields.SchemaField( 'weight', 'Weight', 'string', optional=True, extra_schema_dict_values={'className': 'question-group-weight'})) question_select_data = [ (q.id, q.description) for q in QuestionDAO.get_all()] item_type.add_property(schema_fields.SchemaField( 'question', 'Question', 'string', optional=True, select_data=question_select_data, extra_schema_dict_values={'className': 'question-group-question'})) item_array = schema_fields.FieldArray( 'items', '', item_type=item_type, extra_schema_dict_values={ 'className': 'question-group-items', 'sortable': 'true', 'listAddLabel': 'Add an item', 'listRemoveLabel': 'Delete item'}) question_group.add_property(item_array) return question_group def get(self): """Respond to the REST GET verb with the contents of the group.""" key = self.request.get('key') if not CourseOutlineRights.can_view(self): transforms.send_json_response( self, 401, 'Access denied.', {'key': key}) return if key: question_group = QuestionGroupDAO.load(key) version = question_group.dict.get('version') if self.SCHEMA_VERSION != version: transforms.send_json_response( self, 403, 'Cannot edit a Version %s group.' % version, {'key': key}) return payload_dict = question_group.dict else: payload_dict = { 'version': self.SCHEMA_VERSION, 'items': [{'weight': ''}, {'weight': ''}, {'weight': ''}]} transforms.send_json_response( self, 200, 'Success', payload_dict=payload_dict, xsrf_token=XsrfTokenManager.create_xsrf_token(self.XSRF_TOKEN)) def validate(self, question_group_dict, key): """Validate the question group data sent from the form.""" errors = [] assert question_group_dict['version'] == self.SCHEMA_VERSION if not question_group_dict['description'].strip(): errors.append('The question group must have a description.') descriptions = {question_group.description for question_group in QuestionGroupDAO.get_all() if not key or question_group.id != long(key)} if question_group_dict['description'] in descriptions: errors.append('The description must be different ' 'from existing question groups.') if not question_group_dict['items']: errors.append( 'The question group must contain at least one question.') items = question_group_dict['items'] for index in range(0, len(items)): item = items[index] try: float(item['weight']) except ValueError: errors.append( 'Item %s must have a numeric weight.' % (index + 1)) return errors def put(self): """Store a question group in the datastore in response to a PUT.""" request = transforms.loads(self.request.get('request')) key = request.get('key') if not self.assert_xsrf_token_or_fail( request, self.XSRF_TOKEN, {'key': key}): return if not CourseOutlineRights.can_edit(self): transforms.send_json_response( self, 401, 'Access denied.', {'key': key}) return payload = request.get('payload') question_group_dict = transforms.json_to_dict( transforms.loads(payload), self.get_schema().get_json_schema_dict()) validation_errors = self.validate(question_group_dict, key) if validation_errors: self.validation_error('\n'.join(validation_errors), key=key) return assert self.SCHEMA_VERSION == question_group_dict.get('version') if key: question_group = QuestionGroupDTO(key, question_group_dict) else: question_group = QuestionGroupDTO(None, question_group_dict) key_after_save = QuestionGroupDAO.save(question_group) transforms.send_json_response( self, 200, 'Saved.', payload_dict={'key': key_after_save}) def delete(self): """Delete the question_group in response to REST request.""" key = self.request.get('key') if not self.assert_xsrf_token_or_fail( self.request, self.XSRF_TOKEN, {'key': key}): return if not CourseOutlineRights.can_delete(self): transforms.send_json_response( self, 401, 'Access denied.', {'key': key}) return question_group = QuestionGroupDAO.load(key) if not question_group: transforms.send_json_response( self, 404, 'Question Group not found.', {'key': key}) return QuestionGroupDAO.delete(question_group) transforms.send_json_response(self, 200, 'Deleted.')
apache-2.0
[ 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 15711, 21038, 7143, 436, 20401, 402, 7894, 63, 2634, 1041, 199, 199, 363, 2502, 363, 275, 283, 12923, 4236, 82, 334, 5857, 82, 32, 3098, 14, 957, 3171, 199, 199, 646, 7894, 63, 7515, 199, 504, 4137, 63, 2003, 265, 63, 7515, 492, 5531, 21432, 50, 2492, 199, 199, 504, 2863, 492, 4177, 63, 955, 199, 504, 27325, 14, 1208, 492, 3523, 15740, 2461, 199, 504, 27325, 14, 1208, 492, 1323, 83, 3941, 3264, 2988, 199, 504, 1709, 492, 18501, 199, 504, 1709, 14, 992, 492, 21421, 23270, 199, 504, 1709, 14, 992, 492, 21421, 2448, 23270, 199, 504, 1709, 14, 992, 492, 21421, 2448, 36, 2566, 421, 199, 533, 21421, 2448, 2988, 3325, 10423, 8, 4790, 63, 7515, 14, 1563, 30444, 19979, 10423, 304, 272, 408, 2493, 8823, 367, 20401, 436, 28453, 7894, 63, 2634, 1041, 339, 347, 664, 63, 1160, 63, 1459, 8, 277, 12, 790, 304, 267, 1978, 63, 1459, 275, 1052, 267, 1978, 63, 1459, 459, 1606, 63, 1213, 418, 275, 291, 14, 908, 63, 1213, 360, 4685, 21421, 5611, 358, 267, 1978, 63, 1459, 459, 973, 63, 1317, 418, 275, 291, 14, 362, 63, 964, 8, 288, 21421, 2448, 15740, 2461, 12, 790, 9, 398, 372, 1978, 63, 1459, 339, 347, 664, 63, 525, 63, 4790, 63, 923, 8, 277, 304, 267, 291, 14, 3352, 63, 1606, 8, 277, 14, 362, 63, 1160, 63, 1459, 30991, 339, 347, 664, 63, 3773, 63, 4790, 63, 923, 8, 277, 304, 267, 291, 14, 3352, 63, 1606, 8, 277, 14, 362, 63, 1160, 63, 1459, 8, 277, 14, 1069, 14, 362, 360, 498, 7058, 421, 199, 533, 21421, 2448, 15740, 2461, 8, 1563, 15740, 2461, 304, 272, 408, 15740, 3016, 367, 20401, 7894, 63, 2634, 1041, 339, 9022, 275, 1994, 3911, 15, 4790, 63, 923, 7, 339, 25090, 63, 21194, 275, 359, 267, 283, 71, 2894, 13, 82, 266, 297, 283, 11416, 18173, 13, 5642, 297, 283, 11416, 18173, 13, 2416, 297, 283, 11416, 18173, 13, 875, 297, 267, 283, 11416, 18173, 13, 513, 418, 272, 3651, 13954, 63, 11378, 63, 9472, 275, 942, 339, 1323, 5943, 38, 63, 8803, 275, 283, 4790, 13, 923, 13, 3773, 7, 339, 428, 10364, 63, 4612, 275, 283, 17, 14, 21, 7, 339, 768, 3744, 272, 347, 664, 63, 3629, 8, 1886, 304, 267, 408, 1767, 314, 6924, 920, 4177, 367, 314, 7894, 1572, 8823, 1041, 267, 7894, 63, 923, 275, 4177, 63, 955, 14, 792, 10899, 8, 288, 283, 16778, 5611, 297, 1369, 534, 4790, 63, 923, 358, 398, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 1023, 297, 3260, 283, 875, 297, 2716, 29, 549, 12, 8752, 29, 549, 430, 267, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 1802, 297, 283, 5831, 297, 283, 875, 297, 2716, 29, 549, 430, 267, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 18206, 5199, 297, 283, 3241, 293, 5199, 297, 283, 1360, 297, 2716, 29, 549, 430, 398, 1242, 63, 466, 275, 4177, 63, 955, 14, 792, 10899, 8, 288, 283, 2081, 297, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 1053, 3071, 267, 1242, 63, 466, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 3463, 297, 283, 16359, 297, 283, 875, 297, 2716, 29, 549, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 3463, 20219, 398, 7894, 63, 2416, 63, 576, 275, 359, 288, 334, 81, 14, 344, 12, 1894, 14, 1802, 9, 367, 1894, 315, 21421, 23270, 14, 362, 63, 452, 5106, 398, 1242, 63, 466, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 4790, 297, 283, 16778, 297, 283, 875, 297, 2716, 29, 549, 12, 288, 3504, 63, 576, 29, 4790, 63, 2416, 63, 576, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 4790, 20219, 398, 1242, 63, 1144, 275, 4177, 63, 955, 14, 792, 3836, 8, 288, 283, 1744, 297, 3260, 1242, 63, 466, 29, 1053, 63, 466, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3126, 355, 283, 533, 985, 356, 283, 4790, 13, 923, 13, 1744, 297, 355, 283, 3191, 461, 356, 283, 2052, 297, 355, 283, 513, 1123, 4314, 356, 283, 1123, 376, 1242, 297, 355, 283, 513, 5587, 4314, 356, 283, 5392, 1242, 3071, 398, 7894, 63, 923, 14, 525, 63, 1829, 8, 1053, 63, 1144, 9, 398, 372, 7894, 63, 923, 339, 347, 664, 8, 277, 304, 267, 408, 1322, 31717, 370, 314, 14880, 9576, 16041, 543, 314, 4072, 402, 314, 1572, 1041, 267, 790, 275, 291, 14, 1069, 14, 362, 360, 498, 358, 398, 340, 440, 5531, 21432, 50, 2492, 14, 2425, 63, 1345, 8, 277, 304, 288, 18501, 14, 2254, 63, 1001, 63, 1310, 8, 355, 291, 12, 13952, 12, 283, 3946, 23355, 3130, 791, 498, 356, 790, 1552, 288, 372, 398, 340, 790, 26, 288, 7894, 63, 923, 275, 21421, 2448, 23270, 14, 912, 8, 498, 9, 288, 1015, 275, 7894, 63, 923, 14, 807, 14, 362, 360, 1023 ]
[ 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 13, 1311, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 15711, 21038, 7143, 436, 20401, 402, 7894, 63, 2634, 1041, 199, 199, 363, 2502, 363, 275, 283, 12923, 4236, 82, 334, 5857, 82, 32, 3098, 14, 957, 3171, 199, 199, 646, 7894, 63, 7515, 199, 504, 4137, 63, 2003, 265, 63, 7515, 492, 5531, 21432, 50, 2492, 199, 199, 504, 2863, 492, 4177, 63, 955, 199, 504, 27325, 14, 1208, 492, 3523, 15740, 2461, 199, 504, 27325, 14, 1208, 492, 1323, 83, 3941, 3264, 2988, 199, 504, 1709, 492, 18501, 199, 504, 1709, 14, 992, 492, 21421, 23270, 199, 504, 1709, 14, 992, 492, 21421, 2448, 23270, 199, 504, 1709, 14, 992, 492, 21421, 2448, 36, 2566, 421, 199, 533, 21421, 2448, 2988, 3325, 10423, 8, 4790, 63, 7515, 14, 1563, 30444, 19979, 10423, 304, 272, 408, 2493, 8823, 367, 20401, 436, 28453, 7894, 63, 2634, 1041, 339, 347, 664, 63, 1160, 63, 1459, 8, 277, 12, 790, 304, 267, 1978, 63, 1459, 275, 1052, 267, 1978, 63, 1459, 459, 1606, 63, 1213, 418, 275, 291, 14, 908, 63, 1213, 360, 4685, 21421, 5611, 358, 267, 1978, 63, 1459, 459, 973, 63, 1317, 418, 275, 291, 14, 362, 63, 964, 8, 288, 21421, 2448, 15740, 2461, 12, 790, 9, 398, 372, 1978, 63, 1459, 339, 347, 664, 63, 525, 63, 4790, 63, 923, 8, 277, 304, 267, 291, 14, 3352, 63, 1606, 8, 277, 14, 362, 63, 1160, 63, 1459, 30991, 339, 347, 664, 63, 3773, 63, 4790, 63, 923, 8, 277, 304, 267, 291, 14, 3352, 63, 1606, 8, 277, 14, 362, 63, 1160, 63, 1459, 8, 277, 14, 1069, 14, 362, 360, 498, 7058, 421, 199, 533, 21421, 2448, 15740, 2461, 8, 1563, 15740, 2461, 304, 272, 408, 15740, 3016, 367, 20401, 7894, 63, 2634, 1041, 339, 9022, 275, 1994, 3911, 15, 4790, 63, 923, 7, 339, 25090, 63, 21194, 275, 359, 267, 283, 71, 2894, 13, 82, 266, 297, 283, 11416, 18173, 13, 5642, 297, 283, 11416, 18173, 13, 2416, 297, 283, 11416, 18173, 13, 875, 297, 267, 283, 11416, 18173, 13, 513, 418, 272, 3651, 13954, 63, 11378, 63, 9472, 275, 942, 339, 1323, 5943, 38, 63, 8803, 275, 283, 4790, 13, 923, 13, 3773, 7, 339, 428, 10364, 63, 4612, 275, 283, 17, 14, 21, 7, 339, 768, 3744, 272, 347, 664, 63, 3629, 8, 1886, 304, 267, 408, 1767, 314, 6924, 920, 4177, 367, 314, 7894, 1572, 8823, 1041, 267, 7894, 63, 923, 275, 4177, 63, 955, 14, 792, 10899, 8, 288, 283, 16778, 5611, 297, 1369, 534, 4790, 63, 923, 358, 398, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 1023, 297, 3260, 283, 875, 297, 2716, 29, 549, 12, 8752, 29, 549, 430, 267, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 1802, 297, 283, 5831, 297, 283, 875, 297, 2716, 29, 549, 430, 267, 7894, 63, 923, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 18206, 5199, 297, 283, 3241, 293, 5199, 297, 283, 1360, 297, 2716, 29, 549, 430, 398, 1242, 63, 466, 275, 4177, 63, 955, 14, 792, 10899, 8, 288, 283, 2081, 297, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 1053, 3071, 267, 1242, 63, 466, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 3463, 297, 283, 16359, 297, 283, 875, 297, 2716, 29, 549, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 3463, 20219, 398, 7894, 63, 2416, 63, 576, 275, 359, 288, 334, 81, 14, 344, 12, 1894, 14, 1802, 9, 367, 1894, 315, 21421, 23270, 14, 362, 63, 452, 5106, 398, 1242, 63, 466, 14, 525, 63, 1829, 8, 3629, 63, 955, 14, 6700, 792, 8, 288, 283, 4790, 297, 283, 16778, 297, 283, 875, 297, 2716, 29, 549, 12, 288, 3504, 63, 576, 29, 4790, 63, 2416, 63, 576, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3713, 533, 985, 356, 283, 4790, 13, 923, 13, 4790, 20219, 398, 1242, 63, 1144, 275, 4177, 63, 955, 14, 792, 3836, 8, 288, 283, 1744, 297, 3260, 1242, 63, 466, 29, 1053, 63, 466, 12, 288, 2402, 63, 3629, 63, 807, 63, 1459, 3126, 355, 283, 533, 985, 356, 283, 4790, 13, 923, 13, 1744, 297, 355, 283, 3191, 461, 356, 283, 2052, 297, 355, 283, 513, 1123, 4314, 356, 283, 1123, 376, 1242, 297, 355, 283, 513, 5587, 4314, 356, 283, 5392, 1242, 3071, 398, 7894, 63, 923, 14, 525, 63, 1829, 8, 1053, 63, 1144, 9, 398, 372, 7894, 63, 923, 339, 347, 664, 8, 277, 304, 267, 408, 1322, 31717, 370, 314, 14880, 9576, 16041, 543, 314, 4072, 402, 314, 1572, 1041, 267, 790, 275, 291, 14, 1069, 14, 362, 360, 498, 358, 398, 340, 440, 5531, 21432, 50, 2492, 14, 2425, 63, 1345, 8, 277, 304, 288, 18501, 14, 2254, 63, 1001, 63, 1310, 8, 355, 291, 12, 13952, 12, 283, 3946, 23355, 3130, 791, 498, 356, 790, 1552, 288, 372, 398, 340, 790, 26, 288, 7894, 63, 923, 275, 21421, 2448, 23270, 14, 912, 8, 498, 9, 288, 1015, 275, 7894, 63, 923, 14, 807, 14, 362, 360, 1023, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
XiaodunServerGroup/medicalmooc
common/djangoapps/util/tests/test_sandboxing.py
35
1212
""" Tests for sandboxing.py in util app """ from django.test import TestCase from util.sandboxing import can_execute_unsafe_code from django.test.utils import override_settings class SandboxingTest(TestCase): """ Test sandbox whitelisting """ @override_settings(COURSES_WITH_UNSAFE_CODE=['edX/full/.*']) def test_sandbox_exclusion(self): """ Test to make sure that a non-match returns false """ self.assertFalse(can_execute_unsafe_code('edX/notful/empty')) @override_settings(COURSES_WITH_UNSAFE_CODE=['edX/full/.*']) def test_sandbox_inclusion(self): """ Test to make sure that a match works across course runs """ self.assertTrue(can_execute_unsafe_code('edX/full/2012_Fall')) self.assertTrue(can_execute_unsafe_code('edX/full/2013_Spring')) def test_courses_with_unsafe_code_default(self): """ Test that the default setting for COURSES_WITH_UNSAFE_CODE is an empty setting, e.g. we don't use @override_settings in these tests """ self.assertFalse(can_execute_unsafe_code('edX/full/2012_Fall')) self.assertFalse(can_execute_unsafe_code('edX/full/2013_Spring'))
agpl-3.0
[ 624, 199, 2925, 367, 19699, 316, 14, 647, 315, 4884, 1145, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 4884, 14, 16647, 316, 492, 883, 63, 2526, 63, 14242, 63, 600, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 421, 199, 533, 428, 10075, 316, 774, 8, 1746, 304, 272, 408, 272, 1379, 19699, 10424, 16115, 272, 408, 272, 768, 4415, 63, 1751, 8, 1439, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 2968, 24852, 15, 2861, 15, 2795, 1105, 272, 347, 511, 63, 16647, 63, 476, 10248, 8, 277, 304, 267, 408, 267, 1379, 370, 1852, 3238, 626, 282, 2222, 13, 1431, 2529, 3055, 267, 408, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 1397, 1893, 15, 1667, 1333, 339, 768, 4415, 63, 1751, 8, 1439, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 2968, 24852, 15, 2861, 15, 2795, 1105, 272, 347, 511, 63, 16647, 63, 24265, 8, 277, 304, 267, 408, 267, 1379, 370, 1852, 3238, 626, 282, 1336, 5419, 9371, 2518, 7858, 267, 408, 267, 291, 14, 1815, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 7409, 63, 31354, 1333, 267, 291, 14, 1815, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 6965, 63, 51, 2700, 316, 1333, 339, 347, 511, 63, 11653, 63, 1045, 63, 14242, 63, 600, 63, 885, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 849, 4260, 367, 5099, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 365, 376, 2701, 4260, 12, 325, 14, 71, 14, 781, 2793, 1133, 675, 768, 4415, 63, 1751, 315, 3520, 2295, 267, 408, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 7409, 63, 31354, 1333, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 6965, 63, 51, 2700, 316, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2925, 367, 19699, 316, 14, 647, 315, 4884, 1145, 199, 624, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 4884, 14, 16647, 316, 492, 883, 63, 2526, 63, 14242, 63, 600, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 421, 199, 533, 428, 10075, 316, 774, 8, 1746, 304, 272, 408, 272, 1379, 19699, 10424, 16115, 272, 408, 272, 768, 4415, 63, 1751, 8, 1439, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 2968, 24852, 15, 2861, 15, 2795, 1105, 272, 347, 511, 63, 16647, 63, 476, 10248, 8, 277, 304, 267, 408, 267, 1379, 370, 1852, 3238, 626, 282, 2222, 13, 1431, 2529, 3055, 267, 408, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 1397, 1893, 15, 1667, 1333, 339, 768, 4415, 63, 1751, 8, 1439, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 2968, 24852, 15, 2861, 15, 2795, 1105, 272, 347, 511, 63, 16647, 63, 24265, 8, 277, 304, 267, 408, 267, 1379, 370, 1852, 3238, 626, 282, 1336, 5419, 9371, 2518, 7858, 267, 408, 267, 291, 14, 1815, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 7409, 63, 31354, 1333, 267, 291, 14, 1815, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 6965, 63, 51, 2700, 316, 1333, 339, 347, 511, 63, 11653, 63, 1045, 63, 14242, 63, 600, 63, 885, 8, 277, 304, 267, 408, 267, 1379, 626, 314, 849, 4260, 367, 5099, 28746, 654, 63, 9139, 63, 1734, 27657, 63, 6012, 365, 376, 2701, 4260, 12, 325, 14, 71, 14, 781, 2793, 1133, 675, 768, 4415, 63, 1751, 315, 3520, 2295, 267, 408, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 7409, 63, 31354, 1333, 267, 291, 14, 3334, 8, 2425, 63, 2526, 63, 14242, 63, 600, 360, 24852, 15, 2861, 15, 6965, 63, 51, 2700, 316, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
KohlsTechnology/ansible
lib/ansible/plugins/callback/stderr.py
59
3194
# (c) 2017, Frederic Van Espen <github@freh.be> # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type DOCUMENTATION = ''' callback: stderr callback_type: stdout requirements: - set as main display callback short_description: Splits output, sending failed tasks to stderr version_added: "2.4" extends_documentation_fragment: - default_callback description: - This is the stderr callback plugin, it behaves like the default callback plugin but sends error output to stderr. - Also it does not output skipped host/task/item status ''' from ansible import constants as C from ansible.plugins.callback.default import CallbackModule as CallbackModule_default class CallbackModule(CallbackModule_default): ''' This is the stderr callback plugin, which reuses the default callback plugin but sends error output to stderr. ''' CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'stdout' CALLBACK_NAME = 'stderr' def __init__(self): self.super_ref = super(CallbackModule, self) self.super_ref.__init__() def v2_runner_on_failed(self, result, ignore_errors=False): delegated_vars = result._result.get('_ansible_delegated_vars', None) self._clean_results(result._result, result._task.action) if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid: self._print_task_banner(result._task) self._handle_exception(result._result, errors_to_stderr=True) self._handle_warnings(result._result) if result._task.loop and 'results' in result._result: self._process_items(result) else: if delegated_vars: self._display.display("fatal: [%s -> %s]: FAILED! => %s" % (result._host.get_name(), delegated_vars['ansible_host'], self._dump_results(result._result)), color=C.COLOR_ERROR, stderr=True) else: self._display.display("fatal: [%s]: FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result)), color=C.COLOR_ERROR, stderr=True) if ignore_errors: self._display.display("...ignoring", color=C.COLOR_SKIP) def _handle_exception(self, result, errors_to_stderr=False): if 'exception' in result: msg = "An exception occurred during task execution. " if self._display.verbosity < 3: # extract just the actual error message from the exception text error = result['exception'].strip().split('\n')[-1] msg += "To see the full traceback, use -vvv. The error was: %s" % error else: msg = "The full traceback is:\n" + result['exception'] del result['exception'] self._display.display(msg, color=C.COLOR_ERROR, stderr=errors_to_stderr)
gpl-3.0
[ 3, 334, 67, 9, 9708, 12, 481, 21919, 1567, 812, 290, 662, 681, 287, 665, 5031, 32, 20153, 72, 14, 1235, 30, 199, 3, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 1449, 272, 3233, 26, 4635, 272, 3233, 63, 466, 26, 3839, 272, 9760, 26, 489, 446, 663, 465, 2446, 2929, 3233, 272, 3974, 63, 1802, 26, 11740, 83, 1072, 12, 10209, 3405, 6527, 370, 4635, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 16879, 63, 9970, 63, 7677, 26, 489, 446, 849, 63, 3058, 272, 1369, 26, 267, 446, 961, 365, 314, 4635, 3233, 3589, 12, 652, 25113, 2839, 314, 849, 3233, 3589, 1325, 16178, 1125, 1072, 370, 4635, 14, 267, 446, 6121, 652, 1630, 440, 1072, 9645, 1591, 15, 1765, 15, 1053, 2004, 199, 2344, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 14, 3058, 14, 885, 492, 17555, 2377, 465, 17555, 2377, 63, 885, 421, 199, 533, 17555, 2377, 8, 2806, 2377, 63, 885, 304, 339, 1449, 272, 961, 365, 314, 4635, 3233, 3589, 12, 1314, 295, 5589, 314, 849, 272, 3233, 3589, 1325, 16178, 1125, 1072, 370, 4635, 14, 272, 1449, 339, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 2711, 275, 283, 2703, 7, 272, 24251, 7111, 63, 2339, 275, 283, 3083, 7, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 4792, 63, 1121, 275, 1613, 8, 2806, 2377, 12, 291, 9, 267, 291, 14, 4792, 63, 1121, 855, 826, 4533, 339, 347, 373, 18, 63, 5933, 63, 265, 63, 4892, 8, 277, 12, 754, 12, 3686, 63, 2550, 29, 797, 304, 398, 29598, 63, 2936, 275, 754, 423, 1099, 14, 362, 6412, 4853, 63, 23684, 972, 63, 2936, 297, 488, 9, 267, 291, 423, 3118, 63, 2604, 8, 1099, 423, 1099, 12, 754, 423, 1765, 14, 1287, 9, 398, 340, 291, 423, 2802, 14, 8590, 508, 283, 4624, 7, 436, 291, 423, 2019, 63, 1765, 63, 13066, 1137, 754, 423, 1765, 423, 2580, 26, 288, 291, 423, 1361, 63, 1765, 63, 13066, 8, 1099, 423, 1765, 9, 398, 291, 423, 2479, 63, 1971, 8, 1099, 423, 1099, 12, 2552, 63, 475, 63, 3083, 29, 549, 9, 267, 291, 423, 2479, 63, 5451, 8, 1099, 423, 1099, 9, 398, 340, 754, 423, 1765, 14, 3813, 436, 283, 2604, 7, 315, 754, 423, 1099, 26, 288, 291, 423, 1412, 63, 1744, 8, 1099, 9, 398, 587, 26, 288, 340, 29598, 63, 2936, 26, 355, 291, 423, 2918, 14, 2918, 480, 16208, 26, 8978, 83, 1035, 450, 83, 2189, 26892, 1, 9265, 450, 83, 2, 450, 334, 1099, 423, 1102, 14, 362, 63, 354, 1062, 29598, 63, 2936, 459, 4853, 63, 1102, 995, 6684, 3322, 291, 423, 2724, 63, 2604, 8, 1099, 423, 1099, 1826, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4228, 4635, 29, 549, 9, 288, 587, 26, 355, 291, 423, 2918, 14, 2918, 480, 16208, 26, 8978, 83, 2189, 26892, 1, 9265, 450, 83, 2, 450, 334, 1099, 423, 1102, 14, 362, 63, 354, 1062, 291, 423, 2724, 63, 2604, 8, 1099, 423, 1099, 1826, 4228, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4635, 29, 549, 9, 398, 340, 3686, 63, 2550, 26, 288, 291, 423, 2918, 14, 2918, 480, 1396, 1030, 6854, 401, 3164, 29, 35, 14, 7134, 63, 13525, 9, 339, 347, 485, 2479, 63, 1971, 8, 277, 12, 754, 12, 2552, 63, 475, 63, 3083, 29, 797, 304, 398, 340, 283, 1971, 7, 315, 754, 26, 288, 1499, 275, 298, 2493, 1919, 8920, 5309, 2120, 6451, 14, 298, 288, 340, 291, 423, 2918, 14, 9833, 665, 650, 26, 355, 327, 5536, 2951, 314, 3503, 1125, 1245, 687, 314, 1919, 1318, 355, 1125, 275, 754, 459, 1971, 2278, 1913, 1252, 1294, 2258, 78, 358, 1988, 17, 61, 355, 1499, 847, 298, 1378, 1937, 314, 2615, 5190, 12, 675, 446, 24622, 14, 710, 1125, 1990, 26, 450, 83, 2, 450, 1125, 288, 587, 26, 355, 1499, 275, 298, 1918, 2615, 5190, 365, 3427, 78, 2, 435, 754, 459, 1971, 418, 355, 2150, 754, 459, 1971, 418, 953, 291, 423, 2918, 14, 2918, 8, 1328, 12, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4635, 29, 2550, 63, 475, 63, 3083, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 334, 67, 9, 9708, 12, 481, 21919, 1567, 812, 290, 662, 681, 287, 665, 5031, 32, 20153, 72, 14, 1235, 30, 199, 3, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 1449, 272, 3233, 26, 4635, 272, 3233, 63, 466, 26, 3839, 272, 9760, 26, 489, 446, 663, 465, 2446, 2929, 3233, 272, 3974, 63, 1802, 26, 11740, 83, 1072, 12, 10209, 3405, 6527, 370, 4635, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 16879, 63, 9970, 63, 7677, 26, 489, 446, 849, 63, 3058, 272, 1369, 26, 267, 446, 961, 365, 314, 4635, 3233, 3589, 12, 652, 25113, 2839, 314, 849, 3233, 3589, 1325, 16178, 1125, 1072, 370, 4635, 14, 267, 446, 6121, 652, 1630, 440, 1072, 9645, 1591, 15, 1765, 15, 1053, 2004, 199, 2344, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5265, 14, 3058, 14, 885, 492, 17555, 2377, 465, 17555, 2377, 63, 885, 421, 199, 533, 17555, 2377, 8, 2806, 2377, 63, 885, 304, 339, 1449, 272, 961, 365, 314, 4635, 3233, 3589, 12, 1314, 295, 5589, 314, 849, 272, 3233, 3589, 1325, 16178, 1125, 1072, 370, 4635, 14, 272, 1449, 339, 24251, 7111, 63, 4612, 275, 499, 14, 16, 272, 24251, 7111, 63, 2711, 275, 283, 2703, 7, 272, 24251, 7111, 63, 2339, 275, 283, 3083, 7, 339, 347, 636, 826, 721, 277, 304, 398, 291, 14, 4792, 63, 1121, 275, 1613, 8, 2806, 2377, 12, 291, 9, 267, 291, 14, 4792, 63, 1121, 855, 826, 4533, 339, 347, 373, 18, 63, 5933, 63, 265, 63, 4892, 8, 277, 12, 754, 12, 3686, 63, 2550, 29, 797, 304, 398, 29598, 63, 2936, 275, 754, 423, 1099, 14, 362, 6412, 4853, 63, 23684, 972, 63, 2936, 297, 488, 9, 267, 291, 423, 3118, 63, 2604, 8, 1099, 423, 1099, 12, 754, 423, 1765, 14, 1287, 9, 398, 340, 291, 423, 2802, 14, 8590, 508, 283, 4624, 7, 436, 291, 423, 2019, 63, 1765, 63, 13066, 1137, 754, 423, 1765, 423, 2580, 26, 288, 291, 423, 1361, 63, 1765, 63, 13066, 8, 1099, 423, 1765, 9, 398, 291, 423, 2479, 63, 1971, 8, 1099, 423, 1099, 12, 2552, 63, 475, 63, 3083, 29, 549, 9, 267, 291, 423, 2479, 63, 5451, 8, 1099, 423, 1099, 9, 398, 340, 754, 423, 1765, 14, 3813, 436, 283, 2604, 7, 315, 754, 423, 1099, 26, 288, 291, 423, 1412, 63, 1744, 8, 1099, 9, 398, 587, 26, 288, 340, 29598, 63, 2936, 26, 355, 291, 423, 2918, 14, 2918, 480, 16208, 26, 8978, 83, 1035, 450, 83, 2189, 26892, 1, 9265, 450, 83, 2, 450, 334, 1099, 423, 1102, 14, 362, 63, 354, 1062, 29598, 63, 2936, 459, 4853, 63, 1102, 995, 6684, 3322, 291, 423, 2724, 63, 2604, 8, 1099, 423, 1099, 1826, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4228, 4635, 29, 549, 9, 288, 587, 26, 355, 291, 423, 2918, 14, 2918, 480, 16208, 26, 8978, 83, 2189, 26892, 1, 9265, 450, 83, 2, 450, 334, 1099, 423, 1102, 14, 362, 63, 354, 1062, 291, 423, 2724, 63, 2604, 8, 1099, 423, 1099, 1826, 4228, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4635, 29, 549, 9, 398, 340, 3686, 63, 2550, 26, 288, 291, 423, 2918, 14, 2918, 480, 1396, 1030, 6854, 401, 3164, 29, 35, 14, 7134, 63, 13525, 9, 339, 347, 485, 2479, 63, 1971, 8, 277, 12, 754, 12, 2552, 63, 475, 63, 3083, 29, 797, 304, 398, 340, 283, 1971, 7, 315, 754, 26, 288, 1499, 275, 298, 2493, 1919, 8920, 5309, 2120, 6451, 14, 298, 288, 340, 291, 423, 2918, 14, 9833, 665, 650, 26, 355, 327, 5536, 2951, 314, 3503, 1125, 1245, 687, 314, 1919, 1318, 355, 1125, 275, 754, 459, 1971, 2278, 1913, 1252, 1294, 2258, 78, 358, 1988, 17, 61, 355, 1499, 847, 298, 1378, 1937, 314, 2615, 5190, 12, 675, 446, 24622, 14, 710, 1125, 1990, 26, 450, 83, 2, 450, 1125, 288, 587, 26, 355, 1499, 275, 298, 1918, 2615, 5190, 365, 3427, 78, 2, 435, 754, 459, 1971, 418, 355, 2150, 754, 459, 1971, 418, 953, 291, 423, 2918, 14, 2918, 8, 1328, 12, 3164, 29, 35, 14, 7134, 63, 3170, 12, 4635, 29, 2550, 63, 475, 63, 3083, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import hr_holidays import report import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 26131, 199, 646, 3622, 199, 646, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 26131, 199, 646, 3622, 199, 646, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Emergya/icm-openedx-educamadrid-platform-basic
lms/djangoapps/courseware/tests/helpers.py
46
6508
import json from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.test import TestCase from django.test.client import RequestFactory from courseware.access import has_access from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from student.models import Registration def get_request_for_user(user): """Create a request object for user.""" request = RequestFactory() request.user = user request.COOKIES = {} request.META = {} request.is_secure = lambda: True request.get_host = lambda: "edx.org" request.method = 'GET' return request class LoginEnrollmentTestCase(TestCase): """ Provides support for user creation, activation, login, and course enrollment. """ user = None def setup_user(self): """ Create a user account, activate, and log in. """ self.email = 'foo@test.com' self.password = 'bar' self.username = 'test' self.user = self.create_account( self.username, self.email, self.password, ) self.activate_user(self.email) self.login(self.email, self.password) def assert_request_status_code(self, status_code, url, method="GET", **kwargs): make_request = getattr(self.client, method.lower()) response = make_request(url, **kwargs) self.assertEqual( response.status_code, status_code, "{method} request to {url} returned status code {actual}, " "expected status code {expected}".format( method=method, url=url, actual=response.status_code, expected=status_code ) ) return response # ============ User creation and login ============== def login(self, email, password): """ Login, check that the corresponding view's response has a 200 status code. """ resp = self.client.post(reverse('login'), {'email': email, 'password': password}) self.assertEqual(resp.status_code, 200) data = json.loads(resp.content) self.assertTrue(data['success']) def logout(self): """ Logout; check that the HTTP response code indicates redirection as expected. """ # should redirect self.assert_request_status_code(302, reverse('logout')) def create_account(self, username, email, password): """ Create the account and check that it worked. """ url = reverse('create_account') request_data = { 'username': username, 'email': email, 'password': password, 'name': 'username', 'terms_of_service': 'true', 'honor_code': 'true', } resp = self.assert_request_status_code(200, url, method="POST", data=request_data) data = json.loads(resp.content) self.assertEqual(data['success'], True) # Check both that the user is created, and inactive user = User.objects.get(email=email) self.assertFalse(user.is_active) return user def activate_user(self, email): """ Look up the activation key for the user, then hit the activate view. No error checking. """ activation_key = Registration.objects.get(user__email=email).activation_key # and now we try to activate url = reverse('activate', kwargs={'key': activation_key}) self.assert_request_status_code(200, url) # Now make sure that the user is now actually activated self.assertTrue(User.objects.get(email=email).is_active) def enroll(self, course, verify=False): """ Try to enroll and return boolean indicating result. `course` is an instance of CourseDescriptor. `verify` is an optional boolean parameter specifying whether we want to verify that the student was successfully enrolled in the course. """ resp = self.client.post(reverse('change_enrollment'), { 'enrollment_action': 'enroll', 'course_id': course.id.to_deprecated_string(), 'check_access': True, }) result = resp.status_code == 200 if verify: self.assertTrue(result) return result def unenroll(self, course): """ Unenroll the currently logged-in user, and check that it worked. `course` is an instance of CourseDescriptor. """ url = reverse('change_enrollment') request_data = { 'enrollment_action': 'unenroll', 'course_id': course.id.to_deprecated_string(), } self.assert_request_status_code(200, url, method="POST", data=request_data) class CourseAccessTestMixin(TestCase): """ Utility mixin for asserting access (or lack thereof) to courses. If relevant, also checks access for courses' corresponding CourseOverviews. """ def assertCanAccessCourse(self, user, action, course): """ Assert that a user has access to the given action for a given course. Test with both the given course and with a CourseOverview of the given course. Arguments: user (User): a user. action (str): type of access to test. course (CourseDescriptor): a course. """ self.assertTrue(has_access(user, action, course)) self.assertTrue(has_access(user, action, CourseOverview.get_from_id(course.id))) def assertCannotAccessCourse(self, user, action, course): """ Assert that a user lacks access to the given action the given course. Test with both the given course and with a CourseOverview of the given course. Arguments: user (User): a user. action (str): type of access to test. course (CourseDescriptor): a course. Note: It may seem redundant to have one method for testing access and another method for testing lack thereof (why not just combine them into one method with a boolean flag?), but it makes reading stack traces of failed tests easier to understand at a glance. """ self.assertFalse(has_access(user, action, course)) self.assertFalse(has_access(user, action, CourseOverview.get_from_id(course.id)))
agpl-3.0
[ 646, 2022, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 199, 504, 20736, 14, 2732, 492, 965, 63, 2732, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1972, 63, 1883, 4196, 14, 992, 492, 5531, 28077, 199, 504, 6474, 14, 992, 492, 20764, 421, 199, 318, 664, 63, 1069, 63, 509, 63, 751, 8, 751, 304, 272, 408, 2499, 282, 1056, 909, 367, 922, 1041, 272, 1056, 275, 18638, 342, 272, 1056, 14, 751, 275, 922, 272, 1056, 14, 12189, 2563, 275, 1052, 272, 1056, 14, 10614, 275, 1052, 272, 1056, 14, 374, 63, 7817, 275, 2400, 26, 715, 272, 1056, 14, 362, 63, 1102, 275, 2400, 26, 298, 8268, 14, 1308, 2, 272, 1056, 14, 765, 275, 283, 2970, 7, 272, 372, 1056, 421, 199, 533, 16430, 13842, 1746, 8, 1746, 304, 272, 408, 272, 21552, 2291, 367, 922, 7143, 12, 272, 10361, 12, 4676, 12, 436, 2518, 14869, 14, 272, 408, 272, 922, 275, 488, 339, 347, 3272, 63, 751, 8, 277, 304, 267, 408, 267, 2790, 282, 922, 2933, 12, 15422, 12, 436, 943, 315, 14, 267, 408, 267, 291, 14, 2123, 275, 283, 1421, 32, 396, 14, 957, 7, 267, 291, 14, 2060, 275, 283, 1700, 7, 267, 291, 14, 2473, 275, 283, 396, 7, 267, 291, 14, 751, 275, 291, 14, 981, 63, 2048, 8, 288, 291, 14, 2473, 12, 288, 291, 14, 2123, 12, 288, 291, 14, 2060, 12, 267, 776, 267, 291, 14, 8222, 63, 751, 8, 277, 14, 2123, 9, 267, 291, 14, 2886, 8, 277, 14, 2123, 12, 291, 14, 2060, 9, 339, 347, 702, 63, 1069, 63, 1205, 63, 600, 8, 277, 12, 2004, 63, 600, 12, 1166, 12, 1083, 628, 2970, 401, 1011, 958, 304, 267, 1852, 63, 1069, 275, 2519, 8, 277, 14, 1258, 12, 1083, 14, 2325, 1012, 267, 1177, 275, 1852, 63, 1069, 8, 633, 12, 1011, 958, 9, 267, 291, 14, 629, 8, 288, 1177, 14, 1205, 63, 600, 12, 2004, 63, 600, 12, 288, 5310, 765, 93, 1056, 370, 469, 633, 93, 2138, 2004, 1233, 469, 6514, 1386, 298, 288, 298, 2062, 2004, 1233, 469, 2062, 5469, 908, 8, 355, 1083, 29, 765, 12, 1166, 29, 633, 12, 355, 3503, 29, 1310, 14, 1205, 63, 600, 12, 1420, 29, 1205, 63, 600, 288, 776, 267, 776, 267, 372, 1177, 339, 327, 275, 21326, 2876, 7143, 436, 4676, 275, 9152, 339, 347, 4676, 8, 277, 12, 3031, 12, 2505, 304, 267, 408, 267, 16430, 12, 1104, 626, 314, 5226, 2455, 1159, 1177, 965, 282, 1926, 2004, 1233, 14, 267, 408, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 4471, 360, 2886, 659, 1816, 791, 2123, 356, 3031, 12, 283, 2060, 356, 2505, 1552, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 666, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 291, 14, 1815, 8, 576, 459, 3742, 1105, 339, 347, 22079, 8, 277, 304, 267, 408, 267, 5297, 548, 27, 1104, 626, 314, 3101, 1177, 1233, 9126, 23713, 267, 465, 1420, 14, 267, 408, 267, 327, 1077, 4660, 267, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 8551, 12, 3837, 360, 11646, 1333, 339, 347, 1218, 63, 2048, 8, 277, 12, 3434, 12, 3031, 12, 2505, 304, 267, 408, 267, 2790, 314, 2933, 436, 1104, 626, 652, 26731, 14, 267, 408, 267, 1166, 275, 3837, 360, 981, 63, 2048, 358, 267, 1056, 63, 576, 275, 469, 288, 283, 2473, 356, 3434, 12, 288, 283, 2123, 356, 3031, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 354, 356, 283, 2473, 297, 288, 283, 9187, 63, 1618, 63, 1364, 356, 283, 2052, 297, 288, 283, 19923, 63, 600, 356, 283, 2052, 297, 267, 789, 267, 3085, 275, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 1840, 12, 1166, 12, 1083, 628, 4030, 401, 666, 29, 1069, 63, 576, 9, 267, 666, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 291, 14, 629, 8, 576, 459, 3742, 995, 715, 9, 267, 327, 2670, 3865, 626, 314, 922, 365, 2737, 12, 436, 21325, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2123, 29, 2123, 9, 267, 291, 14, 3334, 8, 751, 14, 374, 63, 2682, 9, 267, 372, 922, 339, 347, 15422, 63, 751, 8, 277, 12, 3031, 304, 267, 408, 267, 12077, 1536, 314, 10361, 790, 367, 314, 922, 12, 2066, 9793, 314, 15422, 2455, 14, 267, 3091, 1125, 7907, 14, 267, 408, 267, 10361, 63, 498, 275, 20764, 14, 1462, 14, 362, 8, 751, 363, 2123, 29, 2123, 680, 12312, 63, 498, 267, 327, 436, 3063, 781, 862, 370, 15422, 267, 1166, 275, 3837, 360, 8222, 297, 2074, 3713, 498, 356, 10361, 63, 498, 1552, 267, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 1840, 12, 1166, 9, 267, 327, 7356, 1852, 3238, 626, 314, 922, 365, 3063, 5965, 22225, 267, 291, 14, 1815, 8, 1899, 14, 1462, 14, 362, 8, 2123, 29, 2123, 680, 374, 63, 2682, 9, 339, 347, 26361, 8, 277, 12, 2518, 12, 4911, 29, 797, 304, 267, 408, 267, 7649, 370, 26361, 436, 372, 5046, 9297, 754, 14, 267, 658, 1972, 64, 365, 376, 1256, 402, 5531, 4311, 14, 267, 658, 4712, 64, 365, 376, 2716, 5046, 2725, 9176, 3775, 781, 267, 2934, 370, 4911, 626, 314, 6474, 1990, 8792, 26802, 267, 315, 314, 2518, 14, 267, 408, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 4471, 360, 1461, 63, 12214, 659, 469, 288, 283, 12214, 63, 1287, 356, 283, 14695, 297, 288, 283, 1972, 63, 344, 356, 2518, 14, 344, 14, 475, 63, 6667, 63, 875, 1062, 288, 283, 1074, 63, 2732, 356, 715, 12, 267, 3828, 267, 754, 275, 3085, 14, 1205, 63, 600, 508, 1926, 267, 340, 4911, 26, 288, 291, 14, 1815, 8, 1099, 9, 267, 372, 754, 339, 347, 625, 14695, 8, 277, 12, 2518, 304, 267, 408, 267, 1910, 14695, 314, 5544, 10367, 13, 262, 922, 12, 436 ]
[ 2022, 199, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 199, 504, 20736, 14, 2732, 492, 965, 63, 2732, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1972, 63, 1883, 4196, 14, 992, 492, 5531, 28077, 199, 504, 6474, 14, 992, 492, 20764, 421, 199, 318, 664, 63, 1069, 63, 509, 63, 751, 8, 751, 304, 272, 408, 2499, 282, 1056, 909, 367, 922, 1041, 272, 1056, 275, 18638, 342, 272, 1056, 14, 751, 275, 922, 272, 1056, 14, 12189, 2563, 275, 1052, 272, 1056, 14, 10614, 275, 1052, 272, 1056, 14, 374, 63, 7817, 275, 2400, 26, 715, 272, 1056, 14, 362, 63, 1102, 275, 2400, 26, 298, 8268, 14, 1308, 2, 272, 1056, 14, 765, 275, 283, 2970, 7, 272, 372, 1056, 421, 199, 533, 16430, 13842, 1746, 8, 1746, 304, 272, 408, 272, 21552, 2291, 367, 922, 7143, 12, 272, 10361, 12, 4676, 12, 436, 2518, 14869, 14, 272, 408, 272, 922, 275, 488, 339, 347, 3272, 63, 751, 8, 277, 304, 267, 408, 267, 2790, 282, 922, 2933, 12, 15422, 12, 436, 943, 315, 14, 267, 408, 267, 291, 14, 2123, 275, 283, 1421, 32, 396, 14, 957, 7, 267, 291, 14, 2060, 275, 283, 1700, 7, 267, 291, 14, 2473, 275, 283, 396, 7, 267, 291, 14, 751, 275, 291, 14, 981, 63, 2048, 8, 288, 291, 14, 2473, 12, 288, 291, 14, 2123, 12, 288, 291, 14, 2060, 12, 267, 776, 267, 291, 14, 8222, 63, 751, 8, 277, 14, 2123, 9, 267, 291, 14, 2886, 8, 277, 14, 2123, 12, 291, 14, 2060, 9, 339, 347, 702, 63, 1069, 63, 1205, 63, 600, 8, 277, 12, 2004, 63, 600, 12, 1166, 12, 1083, 628, 2970, 401, 1011, 958, 304, 267, 1852, 63, 1069, 275, 2519, 8, 277, 14, 1258, 12, 1083, 14, 2325, 1012, 267, 1177, 275, 1852, 63, 1069, 8, 633, 12, 1011, 958, 9, 267, 291, 14, 629, 8, 288, 1177, 14, 1205, 63, 600, 12, 2004, 63, 600, 12, 288, 5310, 765, 93, 1056, 370, 469, 633, 93, 2138, 2004, 1233, 469, 6514, 1386, 298, 288, 298, 2062, 2004, 1233, 469, 2062, 5469, 908, 8, 355, 1083, 29, 765, 12, 1166, 29, 633, 12, 355, 3503, 29, 1310, 14, 1205, 63, 600, 12, 1420, 29, 1205, 63, 600, 288, 776, 267, 776, 267, 372, 1177, 339, 327, 275, 21326, 2876, 7143, 436, 4676, 275, 9152, 339, 347, 4676, 8, 277, 12, 3031, 12, 2505, 304, 267, 408, 267, 16430, 12, 1104, 626, 314, 5226, 2455, 1159, 1177, 965, 282, 1926, 2004, 1233, 14, 267, 408, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 4471, 360, 2886, 659, 1816, 791, 2123, 356, 3031, 12, 283, 2060, 356, 2505, 1552, 267, 291, 14, 629, 8, 4518, 14, 1205, 63, 600, 12, 1926, 9, 267, 666, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 291, 14, 1815, 8, 576, 459, 3742, 1105, 339, 347, 22079, 8, 277, 304, 267, 408, 267, 5297, 548, 27, 1104, 626, 314, 3101, 1177, 1233, 9126, 23713, 267, 465, 1420, 14, 267, 408, 267, 327, 1077, 4660, 267, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 8551, 12, 3837, 360, 11646, 1333, 339, 347, 1218, 63, 2048, 8, 277, 12, 3434, 12, 3031, 12, 2505, 304, 267, 408, 267, 2790, 314, 2933, 436, 1104, 626, 652, 26731, 14, 267, 408, 267, 1166, 275, 3837, 360, 981, 63, 2048, 358, 267, 1056, 63, 576, 275, 469, 288, 283, 2473, 356, 3434, 12, 288, 283, 2123, 356, 3031, 12, 288, 283, 2060, 356, 2505, 12, 288, 283, 354, 356, 283, 2473, 297, 288, 283, 9187, 63, 1618, 63, 1364, 356, 283, 2052, 297, 288, 283, 19923, 63, 600, 356, 283, 2052, 297, 267, 789, 267, 3085, 275, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 1840, 12, 1166, 12, 1083, 628, 4030, 401, 666, 29, 1069, 63, 576, 9, 267, 666, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 291, 14, 629, 8, 576, 459, 3742, 995, 715, 9, 267, 327, 2670, 3865, 626, 314, 922, 365, 2737, 12, 436, 21325, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 2123, 29, 2123, 9, 267, 291, 14, 3334, 8, 751, 14, 374, 63, 2682, 9, 267, 372, 922, 339, 347, 15422, 63, 751, 8, 277, 12, 3031, 304, 267, 408, 267, 12077, 1536, 314, 10361, 790, 367, 314, 922, 12, 2066, 9793, 314, 15422, 2455, 14, 267, 3091, 1125, 7907, 14, 267, 408, 267, 10361, 63, 498, 275, 20764, 14, 1462, 14, 362, 8, 751, 363, 2123, 29, 2123, 680, 12312, 63, 498, 267, 327, 436, 3063, 781, 862, 370, 15422, 267, 1166, 275, 3837, 360, 8222, 297, 2074, 3713, 498, 356, 10361, 63, 498, 1552, 267, 291, 14, 479, 63, 1069, 63, 1205, 63, 600, 8, 1840, 12, 1166, 9, 267, 327, 7356, 1852, 3238, 626, 314, 922, 365, 3063, 5965, 22225, 267, 291, 14, 1815, 8, 1899, 14, 1462, 14, 362, 8, 2123, 29, 2123, 680, 374, 63, 2682, 9, 339, 347, 26361, 8, 277, 12, 2518, 12, 4911, 29, 797, 304, 267, 408, 267, 7649, 370, 26361, 436, 372, 5046, 9297, 754, 14, 267, 658, 1972, 64, 365, 376, 1256, 402, 5531, 4311, 14, 267, 658, 4712, 64, 365, 376, 2716, 5046, 2725, 9176, 3775, 781, 267, 2934, 370, 4911, 626, 314, 6474, 1990, 8792, 26802, 267, 315, 314, 2518, 14, 267, 408, 267, 3085, 275, 291, 14, 1258, 14, 1932, 8, 4471, 360, 1461, 63, 12214, 659, 469, 288, 283, 12214, 63, 1287, 356, 283, 14695, 297, 288, 283, 1972, 63, 344, 356, 2518, 14, 344, 14, 475, 63, 6667, 63, 875, 1062, 288, 283, 1074, 63, 2732, 356, 715, 12, 267, 3828, 267, 754, 275, 3085, 14, 1205, 63, 600, 508, 1926, 267, 340, 4911, 26, 288, 291, 14, 1815, 8, 1099, 9, 267, 372, 754, 339, 347, 625, 14695, 8, 277, 12, 2518, 304, 267, 408, 267, 1910, 14695, 314, 5544, 10367, 13, 262, 922, 12, 436, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sunze/py_flask
venv/lib/python3.4/site-packages/celery/tests/backends/test_rpc.py
8
2317
from __future__ import absolute_import from celery.backends.rpc import RPCBackend from celery._state import _task_stack from celery.tests.case import AppCase, Mock, patch class test_RPCBackend(AppCase): def setup(self): self.b = RPCBackend(app=self.app) def test_oid(self): oid = self.b.oid oid2 = self.b.oid self.assertEqual(oid, oid2) self.assertEqual(oid, self.app.oid) def test_interface(self): self.b.on_reply_declare('task_id') def test_destination_for(self): req = Mock(name='request') req.reply_to = 'reply_to' req.correlation_id = 'corid' self.assertTupleEqual( self.b.destination_for('task_id', req), ('reply_to', 'corid'), ) task = Mock() _task_stack.push(task) try: task.request.reply_to = 'reply_to' task.request.correlation_id = 'corid' self.assertTupleEqual( self.b.destination_for('task_id', None), ('reply_to', 'corid'), ) finally: _task_stack.pop() with self.assertRaises(RuntimeError): self.b.destination_for('task_id', None) def test_binding(self): queue = self.b.binding self.assertEqual(queue.name, self.b.oid) self.assertEqual(queue.exchange, self.b.exchange) self.assertEqual(queue.routing_key, self.b.oid) self.assertFalse(queue.durable) self.assertFalse(queue.auto_delete) def test_many_bindings(self): self.assertListEqual( self.b._many_bindings(['a', 'b']), [self.b.binding], ) def test_create_binding(self): self.assertEqual(self.b._create_binding('id'), self.b.binding) def test_on_task_call(self): with patch('celery.backends.rpc.maybe_declare') as md: with self.app.amqp.producer_pool.acquire() as prod: self.b.on_task_call(prod, 'task_id'), md.assert_called_with( self.b.binding(prod.channel), retry=True, ) def test_create_exchange(self): ex = self.b._create_exchange('name') self.assertIsInstance(ex, self.b.Exchange) self.assertEqual(ex.name, '')
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 22748, 14, 7765, 14, 4354, 492, 11785, 8447, 199, 504, 22748, 423, 929, 492, 485, 1765, 63, 2340, 199, 199, 504, 22748, 14, 2219, 14, 2546, 492, 4693, 1538, 12, 4420, 12, 3371, 421, 199, 533, 511, 63, 8171, 8447, 8, 2640, 1538, 304, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 66, 275, 11785, 8447, 8, 571, 29, 277, 14, 571, 9, 339, 347, 511, 63, 1170, 8, 277, 304, 267, 20109, 275, 291, 14, 66, 14, 1170, 267, 20109, 18, 275, 291, 14, 66, 14, 1170, 267, 291, 14, 629, 8, 1170, 12, 20109, 18, 9, 267, 291, 14, 629, 8, 1170, 12, 291, 14, 571, 14, 1170, 9, 339, 347, 511, 63, 3266, 8, 277, 304, 267, 291, 14, 66, 14, 265, 63, 8102, 63, 16536, 360, 1765, 63, 344, 358, 339, 347, 511, 63, 6881, 63, 509, 8, 277, 304, 267, 2648, 275, 4420, 8, 354, 534, 1069, 358, 267, 2648, 14, 8102, 63, 475, 275, 283, 8102, 63, 475, 7, 267, 2648, 14, 26487, 63, 344, 275, 283, 989, 344, 7, 267, 291, 14, 479, 7075, 591, 8, 288, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 2648, 395, 288, 661, 8102, 63, 475, 297, 283, 989, 344, 659, 267, 776, 267, 2120, 275, 4420, 342, 267, 485, 1765, 63, 2340, 14, 5335, 8, 1765, 9, 267, 862, 26, 288, 2120, 14, 1069, 14, 8102, 63, 475, 275, 283, 8102, 63, 475, 7, 288, 2120, 14, 1069, 14, 26487, 63, 344, 275, 283, 989, 344, 7, 288, 291, 14, 479, 7075, 591, 8, 355, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 488, 395, 355, 661, 8102, 63, 475, 297, 283, 989, 344, 659, 288, 776, 267, 3753, 26, 288, 485, 1765, 63, 2340, 14, 1935, 342, 398, 543, 291, 14, 1855, 8, 13281, 304, 288, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 488, 9, 339, 347, 511, 63, 9140, 8, 277, 304, 267, 4126, 275, 291, 14, 66, 14, 9140, 267, 291, 14, 629, 8, 1825, 14, 354, 12, 291, 14, 66, 14, 1170, 9, 267, 291, 14, 629, 8, 1825, 14, 14197, 12, 291, 14, 66, 14, 14197, 9, 267, 291, 14, 629, 8, 1825, 14, 9492, 63, 498, 12, 291, 14, 66, 14, 1170, 9, 267, 291, 14, 3334, 8, 1825, 14, 68, 15684, 9, 267, 291, 14, 3334, 8, 1825, 14, 2495, 63, 1807, 9, 339, 347, 511, 63, 3479, 63, 10880, 8, 277, 304, 267, 291, 14, 16671, 8, 288, 291, 14, 66, 423, 3479, 63, 10880, 2941, 65, 297, 283, 66, 3815, 288, 359, 277, 14, 66, 14, 9140, 467, 267, 776, 339, 347, 511, 63, 981, 63, 9140, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 423, 981, 63, 9140, 360, 344, 659, 291, 14, 66, 14, 9140, 9, 339, 347, 511, 63, 265, 63, 1765, 63, 1250, 8, 277, 304, 267, 543, 3371, 360, 23593, 14, 7765, 14, 4354, 14, 11853, 63, 16536, 358, 465, 6128, 26, 288, 543, 291, 14, 571, 14, 455, 15202, 14, 16376, 63, 2293, 14, 8174, 342, 465, 12441, 26, 355, 291, 14, 66, 14, 265, 63, 1765, 63, 1250, 8, 8788, 12, 283, 1765, 63, 344, 659, 355, 6128, 14, 479, 63, 3527, 63, 1045, 8, 490, 291, 14, 66, 14, 9140, 8, 8788, 14, 2775, 395, 490, 7269, 29, 549, 12, 355, 776, 339, 347, 511, 63, 981, 63, 14197, 8, 277, 304, 267, 444, 275, 291, 14, 66, 423, 981, 63, 14197, 360, 354, 358, 267, 291, 14, 6926, 8, 476, 12, 291, 14, 66, 14, 13188, 9, 267, 291, 14, 629, 8, 476, 14, 354, 12, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 22748, 14, 7765, 14, 4354, 492, 11785, 8447, 199, 504, 22748, 423, 929, 492, 485, 1765, 63, 2340, 199, 199, 504, 22748, 14, 2219, 14, 2546, 492, 4693, 1538, 12, 4420, 12, 3371, 421, 199, 533, 511, 63, 8171, 8447, 8, 2640, 1538, 304, 339, 347, 3272, 8, 277, 304, 267, 291, 14, 66, 275, 11785, 8447, 8, 571, 29, 277, 14, 571, 9, 339, 347, 511, 63, 1170, 8, 277, 304, 267, 20109, 275, 291, 14, 66, 14, 1170, 267, 20109, 18, 275, 291, 14, 66, 14, 1170, 267, 291, 14, 629, 8, 1170, 12, 20109, 18, 9, 267, 291, 14, 629, 8, 1170, 12, 291, 14, 571, 14, 1170, 9, 339, 347, 511, 63, 3266, 8, 277, 304, 267, 291, 14, 66, 14, 265, 63, 8102, 63, 16536, 360, 1765, 63, 344, 358, 339, 347, 511, 63, 6881, 63, 509, 8, 277, 304, 267, 2648, 275, 4420, 8, 354, 534, 1069, 358, 267, 2648, 14, 8102, 63, 475, 275, 283, 8102, 63, 475, 7, 267, 2648, 14, 26487, 63, 344, 275, 283, 989, 344, 7, 267, 291, 14, 479, 7075, 591, 8, 288, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 2648, 395, 288, 661, 8102, 63, 475, 297, 283, 989, 344, 659, 267, 776, 267, 2120, 275, 4420, 342, 267, 485, 1765, 63, 2340, 14, 5335, 8, 1765, 9, 267, 862, 26, 288, 2120, 14, 1069, 14, 8102, 63, 475, 275, 283, 8102, 63, 475, 7, 288, 2120, 14, 1069, 14, 26487, 63, 344, 275, 283, 989, 344, 7, 288, 291, 14, 479, 7075, 591, 8, 355, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 488, 395, 355, 661, 8102, 63, 475, 297, 283, 989, 344, 659, 288, 776, 267, 3753, 26, 288, 485, 1765, 63, 2340, 14, 1935, 342, 398, 543, 291, 14, 1855, 8, 13281, 304, 288, 291, 14, 66, 14, 6881, 63, 509, 360, 1765, 63, 344, 297, 488, 9, 339, 347, 511, 63, 9140, 8, 277, 304, 267, 4126, 275, 291, 14, 66, 14, 9140, 267, 291, 14, 629, 8, 1825, 14, 354, 12, 291, 14, 66, 14, 1170, 9, 267, 291, 14, 629, 8, 1825, 14, 14197, 12, 291, 14, 66, 14, 14197, 9, 267, 291, 14, 629, 8, 1825, 14, 9492, 63, 498, 12, 291, 14, 66, 14, 1170, 9, 267, 291, 14, 3334, 8, 1825, 14, 68, 15684, 9, 267, 291, 14, 3334, 8, 1825, 14, 2495, 63, 1807, 9, 339, 347, 511, 63, 3479, 63, 10880, 8, 277, 304, 267, 291, 14, 16671, 8, 288, 291, 14, 66, 423, 3479, 63, 10880, 2941, 65, 297, 283, 66, 3815, 288, 359, 277, 14, 66, 14, 9140, 467, 267, 776, 339, 347, 511, 63, 981, 63, 9140, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 423, 981, 63, 9140, 360, 344, 659, 291, 14, 66, 14, 9140, 9, 339, 347, 511, 63, 265, 63, 1765, 63, 1250, 8, 277, 304, 267, 543, 3371, 360, 23593, 14, 7765, 14, 4354, 14, 11853, 63, 16536, 358, 465, 6128, 26, 288, 543, 291, 14, 571, 14, 455, 15202, 14, 16376, 63, 2293, 14, 8174, 342, 465, 12441, 26, 355, 291, 14, 66, 14, 265, 63, 1765, 63, 1250, 8, 8788, 12, 283, 1765, 63, 344, 659, 355, 6128, 14, 479, 63, 3527, 63, 1045, 8, 490, 291, 14, 66, 14, 9140, 8, 8788, 14, 2775, 395, 490, 7269, 29, 549, 12, 355, 776, 339, 347, 511, 63, 981, 63, 14197, 8, 277, 304, 267, 444, 275, 291, 14, 66, 423, 981, 63, 14197, 360, 354, 358, 267, 291, 14, 6926, 8, 476, 12, 291, 14, 66, 14, 13188, 9, 267, 291, 14, 629, 8, 476, 14, 354, 12, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jodosh/MP4GS
python/CameraCalibration/calculateMatrixValuesLeft.py
2
1979
import numpy as np import cv2 import glob # termination criteria criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 100, .01) goodImages = 0 # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) objp = np.zeros((3*4,3), np.float32) objp[:,:2] = np.mgrid[0:4,0:3].T.reshape(-1,2) # Arrays to store object points and image points from all the images. objpoints = [] # 3d point in real world space imgpoints = [] # 2d points in image plane. images = glob.glob('*Left.bmp') for fname in images: print("Working on file: %s" % (fname)) img = cv2.imread(fname,cv2.CV_LOAD_IMAGE_COLOR) gray = cv2.imread(fname,0) # Find the chess board corners ret, corners = cv2.findChessboardCorners(gray, (4,3),None) # If found, add object points, image points (after refining them) if ret == True: print("Found Corners for %s" % (fname)) objpoints.append(objp) cv2.cornerSubPix(gray,corners,(5,5),(-1,-1),criteria) if corners is None: print("Something went wrong with cornerSubPix in file: %s" % (fname)) else: imgpoints.append(corners) goodImages+=1 # Draw and display the corners cv2.drawChessboardCorners(img, (4,3), corners,ret) cv2.imshow('img',img) cv2.waitKey(0) if goodImages >9: ret, intrinsicMatrix, distortionCoeffs, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None) h, w = img.shape[:2] refinedCameraMatrix, roi=cv2.getOptimalNewCameraMatrix(intrinsicMatrix,distortionCoeffs,(w,h),1,(w,h)) print (roi) np.savez("LeftCamera", refinedCameraMatrix=refinedCameraMatrix, roi=roi, intrinsicMatrix=intrinsicMatrix, distortionCoeffs=distortionCoeffs) #np.savez("refinedCameraMatrixLeft", refinedCameraMatrix) #np.savez("ROILeft", roi) #np.savez("intrinsicMatrixLeft", intrinsicMatrix) #np.savez("distortionCoeffsLeft", distortionCoeffs) else: print("You need to supply at least 10 good images. You supplied %d" % (goodImages)) cv2.destroyAllWindows()
bsd-3-clause
[ 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 646, 5739, 199, 199, 3, 23868, 15647, 199, 20525, 275, 334, 5107, 18, 14, 16718, 63, 2944, 11084, 13033, 63, 25711, 1204, 6277, 18, 14, 16718, 63, 2944, 11084, 13033, 63, 8760, 12, 2948, 12, 1275, 614, 9, 199, 8302, 18882, 275, 378, 199, 199, 3, 9275, 909, 4501, 12, 2839, 334, 16, 12, 16, 12, 16, 395, 334, 17, 12, 16, 12, 16, 395, 334, 18, 12, 16, 12, 16, 9, 29222, 12803, 22, 12, 21, 12, 16, 9, 199, 1113, 80, 275, 980, 14, 4250, 1332, 19, 10, 20, 12, 19, 395, 980, 14, 1609, 708, 9, 199, 1113, 80, 3981, 26, 18, 61, 275, 980, 14, 77, 3825, 59, 16, 26, 20, 12, 16, 26, 19, 1055, 52, 14, 5217, 2801, 17, 12, 18, 9, 199, 199, 3, 1952, 4814, 370, 3877, 909, 4501, 436, 1834, 4501, 687, 1006, 314, 5935, 14, 199, 1113, 3438, 275, 942, 327, 650, 68, 2376, 315, 3363, 6701, 4601, 199, 4060, 3438, 275, 942, 327, 499, 68, 4501, 315, 1834, 16388, 14, 199, 199, 4782, 275, 5739, 14, 6463, 18225, 8185, 14, 22308, 358, 199, 199, 509, 6748, 315, 5935, 26, 199, 198, 1361, 480, 18356, 641, 570, 26, 450, 83, 2, 450, 334, 5252, 430, 199, 198, 4060, 275, 6277, 18, 14, 1017, 739, 8, 5252, 12, 5107, 18, 14, 12847, 63, 7405, 63, 9438, 63, 7134, 9, 199, 198, 12150, 275, 6277, 18, 14, 1017, 739, 8, 5252, 12, 16, 9, 339, 327, 6668, 314, 17546, 385, 13811, 31657, 199, 198, 3292, 12, 31657, 275, 6277, 18, 14, 1623, 20335, 385, 3576, 35, 6161, 1192, 8, 12150, 12, 334, 20, 12, 19, 395, 403, 9, 339, 327, 982, 1911, 12, 1050, 909, 4501, 12, 1834, 4501, 334, 4399, 295, 2408, 316, 3062, 9, 199, 198, 692, 2203, 508, 715, 26, 507, 198, 1361, 480, 3601, 445, 6161, 1192, 367, 450, 83, 2, 450, 334, 5252, 430, 1871, 507, 198, 1113, 3438, 14, 740, 8, 1113, 80, 9, 2742, 198, 5107, 18, 14, 22605, 2610, 25747, 8, 12150, 12, 30652, 12803, 21, 12, 21, 395, 2801, 17, 3057, 17, 395, 20525, 9, 507, 198, 692, 31657, 365, 488, 26, 686, 198, 1361, 480, 20641, 22396, 6835, 543, 17703, 2610, 25747, 315, 570, 26, 450, 83, 2, 450, 334, 5252, 430, 507, 198, 2836, 26, 686, 198, 4060, 3438, 14, 740, 8, 30652, 9, 686, 198, 8302, 18882, 10365, 17, 6319, 198, 3, 17813, 436, 2929, 314, 31657, 686, 198, 5107, 18, 14, 5485, 20335, 385, 3576, 35, 6161, 1192, 8, 4060, 12, 334, 20, 12, 19, 395, 31657, 12, 3292, 9, 686, 198, 5107, 18, 14, 20413, 360, 4060, 297, 4060, 9, 686, 198, 5107, 18, 14, 2573, 1197, 8, 16, 9, 16737, 1585, 199, 692, 6954, 18882, 690, 25, 26, 9622, 199, 198, 3292, 12, 31570, 262, 9916, 6443, 12, 2917, 15029, 967, 3609, 83, 12, 519, 25130, 12, 307, 25130, 275, 6277, 18, 14, 15737, 1866, 18425, 8, 1113, 3438, 12, 6050, 3438, 12, 21977, 14, 1392, 14172, 17, 467, 403, 12, 403, 9, 4388, 198, 72, 12, 221, 336, 275, 6050, 14, 1392, 1491, 18, 61, 199, 198, 1121, 1942, 18425, 6443, 12, 30240, 29, 5107, 18, 14, 362, 4619, 16757, 4665, 18425, 6443, 8, 442, 24667, 9916, 6443, 12, 2686, 15029, 967, 3609, 83, 12803, 87, 12, 72, 395, 17, 12803, 87, 12, 72, 430, 421, 198, 1361, 334, 20581, 9, 199, 198, 1590, 14, 2117, 90, 480, 8185, 18425, 401, 2984, 1942, 18425, 6443, 29, 1121, 1942, 18425, 6443, 12, 30240, 29, 20581, 12, 31570, 262, 9916, 6443, 29, 442, 24667, 9916, 6443, 12, 2917, 15029, 967, 3609, 83, 29, 2686, 15029, 967, 3609, 83, 9, 8299, 198, 3, 1590, 14, 2117, 90, 480, 1121, 1942, 18425, 6443, 8185, 401, 2984, 1942, 18425, 6443, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 1092, 1193, 69, 856, 401, 30240, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 442, 24667, 9916, 6443, 8185, 401, 31570, 262, 9916, 6443, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 2686, 15029, 967, 3609, 83, 8185, 401, 2917, 15029, 967, 3609, 83, 9, 199, 2836, 26, 199, 198, 1361, 480, 5556, 1929, 370, 17169, 737, 5210, 1616, 6954, 5935, 14, 2047, 6841, 450, 68, 2, 450, 334, 8302, 18882, 430, 199, 5107, 18, 14, 7237, 2422, 8647, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2680, 465, 980, 199, 646, 6277, 18, 199, 646, 5739, 199, 199, 3, 23868, 15647, 199, 20525, 275, 334, 5107, 18, 14, 16718, 63, 2944, 11084, 13033, 63, 25711, 1204, 6277, 18, 14, 16718, 63, 2944, 11084, 13033, 63, 8760, 12, 2948, 12, 1275, 614, 9, 199, 8302, 18882, 275, 378, 199, 199, 3, 9275, 909, 4501, 12, 2839, 334, 16, 12, 16, 12, 16, 395, 334, 17, 12, 16, 12, 16, 395, 334, 18, 12, 16, 12, 16, 9, 29222, 12803, 22, 12, 21, 12, 16, 9, 199, 1113, 80, 275, 980, 14, 4250, 1332, 19, 10, 20, 12, 19, 395, 980, 14, 1609, 708, 9, 199, 1113, 80, 3981, 26, 18, 61, 275, 980, 14, 77, 3825, 59, 16, 26, 20, 12, 16, 26, 19, 1055, 52, 14, 5217, 2801, 17, 12, 18, 9, 199, 199, 3, 1952, 4814, 370, 3877, 909, 4501, 436, 1834, 4501, 687, 1006, 314, 5935, 14, 199, 1113, 3438, 275, 942, 327, 650, 68, 2376, 315, 3363, 6701, 4601, 199, 4060, 3438, 275, 942, 327, 499, 68, 4501, 315, 1834, 16388, 14, 199, 199, 4782, 275, 5739, 14, 6463, 18225, 8185, 14, 22308, 358, 199, 199, 509, 6748, 315, 5935, 26, 199, 198, 1361, 480, 18356, 641, 570, 26, 450, 83, 2, 450, 334, 5252, 430, 199, 198, 4060, 275, 6277, 18, 14, 1017, 739, 8, 5252, 12, 5107, 18, 14, 12847, 63, 7405, 63, 9438, 63, 7134, 9, 199, 198, 12150, 275, 6277, 18, 14, 1017, 739, 8, 5252, 12, 16, 9, 339, 327, 6668, 314, 17546, 385, 13811, 31657, 199, 198, 3292, 12, 31657, 275, 6277, 18, 14, 1623, 20335, 385, 3576, 35, 6161, 1192, 8, 12150, 12, 334, 20, 12, 19, 395, 403, 9, 339, 327, 982, 1911, 12, 1050, 909, 4501, 12, 1834, 4501, 334, 4399, 295, 2408, 316, 3062, 9, 199, 198, 692, 2203, 508, 715, 26, 507, 198, 1361, 480, 3601, 445, 6161, 1192, 367, 450, 83, 2, 450, 334, 5252, 430, 1871, 507, 198, 1113, 3438, 14, 740, 8, 1113, 80, 9, 2742, 198, 5107, 18, 14, 22605, 2610, 25747, 8, 12150, 12, 30652, 12803, 21, 12, 21, 395, 2801, 17, 3057, 17, 395, 20525, 9, 507, 198, 692, 31657, 365, 488, 26, 686, 198, 1361, 480, 20641, 22396, 6835, 543, 17703, 2610, 25747, 315, 570, 26, 450, 83, 2, 450, 334, 5252, 430, 507, 198, 2836, 26, 686, 198, 4060, 3438, 14, 740, 8, 30652, 9, 686, 198, 8302, 18882, 10365, 17, 6319, 198, 3, 17813, 436, 2929, 314, 31657, 686, 198, 5107, 18, 14, 5485, 20335, 385, 3576, 35, 6161, 1192, 8, 4060, 12, 334, 20, 12, 19, 395, 31657, 12, 3292, 9, 686, 198, 5107, 18, 14, 20413, 360, 4060, 297, 4060, 9, 686, 198, 5107, 18, 14, 2573, 1197, 8, 16, 9, 16737, 1585, 199, 692, 6954, 18882, 690, 25, 26, 9622, 199, 198, 3292, 12, 31570, 262, 9916, 6443, 12, 2917, 15029, 967, 3609, 83, 12, 519, 25130, 12, 307, 25130, 275, 6277, 18, 14, 15737, 1866, 18425, 8, 1113, 3438, 12, 6050, 3438, 12, 21977, 14, 1392, 14172, 17, 467, 403, 12, 403, 9, 4388, 198, 72, 12, 221, 336, 275, 6050, 14, 1392, 1491, 18, 61, 199, 198, 1121, 1942, 18425, 6443, 12, 30240, 29, 5107, 18, 14, 362, 4619, 16757, 4665, 18425, 6443, 8, 442, 24667, 9916, 6443, 12, 2686, 15029, 967, 3609, 83, 12803, 87, 12, 72, 395, 17, 12803, 87, 12, 72, 430, 421, 198, 1361, 334, 20581, 9, 199, 198, 1590, 14, 2117, 90, 480, 8185, 18425, 401, 2984, 1942, 18425, 6443, 29, 1121, 1942, 18425, 6443, 12, 30240, 29, 20581, 12, 31570, 262, 9916, 6443, 29, 442, 24667, 9916, 6443, 12, 2917, 15029, 967, 3609, 83, 29, 2686, 15029, 967, 3609, 83, 9, 8299, 198, 3, 1590, 14, 2117, 90, 480, 1121, 1942, 18425, 6443, 8185, 401, 2984, 1942, 18425, 6443, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 1092, 1193, 69, 856, 401, 30240, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 442, 24667, 9916, 6443, 8185, 401, 31570, 262, 9916, 6443, 9, 199, 198, 3, 1590, 14, 2117, 90, 480, 2686, 15029, 967, 3609, 83, 8185, 401, 2917, 15029, 967, 3609, 83, 9, 199, 2836, 26, 199, 198, 1361, 480, 5556, 1929, 370, 17169, 737, 5210, 1616, 6954, 5935, 14, 2047, 6841, 450, 68, 2, 450, 334, 8302, 18882, 430, 199, 5107, 18, 14, 7237, 2422, 8647, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SlimRoms/android_external_chromium_org
tools/site_compare/scrapers/firefox/firefox2.py
189
6725
#!/usr/bin/env python # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Does scraping for Firefox 2.0.""" import pywintypes import time import types from drivers import keyboard from drivers import mouse from drivers import windowing # Default version version = "2.0.0.6" DEFAULT_PATH = r"c:\program files\mozilla firefox\firefox.exe" # TODO(jhaas): the Firefox scraper is a bit rickety at the moment. Known # issues: 1) won't work if the default profile puts toolbars in different # locations, 2) uses sleep() statements rather than more robust checks, # 3) fails badly if an existing Firefox window is open when the scrape # is invoked. This needs to be fortified at some point. def GetBrowser(path): """Invoke the Firefox browser and return the process and window. Args: path: full path to browser Returns: A tuple of (process handle, render pane) """ if not path: path = DEFAULT_PATH # Invoke Firefox (proc, wnd) = windowing.InvokeAndWait(path) # Get the content pane render_pane = windowing.FindChildWindow( wnd, "MozillaWindowClass/MozillaWindowClass/MozillaWindowClass") return (proc, wnd, render_pane) def InvokeBrowser(path): """Invoke the Firefox browser. Args: path: full path to browser Returns: A tuple of (main window, process handle, render pane) """ # Reuse an existing instance of the browser if we can find one. This # may not work correctly, especially if the window is behind other windows. wnds = windowing.FindChildWindows(0, "MozillaUIWindowClass") if len(wnds): wnd = wnds[0] proc = None else: # Invoke Firefox (proc, wnd) = windowing.InvokeAndWait(path) # Get the content pane render_pane = windowing.FindChildWindow( wnd, "MozillaWindowClass/MozillaWindowClass/MozillaWindowClass") return (wnd, proc, render_pane) def Scrape(urls, outdir, size, pos, timeout=20, **kwargs): """Invoke a browser, send it to a series of URLs, and save its output. Args: urls: list of URLs to scrape outdir: directory to place output size: size of browser window to use pos: position of browser window timeout: amount of time to wait for page to load kwargs: miscellaneous keyword args Returns: None if success, else an error string """ if "path" in kwargs and kwargs["path"]: path = kwargs["path"] else: path = DEFAULT_PATH (wnd, proc, render_pane) = InvokeBrowser(path) # Resize and reposition the frame windowing.MoveAndSizeWindow(wnd, pos, size, render_pane) time.sleep(3) # Firefox is a bit of a pain: it doesn't use standard edit controls, # and it doesn't display a throbber when there's no tab. Let's make # sure there's at least one tab, then select the first one mouse.ClickInWindow(wnd) keyboard.TypeString("[t]", True) mouse.ClickInWindow(wnd, (30, 115)) time.sleep(2) timedout = False # Visit each URL we're given if type(urls) in types.StringTypes: urls = [urls] for url in urls: # Use keyboard shortcuts keyboard.TypeString("{d}", True) keyboard.TypeString(url) keyboard.TypeString("\n") # Wait for the page to finish loading load_time = windowing.WaitForThrobber(wnd, (10, 96, 26, 112), timeout) timedout = load_time < 0 if timedout: break # Scrape the page image = windowing.ScrapeWindow(render_pane) # Save to disk if "filename" in kwargs: if callable(kwargs["filename"]): filename = kwargs["filename"](url) else: filename = kwargs["filename"] else: filename = windowing.URLtoFilename(url, outdir, ".bmp") image.save(filename) # Close all the tabs, cheesily mouse.ClickInWindow(wnd) while len(windowing.FindChildWindows(0, "MozillaUIWindowClass")): keyboard.TypeString("[w]", True) time.sleep(1) if timedout: return "timeout" def Time(urls, size, timeout, **kwargs): """Measure how long it takes to load each of a series of URLs Args: urls: list of URLs to time size: size of browser window to use timeout: amount of time to wait for page to load kwargs: miscellaneous keyword args Returns: A list of tuples (url, time). "time" can be "crashed" or "timeout" """ if "path" in kwargs and kwargs["path"]: path = kwargs["path"] else: path = DEFAULT_PATH proc = None # Visit each URL we're given if type(urls) in types.StringTypes: urls = [urls] ret = [] for url in urls: try: # Invoke the browser if necessary if not proc: (wnd, proc, render_pane) = InvokeBrowser(path) # Resize and reposition the frame windowing.MoveAndSizeWindow(wnd, (0,0), size, render_pane) time.sleep(3) # Firefox is a bit of a pain: it doesn't use standard edit controls, # and it doesn't display a throbber when there's no tab. Let's make # sure there's at least one tab, then select the first one mouse.ClickInWindow(wnd) keyboard.TypeString("[t]", True) mouse.ClickInWindow(wnd, (30, 115)) time.sleep(2) # Use keyboard shortcuts keyboard.TypeString("{d}", True) keyboard.TypeString(url) keyboard.TypeString("\n") # Wait for the page to finish loading load_time = windowing.WaitForThrobber(wnd, (10, 96, 26, 112), timeout) timedout = load_time < 0 if timedout: load_time = "timeout" # Try to close the browser; if this fails it's probably a crash mouse.ClickInWindow(wnd) count = 0 while (len(windowing.FindChildWindows(0, "MozillaUIWindowClass")) and count < 5): keyboard.TypeString("[w]", True) time.sleep(1) count = count + 1 if len(windowing.FindChildWindows(0, "MozillaUIWindowClass")): windowing.EndProcess(proc) load_time = "crashed" proc = None except pywintypes.error: proc = None load_time = "crashed" ret.append( (url, load_time) ) if proc: count = 0 while (len(windowing.FindChildWindows(0, "MozillaUIWindowClass")) and count < 5): keyboard.TypeString("[w]", True) time.sleep(1) count = count + 1 return ret def main(): # We're being invoked rather than imported, so run some tests path = r"c:\sitecompare\scrapes\Firefox\2.0.0.6" windowing.PreparePath(path) # Scrape three sites and save the results Scrape( ["http://www.microsoft.com", "http://www.google.com", "http://www.sun.com"], path, (1024, 768), (0, 0)) return 0 if __name__ == "__main__": sys.exit(main())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 6586, 4061, 1330, 316, 367, 24584, 499, 14, 16, 1041, 199, 199, 646, 1134, 27171, 199, 646, 900, 199, 646, 2943, 199, 199, 504, 19016, 492, 18716, 199, 504, 19016, 492, 12817, 199, 504, 19016, 492, 4353, 316, 199, 199, 3, 3758, 1015, 199, 1023, 275, 298, 18, 14, 16, 14, 16, 14, 22, 2, 199, 199, 3472, 63, 3243, 275, 519, 2, 67, 3427, 6815, 1584, 60, 12102, 8344, 9849, 60, 15394, 14, 5803, 2, 199, 199, 3, 3254, 8, 74, 2411, 305, 304, 314, 24584, 21435, 365, 282, 4546, 8012, 21531, 369, 737, 314, 12427, 14, 31862, 199, 3, 10876, 26, 413, 9, 7859, 1133, 1736, 340, 314, 849, 4690, 27000, 4744, 16264, 315, 3365, 199, 3, 9918, 12, 499, 9, 4440, 9435, 342, 9834, 7830, 2419, 1655, 23399, 5920, 12, 199, 3, 650, 9, 6918, 4875, 590, 340, 376, 3411, 24584, 4353, 365, 1551, 1380, 314, 10328, 321, 199, 3, 365, 10302, 14, 961, 4839, 370, 506, 367, 8981, 737, 2005, 2376, 14, 199, 199, 318, 2372, 11930, 8, 515, 304, 523, 408, 27736, 314, 24584, 7042, 436, 372, 314, 2112, 436, 4353, 14, 819, 3033, 26, 272, 931, 26, 2615, 931, 370, 7042, 819, 1803, 26, 272, 437, 2008, 402, 334, 1412, 2429, 12, 3795, 299, 5865, 9, 523, 408, 523, 340, 440, 931, 26, 931, 275, 6186, 63, 3243, 819, 327, 31049, 24584, 523, 334, 4687, 12, 336, 977, 9, 275, 4353, 316, 14, 27736, 3325, 7536, 8, 515, 9, 819, 327, 2372, 314, 1564, 299, 5865, 523, 3795, 63, 29092, 275, 4353, 316, 14, 6591, 3493, 4301, 8, 272, 336, 977, 12, 272, 298, 22285, 4301, 2543, 15, 22285, 4301, 2543, 15, 22285, 4301, 2543, 531, 819, 372, 334, 4687, 12, 336, 977, 12, 3795, 63, 29092, 9, 421, 199, 318, 31049, 11930, 8, 515, 304, 523, 408, 27736, 314, 24584, 7042, 14, 819, 3033, 26, 272, 931, 26, 2615, 931, 370, 7042, 819, 1803, 26, 272, 437, 2008, 402, 334, 973, 4353, 12, 2112, 2429, 12, 3795, 299, 5865, 9, 523, 408, 523, 327, 799, 1180, 376, 3411, 1256, 402, 314, 7042, 340, 781, 883, 2342, 1373, 14, 961, 523, 327, 1443, 440, 1736, 6657, 12, 24002, 340, 314, 4353, 365, 22172, 1163, 10061, 14, 523, 336, 78, 795, 275, 4353, 316, 14, 6591, 3493, 8647, 8, 16, 12, 298, 22285, 6379, 4301, 2543, 531, 523, 340, 822, 8, 3501, 795, 304, 272, 336, 977, 275, 336, 78, 795, 59, 16, 61, 272, 6499, 275, 488, 523, 587, 26, 272, 327, 31049, 24584, 272, 334, 4687, 12, 336, 977, 9, 275, 4353, 316, 14, 27736, 3325, 7536, 8, 515, 9, 819, 327, 2372, 314, 1564, 299, 5865, 523, 3795, 63, 29092, 275, 4353, 316, 14, 6591, 3493, 4301, 8, 272, 336, 977, 12, 272, 298, 22285, 4301, 2543, 15, 22285, 4301, 2543, 15, 22285, 4301, 2543, 531, 819, 372, 334, 87, 977, 12, 6499, 12, 3795, 63, 29092, 9, 421, 199, 318, 13916, 345, 321, 8, 3603, 12, 24670, 12, 1568, 12, 2086, 12, 2653, 29, 1165, 12, 1011, 958, 304, 523, 408, 27736, 282, 7042, 12, 3222, 652, 370, 282, 6779, 402, 10867, 12, 436, 3354, 2399, 1072, 14, 819, 3033, 26, 272, 8187, 26, 769, 402, 10867, 370, 10328, 321, 272, 24670, 26, 2082, 370, 4192, 1072, 272, 1568, 26, 1568, 402, 7042, 4353, 370, 675, 272, 2086, 26, 3421, 402, 7042, 4353, 272, 2653, 26, 5982, 402, 900, 370, 3618, 367, 2034, 370, 2248, 272, 2074, 26, 3201, 19549, 4252, 1249, 819, 1803, 26, 272, 488, 340, 3182, 12, 587, 376, 1125, 1059, 523, 408, 523, 340, 298, 515, 2, 315, 2074, 436, 2074, 905, 515, 6229, 931, 275, 2074, 905, 515, 937, 523, 587, 26, 931, 275, 6186, 63, 3243, 819, 334, 87, 977, 12, 6499, 12, 3795, 63, 29092, 9, 275, 31049, 11930, 8, 515, 9, 819, 327, 799, 890, 436, 295, 3124, 314, 2787, 523, 4353, 316, 14, 10370, 3325, 2320, 4301, 8, 87, 977, 12, 2086, 12, 1568, 12, 3795, 63, 29092, 9, 819, 900, 14, 4532, 8, 19, 9, 819, 327, 24584, 365, 282, 4546, 402, 282, 691, 262, 26, 652, 3181, 1133, 675, 4465, 5283, 13467, 12, 523, 327, 436, 652, 3181, 1133, 2929, 282, 294, 29891, 605, 1380, 2337, 1159, 949, 5174, 14, 12230, 1159, 1852, 523, 327, 3238, 2337, 1159, 737, 5210, 1373, 5174, 12, 2066, 3504, 314, 1642, 1373, 819, 12817, 14, 12040, 607, 4301, 8, 87, 977, 9, 523, 18716, 14, 804, 1558, 10994, 84, 11472, 715, 9, 523, 12817, 14, 12040, 607, 4301, 8, 87, 977, 12, 334, 1216, 12, 22560, 430, 523, 900, 14, 4532, 8, 18, 9, 819, 18590, 548, 275, 756, 819, 327, 29614, 1924, 2851, 781, 3984, 1627, 523, 340, 730, 8, 3603, 9, 315, 2943, 14, 1558, 4100, 26, 8187, 275, 359, 3603, 61, 819, 367, 1166, 315, 8187, 26, 339, 327, 3645, 18716, 3974, 12946, 272, 18716, 14, 804, 1558, 13076, 68, 10750, 715, 9, 272, 18716, 14, 804, 1558, 8, 633, 9, 272, 18716, 14, 804, 1558, 4582, 78, 531, 339, 327, 13144, 367, 314, 2034, 370, 9578, 8697, 272, 2248, 63, 521, 275, 4353, 316, 14, 21433, 2719, 29891, 605, 8, 87, 977, 12, 334, 709, 12, 15580, 12, 7875, 12, 20240, 395, 2653, 9, 272, 18590, 548, 275, 2248, 63, 521, 665, 378, 339, 340, 18590, 548, 26, 489, 2059, 339, 327, 13916, 345, 321, 314, 2034, 272, 1834, 275, 4353, 316, 14, 7181, 345, 321, 4301, 8, 3352, 63, 29092, 9, 339, 327, 11063, 370, 4543, 272, 340, 298, 1501, 2, 315, 2074, 26, 489, 340, 4550, 8, 958, 905, 1501, 21473, 267, 1788, 275, 2074, 905, 1501, 937, 8, 633, 9, 489, 587, 26, 267, 1788, 275, 2074, 905, 1501, 937, 272, 587, 26, 489, 1788, 275, 4353, 316, 14, 2632, 475, 8117, 8, 633, 12, 24670, 12, 3680, 22308, 531 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 7760, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 6586, 4061, 1330, 316, 367, 24584, 499, 14, 16, 1041, 199, 199, 646, 1134, 27171, 199, 646, 900, 199, 646, 2943, 199, 199, 504, 19016, 492, 18716, 199, 504, 19016, 492, 12817, 199, 504, 19016, 492, 4353, 316, 199, 199, 3, 3758, 1015, 199, 1023, 275, 298, 18, 14, 16, 14, 16, 14, 22, 2, 199, 199, 3472, 63, 3243, 275, 519, 2, 67, 3427, 6815, 1584, 60, 12102, 8344, 9849, 60, 15394, 14, 5803, 2, 199, 199, 3, 3254, 8, 74, 2411, 305, 304, 314, 24584, 21435, 365, 282, 4546, 8012, 21531, 369, 737, 314, 12427, 14, 31862, 199, 3, 10876, 26, 413, 9, 7859, 1133, 1736, 340, 314, 849, 4690, 27000, 4744, 16264, 315, 3365, 199, 3, 9918, 12, 499, 9, 4440, 9435, 342, 9834, 7830, 2419, 1655, 23399, 5920, 12, 199, 3, 650, 9, 6918, 4875, 590, 340, 376, 3411, 24584, 4353, 365, 1551, 1380, 314, 10328, 321, 199, 3, 365, 10302, 14, 961, 4839, 370, 506, 367, 8981, 737, 2005, 2376, 14, 199, 199, 318, 2372, 11930, 8, 515, 304, 523, 408, 27736, 314, 24584, 7042, 436, 372, 314, 2112, 436, 4353, 14, 819, 3033, 26, 272, 931, 26, 2615, 931, 370, 7042, 819, 1803, 26, 272, 437, 2008, 402, 334, 1412, 2429, 12, 3795, 299, 5865, 9, 523, 408, 523, 340, 440, 931, 26, 931, 275, 6186, 63, 3243, 819, 327, 31049, 24584, 523, 334, 4687, 12, 336, 977, 9, 275, 4353, 316, 14, 27736, 3325, 7536, 8, 515, 9, 819, 327, 2372, 314, 1564, 299, 5865, 523, 3795, 63, 29092, 275, 4353, 316, 14, 6591, 3493, 4301, 8, 272, 336, 977, 12, 272, 298, 22285, 4301, 2543, 15, 22285, 4301, 2543, 15, 22285, 4301, 2543, 531, 819, 372, 334, 4687, 12, 336, 977, 12, 3795, 63, 29092, 9, 421, 199, 318, 31049, 11930, 8, 515, 304, 523, 408, 27736, 314, 24584, 7042, 14, 819, 3033, 26, 272, 931, 26, 2615, 931, 370, 7042, 819, 1803, 26, 272, 437, 2008, 402, 334, 973, 4353, 12, 2112, 2429, 12, 3795, 299, 5865, 9, 523, 408, 523, 327, 799, 1180, 376, 3411, 1256, 402, 314, 7042, 340, 781, 883, 2342, 1373, 14, 961, 523, 327, 1443, 440, 1736, 6657, 12, 24002, 340, 314, 4353, 365, 22172, 1163, 10061, 14, 523, 336, 78, 795, 275, 4353, 316, 14, 6591, 3493, 8647, 8, 16, 12, 298, 22285, 6379, 4301, 2543, 531, 523, 340, 822, 8, 3501, 795, 304, 272, 336, 977, 275, 336, 78, 795, 59, 16, 61, 272, 6499, 275, 488, 523, 587, 26, 272, 327, 31049, 24584, 272, 334, 4687, 12, 336, 977, 9, 275, 4353, 316, 14, 27736, 3325, 7536, 8, 515, 9, 819, 327, 2372, 314, 1564, 299, 5865, 523, 3795, 63, 29092, 275, 4353, 316, 14, 6591, 3493, 4301, 8, 272, 336, 977, 12, 272, 298, 22285, 4301, 2543, 15, 22285, 4301, 2543, 15, 22285, 4301, 2543, 531, 819, 372, 334, 87, 977, 12, 6499, 12, 3795, 63, 29092, 9, 421, 199, 318, 13916, 345, 321, 8, 3603, 12, 24670, 12, 1568, 12, 2086, 12, 2653, 29, 1165, 12, 1011, 958, 304, 523, 408, 27736, 282, 7042, 12, 3222, 652, 370, 282, 6779, 402, 10867, 12, 436, 3354, 2399, 1072, 14, 819, 3033, 26, 272, 8187, 26, 769, 402, 10867, 370, 10328, 321, 272, 24670, 26, 2082, 370, 4192, 1072, 272, 1568, 26, 1568, 402, 7042, 4353, 370, 675, 272, 2086, 26, 3421, 402, 7042, 4353, 272, 2653, 26, 5982, 402, 900, 370, 3618, 367, 2034, 370, 2248, 272, 2074, 26, 3201, 19549, 4252, 1249, 819, 1803, 26, 272, 488, 340, 3182, 12, 587, 376, 1125, 1059, 523, 408, 523, 340, 298, 515, 2, 315, 2074, 436, 2074, 905, 515, 6229, 931, 275, 2074, 905, 515, 937, 523, 587, 26, 931, 275, 6186, 63, 3243, 819, 334, 87, 977, 12, 6499, 12, 3795, 63, 29092, 9, 275, 31049, 11930, 8, 515, 9, 819, 327, 799, 890, 436, 295, 3124, 314, 2787, 523, 4353, 316, 14, 10370, 3325, 2320, 4301, 8, 87, 977, 12, 2086, 12, 1568, 12, 3795, 63, 29092, 9, 819, 900, 14, 4532, 8, 19, 9, 819, 327, 24584, 365, 282, 4546, 402, 282, 691, 262, 26, 652, 3181, 1133, 675, 4465, 5283, 13467, 12, 523, 327, 436, 652, 3181, 1133, 2929, 282, 294, 29891, 605, 1380, 2337, 1159, 949, 5174, 14, 12230, 1159, 1852, 523, 327, 3238, 2337, 1159, 737, 5210, 1373, 5174, 12, 2066, 3504, 314, 1642, 1373, 819, 12817, 14, 12040, 607, 4301, 8, 87, 977, 9, 523, 18716, 14, 804, 1558, 10994, 84, 11472, 715, 9, 523, 12817, 14, 12040, 607, 4301, 8, 87, 977, 12, 334, 1216, 12, 22560, 430, 523, 900, 14, 4532, 8, 18, 9, 819, 18590, 548, 275, 756, 819, 327, 29614, 1924, 2851, 781, 3984, 1627, 523, 340, 730, 8, 3603, 9, 315, 2943, 14, 1558, 4100, 26, 8187, 275, 359, 3603, 61, 819, 367, 1166, 315, 8187, 26, 339, 327, 3645, 18716, 3974, 12946, 272, 18716, 14, 804, 1558, 13076, 68, 10750, 715, 9, 272, 18716, 14, 804, 1558, 8, 633, 9, 272, 18716, 14, 804, 1558, 4582, 78, 531, 339, 327, 13144, 367, 314, 2034, 370, 9578, 8697, 272, 2248, 63, 521, 275, 4353, 316, 14, 21433, 2719, 29891, 605, 8, 87, 977, 12, 334, 709, 12, 15580, 12, 7875, 12, 20240, 395, 2653, 9, 272, 18590, 548, 275, 2248, 63, 521, 665, 378, 339, 340, 18590, 548, 26, 489, 2059, 339, 327, 13916, 345, 321, 314, 2034, 272, 1834, 275, 4353, 316, 14, 7181, 345, 321, 4301, 8, 3352, 63, 29092, 9, 339, 327, 11063, 370, 4543, 272, 340, 298, 1501, 2, 315, 2074, 26, 489, 340, 4550, 8, 958, 905, 1501, 21473, 267, 1788, 275, 2074, 905, 1501, 937, 8, 633, 9, 489, 587, 26, 267, 1788, 275, 2074, 905, 1501, 937, 272, 587, 26, 489, 1788, 275, 4353, 316, 14, 2632, 475, 8117, 8, 633, 12, 24670, 12, 3680, 22308, 531, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zachjanicki/osf.io
tests/framework_tests/test_email.py
26
2676
# -*- coding: utf-8 -*- import unittest import smtplib import mock from nose.tools import * # flake8: noqa (PEP8 asserts) import sendgrid from framework.email.tasks import send_email, _send_with_sendgrid from website import settings from tests.base import fake # Check if local mail server is running SERVER_RUNNING = True try: s = smtplib.SMTP(settings.MAIL_SERVER) s.quit() except Exception as err: SERVER_RUNNING = False class TestEmail(unittest.TestCase): @unittest.skipIf(not SERVER_RUNNING, "Mailserver isn't running. Run \"invoke mailserver\".") @unittest.skipIf(not settings.USE_EMAIL, "settings.USE_EMAIL is False") def test_sending_email(self): assert_true(send_email("foo@bar.com", "baz@quux.com", subject='no subject', message="<h1>Greetings!</h1>", ttls=False, login=False)) def test_send_with_sendgrid_success(self): mock_client = mock.MagicMock() mock_client.send.return_value = 200, 'success' from_addr, to_addr = fake.email(), fake.email() category1, category2 = fake.word(), fake.word() subject = fake.bs() message = fake.text() ret = _send_with_sendgrid( from_addr=from_addr, to_addr=to_addr, subject=subject, message=message, mimetype='txt', client=mock_client, categories=(category1, category2) ) assert_true(ret) assert_equal(mock_client.send.call_count, 1) # First call's argument should be a Mail object with # the correct configuration first_call_arg = mock_client.send.call_args[0][0] assert_is_instance(first_call_arg, sendgrid.Mail) assert_equal(first_call_arg.from_email, from_addr) assert_equal(first_call_arg.to[0], to_addr) assert_equal(first_call_arg.subject, subject) assert_equal(first_call_arg.text, message) # Categories are set assert_equal(first_call_arg.smtpapi.data['category'], (category1, category2)) def test_send_with_sendgrid_failure_returns_false(self): mock_client = mock.MagicMock() mock_client.send.return_value = 400, 'failed' from_addr, to_addr = fake.email(), fake.email() subject = fake.bs() message = fake.text() ret = _send_with_sendgrid( from_addr=from_addr, to_addr=to_addr, subject=subject, message=message, mimetype='txt', client=mock_client ) assert_false(ret) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 646, 30475, 199, 199, 646, 1683, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 27510, 24, 26, 8151, 334, 25633, 24, 702, 83, 9, 199, 646, 3222, 3825, 199, 199, 504, 10059, 14, 2123, 14, 5054, 492, 3222, 63, 2123, 12, 485, 2254, 63, 1045, 63, 2254, 3825, 199, 504, 10691, 492, 2202, 199, 504, 2295, 14, 1095, 492, 4026, 199, 199, 3, 2670, 340, 2257, 6016, 1654, 365, 3879, 199, 6613, 63, 17305, 275, 715, 199, 893, 26, 272, 308, 275, 30475, 14, 20927, 8, 1751, 14, 8175, 63, 6613, 9, 272, 308, 14, 10589, 342, 199, 2590, 2186, 465, 2329, 26, 272, 23578, 63, 17305, 275, 756, 421, 199, 533, 1379, 7035, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 1397, 23578, 63, 17305, 12, 2151, 298, 13681, 1000, 5712, 1133, 3879, 14, 3378, 8441, 15195, 6016, 1000, 60, 1674, 531, 272, 768, 2796, 14, 15118, 8, 1397, 2202, 14, 4701, 63, 10089, 12, 2151, 298, 1751, 14, 4701, 63, 10089, 365, 756, 531, 272, 347, 511, 63, 24450, 63, 2123, 8, 277, 304, 267, 702, 63, 2052, 8, 2254, 63, 2123, 480, 1421, 32, 1700, 14, 957, 401, 298, 6185, 32, 32050, 14, 957, 401, 5420, 534, 889, 5420, 297, 639, 1245, 28066, 72, 17, 30, 39, 7936, 780, 28718, 72, 17, 7166, 307, 9945, 29, 797, 12, 4676, 29, 797, 430, 339, 347, 511, 63, 2254, 63, 1045, 63, 2254, 3825, 63, 3742, 8, 277, 304, 267, 1683, 63, 1258, 275, 1683, 14, 11988, 342, 267, 1683, 63, 1258, 14, 2254, 14, 1107, 63, 585, 275, 1926, 12, 283, 3742, 7, 267, 687, 63, 2697, 12, 370, 63, 2697, 275, 4026, 14, 2123, 1062, 4026, 14, 2123, 342, 267, 4637, 17, 12, 4637, 18, 275, 4026, 14, 1027, 1062, 4026, 14, 1027, 342, 267, 5420, 275, 4026, 14, 1533, 342, 267, 1245, 275, 4026, 14, 505, 342, 267, 2203, 275, 485, 2254, 63, 1045, 63, 2254, 3825, 8, 288, 687, 63, 2697, 29, 504, 63, 2697, 12, 288, 370, 63, 2697, 29, 475, 63, 2697, 12, 288, 5420, 29, 5875, 12, 288, 1245, 29, 1188, 12, 288, 12200, 534, 2424, 297, 288, 1890, 29, 1805, 63, 1258, 12, 288, 9695, 2687, 3710, 17, 12, 4637, 18, 9, 267, 776, 267, 702, 63, 2052, 8, 3292, 9, 398, 702, 63, 1452, 8, 1805, 63, 1258, 14, 2254, 14, 1250, 63, 835, 12, 413, 9, 267, 327, 7758, 1240, 1159, 1423, 1077, 506, 282, 18027, 909, 543, 267, 327, 314, 3211, 2897, 267, 1642, 63, 1250, 63, 1273, 275, 1683, 63, 1258, 14, 2254, 14, 1250, 63, 589, 59, 16, 1527, 16, 61, 267, 702, 63, 374, 63, 842, 8, 2246, 63, 1250, 63, 1273, 12, 3222, 3825, 14, 13681, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 504, 63, 2123, 12, 687, 63, 2697, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 475, 59, 16, 467, 370, 63, 2697, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 5875, 12, 5420, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 505, 12, 1245, 9, 267, 327, 23995, 6112, 787, 663, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 83, 2037, 387, 1038, 14, 576, 459, 3710, 995, 334, 3710, 17, 12, 4637, 18, 430, 339, 347, 511, 63, 2254, 63, 1045, 63, 2254, 3825, 63, 5328, 63, 5808, 63, 3910, 8, 277, 304, 267, 1683, 63, 1258, 275, 1683, 14, 11988, 342, 267, 1683, 63, 1258, 14, 2254, 14, 1107, 63, 585, 275, 8290, 12, 283, 4892, 7, 267, 687, 63, 2697, 12, 370, 63, 2697, 275, 4026, 14, 2123, 1062, 4026, 14, 2123, 342, 267, 5420, 275, 4026, 14, 1533, 342, 267, 1245, 275, 4026, 14, 505, 342, 267, 2203, 275, 485, 2254, 63, 1045, 63, 2254, 3825, 8, 288, 687, 63, 2697, 29, 504, 63, 2697, 12, 288, 370, 63, 2697, 29, 475, 63, 2697, 12, 288, 5420, 29, 5875, 12, 288, 1245, 29, 1188, 12, 288, 12200, 534, 2424, 297, 288, 1890, 29, 1805, 63, 1258, 267, 776, 267, 702, 63, 3910, 8, 3292, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 646, 30475, 199, 199, 646, 1683, 199, 504, 11354, 14, 2537, 492, 627, 221, 327, 27510, 24, 26, 8151, 334, 25633, 24, 702, 83, 9, 199, 646, 3222, 3825, 199, 199, 504, 10059, 14, 2123, 14, 5054, 492, 3222, 63, 2123, 12, 485, 2254, 63, 1045, 63, 2254, 3825, 199, 504, 10691, 492, 2202, 199, 504, 2295, 14, 1095, 492, 4026, 199, 199, 3, 2670, 340, 2257, 6016, 1654, 365, 3879, 199, 6613, 63, 17305, 275, 715, 199, 893, 26, 272, 308, 275, 30475, 14, 20927, 8, 1751, 14, 8175, 63, 6613, 9, 272, 308, 14, 10589, 342, 199, 2590, 2186, 465, 2329, 26, 272, 23578, 63, 17305, 275, 756, 421, 199, 533, 1379, 7035, 8, 2796, 14, 1746, 304, 339, 768, 2796, 14, 15118, 8, 1397, 23578, 63, 17305, 12, 2151, 298, 13681, 1000, 5712, 1133, 3879, 14, 3378, 8441, 15195, 6016, 1000, 60, 1674, 531, 272, 768, 2796, 14, 15118, 8, 1397, 2202, 14, 4701, 63, 10089, 12, 2151, 298, 1751, 14, 4701, 63, 10089, 365, 756, 531, 272, 347, 511, 63, 24450, 63, 2123, 8, 277, 304, 267, 702, 63, 2052, 8, 2254, 63, 2123, 480, 1421, 32, 1700, 14, 957, 401, 298, 6185, 32, 32050, 14, 957, 401, 5420, 534, 889, 5420, 297, 639, 1245, 28066, 72, 17, 30, 39, 7936, 780, 28718, 72, 17, 7166, 307, 9945, 29, 797, 12, 4676, 29, 797, 430, 339, 347, 511, 63, 2254, 63, 1045, 63, 2254, 3825, 63, 3742, 8, 277, 304, 267, 1683, 63, 1258, 275, 1683, 14, 11988, 342, 267, 1683, 63, 1258, 14, 2254, 14, 1107, 63, 585, 275, 1926, 12, 283, 3742, 7, 267, 687, 63, 2697, 12, 370, 63, 2697, 275, 4026, 14, 2123, 1062, 4026, 14, 2123, 342, 267, 4637, 17, 12, 4637, 18, 275, 4026, 14, 1027, 1062, 4026, 14, 1027, 342, 267, 5420, 275, 4026, 14, 1533, 342, 267, 1245, 275, 4026, 14, 505, 342, 267, 2203, 275, 485, 2254, 63, 1045, 63, 2254, 3825, 8, 288, 687, 63, 2697, 29, 504, 63, 2697, 12, 288, 370, 63, 2697, 29, 475, 63, 2697, 12, 288, 5420, 29, 5875, 12, 288, 1245, 29, 1188, 12, 288, 12200, 534, 2424, 297, 288, 1890, 29, 1805, 63, 1258, 12, 288, 9695, 2687, 3710, 17, 12, 4637, 18, 9, 267, 776, 267, 702, 63, 2052, 8, 3292, 9, 398, 702, 63, 1452, 8, 1805, 63, 1258, 14, 2254, 14, 1250, 63, 835, 12, 413, 9, 267, 327, 7758, 1240, 1159, 1423, 1077, 506, 282, 18027, 909, 543, 267, 327, 314, 3211, 2897, 267, 1642, 63, 1250, 63, 1273, 275, 1683, 63, 1258, 14, 2254, 14, 1250, 63, 589, 59, 16, 1527, 16, 61, 267, 702, 63, 374, 63, 842, 8, 2246, 63, 1250, 63, 1273, 12, 3222, 3825, 14, 13681, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 504, 63, 2123, 12, 687, 63, 2697, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 475, 59, 16, 467, 370, 63, 2697, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 5875, 12, 5420, 9, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 505, 12, 1245, 9, 267, 327, 23995, 6112, 787, 663, 267, 702, 63, 1452, 8, 2246, 63, 1250, 63, 1273, 14, 83, 2037, 387, 1038, 14, 576, 459, 3710, 995, 334, 3710, 17, 12, 4637, 18, 430, 339, 347, 511, 63, 2254, 63, 1045, 63, 2254, 3825, 63, 5328, 63, 5808, 63, 3910, 8, 277, 304, 267, 1683, 63, 1258, 275, 1683, 14, 11988, 342, 267, 1683, 63, 1258, 14, 2254, 14, 1107, 63, 585, 275, 8290, 12, 283, 4892, 7, 267, 687, 63, 2697, 12, 370, 63, 2697, 275, 4026, 14, 2123, 1062, 4026, 14, 2123, 342, 267, 5420, 275, 4026, 14, 1533, 342, 267, 1245, 275, 4026, 14, 505, 342, 267, 2203, 275, 485, 2254, 63, 1045, 63, 2254, 3825, 8, 288, 687, 63, 2697, 29, 504, 63, 2697, 12, 288, 370, 63, 2697, 29, 475, 63, 2697, 12, 288, 5420, 29, 5875, 12, 288, 1245, 29, 1188, 12, 288, 12200, 534, 2424, 297, 288, 1890, 29, 1805, 63, 1258, 267, 776, 267, 702, 63, 3910, 8, 3292, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
edx/edx-platform
openedx/features/course_experience/__init__.py
3
6887
""" Unified course experience settings and helper methods. """ import crum from django.utils.translation import ugettext as _ from edx_django_utils.monitoring import set_custom_attribute from waffle import flag_is_active # lint-amnesty, pylint: disable=invalid-django-waffle-import from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace from openedx.core.djangoapps.util.user_messages import UserMessageCollection from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag # Namespace for course experience waffle flags. WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='course_experience') COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='course_experience') # Waffle flag to disable the separate course outline page and full width content. DISABLE_COURSE_OUTLINE_PAGE_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE, 'disable_course_outline_page', __name__ ) # Waffle flag to enable a single unified "Course" tab. DISABLE_UNIFIED_COURSE_TAB_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE, 'disable_unified_course_tab', __name__ ) # Waffle flag to enable the sock on the footer of the home and courseware pages. DISPLAY_COURSE_SOCK_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'display_course_sock', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # Waffle flag to let learners access a course before its start date. COURSE_PRE_START_ACCESS_FLAG = LegacyWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'pre_start_access', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # .. toggle_name: course_experience.enable_course_goals # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: Used to determine whether or not to use course goals for the particular course. # .. toggle_use_cases: opt_out, temporary # .. toggle_creation_date: 2017-09-11 # .. toggle_target_removal_date: None # .. toggle_warnings: This temporary feature toggle does not have a target removal date. ENABLE_COURSE_GOALS = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'enable_course_goals', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # Waffle flag to control the display of the hero SHOW_UPGRADE_MSG_ON_COURSE_HOME = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'show_upgrade_msg_on_course_home', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # Waffle flag to control the display of the upgrade deadline message UPGRADE_DEADLINE_MESSAGE = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'upgrade_deadline_message', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # .. toggle_name: course_experience.latest_update # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: Used to switch between 'welcome message' and 'latest update' on the course home page. # .. toggle_use_cases: opt_out, temporary # .. toggle_creation_date: 2017-09-11 # .. toggle_target_removal_date: None # .. toggle_warnings: This is meant to be configured using waffle_utils course override only. Either do not create the # actual waffle flag, or be sure to unset the flag even for Superusers. This is no longer used in the learning MFE # and can be removed when the outline tab is fully moved to the learning MFE. LATEST_UPDATE_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'latest_update', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # Waffle flag to enable anonymous access to a course SEO_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='seo') COURSE_ENABLE_UNENROLLED_ACCESS_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation SEO_WAFFLE_FLAG_NAMESPACE, 'enable_anonymous_courseware_access', __name__, ) # .. toggle_name: course_experience.relative_dates # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: Waffle flag to enable relative dates for course content. A 'Dates' tab will be visible in the # course view showing key course dates. Was previously an ExperimentWaffleFlag with experiment_id=17. # .. toggle_use_cases: opt_in # .. toggle_creation_date: 2020-02-10 # .. toggle_warnings: To set a relative due date for self-paced courses, the weeks_to_complete field for a course run # needs to be set. Currently it can be set through the publisher app. # .. toggle_tickets: https://openedx.atlassian.net/browse/AA-27 RELATIVE_DATES_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'relative_dates', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation # .. toggle_name: course_experience.calendar_sync # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: This course flag enables a course tool (which is a tool that is added on a course home page) # that sends course assignment calendars to course students, whenever they click on the "Subscribe to calendar # updates" button. The email contains an ics attachment that students can then use to sync with their own calendar # apps. # .. toggle_warnings: For this toggle to have an effect, the RELATIVE_DATES_FLAG toggle must be enabled, too. # .. toggle_use_cases: temporary # .. toggle_creation_date: 2021-01-26 # .. toggle_target_removal_date: 2021-04-26 # .. toggle_tickets: https://openedx.atlassian.net/browse/AA-36 CALENDAR_SYNC_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'calendar_sync', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation def course_home_page_title(course): # pylint: disable=unused-argument """ Returns the title for the course home page. """ return _('Course') def default_course_url_name(course_id): """ Returns the default course URL name for the current user. Arguments: course_id (CourseKey): The course id of the current course. """ if DISABLE_COURSE_OUTLINE_PAGE_FLAG.is_enabled(course_id): return 'courseware' return 'openedx.course_experience.course_home' def course_home_url_name(course_key): """ Returns the course home page's URL name for the current user. Arguments: course_key (CourseKey): The course key for which the home url is being requested. """ if DISABLE_UNIFIED_COURSE_TAB_FLAG.is_enabled(course_key): return 'info' return 'openedx.course_experience.course_home' class CourseHomeMessages(UserMessageCollection): """ This set of messages appear above the outline on the course home page. """ NAMESPACE = 'course_home_level_messages' @classmethod def get_namespace(cls): """ Returns the namespace of the message collection. """ return cls.NAMESPACE
agpl-3.0
[ 624, 199, 1358, 4541, 2518, 444, 24242, 2202, 436, 5922, 3102, 14, 199, 624, 199, 646, 2467, 453, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 22435, 63, 1176, 63, 1208, 14, 20554, 492, 663, 63, 4229, 63, 3215, 199, 504, 336, 9181, 274, 492, 3305, 63, 374, 63, 2682, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 3197, 13, 1176, 13, 758, 556, 274, 13, 646, 199, 199, 504, 22435, 63, 475, 2721, 2978, 14, 475, 2721, 2978, 492, 26251, 55, 9181, 274, 5318, 12, 26251, 55, 9181, 274, 5318, 8814, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1974, 14, 751, 63, 3431, 492, 2876, 2209, 7768, 199, 504, 22709, 14, 1018, 14, 16432, 14, 758, 556, 274, 63, 1208, 492, 5531, 55, 9181, 274, 5318, 199, 199, 3, 19317, 367, 2518, 444, 24242, 336, 9181, 274, 3285, 14, 199, 9004, 1665, 906, 63, 3719, 63, 13001, 275, 26251, 55, 9181, 274, 5318, 8814, 8, 354, 534, 1972, 63, 476, 24242, 358, 199, 199, 15552, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 275, 26251, 55, 9181, 274, 5318, 8814, 8, 354, 534, 1972, 63, 476, 24242, 358, 199, 199, 3, 644, 9181, 274, 3305, 370, 3507, 314, 7396, 2518, 17964, 2034, 436, 2615, 3462, 1564, 14, 199, 13052, 63, 15552, 63, 1877, 6174, 63, 12898, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 272, 5099, 14302, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 5993, 63, 1972, 63, 11550, 63, 1606, 297, 636, 354, 363, 199, 9, 199, 199, 3, 644, 9181, 274, 3305, 370, 4756, 282, 2849, 25344, 298, 6979, 2, 5174, 14, 199, 13052, 63, 1734, 31223, 63, 15552, 63, 10129, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 272, 5099, 14302, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 5993, 63, 32180, 63, 1972, 63, 2902, 297, 636, 354, 363, 199, 9, 199, 199, 3, 644, 9181, 274, 3305, 370, 4756, 314, 6771, 641, 314, 14178, 402, 314, 5629, 436, 20736, 6497, 14, 199, 20993, 63, 15552, 63, 9469, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 2918, 63, 1972, 63, 5096, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 4691, 12537, 1192, 2879, 282, 2518, 2544, 2399, 1343, 1434, 14, 199, 15552, 63, 4225, 63, 7363, 63, 11074, 63, 3719, 275, 26251, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 657, 63, 928, 63, 2732, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 2508, 19420, 63, 354, 26, 2518, 63, 476, 24242, 14, 4296, 63, 1972, 63, 30970, 199, 3, 2508, 19420, 63, 12236, 26, 5531, 55, 9181, 274, 5318, 199, 3, 2508, 19420, 63, 885, 26, 756, 199, 3, 2508, 19420, 63, 1802, 26, 8051, 370, 6705, 3775, 503, 440, 370, 675, 2518, 2621, 2551, 367, 314, 6770, 2518, 14, 199, 3, 2508, 19420, 63, 1180, 63, 9403, 26, 2450, 63, 548, 12, 7937, 199, 3, 2508, 19420, 63, 8782, 63, 602, 26, 9708, 13, 1643, 13, 845, 199, 3, 2508, 19420, 63, 1375, 63, 25818, 63, 602, 26, 488, 199, 3, 2508, 19420, 63, 5451, 26, 961, 7937, 3878, 19420, 1630, 440, 1172, 282, 1347, 20055, 1434, 14, 199, 8898, 63, 15552, 63, 13160, 748, 51, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 4296, 63, 1972, 63, 30970, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 3304, 314, 2929, 402, 314, 394, 3478, 199, 19085, 63, 2160, 28594, 63, 9740, 63, 615, 63, 15552, 63, 9524, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 2384, 63, 9375, 63, 1328, 63, 265, 63, 1972, 63, 4219, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 3304, 314, 2929, 402, 314, 10754, 23081, 1245, 199, 2160, 28594, 63, 29031, 6174, 63, 8272, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 9375, 63, 22357, 63, 1188, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 2508, 19420, 63, 354, 26, 2518, 63, 476, 24242, 14, 7410, 63, 873, 199, 3, 2508, 19420, 63, 12236, 26, 5531, 55, 9181, 274, 5318, 199, 3, 2508, 19420, 63, 885, 26, 756, 199, 3, 2508, 19420, 63, 1802, 26, 8051, 370, 6258, 3382, 283, 28508, 1245, 7, 436, 283, 7410, 1678, 7, 641, 314, 2518, 5629, 2034, 14, 199, 3, 2508, 19420, 63, 1180, 63, 9403, 26, 2450, 63, 548, 12, 7937, 199, 3, 2508, 19420, 63, 8782, 63, 602, 26, 9708, 13, 1643, 13, 845, 199, 3, 2508, 19420, 63, 1375, 63, 25818, 63, 602, 26, 488, 199, 3, 2508, 19420, 63, 5451, 26, 961, 365, 18329, 370, 506, 7526, 1808, 336, 9181, 274, 63, 1208, 2518, 4278, 1454, 14, 13083, 886, 440, 1218, 314, 199, 3, 257, 3503, 336, 9181, 274, 3305, 12, 503, 506, 3238, 370, 15376, 314, 3305, 2755, 367, 17897, 3707, 14, 961, 365, 949, 8088, 1202, 315, 314, 9328, 603, 5100, 199, 3, 257, 436, 883, 506, 4829, 1380, 314, 17964, 5174, 365, 9999, 12155, 370, 314, 9328, 603, 5100, 14, 199, 20307, 1719, 63, 10383, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906 ]
[ 199, 1358, 4541, 2518, 444, 24242, 2202, 436, 5922, 3102, 14, 199, 624, 199, 646, 2467, 453, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 22435, 63, 1176, 63, 1208, 14, 20554, 492, 663, 63, 4229, 63, 3215, 199, 504, 336, 9181, 274, 492, 3305, 63, 374, 63, 2682, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 3197, 13, 1176, 13, 758, 556, 274, 13, 646, 199, 199, 504, 22435, 63, 475, 2721, 2978, 14, 475, 2721, 2978, 492, 26251, 55, 9181, 274, 5318, 12, 26251, 55, 9181, 274, 5318, 8814, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1974, 14, 751, 63, 3431, 492, 2876, 2209, 7768, 199, 504, 22709, 14, 1018, 14, 16432, 14, 758, 556, 274, 63, 1208, 492, 5531, 55, 9181, 274, 5318, 199, 199, 3, 19317, 367, 2518, 444, 24242, 336, 9181, 274, 3285, 14, 199, 9004, 1665, 906, 63, 3719, 63, 13001, 275, 26251, 55, 9181, 274, 5318, 8814, 8, 354, 534, 1972, 63, 476, 24242, 358, 199, 199, 15552, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 275, 26251, 55, 9181, 274, 5318, 8814, 8, 354, 534, 1972, 63, 476, 24242, 358, 199, 199, 3, 644, 9181, 274, 3305, 370, 3507, 314, 7396, 2518, 17964, 2034, 436, 2615, 3462, 1564, 14, 199, 13052, 63, 15552, 63, 1877, 6174, 63, 12898, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 272, 5099, 14302, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 5993, 63, 1972, 63, 11550, 63, 1606, 297, 636, 354, 363, 199, 9, 199, 199, 3, 644, 9181, 274, 3305, 370, 4756, 282, 2849, 25344, 298, 6979, 2, 5174, 14, 199, 13052, 63, 1734, 31223, 63, 15552, 63, 10129, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 272, 5099, 14302, 63, 1438, 4227, 41, 6013, 63, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 5993, 63, 32180, 63, 1972, 63, 2902, 297, 636, 354, 363, 199, 9, 199, 199, 3, 644, 9181, 274, 3305, 370, 4756, 314, 6771, 641, 314, 14178, 402, 314, 5629, 436, 20736, 6497, 14, 199, 20993, 63, 15552, 63, 9469, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 2918, 63, 1972, 63, 5096, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 4691, 12537, 1192, 2879, 282, 2518, 2544, 2399, 1343, 1434, 14, 199, 15552, 63, 4225, 63, 7363, 63, 11074, 63, 3719, 275, 26251, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 657, 63, 928, 63, 2732, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 2508, 19420, 63, 354, 26, 2518, 63, 476, 24242, 14, 4296, 63, 1972, 63, 30970, 199, 3, 2508, 19420, 63, 12236, 26, 5531, 55, 9181, 274, 5318, 199, 3, 2508, 19420, 63, 885, 26, 756, 199, 3, 2508, 19420, 63, 1802, 26, 8051, 370, 6705, 3775, 503, 440, 370, 675, 2518, 2621, 2551, 367, 314, 6770, 2518, 14, 199, 3, 2508, 19420, 63, 1180, 63, 9403, 26, 2450, 63, 548, 12, 7937, 199, 3, 2508, 19420, 63, 8782, 63, 602, 26, 9708, 13, 1643, 13, 845, 199, 3, 2508, 19420, 63, 1375, 63, 25818, 63, 602, 26, 488, 199, 3, 2508, 19420, 63, 5451, 26, 961, 7937, 3878, 19420, 1630, 440, 1172, 282, 1347, 20055, 1434, 14, 199, 8898, 63, 15552, 63, 13160, 748, 51, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 4296, 63, 1972, 63, 30970, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 3304, 314, 2929, 402, 314, 394, 3478, 199, 19085, 63, 2160, 28594, 63, 9740, 63, 615, 63, 15552, 63, 9524, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 2384, 63, 9375, 63, 1328, 63, 265, 63, 1972, 63, 4219, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 644, 9181, 274, 3305, 370, 3304, 314, 2929, 402, 314, 10754, 23081, 1245, 199, 2160, 28594, 63, 29031, 6174, 63, 8272, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 63, 3719, 63, 13001, 12, 283, 9375, 63, 22357, 63, 1188, 297, 636, 354, 3368, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 13396, 13, 4752, 13, 9340, 199, 199, 3, 2508, 19420, 63, 354, 26, 2518, 63, 476, 24242, 14, 7410, 63, 873, 199, 3, 2508, 19420, 63, 12236, 26, 5531, 55, 9181, 274, 5318, 199, 3, 2508, 19420, 63, 885, 26, 756, 199, 3, 2508, 19420, 63, 1802, 26, 8051, 370, 6258, 3382, 283, 28508, 1245, 7, 436, 283, 7410, 1678, 7, 641, 314, 2518, 5629, 2034, 14, 199, 3, 2508, 19420, 63, 1180, 63, 9403, 26, 2450, 63, 548, 12, 7937, 199, 3, 2508, 19420, 63, 8782, 63, 602, 26, 9708, 13, 1643, 13, 845, 199, 3, 2508, 19420, 63, 1375, 63, 25818, 63, 602, 26, 488, 199, 3, 2508, 19420, 63, 5451, 26, 961, 365, 18329, 370, 506, 7526, 1808, 336, 9181, 274, 63, 1208, 2518, 4278, 1454, 14, 13083, 886, 440, 1218, 314, 199, 3, 257, 3503, 336, 9181, 274, 3305, 12, 503, 506, 3238, 370, 15376, 314, 3305, 2755, 367, 17897, 3707, 14, 961, 365, 949, 8088, 1202, 315, 314, 9328, 603, 5100, 199, 3, 257, 436, 883, 506, 4829, 1380, 314, 17964, 5174, 365, 9999, 12155, 370, 314, 9328, 603, 5100, 14, 199, 20307, 1719, 63, 10383, 63, 3719, 275, 5531, 55, 9181, 274, 5318, 8, 9004, 1665, 906, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
eagle00789/PythonMiniProbe
miniprobe/miniprobe.py
2
5761
#!/usr/bin/env python # Copyright (c) 2014, Paessler AG <support@paessler.com> # All rights reserved. # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the # following conditions are met: # 1. Redistributions of source code must retain the above copyright notice, this list of conditions # and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions # and the following disclaimer in the documentation and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse # or promote products derived from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # PRTG Python Miniprobe # Miniprobe needs at least Python 2.7 because of "importlib" # If older python version is used you will have to install "importlib" # import general modules import sys import hashlib import importlib import gc import logging import subprocess import os # import own modules sys.path.append('./') try: import sensors except Exception as e: print e class MiniProbe(object): """ Main class for the Python Mini Probe """ def __init__(self): gc.enable() logging.basicConfig( filename="./logs/probe.log", filemode="a", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s", datefmt='%m/%d/%Y %H:%M:%S' ) def get_import_sensors(self): """ import available sensor modules and return list of sensor objects """ sensor_objects = [] for mod in sensors.__all__: try: sensor_objects.append(self.load_class("sensors.%s.%s" % (mod.lower(), mod))) except Exception as import_error: logging.error("Sensor Import Error! Error message: %s" % import_error) return sensor_objects @staticmethod def load_class(full_class_string): """ dynamically load a class from a string """ class_data = full_class_string.split(".") module_path = ".".join(class_data[:-1]) class_str = class_data[-1] module = importlib.import_module(module_path) return getattr(module, class_str) def read_config(self, path): """ read configuration file and write data to dict """ config = {} try: conf_file = open(path) for line in conf_file: if not (line == '\n'): if not (line.startswith('#')): config[line.split(':')[0]] = line.split(':')[1].rstrip() conf_file.close() return config except Exception as read_error: logging.error("No config found! Error Message: %s Exiting!" % read_error) sys.exit() @staticmethod def hash_access_key(key): """ create hash of probes access key """ return hashlib.sha1(key).hexdigest() def create_parameters(self, config, jsondata, i=None): """ create URL parameters for announce, task and data requests """ if i == 'announce': return {'gid': config['gid'], 'key': self.hash_access_key(config['key']), 'protocol': config['protocol'], 'name': config['name'], 'baseinterval': config['baseinterval'], 'sensors': jsondata} else: return {'gid': config['gid'], 'key': self.hash_access_key(config['key']), 'protocol': config['protocol']} def create_url(self, config, i=None, http=False): """ creating the actual URL """ prefix = "https" if http: prefix = "http" if not (i is None) and (i != "data"): return "%s://%s:%s/probe/%s" % ( prefix, config['server'], config['port'], i) elif i == "data": return "%s://%s:%s/probe/%s?gid=%s&protocol=%s&key=%s" % (prefix, config['server'], config['port'], i, config['gid'], config['protocol'], self.hash_access_key(config['key'])) pass else: return "No method given" def build_announce(self, sensor_list): """ build json for announce request """ sensors_avail = [] for sensor in sensor_list: if not sensor.get_sensordef() == "": sensors_avail.append(sensor.get_sensordef()) return sensors_avail @staticmethod def clean_mem(): """Ugly brute force method to clean up Mem""" subprocess.call("sync", shell=False) os.popen("sysctl vm.drop_caches=1") os.popen("sysctl vm.drop_caches=2") os.popen("sysctl vm.drop_caches=3")
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6927, 12, 510, 3624, 385, 1435, 26787, 665, 4058, 32, 387, 16709, 1435, 14, 957, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 199, 3, 2569, 3704, 787, 7647, 26, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 199, 3, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 199, 3, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 199, 3, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 199, 3, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 199, 3, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 3, 12218, 6332, 2018, 24954, 15944, 199, 3, 24954, 15944, 4839, 737, 5210, 2018, 499, 14, 23, 2952, 402, 298, 25893, 2, 199, 3, 982, 12731, 2366, 1015, 365, 1202, 1265, 911, 1172, 370, 3907, 298, 25893, 2, 199, 199, 3, 492, 8605, 4621, 199, 646, 984, 199, 646, 8337, 199, 646, 14802, 199, 646, 9486, 199, 646, 2050, 199, 646, 3873, 199, 646, 747, 199, 199, 3, 492, 5705, 4621, 199, 1274, 14, 515, 14, 740, 5175, 6217, 199, 199, 893, 26, 272, 492, 19678, 199, 2590, 2186, 465, 325, 26, 272, 870, 325, 421, 199, 533, 24954, 16939, 8, 785, 304, 272, 408, 272, 11298, 1021, 367, 314, 2018, 24954, 2165, 1235, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 9486, 14, 4296, 342, 267, 2050, 14, 19602, 8, 288, 1788, 628, 13186, 7270, 15, 15944, 14, 793, 401, 288, 32429, 628, 65, 401, 288, 2166, 29, 4806, 14, 4531, 12, 288, 1475, 17662, 18331, 9, 83, 446, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 401, 288, 1434, 5045, 9569, 77, 3149, 68, 3149, 57, 450, 40, 2689, 45, 2689, 51, 7, 267, 776, 339, 347, 664, 63, 646, 63, 22675, 8, 277, 304, 267, 408, 267, 492, 2808, 8778, 4621, 436, 372, 769, 402, 8778, 2251, 267, 408, 267, 8778, 63, 1462, 275, 942, 267, 367, 3413, 315, 19678, 855, 452, 10651, 288, 862, 26, 355, 8778, 63, 1462, 14, 740, 8, 277, 14, 912, 63, 533, 480, 22675, 4111, 83, 4111, 83, 2, 450, 334, 1494, 14, 2325, 1062, 3413, 1724, 288, 871, 2186, 465, 492, 63, 705, 26, 355, 2050, 14, 705, 480, 10160, 3161, 4520, 1, 4520, 1245, 26, 450, 83, 2, 450, 492, 63, 705, 9, 267, 372, 8778, 63, 1462, 339, 768, 4639, 272, 347, 2248, 63, 533, 8, 2861, 63, 533, 63, 875, 304, 267, 408, 267, 18774, 2248, 282, 1021, 687, 282, 1059, 267, 408, 267, 1021, 63, 576, 275, 2615, 63, 533, 63, 875, 14, 1294, 15857, 267, 859, 63, 515, 275, 32443, 904, 8, 533, 63, 576, 4439, 17, 566, 267, 1021, 63, 495, 275, 1021, 63, 576, 1988, 17, 61, 267, 859, 275, 14802, 14, 646, 63, 578, 8, 578, 63, 515, 9, 267, 372, 2519, 8, 578, 12, 1021, 63, 495, 9, 339, 347, 1586, 63, 888, 8, 277, 12, 931, 304, 267, 408, 267, 1586, 2897, 570, 436, 2218, 666, 370, 1211, 267, 408, 267, 1101, 275, 1052, 267, 862, 26, 288, 3743, 63, 493, 275, 1551, 8, 515, 9, 288, 367, 1004, 315, 3743, 63, 493, 26, 355, 340, 440, 334, 604, 508, 1557, 78, 735, 490, 340, 440, 334, 604, 14, 2460, 7863, 8109, 717, 1101, 59, 604, 14, 1294, 24050, 16, 2677, 275, 1004, 14, 1294, 24050, 17, 1055, 6735, 342, 288, 3743, 63, 493, 14, 1600, 342, 288, 372, 1101, 267, 871, 2186, 465, 1586, 63, 705, 26, 288, 2050, 14, 705, 480, 1944, 1101, 1911, 1, 4520, 6430, 26, 450, 83, 18704, 316, 9539, 450, 1586, 63, 705, 9, 288, 984, 14, 2224, 342, 339, 768, 4639, 272, 347, 2631, 63, 2732, 63, 498, 8, 498, 304, 267, 408, 267, 1218, 2631, 402, 5128, 397, 2879, 790, 267, 408, 267, 372, 8337, 14, 4835, 17, 8, 498, 680, 11453, 342, 339, 347, 1218, 63, 3214, 8, 277, 12, 1101, 12, 2022, 576, 12, 284, 29, 403, 304, 267, 408, 267, 1218, 2851, 2633, 367, 28136, 12, 2120, 436, 666, 4145, 267, 408, 267, 340, 284, 508, 283, 17803, 356, 288, 372, 791, 8787, 356, 1101, 459, 8787, 995, 283, 498, 356, 291, 14, 2227, 63, 2732, 63, 498, 8, 888, 459, 498, 3815, 283, 3922, 356, 1101, 459, 3922, 995, 490, 283, 354, 356, 1101, 459, 354, 995, 283, 1095, 4284, 356, 1101, 459, 1095, 4284, 995, 283, 22675, 356, 2022, 576, 93, 267, 587, 26, 288, 372, 791, 8787, 356, 1101, 459, 8787, 995, 283, 498, 356, 291, 14, 2227, 63, 2732, 63, 498, 8, 888, 459, 498, 3815, 283, 3922, 356, 1101, 459, 3922, 12074, 339, 347, 1218, 63, 633, 8, 277, 12, 1101, 12, 284, 29, 403, 12, 1455, 29, 797, 304, 267, 408, 267, 6425, 314, 3503, 2851, 267, 408, 267 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6927, 12, 510, 3624, 385, 1435, 26787, 665, 4058, 32, 387, 16709, 1435, 14, 957, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 199, 3, 2569, 3704, 787, 7647, 26, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 199, 3, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 199, 3, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 650, 14, 11443, 314, 536, 402, 314, 4248, 16712, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 199, 3, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 199, 3, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 199, 3, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 199, 3, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 3, 12218, 6332, 2018, 24954, 15944, 199, 3, 24954, 15944, 4839, 737, 5210, 2018, 499, 14, 23, 2952, 402, 298, 25893, 2, 199, 3, 982, 12731, 2366, 1015, 365, 1202, 1265, 911, 1172, 370, 3907, 298, 25893, 2, 199, 199, 3, 492, 8605, 4621, 199, 646, 984, 199, 646, 8337, 199, 646, 14802, 199, 646, 9486, 199, 646, 2050, 199, 646, 3873, 199, 646, 747, 199, 199, 3, 492, 5705, 4621, 199, 1274, 14, 515, 14, 740, 5175, 6217, 199, 199, 893, 26, 272, 492, 19678, 199, 2590, 2186, 465, 325, 26, 272, 870, 325, 421, 199, 533, 24954, 16939, 8, 785, 304, 272, 408, 272, 11298, 1021, 367, 314, 2018, 24954, 2165, 1235, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 9486, 14, 4296, 342, 267, 2050, 14, 19602, 8, 288, 1788, 628, 13186, 7270, 15, 15944, 14, 793, 401, 288, 32429, 628, 65, 401, 288, 2166, 29, 4806, 14, 4531, 12, 288, 1475, 17662, 18331, 9, 83, 446, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 401, 288, 1434, 5045, 9569, 77, 3149, 68, 3149, 57, 450, 40, 2689, 45, 2689, 51, 7, 267, 776, 339, 347, 664, 63, 646, 63, 22675, 8, 277, 304, 267, 408, 267, 492, 2808, 8778, 4621, 436, 372, 769, 402, 8778, 2251, 267, 408, 267, 8778, 63, 1462, 275, 942, 267, 367, 3413, 315, 19678, 855, 452, 10651, 288, 862, 26, 355, 8778, 63, 1462, 14, 740, 8, 277, 14, 912, 63, 533, 480, 22675, 4111, 83, 4111, 83, 2, 450, 334, 1494, 14, 2325, 1062, 3413, 1724, 288, 871, 2186, 465, 492, 63, 705, 26, 355, 2050, 14, 705, 480, 10160, 3161, 4520, 1, 4520, 1245, 26, 450, 83, 2, 450, 492, 63, 705, 9, 267, 372, 8778, 63, 1462, 339, 768, 4639, 272, 347, 2248, 63, 533, 8, 2861, 63, 533, 63, 875, 304, 267, 408, 267, 18774, 2248, 282, 1021, 687, 282, 1059, 267, 408, 267, 1021, 63, 576, 275, 2615, 63, 533, 63, 875, 14, 1294, 15857, 267, 859, 63, 515, 275, 32443, 904, 8, 533, 63, 576, 4439, 17, 566, 267, 1021, 63, 495, 275, 1021, 63, 576, 1988, 17, 61, 267, 859, 275, 14802, 14, 646, 63, 578, 8, 578, 63, 515, 9, 267, 372, 2519, 8, 578, 12, 1021, 63, 495, 9, 339, 347, 1586, 63, 888, 8, 277, 12, 931, 304, 267, 408, 267, 1586, 2897, 570, 436, 2218, 666, 370, 1211, 267, 408, 267, 1101, 275, 1052, 267, 862, 26, 288, 3743, 63, 493, 275, 1551, 8, 515, 9, 288, 367, 1004, 315, 3743, 63, 493, 26, 355, 340, 440, 334, 604, 508, 1557, 78, 735, 490, 340, 440, 334, 604, 14, 2460, 7863, 8109, 717, 1101, 59, 604, 14, 1294, 24050, 16, 2677, 275, 1004, 14, 1294, 24050, 17, 1055, 6735, 342, 288, 3743, 63, 493, 14, 1600, 342, 288, 372, 1101, 267, 871, 2186, 465, 1586, 63, 705, 26, 288, 2050, 14, 705, 480, 1944, 1101, 1911, 1, 4520, 6430, 26, 450, 83, 18704, 316, 9539, 450, 1586, 63, 705, 9, 288, 984, 14, 2224, 342, 339, 768, 4639, 272, 347, 2631, 63, 2732, 63, 498, 8, 498, 304, 267, 408, 267, 1218, 2631, 402, 5128, 397, 2879, 790, 267, 408, 267, 372, 8337, 14, 4835, 17, 8, 498, 680, 11453, 342, 339, 347, 1218, 63, 3214, 8, 277, 12, 1101, 12, 2022, 576, 12, 284, 29, 403, 304, 267, 408, 267, 1218, 2851, 2633, 367, 28136, 12, 2120, 436, 666, 4145, 267, 408, 267, 340, 284, 508, 283, 17803, 356, 288, 372, 791, 8787, 356, 1101, 459, 8787, 995, 283, 498, 356, 291, 14, 2227, 63, 2732, 63, 498, 8, 888, 459, 498, 3815, 283, 3922, 356, 1101, 459, 3922, 995, 490, 283, 354, 356, 1101, 459, 354, 995, 283, 1095, 4284, 356, 1101, 459, 1095, 4284, 995, 283, 22675, 356, 2022, 576, 93, 267, 587, 26, 288, 372, 791, 8787, 356, 1101, 459, 8787, 995, 283, 498, 356, 291, 14, 2227, 63, 2732, 63, 498, 8, 888, 459, 498, 3815, 283, 3922, 356, 1101, 459, 3922, 12074, 339, 347, 1218, 63, 633, 8, 277, 12, 1101, 12, 284, 29, 403, 12, 1455, 29, 797, 304, 267, 408, 267, 6425, 314, 3503, 2851, 267, 408, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
BirchJD/RPiTimer
PiTimer_Step-4/Schedule.py
1
5941
# PiTimer - Python Hardware Programming Education Project For Raspberry Pi # Copyright (C) 2015 Jason Birch # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #/****************************************************************************/ #/* PiTimer - Step 4 - Schedule functions. */ #/* ------------------------------------------------------------------------ */ #/* V1.00 - 2015-07-04 - Jason Birch */ #/* ------------------------------------------------------------------------ */ #/* Class to handle scheduling events for specific relays. Such as adding, */ #/* removing, displaying, sorting. */ #/****************************************************************************/ import datetime import ScheduleItem #/****************************************************************************/ #/* Function to return the schedule date of a schedule item for when sorting */ #/* the items using the Python list sort feature. */ #/****************************************************************************/ def SortGetKey(Object): return Object.GetScheduleDate() class Schedule: def __init__(self): # Define an array to store the schedule items in. self.ScheduleItems = [] #/*********************************************/ #/* Get the item at the specific array index. */ #/*********************************************/ def GetItem(self, ItemIndex): if len(self.ScheduleItems) > ItemIndex: return self.ScheduleItems[ItemIndex] else: return False #/**************************************************/ #/* Find the schedule item with the specificed ID. */ #/**************************************************/ def FindItem(self, FindItemID): ThisItem = False for ThisScheduleItem in self.ScheduleItems: if ThisScheduleItem.GetItemID() == FindItemID: ThisItem = ThisScheduleItem return ThisItem #/*******************************************************/ #/* Function to display the current schedule of events. */ #/* In a tabulated form. */ #/*******************************************************/ def DisplaySchedule(self, SelectedItemID): if len(self.ScheduleItems): self.ScheduleItems[0].DisplayHeader() for ThisScheduleItem in self.ScheduleItems: if SelectedItemID == ThisScheduleItem.GetItemID(): SelectLeftChar = ">" SelectRightChar = "<" else: SelectLeftChar = " " SelectRightChar = " " ThisScheduleItem.DisplayItem(SelectLeftChar, SelectRightChar) if len(self.ScheduleItems): self.ScheduleItems[0].DisplayFooter() #/*************************************************/ #/* Add a new schedule item to the schedle array. */ #/*************************************************/ def AddSchedule(self, NewRelayNumber, NewScheduleDate, NewRelayState, NewRepeat): self.ScheduleItems.append(ScheduleItem.ScheduleItem(NewRelayNumber, NewScheduleDate, NewRelayState, NewRepeat)) self.SortSchedule() #/**************************************************/ #/* Delete a schedule item from the schedle array. */ #/**************************************************/ def DelSchedule(self, ItemID): ThisScheduleItem = self.FindItem(ItemID) if ThisScheduleItem: self.ScheduleItems.remove(ThisScheduleItem) self.SortSchedule() #/*********************************************/ #/* Sort the list of schedule items so the */ #/* expired items are at the top of the list. */ #/*********************************************/ def SortSchedule(self): self.ScheduleItems.sort(key=SortGetKey) #/*************************************************************************/ #/* If the top schedule item is in the past return it's ID as being */ #/* triggered. The schedule items are kept in date order, so the top item */ #/* is the one which will trigger first. The calling function is */ #/* responsible for removing the triggered item from the scheduled items */ #/* or updating the scheduled item if the item is to be repeated once */ #/* the calling function has processed it; by calling the function: */ #/* SetNextScheduleDate(). */ #/*************************************************************************/ def ScheduleTrigger(self): ThisItemID = False Now = datetime.datetime.now() ThisItem = self.GetItem(0) if ThisItem and ThisItem.GetScheduleDate() <= Now: ThisItemID = ThisItem.GetItemID() return ThisItemID #/*********************************************************************/ #/* Set the date and time of the specified schedule item to it's next */ #/* trigger date/time. If the item does not have a repeat period, */ #/* remove the schedule item. */ #/*********************************************************************/ def SetNextScheduleDate(self, ThisItemID): ThisItem = self.FindItem(ThisItemID) if ThisItem and ThisItem.SetNextScheduleDate() == False: self.DelSchedule(ThisItemID) self.SortSchedule()
gpl-3.0
[ 3, 19835, 7929, 446, 2018, 22825, 1068, 2165, 9258, 662, 5905, 425, 7290, 2104, 820, 20222, 605, 651, 19835, 199, 3, 1898, 334, 35, 9, 6900, 1603, 2660, 699, 723, 335, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 15, 14355, 1116, 15, 199, 3, 6331, 19835, 7929, 446, 13382, 841, 446, 24317, 3423, 14, 15530, 11589, 199, 3, 6331, 5620, 518, 11589, 199, 3, 6331, 812, 17, 14, 383, 446, 6900, 13, 1780, 13, 966, 446, 1603, 2660, 699, 723, 335, 2476, 260, 11589, 199, 3, 6331, 5620, 518, 11589, 199, 3, 6331, 8089, 370, 2429, 23800, 4474, 367, 2488, 295, 9316, 14, 32753, 465, 7791, 12, 257, 11589, 199, 3, 6331, 12881, 12, 20589, 12, 13351, 14, 2476, 3698, 11589, 199, 3, 15, 14355, 1116, 15, 421, 199, 646, 2197, 199, 646, 24317, 2081, 421, 199, 3, 15, 14355, 1116, 15, 199, 3, 6331, 6801, 370, 372, 314, 8732, 1434, 402, 282, 8732, 1242, 367, 1380, 13351, 11589, 199, 3, 6331, 314, 2974, 1808, 314, 2018, 769, 4069, 3878, 14, 14960, 11589, 199, 3, 15, 14355, 1116, 15, 199, 318, 16722, 1002, 1197, 8, 1692, 304, 2043, 372, 6935, 14, 1002, 15535, 2506, 342, 421, 199, 533, 24317, 26, 8410, 347, 636, 826, 721, 277, 304, 199, 3, 13930, 376, 1625, 370, 3877, 314, 8732, 2974, 315, 14, 489, 291, 14, 15535, 7412, 275, 942, 421, 199, 3, 15, 5815, 1801, 1116, 15870, 199, 3, 6331, 2372, 314, 1242, 737, 314, 2488, 1625, 1478, 14, 11589, 199, 3, 15, 5815, 1801, 1116, 15870, 2043, 347, 2372, 2081, 8, 277, 12, 7020, 2681, 304, 489, 340, 822, 8, 277, 14, 15535, 7412, 9, 690, 7020, 2681, 26, 268, 372, 291, 14, 15535, 7412, 59, 2081, 2681, 61, 489, 587, 26, 268, 372, 756, 421, 199, 3, 15, 5815, 3096, 538, 15, 199, 3, 6331, 6668, 314, 8732, 1242, 543, 314, 1106, 329, 6867, 2870, 14, 11589, 199, 3, 15, 5815, 3096, 538, 15, 2043, 347, 6668, 2081, 8, 277, 12, 6668, 2081, 998, 304, 489, 961, 2081, 275, 756, 489, 367, 961, 15535, 2081, 315, 291, 14, 15535, 7412, 26, 268, 340, 961, 15535, 2081, 14, 32474, 998, 342, 508, 6668, 2081, 998, 26, 288, 961, 2081, 275, 961, 15535, 2081, 489, 372, 961, 2081, 421, 199, 3, 15, 5815, 3096, 1116, 9153, 15, 199, 3, 6331, 6801, 370, 2929, 314, 1453, 8732, 402, 4474, 14, 11589, 199, 3, 6331, 1010, 282, 5174, 8097, 1824, 14, 13293, 11589, 199, 3, 15, 5815, 3096, 1116, 9153, 15, 2043, 347, 12175, 15535, 8, 277, 12, 3240, 2820, 2081, 998, 304, 489, 340, 822, 8, 277, 14, 15535, 7412, 304, 268, 291, 14, 15535, 7412, 59, 16, 1055, 7687, 2567, 342, 2541, 367, 961, 15535, 2081, 315, 291, 14, 15535, 7412, 26, 268, 340, 3240, 2820, 2081, 998, 508, 961, 15535, 2081, 14, 32474, 998, 837, 288, 9496, 8185, 1610, 275, 28192, 288, 9496, 9121, 1610, 275, 3886, 2, 268, 587, 26, 288, 9496, 8185, 1610, 275, 298, 298, 288, 9496, 9121, 1610, 275, 298, 298, 268, 961, 15535, 2081, 14, 7687, 2081, 8, 5446, 8185, 1610, 12, 9496, 9121, 1610, 9, 2541, 340, 822, 8, 277, 14, 15535, 7412, 304, 268, 291, 14, 15535, 7412, 59, 16, 1055, 7687, 5686, 351, 342, 421, 199, 3, 15, 5815, 3096, 15870, 199, 3, 6331, 2654, 282, 892, 8732, 1242, 370, 314, 10286, 274, 1625, 14, 11589, 199, 3, 15, 5815, 3096, 15870, 2043, 347, 2654, 15535, 8, 277, 12, 7053, 5640, 1187, 3259, 12, 7053, 15535, 2506, 12, 7053, 5640, 1187, 2223, 12, 7053, 27600, 304, 489, 291, 14, 15535, 7412, 14, 740, 8, 15535, 2081, 14, 15535, 2081, 8, 4665, 5640, 1187, 3259, 12, 7053, 15535, 2506, 12, 7053, 5640, 1187, 2223, 12, 7053, 27600, 430, 489, 291, 14, 14376, 15535, 342, 421, 199, 3, 15, 5815, 3096, 538, 15, 199, 3, 6331, 8496, 282, 8732, 1242, 687, 314, 10286, 274, 1625, 14, 11589, 199, 3, 15, 5815, 3096, 538, 15, 2043, 347, 18464, 15535, 8, 277, 12, 7020, 998, 304, 489, 961, 15535, 2081, 275, 291, 14, 6591, 2081, 8, 2081, 998, 9, 489, 340, 961, 15535, 2081, 26, 268, 291, 14, 15535, 7412, 14, 2168, 8, 2765, 15535, 2081, 9, 489, 291, 14, 14376, 15535, 342, 421, 199, 3, 15, 5815, 1801, 1116, 15870, 199, 3, 6331, 16722, 314, 769, 402, 8732, 2974, 880, 314, 259, 11589, 199, 3, 6331, 14721, 2974, 787, 737, 314, 2746, 402, 314, 769, 14, 11589, 199, 3, 15, 5815, 1801, 1116, 15870, 2043, 347, 16722, 15535, 8, 277, 304, 489, 291, 14, 15535, 7412, 14, 3191, 8, 498, 29, 14376, 1002, 1197, 9, 421, 199, 3, 15, 14355, 15870, 199, 3, 6331, 982, 314, 2746, 8732, 1242, 365, 315, 314, 13541, 372, 652, 1159, 2870, 465, 3769, 755, 11589, 199, 3, 6331, 15572, 14, 710, 8732, 2974, 787, 16204, 315, 1434, 1865, 12, 880, 314, 2746, 1242, 11589, 199, 3, 6331, 365, 314, 1373, 1314, 911, 6804, 1642, 14, 710, 6358, 805, 365, 3515, 11589, 199, 3, 6331, 17845, 367, 12881, 314, 15572, 1242, 687, 314, 18416, 2974, 221, 11589, 199, 3, 6331, 503, 12928, 314, 18416, 1242, 340, 314, 1242, 365, 370, 506, 221, 10877, 5403, 259, 11589, 199, 3, 6331, 314, 6358, 805, 965, 7686, 652, 27, 701, 6358, 314 ]
[ 19835, 7929, 446, 2018, 22825, 1068, 2165, 9258, 662, 5905, 425, 7290, 2104, 820, 20222, 605, 651, 19835, 199, 3, 1898, 334, 35, 9, 6900, 1603, 2660, 699, 723, 335, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 15, 14355, 1116, 15, 199, 3, 6331, 19835, 7929, 446, 13382, 841, 446, 24317, 3423, 14, 15530, 11589, 199, 3, 6331, 5620, 518, 11589, 199, 3, 6331, 812, 17, 14, 383, 446, 6900, 13, 1780, 13, 966, 446, 1603, 2660, 699, 723, 335, 2476, 260, 11589, 199, 3, 6331, 5620, 518, 11589, 199, 3, 6331, 8089, 370, 2429, 23800, 4474, 367, 2488, 295, 9316, 14, 32753, 465, 7791, 12, 257, 11589, 199, 3, 6331, 12881, 12, 20589, 12, 13351, 14, 2476, 3698, 11589, 199, 3, 15, 14355, 1116, 15, 421, 199, 646, 2197, 199, 646, 24317, 2081, 421, 199, 3, 15, 14355, 1116, 15, 199, 3, 6331, 6801, 370, 372, 314, 8732, 1434, 402, 282, 8732, 1242, 367, 1380, 13351, 11589, 199, 3, 6331, 314, 2974, 1808, 314, 2018, 769, 4069, 3878, 14, 14960, 11589, 199, 3, 15, 14355, 1116, 15, 199, 318, 16722, 1002, 1197, 8, 1692, 304, 2043, 372, 6935, 14, 1002, 15535, 2506, 342, 421, 199, 533, 24317, 26, 8410, 347, 636, 826, 721, 277, 304, 199, 3, 13930, 376, 1625, 370, 3877, 314, 8732, 2974, 315, 14, 489, 291, 14, 15535, 7412, 275, 942, 421, 199, 3, 15, 5815, 1801, 1116, 15870, 199, 3, 6331, 2372, 314, 1242, 737, 314, 2488, 1625, 1478, 14, 11589, 199, 3, 15, 5815, 1801, 1116, 15870, 2043, 347, 2372, 2081, 8, 277, 12, 7020, 2681, 304, 489, 340, 822, 8, 277, 14, 15535, 7412, 9, 690, 7020, 2681, 26, 268, 372, 291, 14, 15535, 7412, 59, 2081, 2681, 61, 489, 587, 26, 268, 372, 756, 421, 199, 3, 15, 5815, 3096, 538, 15, 199, 3, 6331, 6668, 314, 8732, 1242, 543, 314, 1106, 329, 6867, 2870, 14, 11589, 199, 3, 15, 5815, 3096, 538, 15, 2043, 347, 6668, 2081, 8, 277, 12, 6668, 2081, 998, 304, 489, 961, 2081, 275, 756, 489, 367, 961, 15535, 2081, 315, 291, 14, 15535, 7412, 26, 268, 340, 961, 15535, 2081, 14, 32474, 998, 342, 508, 6668, 2081, 998, 26, 288, 961, 2081, 275, 961, 15535, 2081, 489, 372, 961, 2081, 421, 199, 3, 15, 5815, 3096, 1116, 9153, 15, 199, 3, 6331, 6801, 370, 2929, 314, 1453, 8732, 402, 4474, 14, 11589, 199, 3, 6331, 1010, 282, 5174, 8097, 1824, 14, 13293, 11589, 199, 3, 15, 5815, 3096, 1116, 9153, 15, 2043, 347, 12175, 15535, 8, 277, 12, 3240, 2820, 2081, 998, 304, 489, 340, 822, 8, 277, 14, 15535, 7412, 304, 268, 291, 14, 15535, 7412, 59, 16, 1055, 7687, 2567, 342, 2541, 367, 961, 15535, 2081, 315, 291, 14, 15535, 7412, 26, 268, 340, 3240, 2820, 2081, 998, 508, 961, 15535, 2081, 14, 32474, 998, 837, 288, 9496, 8185, 1610, 275, 28192, 288, 9496, 9121, 1610, 275, 3886, 2, 268, 587, 26, 288, 9496, 8185, 1610, 275, 298, 298, 288, 9496, 9121, 1610, 275, 298, 298, 268, 961, 15535, 2081, 14, 7687, 2081, 8, 5446, 8185, 1610, 12, 9496, 9121, 1610, 9, 2541, 340, 822, 8, 277, 14, 15535, 7412, 304, 268, 291, 14, 15535, 7412, 59, 16, 1055, 7687, 5686, 351, 342, 421, 199, 3, 15, 5815, 3096, 15870, 199, 3, 6331, 2654, 282, 892, 8732, 1242, 370, 314, 10286, 274, 1625, 14, 11589, 199, 3, 15, 5815, 3096, 15870, 2043, 347, 2654, 15535, 8, 277, 12, 7053, 5640, 1187, 3259, 12, 7053, 15535, 2506, 12, 7053, 5640, 1187, 2223, 12, 7053, 27600, 304, 489, 291, 14, 15535, 7412, 14, 740, 8, 15535, 2081, 14, 15535, 2081, 8, 4665, 5640, 1187, 3259, 12, 7053, 15535, 2506, 12, 7053, 5640, 1187, 2223, 12, 7053, 27600, 430, 489, 291, 14, 14376, 15535, 342, 421, 199, 3, 15, 5815, 3096, 538, 15, 199, 3, 6331, 8496, 282, 8732, 1242, 687, 314, 10286, 274, 1625, 14, 11589, 199, 3, 15, 5815, 3096, 538, 15, 2043, 347, 18464, 15535, 8, 277, 12, 7020, 998, 304, 489, 961, 15535, 2081, 275, 291, 14, 6591, 2081, 8, 2081, 998, 9, 489, 340, 961, 15535, 2081, 26, 268, 291, 14, 15535, 7412, 14, 2168, 8, 2765, 15535, 2081, 9, 489, 291, 14, 14376, 15535, 342, 421, 199, 3, 15, 5815, 1801, 1116, 15870, 199, 3, 6331, 16722, 314, 769, 402, 8732, 2974, 880, 314, 259, 11589, 199, 3, 6331, 14721, 2974, 787, 737, 314, 2746, 402, 314, 769, 14, 11589, 199, 3, 15, 5815, 1801, 1116, 15870, 2043, 347, 16722, 15535, 8, 277, 304, 489, 291, 14, 15535, 7412, 14, 3191, 8, 498, 29, 14376, 1002, 1197, 9, 421, 199, 3, 15, 14355, 15870, 199, 3, 6331, 982, 314, 2746, 8732, 1242, 365, 315, 314, 13541, 372, 652, 1159, 2870, 465, 3769, 755, 11589, 199, 3, 6331, 15572, 14, 710, 8732, 2974, 787, 16204, 315, 1434, 1865, 12, 880, 314, 2746, 1242, 11589, 199, 3, 6331, 365, 314, 1373, 1314, 911, 6804, 1642, 14, 710, 6358, 805, 365, 3515, 11589, 199, 3, 6331, 17845, 367, 12881, 314, 15572, 1242, 687, 314, 18416, 2974, 221, 11589, 199, 3, 6331, 503, 12928, 314, 18416, 1242, 340, 314, 1242, 365, 370, 506, 221, 10877, 5403, 259, 11589, 199, 3, 6331, 314, 6358, 805, 965, 7686, 652, 27, 701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, 1, 1, 1, 1, 1 ]
todaychi/hue
desktop/core/ext-py/pycrypto-2.6.1/lib/Crypto/Util/py3compat.py
145
3912
# -*- coding: utf-8 -*- # # Util/py3compat.py : Compatibility code for handling Py3k / Python 2.x # # Written in 2010 by Thorsten Behrens # # =================================================================== # The contents of this file are dedicated to the public domain. To # the extent that dedication to the public domain is not available, # everyone is granted a worldwide, perpetual, royalty-free, # non-exclusive license to exercise all rights associated with the # contents of this file for any purpose whatsoever. # No rights are reserved. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # =================================================================== """Compatibility code for handling string/bytes changes from Python 2.x to Py3k In Python 2.x, strings (of type ''str'') contain binary data, including encoded Unicode text (e.g. UTF-8). The separate type ''unicode'' holds Unicode text. Unicode literals are specified via the u'...' prefix. Indexing or slicing either type always produces a string of the same type as the original. Data read from a file is always of '''str'' type. In Python 3.x, strings (type ''str'') may only contain Unicode text. The u'...' prefix and the ''unicode'' type are now redundant. A new type (called ''bytes'') has to be used for binary data (including any particular ''encoding'' of a string). The b'...' prefix allows one to specify a binary literal. Indexing or slicing a string produces another string. Slicing a byte string produces another byte string, but the indexing operation produces an integer. Data read from a file is of '''str'' type if the file was opened in text mode, or of ''bytes'' type otherwise. Since PyCrypto aims at supporting both Python 2.x and 3.x, the following helper functions are used to keep the rest of the library as independent as possible from the actual Python version. In general, the code should always deal with binary strings, and use integers instead of 1-byte character strings. b(s) Take a text string literal (with no prefix or with u'...' prefix) and make a byte string. bchr(c) Take an integer and make a 1-character byte string. bord(c) Take the result of indexing on a byte string and make an integer. tobytes(s) Take a text string, a byte string, or a sequence of character taken from a byte string and make a byte string. """ __revision__ = "$Id$" import sys if sys.version_info[0] == 2: def b(s): return s def bchr(s): return chr(s) def bstr(s): return str(s) def bord(s): return ord(s) if sys.version_info[1] == 1: def tobytes(s): try: return s.encode('latin-1') except: return ''.join(s) else: def tobytes(s): if isinstance(s, unicode): return s.encode("latin-1") else: return ''.join(s) else: def b(s): return s.encode("latin-1") # utf-8 would cause some side-effects we don't want def bchr(s): return bytes([s]) def bstr(s): if isinstance(s,str): return bytes(s,"latin-1") else: return bytes(s) def bord(s): return s def tobytes(s): if isinstance(s,bytes): return s else: if isinstance(s,str): return s.encode("latin-1") else: return bytes(s) # vim:set ts=4 sw=4 sts=4 expandtab:
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 21248, 15, 647, 19, 5819, 14, 647, 520, 3599, 5880, 1233, 367, 7252, 1611, 19, 75, 1182, 2018, 499, 14, 88, 199, 3, 199, 3, 27694, 315, 7129, 701, 3868, 1384, 724, 6423, 72, 27667, 199, 3, 199, 3, 7819, 389, 199, 3, 710, 4072, 402, 642, 570, 787, 29711, 370, 314, 4575, 2881, 14, 221, 4005, 199, 3, 314, 13675, 626, 477, 21171, 370, 314, 4575, 2881, 365, 440, 2808, 12, 199, 3, 4036, 368, 365, 10009, 282, 6701, 13062, 12, 1126, 321, 1688, 12, 882, 89, 13248, 13, 4624, 12, 199, 3, 2222, 13, 12730, 4190, 370, 26511, 1006, 4481, 4568, 543, 314, 199, 3, 4072, 402, 642, 570, 367, 1263, 12016, 4052, 1152, 5907, 14, 199, 3, 3091, 4481, 787, 4644, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 7819, 389, 199, 199, 624, 2404, 5880, 1233, 367, 7252, 1059, 15, 2394, 4493, 687, 2018, 499, 14, 88, 370, 1611, 19, 75, 199, 199, 607, 2018, 499, 14, 88, 12, 3326, 334, 1618, 730, 2125, 495, 17483, 1395, 3366, 666, 12, 5893, 5737, 199, 7087, 1318, 334, 69, 14, 71, 14, 9094, 13, 24, 680, 221, 710, 7396, 730, 2125, 2975, 891, 15164, 6140, 1318, 14, 199, 7087, 18041, 787, 2013, 4799, 314, 399, 7, 13698, 2403, 14, 221, 5499, 316, 503, 23647, 199, 22051, 730, 3544, 16904, 282, 1059, 402, 314, 2011, 730, 465, 314, 3379, 14, 199, 1451, 1586, 687, 282, 570, 365, 3544, 402, 1449, 495, 891, 730, 14, 199, 199, 607, 2018, 650, 14, 88, 12, 3326, 334, 466, 2125, 495, 17483, 1443, 1454, 1395, 6140, 1318, 14, 710, 399, 7, 13698, 199, 1861, 436, 314, 2125, 2975, 891, 730, 787, 3063, 22649, 14, 221, 437, 892, 730, 334, 3527, 199, 891, 2394, 17483, 965, 370, 506, 1202, 367, 3366, 666, 334, 15768, 1263, 6770, 199, 891, 2991, 891, 402, 282, 1059, 680, 221, 710, 330, 7, 13698, 2403, 6127, 1373, 370, 4165, 282, 3366, 199, 8939, 14, 221, 5499, 316, 503, 23647, 282, 1059, 16904, 4573, 1059, 14, 221, 428, 17463, 282, 3696, 199, 875, 16904, 4573, 3696, 1059, 12, 1325, 314, 16356, 3439, 16904, 376, 199, 4115, 14, 221, 3918, 1586, 687, 282, 570, 365, 402, 1449, 495, 891, 730, 340, 314, 570, 1990, 12123, 315, 199, 505, 818, 12, 503, 402, 2125, 2394, 891, 730, 4257, 14, 199, 199, 24430, 1611, 17134, 282, 11171, 737, 21038, 3865, 2018, 499, 14, 88, 436, 650, 14, 88, 12, 314, 2569, 5922, 199, 5777, 787, 1202, 370, 4215, 314, 4618, 402, 314, 3555, 465, 12717, 465, 3962, 199, 504, 314, 3503, 2018, 1015, 14, 199, 199, 607, 8605, 12, 314, 1233, 1077, 3544, 7962, 543, 3366, 3326, 12, 436, 675, 9446, 199, 23145, 402, 413, 13, 4414, 4528, 3326, 14, 199, 199, 66, 8, 83, 9, 272, 18146, 282, 1318, 1059, 8785, 334, 1045, 949, 2403, 503, 543, 399, 7, 13698, 2403, 9, 436, 272, 1852, 282, 3696, 1059, 14, 199, 66, 10194, 8, 67, 9, 272, 18146, 376, 3000, 436, 1852, 282, 413, 13, 10856, 3696, 1059, 14, 199, 66, 2181, 8, 67, 9, 272, 18146, 314, 754, 402, 16356, 641, 282, 3696, 1059, 436, 1852, 376, 3000, 14, 199, 32557, 8, 83, 9, 272, 18146, 282, 1318, 1059, 12, 282, 3696, 1059, 12, 503, 282, 3414, 402, 4528, 9394, 687, 272, 282, 3696, 1059, 436, 1852, 282, 3696, 1059, 14, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 26, 272, 347, 330, 8, 83, 304, 267, 372, 308, 272, 347, 330, 10194, 8, 83, 304, 267, 372, 8678, 8, 83, 9, 272, 347, 330, 495, 8, 83, 304, 267, 372, 620, 8, 83, 9, 272, 347, 330, 2181, 8, 83, 304, 267, 372, 6206, 8, 83, 9, 272, 340, 984, 14, 1023, 63, 815, 59, 17, 61, 508, 413, 26, 267, 347, 370, 2394, 8, 83, 304, 288, 862, 26, 355, 372, 308, 14, 2143, 360, 10378, 13, 17, 358, 288, 871, 26, 355, 372, 6522, 904, 8, 83, 9, 272, 587, 26, 267, 347, 370, 2394, 8, 83, 304, 288, 340, 1228, 8, 83, 12, 2649, 304, 355, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 288, 587, 26, 355, 372, 6522, 904, 8, 83, 9, 199, 2836, 26, 272, 347, 330, 8, 83, 304, 2126, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 327, 2774, 13, 24, 3955, 7675, 2005, 5366, 13, 27626, 781, 2793, 1133, 2934, 272, 347, 330, 10194, 8, 83, 304, 267, 372, 2783, 779, 83, 566, 272, 347, 330, 495, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 495, 304, 288, 372, 2783, 8, 83, 4589, 10378, 13, 17, 531, 267, 587, 26, 288, 372, 2783, 8, 83, 9, 272, 347, 330, 2181, 8, 83, 304, 267, 372, 308, 272, 347, 370, 2394, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2394, 304, 288, 372, 308, 267, 587, 26, 288, 340, 1228, 8, 83, 12, 495, 304, 355, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 288, 587, 26, 355, 372, 2783, 8, 83, 9, 199, 199, 3, 6695, 26, 409, 6714, 29, 20, 5584, 29, 20, 23014, 29, 20, 26414, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 21248, 15, 647, 19, 5819, 14, 647, 520, 3599, 5880, 1233, 367, 7252, 1611, 19, 75, 1182, 2018, 499, 14, 88, 199, 3, 199, 3, 27694, 315, 7129, 701, 3868, 1384, 724, 6423, 72, 27667, 199, 3, 199, 3, 7819, 389, 199, 3, 710, 4072, 402, 642, 570, 787, 29711, 370, 314, 4575, 2881, 14, 221, 4005, 199, 3, 314, 13675, 626, 477, 21171, 370, 314, 4575, 2881, 365, 440, 2808, 12, 199, 3, 4036, 368, 365, 10009, 282, 6701, 13062, 12, 1126, 321, 1688, 12, 882, 89, 13248, 13, 4624, 12, 199, 3, 2222, 13, 12730, 4190, 370, 26511, 1006, 4481, 4568, 543, 314, 199, 3, 4072, 402, 642, 570, 367, 1263, 12016, 4052, 1152, 5907, 14, 199, 3, 3091, 4481, 787, 4644, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 199, 3, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 199, 3, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 199, 3, 7819, 389, 199, 199, 624, 2404, 5880, 1233, 367, 7252, 1059, 15, 2394, 4493, 687, 2018, 499, 14, 88, 370, 1611, 19, 75, 199, 199, 607, 2018, 499, 14, 88, 12, 3326, 334, 1618, 730, 2125, 495, 17483, 1395, 3366, 666, 12, 5893, 5737, 199, 7087, 1318, 334, 69, 14, 71, 14, 9094, 13, 24, 680, 221, 710, 7396, 730, 2125, 2975, 891, 15164, 6140, 1318, 14, 199, 7087, 18041, 787, 2013, 4799, 314, 399, 7, 13698, 2403, 14, 221, 5499, 316, 503, 23647, 199, 22051, 730, 3544, 16904, 282, 1059, 402, 314, 2011, 730, 465, 314, 3379, 14, 199, 1451, 1586, 687, 282, 570, 365, 3544, 402, 1449, 495, 891, 730, 14, 199, 199, 607, 2018, 650, 14, 88, 12, 3326, 334, 466, 2125, 495, 17483, 1443, 1454, 1395, 6140, 1318, 14, 710, 399, 7, 13698, 199, 1861, 436, 314, 2125, 2975, 891, 730, 787, 3063, 22649, 14, 221, 437, 892, 730, 334, 3527, 199, 891, 2394, 17483, 965, 370, 506, 1202, 367, 3366, 666, 334, 15768, 1263, 6770, 199, 891, 2991, 891, 402, 282, 1059, 680, 221, 710, 330, 7, 13698, 2403, 6127, 1373, 370, 4165, 282, 3366, 199, 8939, 14, 221, 5499, 316, 503, 23647, 282, 1059, 16904, 4573, 1059, 14, 221, 428, 17463, 282, 3696, 199, 875, 16904, 4573, 3696, 1059, 12, 1325, 314, 16356, 3439, 16904, 376, 199, 4115, 14, 221, 3918, 1586, 687, 282, 570, 365, 402, 1449, 495, 891, 730, 340, 314, 570, 1990, 12123, 315, 199, 505, 818, 12, 503, 402, 2125, 2394, 891, 730, 4257, 14, 199, 199, 24430, 1611, 17134, 282, 11171, 737, 21038, 3865, 2018, 499, 14, 88, 436, 650, 14, 88, 12, 314, 2569, 5922, 199, 5777, 787, 1202, 370, 4215, 314, 4618, 402, 314, 3555, 465, 12717, 465, 3962, 199, 504, 314, 3503, 2018, 1015, 14, 199, 199, 607, 8605, 12, 314, 1233, 1077, 3544, 7962, 543, 3366, 3326, 12, 436, 675, 9446, 199, 23145, 402, 413, 13, 4414, 4528, 3326, 14, 199, 199, 66, 8, 83, 9, 272, 18146, 282, 1318, 1059, 8785, 334, 1045, 949, 2403, 503, 543, 399, 7, 13698, 2403, 9, 436, 272, 1852, 282, 3696, 1059, 14, 199, 66, 10194, 8, 67, 9, 272, 18146, 376, 3000, 436, 1852, 282, 413, 13, 10856, 3696, 1059, 14, 199, 66, 2181, 8, 67, 9, 272, 18146, 314, 754, 402, 16356, 641, 282, 3696, 1059, 436, 1852, 376, 3000, 14, 199, 32557, 8, 83, 9, 272, 18146, 282, 1318, 1059, 12, 282, 3696, 1059, 12, 503, 282, 3414, 402, 4528, 9394, 687, 272, 282, 3696, 1059, 436, 1852, 282, 3696, 1059, 14, 199, 624, 199, 199, 363, 5792, 363, 275, 7880, 1304, 17351, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 26, 272, 347, 330, 8, 83, 304, 267, 372, 308, 272, 347, 330, 10194, 8, 83, 304, 267, 372, 8678, 8, 83, 9, 272, 347, 330, 495, 8, 83, 304, 267, 372, 620, 8, 83, 9, 272, 347, 330, 2181, 8, 83, 304, 267, 372, 6206, 8, 83, 9, 272, 340, 984, 14, 1023, 63, 815, 59, 17, 61, 508, 413, 26, 267, 347, 370, 2394, 8, 83, 304, 288, 862, 26, 355, 372, 308, 14, 2143, 360, 10378, 13, 17, 358, 288, 871, 26, 355, 372, 6522, 904, 8, 83, 9, 272, 587, 26, 267, 347, 370, 2394, 8, 83, 304, 288, 340, 1228, 8, 83, 12, 2649, 304, 355, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 288, 587, 26, 355, 372, 6522, 904, 8, 83, 9, 199, 2836, 26, 272, 347, 330, 8, 83, 304, 2126, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 327, 2774, 13, 24, 3955, 7675, 2005, 5366, 13, 27626, 781, 2793, 1133, 2934, 272, 347, 330, 10194, 8, 83, 304, 267, 372, 2783, 779, 83, 566, 272, 347, 330, 495, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 495, 304, 288, 372, 2783, 8, 83, 4589, 10378, 13, 17, 531, 267, 587, 26, 288, 372, 2783, 8, 83, 9, 272, 347, 330, 2181, 8, 83, 304, 267, 372, 308, 272, 347, 370, 2394, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2394, 304, 288, 372, 308, 267, 587, 26, 288, 340, 1228, 8, 83, 12, 495, 304, 355, 372, 308, 14, 2143, 480, 10378, 13, 17, 531, 288, 587, 26, 355, 372, 2783, 8, 83, 9, 199, 199, 3, 6695, 26, 409, 6714, 29, 20, 5584, 29, 20, 23014, 29, 20, 26414, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
PaulieC/sprint5-Council
AvailableTournaments/AllPlayAll.py
2
1192
__author__ = "Paul Council, Anand Patel" __version__ = "sprint1" __credits__ = ["William Ezekiel"] # imports from ServerPackage.Tournament import * class AllPlayAll(Tournament): """ AllPlayAll Tournament Type, every player is in a match with every other player """ def __init__(self): """ Initialize AllPlayAll :param rounds: the number of rounds per match, 5 by default :type rounds: list """ Tournament.__init__(self) # variables to help us pick players 1 and 2. self.p = 0 # player 1 index self.q = 1 # player 2 index self.name = "All-Play-All" def create_next_match(self): """ Create the next match :return match: The new match :rtype: tuple """ self.playerList = self.get_players() if self.q >= len(self.playerList): # Go through all possible matches. return None match = ((self.playerList[self.p], self.playerList[self.q]), self.rounds) self.q += 1 if self.q >= len(self.playerList): # if index out of bounds self.p += 1 self.q = self.p+1 return match
apache-2.0
[ 363, 2502, 363, 275, 298, 28282, 1849, 1097, 382, 12, 1626, 460, 510, 21163, 2, 199, 363, 1023, 363, 275, 298, 681, 672, 17, 2, 199, 363, 22461, 363, 275, 2097, 55, 8148, 455, 662, 806, 8810, 352, 937, 199, 199, 3, 8925, 199, 504, 7146, 8599, 14, 1378, 23474, 492, 627, 421, 199, 533, 2900, 9651, 2422, 8, 1378, 23474, 304, 272, 408, 2900, 9651, 2422, 4005, 23474, 2434, 12, 4036, 7748, 365, 315, 282, 1336, 543, 4036, 1163, 7748, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 267, 11578, 2900, 9651, 2422, 267, 520, 635, 27194, 26, 314, 1329, 402, 27194, 1126, 1336, 12, 959, 701, 849, 267, 520, 466, 27194, 26, 769, 267, 408, 267, 4005, 23474, 855, 826, 721, 277, 9, 267, 327, 2860, 370, 1720, 2739, 3732, 30130, 413, 436, 499, 14, 267, 291, 14, 80, 275, 378, 258, 327, 7748, 413, 1478, 267, 291, 14, 81, 275, 413, 258, 327, 7748, 499, 1478, 267, 291, 14, 354, 275, 298, 2422, 13, 9651, 13, 2422, 2, 339, 347, 1218, 63, 2184, 63, 1431, 8, 277, 304, 267, 408, 267, 2790, 314, 2163, 1336, 267, 520, 1107, 1336, 26, 710, 892, 1336, 267, 520, 4500, 26, 2008, 267, 408, 267, 291, 14, 6147, 1296, 275, 291, 14, 362, 63, 20716, 342, 267, 340, 291, 14, 81, 2356, 822, 8, 277, 14, 6147, 1296, 304, 257, 327, 3971, 4012, 1006, 3962, 4450, 14, 288, 372, 488, 267, 1336, 275, 3666, 277, 14, 6147, 1296, 59, 277, 14, 80, 467, 291, 14, 6147, 1296, 59, 277, 14, 81, 2522, 291, 14, 23171, 9, 267, 291, 14, 81, 847, 413, 267, 340, 291, 14, 81, 2356, 822, 8, 277, 14, 6147, 1296, 304, 259, 327, 340, 1478, 734, 402, 10461, 288, 291, 14, 80, 847, 413, 288, 291, 14, 81, 275, 291, 14, 80, 11, 17, 267, 372, 1336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2502, 363, 275, 298, 28282, 1849, 1097, 382, 12, 1626, 460, 510, 21163, 2, 199, 363, 1023, 363, 275, 298, 681, 672, 17, 2, 199, 363, 22461, 363, 275, 2097, 55, 8148, 455, 662, 806, 8810, 352, 937, 199, 199, 3, 8925, 199, 504, 7146, 8599, 14, 1378, 23474, 492, 627, 421, 199, 533, 2900, 9651, 2422, 8, 1378, 23474, 304, 272, 408, 2900, 9651, 2422, 4005, 23474, 2434, 12, 4036, 7748, 365, 315, 282, 1336, 543, 4036, 1163, 7748, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 267, 11578, 2900, 9651, 2422, 267, 520, 635, 27194, 26, 314, 1329, 402, 27194, 1126, 1336, 12, 959, 701, 849, 267, 520, 466, 27194, 26, 769, 267, 408, 267, 4005, 23474, 855, 826, 721, 277, 9, 267, 327, 2860, 370, 1720, 2739, 3732, 30130, 413, 436, 499, 14, 267, 291, 14, 80, 275, 378, 258, 327, 7748, 413, 1478, 267, 291, 14, 81, 275, 413, 258, 327, 7748, 499, 1478, 267, 291, 14, 354, 275, 298, 2422, 13, 9651, 13, 2422, 2, 339, 347, 1218, 63, 2184, 63, 1431, 8, 277, 304, 267, 408, 267, 2790, 314, 2163, 1336, 267, 520, 1107, 1336, 26, 710, 892, 1336, 267, 520, 4500, 26, 2008, 267, 408, 267, 291, 14, 6147, 1296, 275, 291, 14, 362, 63, 20716, 342, 267, 340, 291, 14, 81, 2356, 822, 8, 277, 14, 6147, 1296, 304, 257, 327, 3971, 4012, 1006, 3962, 4450, 14, 288, 372, 488, 267, 1336, 275, 3666, 277, 14, 6147, 1296, 59, 277, 14, 80, 467, 291, 14, 6147, 1296, 59, 277, 14, 81, 2522, 291, 14, 23171, 9, 267, 291, 14, 81, 847, 413, 267, 340, 291, 14, 81, 2356, 822, 8, 277, 14, 6147, 1296, 304, 259, 327, 340, 1478, 734, 402, 10461, 288, 291, 14, 80, 847, 413, 288, 291, 14, 81, 275, 291, 14, 80, 11, 17, 267, 372, 1336, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
eLRuLL/scrapy
scrapy/utils/serialize.py
29
1201
import json import datetime import decimal from twisted.internet import defer from scrapy.http import Request, Response from scrapy.item import BaseItem class ScrapyJSONEncoder(json.JSONEncoder): DATE_FORMAT = "%Y-%m-%d" TIME_FORMAT = "%H:%M:%S" def default(self, o): if isinstance(o, set): return list(o) elif isinstance(o, datetime.datetime): return o.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT)) elif isinstance(o, datetime.date): return o.strftime(self.DATE_FORMAT) elif isinstance(o, datetime.time): return o.strftime(self.TIME_FORMAT) elif isinstance(o, decimal.Decimal): return str(o) elif isinstance(o, defer.Deferred): return str(o) elif isinstance(o, BaseItem): return dict(o) elif isinstance(o, Request): return "<%s %s %s>" % (type(o).__name__, o.method, o.url) elif isinstance(o, Response): return "<%s %s %s>" % (type(o).__name__, o.status, o.url) else: return super(ScrapyJSONEncoder, self).default(o) class ScrapyJSONDecoder(json.JSONDecoder): pass
bsd-3-clause
[ 646, 2022, 199, 646, 2197, 199, 646, 6107, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 199, 504, 18918, 14, 1014, 492, 4784, 12, 7232, 199, 504, 18918, 14, 1053, 492, 3523, 2081, 421, 199, 533, 13916, 345, 647, 23069, 8, 1001, 14, 23069, 304, 339, 30131, 63, 4807, 275, 2071, 57, 3295, 77, 3295, 68, 2, 272, 17032, 63, 4807, 275, 2071, 40, 2689, 45, 2689, 51, 2, 339, 347, 849, 8, 277, 12, 312, 304, 267, 340, 1228, 8, 79, 12, 663, 304, 288, 372, 769, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 2197, 14, 2083, 304, 288, 372, 312, 14, 6205, 3647, 83, 450, 83, 2, 450, 334, 277, 14, 5390, 63, 4807, 12, 291, 14, 4961, 63, 4807, 430, 267, 916, 1228, 8, 79, 12, 2197, 14, 602, 304, 288, 372, 312, 14, 6205, 8, 277, 14, 5390, 63, 4807, 9, 267, 916, 1228, 8, 79, 12, 2197, 14, 521, 304, 288, 372, 312, 14, 6205, 8, 277, 14, 4961, 63, 4807, 9, 267, 916, 1228, 8, 79, 12, 6107, 14, 6745, 304, 288, 372, 620, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 10133, 14, 9937, 304, 288, 372, 620, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 3523, 2081, 304, 288, 372, 1211, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 4784, 304, 288, 372, 23054, 83, 450, 83, 450, 83, 4335, 450, 334, 466, 8, 79, 2843, 354, 3108, 312, 14, 765, 12, 312, 14, 633, 9, 267, 916, 1228, 8, 79, 12, 7232, 304, 288, 372, 23054, 83, 450, 83, 450, 83, 4335, 450, 334, 466, 8, 79, 2843, 354, 3108, 312, 14, 1205, 12, 312, 14, 633, 9, 267, 587, 26, 288, 372, 1613, 8, 7181, 345, 647, 23069, 12, 291, 680, 885, 8, 79, 9, 421, 199, 533, 13916, 345, 647, 6243, 8326, 8, 1001, 14, 6243, 8326, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2022, 199, 646, 2197, 199, 646, 6107, 199, 199, 504, 7390, 14, 4901, 492, 10133, 199, 199, 504, 18918, 14, 1014, 492, 4784, 12, 7232, 199, 504, 18918, 14, 1053, 492, 3523, 2081, 421, 199, 533, 13916, 345, 647, 23069, 8, 1001, 14, 23069, 304, 339, 30131, 63, 4807, 275, 2071, 57, 3295, 77, 3295, 68, 2, 272, 17032, 63, 4807, 275, 2071, 40, 2689, 45, 2689, 51, 2, 339, 347, 849, 8, 277, 12, 312, 304, 267, 340, 1228, 8, 79, 12, 663, 304, 288, 372, 769, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 2197, 14, 2083, 304, 288, 372, 312, 14, 6205, 3647, 83, 450, 83, 2, 450, 334, 277, 14, 5390, 63, 4807, 12, 291, 14, 4961, 63, 4807, 430, 267, 916, 1228, 8, 79, 12, 2197, 14, 602, 304, 288, 372, 312, 14, 6205, 8, 277, 14, 5390, 63, 4807, 9, 267, 916, 1228, 8, 79, 12, 2197, 14, 521, 304, 288, 372, 312, 14, 6205, 8, 277, 14, 4961, 63, 4807, 9, 267, 916, 1228, 8, 79, 12, 6107, 14, 6745, 304, 288, 372, 620, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 10133, 14, 9937, 304, 288, 372, 620, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 3523, 2081, 304, 288, 372, 1211, 8, 79, 9, 267, 916, 1228, 8, 79, 12, 4784, 304, 288, 372, 23054, 83, 450, 83, 450, 83, 4335, 450, 334, 466, 8, 79, 2843, 354, 3108, 312, 14, 765, 12, 312, 14, 633, 9, 267, 916, 1228, 8, 79, 12, 7232, 304, 288, 372, 23054, 83, 450, 83, 450, 83, 4335, 450, 334, 466, 8, 79, 2843, 354, 3108, 312, 14, 1205, 12, 312, 14, 633, 9, 267, 587, 26, 288, 372, 1613, 8, 7181, 345, 647, 23069, 12, 291, 680, 885, 8, 79, 9, 421, 199, 533, 13916, 345, 647, 6243, 8326, 8, 1001, 14, 6243, 8326, 304, 272, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ujjvala-addsol/addsol_hr
openerp/addons/payment_ogone/tests/test_ogone.py
430
9309
# -*- coding: utf-8 -*- from lxml import objectify import time import urlparse from openerp.addons.payment.models.payment_acquirer import ValidationError from openerp.addons.payment.tests.common import PaymentAcquirerCommon from openerp.addons.payment_ogone.controllers.main import OgoneController from openerp.tools import mute_logger class OgonePayment(PaymentAcquirerCommon): def setUp(self): super(OgonePayment, self).setUp() cr, uid = self.cr, self.uid self.base_url = self.registry('ir.config_parameter').get_param(cr, uid, 'web.base.url') # get the adyen account model, self.ogone_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'payment_ogone', 'payment_acquirer_ogone') def test_10_ogone_form_render(self): cr, uid, context = self.cr, self.uid, {} # be sure not to do stupid thing ogone = self.payment_acquirer.browse(self.cr, self.uid, self.ogone_id, None) self.assertEqual(ogone.environment, 'test', 'test without test environment') # ---------------------------------------- # Test: button direct rendering + shasign # ---------------------------------------- form_values = { 'PSPID': 'dummy', 'ORDERID': 'test_ref0', 'AMOUNT': '1', 'CURRENCY': 'EUR', 'LANGUAGE': 'en_US', 'CN': 'Norbert Buyer', 'EMAIL': 'norbert.buyer@example.com', 'OWNERZIP': '1000', 'OWNERADDRESS': 'Huge Street 2/543', 'OWNERCTY': 'Belgium', 'OWNERTOWN': 'Sin City', 'OWNERTELNO': '0032 12 34 56 78', 'SHASIGN': '815f67b8ff70d234ffcf437c13a9fa7f807044cc', 'ACCEPTURL': '%s' % urlparse.urljoin(self.base_url, OgoneController._accept_url), 'DECLINEURL': '%s' % urlparse.urljoin(self.base_url, OgoneController._decline_url), 'EXCEPTIONURL': '%s' % urlparse.urljoin(self.base_url, OgoneController._exception_url), 'CANCELURL': '%s' % urlparse.urljoin(self.base_url, OgoneController._cancel_url), } # render the button res = self.payment_acquirer.render( cr, uid, self.ogone_id, 'test_ref0', 0.01, self.currency_euro_id, partner_id=None, partner_values=self.buyer_values, context=context) # check form result tree = objectify.fromstring(res) self.assertEqual(tree.get('action'), 'https://secure.ogone.com/ncol/test/orderstandard.asp', 'ogone: wrong form POST url') for form_input in tree.input: if form_input.get('name') in ['submit']: continue self.assertEqual( form_input.get('value'), form_values[form_input.get('name')], 'ogone: wrong value for input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')]) ) # ---------------------------------------- # Test2: button using tx + validation # ---------------------------------------- # create a new draft tx tx_id = self.payment_transaction.create( cr, uid, { 'amount': 0.01, 'acquirer_id': self.ogone_id, 'currency_id': self.currency_euro_id, 'reference': 'test_ref0', 'partner_id': self.buyer_id, }, context=context ) # render the button res = self.payment_acquirer.render( cr, uid, self.ogone_id, 'should_be_erased', 0.01, self.currency_euro, tx_id=tx_id, partner_id=None, partner_values=self.buyer_values, context=context) # check form result tree = objectify.fromstring(res) self.assertEqual(tree.get('action'), 'https://secure.ogone.com/ncol/test/orderstandard.asp', 'ogone: wrong form POST url') for form_input in tree.input: if form_input.get('name') in ['submit']: continue self.assertEqual( form_input.get('value'), form_values[form_input.get('name')], 'ogone: wrong value for form input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')]) ) @mute_logger('openerp.addons.payment_ogone.models.ogone', 'ValidationError') def test_20_ogone_form_management(self): cr, uid, context = self.cr, self.uid, {} # be sure not to do stupid thing ogone = self.payment_acquirer.browse(self.cr, self.uid, self.ogone_id, None) self.assertEqual(ogone.environment, 'test', 'test without test environment') # typical data posted by ogone after client has successfully paid ogone_post_data = { 'orderID': u'test_ref_2', 'STATUS': u'9', 'CARDNO': u'XXXXXXXXXXXX0002', 'PAYID': u'25381582', 'CN': u'Norbert Buyer', 'NCERROR': u'0', 'TRXDATE': u'11/15/13', 'IP': u'85.201.233.72', 'BRAND': u'VISA', 'ACCEPTANCE': u'test123', 'currency': u'EUR', 'amount': u'1.95', 'SHASIGN': u'7B7B0ED9CBC4A85543A9073374589033A62A05A5', 'ED': u'0315', 'PM': u'CreditCard' } # should raise error about unknown tx with self.assertRaises(ValidationError): self.payment_transaction.ogone_form_feedback(cr, uid, ogone_post_data, context=context) # create tx tx_id = self.payment_transaction.create( cr, uid, { 'amount': 1.95, 'acquirer_id': self.ogone_id, 'currency_id': self.currency_euro_id, 'reference': 'test_ref_2', 'partner_name': 'Norbert Buyer', 'partner_country_id': self.country_france_id, }, context=context ) # validate it self.payment_transaction.ogone_form_feedback(cr, uid, ogone_post_data, context=context) # check state tx = self.payment_transaction.browse(cr, uid, tx_id, context=context) self.assertEqual(tx.state, 'done', 'ogone: validation did not put tx into done state') self.assertEqual(tx.ogone_payid, ogone_post_data.get('PAYID'), 'ogone: validation did not update tx payid') # reset tx tx.write({'state': 'draft', 'date_validate': False, 'ogone_payid': False}) # now ogone post is ok: try to modify the SHASIGN ogone_post_data['SHASIGN'] = 'a4c16bae286317b82edb49188d3399249a784691' with self.assertRaises(ValidationError): self.payment_transaction.ogone_form_feedback(cr, uid, ogone_post_data, context=context) # simulate an error ogone_post_data['STATUS'] = 2 ogone_post_data['SHASIGN'] = 'a4c16bae286317b82edb49188d3399249a784691' self.payment_transaction.ogone_form_feedback(cr, uid, ogone_post_data, context=context) # check state tx = self.payment_transaction.browse(cr, uid, tx_id, context=context) self.assertEqual(tx.state, 'error', 'ogone: erroneous validation did not put tx into error state') def test_30_ogone_s2s(self): test_ref = 'test_ref_%.15f' % time.time() cr, uid, context = self.cr, self.uid, {} # be sure not to do stupid thing ogone = self.payment_acquirer.browse(self.cr, self.uid, self.ogone_id, None) self.assertEqual(ogone.environment, 'test', 'test without test environment') # create a new draft tx tx_id = self.payment_transaction.create( cr, uid, { 'amount': 0.01, 'acquirer_id': self.ogone_id, 'currency_id': self.currency_euro_id, 'reference': test_ref, 'partner_id': self.buyer_id, 'type': 'server2server', }, context=context ) # create an alias res = self.payment_transaction.ogone_s2s_create_alias( cr, uid, tx_id, { 'expiry_date_mm': '01', 'expiry_date_yy': '2015', 'holder_name': 'Norbert Poilu', 'number': '4000000000000002', 'brand': 'VISA', }, context=context) # check an alias is set, containing at least OPENERP tx = self.payment_transaction.browse(cr, uid, tx_id, context=context) self.assertIn('OPENERP', tx.partner_reference, 'ogone: wrong partner reference after creating an alias') res = self.payment_transaction.ogone_s2s_execute(cr, uid, tx_id, {}, context=context) # print res # { # 'orderID': u'reference', # 'STATUS': u'9', # 'CARDNO': u'XXXXXXXXXXXX0002', # 'PAYID': u'24998692', # 'CN': u'Norbert Poilu', # 'NCERROR': u'0', # 'TRXDATE': u'11/05/13', # 'IP': u'85.201.233.72', # 'BRAND': u'VISA', # 'ACCEPTANCE': u'test123', # 'currency': u'EUR', # 'amount': u'1.95', # 'SHASIGN': u'EFDC56879EF7DE72CCF4B397076B5C9A844CB0FA', # 'ED': u'0314', # 'PM': u'CreditCard' # }
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 14490, 492, 1559, 825, 3338, 199, 646, 900, 199, 646, 7097, 199, 199, 504, 5166, 14, 10788, 14, 7948, 14, 992, 14, 7948, 63, 28729, 492, 8505, 199, 504, 5166, 14, 10788, 14, 7948, 14, 2219, 14, 2330, 492, 25523, 1945, 2272, 82, 7844, 199, 504, 5166, 14, 10788, 14, 7948, 63, 29163, 14, 20531, 14, 973, 492, 593, 32227, 7506, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 593, 32227, 22374, 8, 22374, 1945, 2272, 82, 7844, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 47, 32227, 22374, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 1095, 63, 633, 275, 291, 14, 5189, 360, 723, 14, 888, 63, 5329, 1959, 362, 63, 635, 8, 1556, 12, 1747, 12, 283, 2520, 14, 1095, 14, 633, 358, 398, 327, 664, 314, 1503, 28695, 2933, 267, 1402, 12, 291, 14, 29163, 63, 344, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 7948, 63, 29163, 297, 283, 7948, 63, 28729, 63, 29163, 358, 339, 347, 511, 63, 709, 63, 29163, 63, 964, 63, 3352, 8, 277, 304, 267, 2467, 12, 1747, 12, 1067, 275, 291, 14, 1556, 12, 291, 14, 1535, 12, 1052, 267, 327, 506, 3238, 440, 370, 886, 410, 31596, 8377, 267, 312, 32227, 275, 291, 14, 7948, 63, 28729, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 29163, 63, 344, 12, 488, 9, 267, 291, 14, 629, 8, 29163, 14, 5418, 12, 283, 396, 297, 283, 396, 1928, 511, 3734, 358, 398, 327, 11016, 518, 267, 327, 1379, 26, 5528, 4125, 14066, 435, 1033, 305, 1030, 267, 327, 11016, 518, 398, 1824, 63, 1459, 275, 469, 288, 283, 5067, 16098, 356, 283, 5869, 297, 288, 283, 12125, 998, 356, 283, 396, 63, 1121, 16, 297, 288, 283, 1156, 47, 17252, 356, 283, 17, 297, 288, 283, 7013, 24861, 356, 283, 37, 1230, 297, 288, 283, 13947, 356, 283, 287, 63, 1668, 297, 288, 283, 12874, 356, 283, 23008, 12504, 4779, 23009, 297, 288, 283, 10089, 356, 283, 6505, 12504, 14, 464, 23009, 32, 2694, 14, 957, 297, 288, 283, 22307, 16977, 356, 283, 5279, 297, 288, 283, 22307, 12368, 356, 283, 40, 17730, 14259, 499, 15, 20103, 297, 288, 283, 22307, 1028, 57, 356, 283, 34, 352, 71, 5170, 297, 288, 283, 22307, 2566, 3705, 356, 283, 30840, 14753, 297, 288, 283, 47, 3705, 5397, 2901, 2826, 356, 283, 30867, 3144, 8177, 12001, 14679, 297, 288, 283, 3234, 1179, 3203, 356, 283, 28250, 70, 1822, 66, 24, 556, 2760, 68, 5533, 556, 2177, 21717, 67, 969, 65, 25, 667, 23, 70, 11369, 9111, 2055, 297, 288, 283, 13089, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 5694, 63, 633, 395, 288, 283, 27402, 3565, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 9427, 1132, 63, 633, 395, 288, 283, 15375, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 1971, 63, 633, 395, 288, 283, 20707, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 6406, 63, 633, 395, 267, 789, 398, 327, 3795, 314, 5528, 267, 522, 275, 291, 14, 7948, 63, 28729, 14, 3352, 8, 288, 2467, 12, 1747, 12, 291, 14, 29163, 63, 344, 12, 288, 283, 396, 63, 1121, 16, 297, 378, 14, 614, 12, 291, 14, 4968, 63, 27089, 63, 344, 12, 288, 5854, 63, 344, 29, 403, 12, 288, 5854, 63, 1459, 29, 277, 14, 464, 23009, 63, 1459, 12, 288, 1067, 29, 1100, 9, 398, 327, 1104, 1824, 754, 267, 3123, 275, 1559, 825, 3338, 14, 13521, 8, 470, 9, 267, 291, 14, 629, 8, 2350, 14, 362, 360, 1287, 659, 283, 2859, 921, 7817, 14, 29163, 14, 957, 15, 78, 761, 15, 396, 15, 1648, 6807, 14, 20222, 297, 283, 29163, 26, 6835, 1824, 8761, 1166, 358, 267, 367, 1824, 63, 1210, 315, 3123, 14, 1210, 26, 288, 340, 1824, 63, 1210, 14, 362, 360, 354, 358, 315, 788, 7275, 2565, 355, 1980, 288, 291, 14, 629, 8, 355, 1824, 63, 1210, 14, 362, 360, 585, 659, 355, 1824, 63, 1459, 59, 964, 63, 1210, 14, 362, 360, 354, 2665, 355, 283, 29163, 26, 6835, 574, 367, 1324, 450, 83, 26, 3086, 450, 83, 3140, 402, 450, 83, 7, 450, 334, 964, 63, 1210, 14, 362, 360, 354, 659, 1824, 63, 1210, 14, 362, 360, 585, 659, 1824, 63, 1459, 59, 964, 63, 1210, 14, 362, 360, 354, 2023, 288, 776, 398, 327, 11016, 518, 267, 327, 1379, 18, 26, 5528, 1808, 4773, 435, 6411, 267, 327, 11016, 518, 398, 327, 1218, 282, 892, 11872, 4773, 267, 4773, 63, 344, 275, 291, 14, 7948, 63, 5945, 14, 981, 8, 288, 2467, 12, 1747, 12, 469, 355, 283, 4606, 356, 378, 14, 614, 12, 355, 283, 28729, 63, 344, 356, 291, 14, 29163, 63, 344, 12, 355, 283, 4968, 63, 344, 356, 291, 14, 4968, 63, 27089, 63, 344, 12, 355, 283, 4443, 356, 283, 396, 63, 1121, 16, 297, 355, 283, 3899, 63, 344, 356, 291, 14, 464, 23009, 63, 344, 12, 288, 1660, 1067, 29, 1100, 267, 776, 267, 327, 3795, 314, 5528, 267, 522, 275, 291, 14, 7948, 63, 28729, 14, 3352, 8, 288, 2467, 12, 1747, 12, 291, 14, 29163, 63, 344, 12, 288, 283, 5626, 63, 1235, 63, 281, 11185, 297, 378, 14, 614, 12, 291, 14, 4968, 63, 27089, 12, 288, 4773, 63, 344, 29, 2347, 63, 344, 12, 288, 5854, 63, 344, 29, 403, 12, 288, 5854, 63, 1459, 29, 277, 14, 464, 23009, 63, 1459, 12, 288, 1067, 29, 1100, 9, 398, 327, 1104, 1824, 754, 267, 3123, 275, 1559, 825, 3338, 14, 13521, 8, 470, 9, 267, 291, 14, 629, 8, 2350, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 14490, 492, 1559, 825, 3338, 199, 646, 900, 199, 646, 7097, 199, 199, 504, 5166, 14, 10788, 14, 7948, 14, 992, 14, 7948, 63, 28729, 492, 8505, 199, 504, 5166, 14, 10788, 14, 7948, 14, 2219, 14, 2330, 492, 25523, 1945, 2272, 82, 7844, 199, 504, 5166, 14, 10788, 14, 7948, 63, 29163, 14, 20531, 14, 973, 492, 593, 32227, 7506, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 593, 32227, 22374, 8, 22374, 1945, 2272, 82, 7844, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 47, 32227, 22374, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 1095, 63, 633, 275, 291, 14, 5189, 360, 723, 14, 888, 63, 5329, 1959, 362, 63, 635, 8, 1556, 12, 1747, 12, 283, 2520, 14, 1095, 14, 633, 358, 398, 327, 664, 314, 1503, 28695, 2933, 267, 1402, 12, 291, 14, 29163, 63, 344, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 7948, 63, 29163, 297, 283, 7948, 63, 28729, 63, 29163, 358, 339, 347, 511, 63, 709, 63, 29163, 63, 964, 63, 3352, 8, 277, 304, 267, 2467, 12, 1747, 12, 1067, 275, 291, 14, 1556, 12, 291, 14, 1535, 12, 1052, 267, 327, 506, 3238, 440, 370, 886, 410, 31596, 8377, 267, 312, 32227, 275, 291, 14, 7948, 63, 28729, 14, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 29163, 63, 344, 12, 488, 9, 267, 291, 14, 629, 8, 29163, 14, 5418, 12, 283, 396, 297, 283, 396, 1928, 511, 3734, 358, 398, 327, 11016, 518, 267, 327, 1379, 26, 5528, 4125, 14066, 435, 1033, 305, 1030, 267, 327, 11016, 518, 398, 1824, 63, 1459, 275, 469, 288, 283, 5067, 16098, 356, 283, 5869, 297, 288, 283, 12125, 998, 356, 283, 396, 63, 1121, 16, 297, 288, 283, 1156, 47, 17252, 356, 283, 17, 297, 288, 283, 7013, 24861, 356, 283, 37, 1230, 297, 288, 283, 13947, 356, 283, 287, 63, 1668, 297, 288, 283, 12874, 356, 283, 23008, 12504, 4779, 23009, 297, 288, 283, 10089, 356, 283, 6505, 12504, 14, 464, 23009, 32, 2694, 14, 957, 297, 288, 283, 22307, 16977, 356, 283, 5279, 297, 288, 283, 22307, 12368, 356, 283, 40, 17730, 14259, 499, 15, 20103, 297, 288, 283, 22307, 1028, 57, 356, 283, 34, 352, 71, 5170, 297, 288, 283, 22307, 2566, 3705, 356, 283, 30840, 14753, 297, 288, 283, 47, 3705, 5397, 2901, 2826, 356, 283, 30867, 3144, 8177, 12001, 14679, 297, 288, 283, 3234, 1179, 3203, 356, 283, 28250, 70, 1822, 66, 24, 556, 2760, 68, 5533, 556, 2177, 21717, 67, 969, 65, 25, 667, 23, 70, 11369, 9111, 2055, 297, 288, 283, 13089, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 5694, 63, 633, 395, 288, 283, 27402, 3565, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 9427, 1132, 63, 633, 395, 288, 283, 15375, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 1971, 63, 633, 395, 288, 283, 20707, 2632, 356, 1543, 83, 7, 450, 7097, 14, 17755, 8, 277, 14, 1095, 63, 633, 12, 593, 32227, 7506, 423, 6406, 63, 633, 395, 267, 789, 398, 327, 3795, 314, 5528, 267, 522, 275, 291, 14, 7948, 63, 28729, 14, 3352, 8, 288, 2467, 12, 1747, 12, 291, 14, 29163, 63, 344, 12, 288, 283, 396, 63, 1121, 16, 297, 378, 14, 614, 12, 291, 14, 4968, 63, 27089, 63, 344, 12, 288, 5854, 63, 344, 29, 403, 12, 288, 5854, 63, 1459, 29, 277, 14, 464, 23009, 63, 1459, 12, 288, 1067, 29, 1100, 9, 398, 327, 1104, 1824, 754, 267, 3123, 275, 1559, 825, 3338, 14, 13521, 8, 470, 9, 267, 291, 14, 629, 8, 2350, 14, 362, 360, 1287, 659, 283, 2859, 921, 7817, 14, 29163, 14, 957, 15, 78, 761, 15, 396, 15, 1648, 6807, 14, 20222, 297, 283, 29163, 26, 6835, 1824, 8761, 1166, 358, 267, 367, 1824, 63, 1210, 315, 3123, 14, 1210, 26, 288, 340, 1824, 63, 1210, 14, 362, 360, 354, 358, 315, 788, 7275, 2565, 355, 1980, 288, 291, 14, 629, 8, 355, 1824, 63, 1210, 14, 362, 360, 585, 659, 355, 1824, 63, 1459, 59, 964, 63, 1210, 14, 362, 360, 354, 2665, 355, 283, 29163, 26, 6835, 574, 367, 1324, 450, 83, 26, 3086, 450, 83, 3140, 402, 450, 83, 7, 450, 334, 964, 63, 1210, 14, 362, 360, 354, 659, 1824, 63, 1210, 14, 362, 360, 585, 659, 1824, 63, 1459, 59, 964, 63, 1210, 14, 362, 360, 354, 2023, 288, 776, 398, 327, 11016, 518, 267, 327, 1379, 18, 26, 5528, 1808, 4773, 435, 6411, 267, 327, 11016, 518, 398, 327, 1218, 282, 892, 11872, 4773, 267, 4773, 63, 344, 275, 291, 14, 7948, 63, 5945, 14, 981, 8, 288, 2467, 12, 1747, 12, 469, 355, 283, 4606, 356, 378, 14, 614, 12, 355, 283, 28729, 63, 344, 356, 291, 14, 29163, 63, 344, 12, 355, 283, 4968, 63, 344, 356, 291, 14, 4968, 63, 27089, 63, 344, 12, 355, 283, 4443, 356, 283, 396, 63, 1121, 16, 297, 355, 283, 3899, 63, 344, 356, 291, 14, 464, 23009, 63, 344, 12, 288, 1660, 1067, 29, 1100, 267, 776, 267, 327, 3795, 314, 5528, 267, 522, 275, 291, 14, 7948, 63, 28729, 14, 3352, 8, 288, 2467, 12, 1747, 12, 291, 14, 29163, 63, 344, 12, 288, 283, 5626, 63, 1235, 63, 281, 11185, 297, 378, 14, 614, 12, 291, 14, 4968, 63, 27089, 12, 288, 4773, 63, 344, 29, 2347, 63, 344, 12, 288, 5854, 63, 344, 29, 403, 12, 288, 5854, 63, 1459, 29, 277, 14, 464, 23009, 63, 1459, 12, 288, 1067, 29, 1100, 9, 398, 327, 1104, 1824, 754, 267, 3123, 275, 1559, 825, 3338, 14, 13521, 8, 470, 9, 267, 291, 14, 629, 8, 2350, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dweisz/pydolphot
make_fakerun.py
1
2967
import numpy as np import sys import subprocess import os ''' def makephotfiles(base, nstart, nruns, nimages): for i in range(nstart,nstart+nruns): for j in range(1, nimages+1): subprocess.call("ln -s "+base+"."+np.str(j)+".res.fits " + base+"_"+np.str(i)+"."+np.str(j)+".res.fits", shell=True) subprocess.call("ln -s "+base+"."+np.str(j)+".psf.fits " + base+"_"+np.str(i)+"."+np.str(j)+".psf.fits", shell=True) subprocess.call("ln -s "+base+".info " + base+"_"+np.str(i)+".info", shell=True) subprocess.call("ln -s "+base+".apcor " + base+"_"+np.str(i)+".apcor", shell=True) subprocess.call("ln -s "+base+".psfs " + base+"_"+np.str(i)+".psfs", shell=True) subprocess.call("ln -s "+base+".columns " + base+"_"+np.str(i)+".columns", shell=True) subprocess.call("ln -s "+base + " " + base+"_"+np.str(i), shell=True) ''' def makefakelist(photfile, filter1, filter2, fmin, fmax, cmin, cmax, nruns, nstars=15000, nstart=1): for i in range(nstart, nstart+nruns): subprocess.call('fakelist '+ np.str(photfile) + ' ' + np.str(filter1) + ' ' + np.str(filter2) + ' ' + np.str(fmin) + ' ' + np.str(fmax) + ' ' + np.str(cmin) + ' ' + np.str(cmax) + ' ' + "-nstar=" + np.str(nstars) + "> fake.list_" + np.str(i), shell=True) subprocess.call('sleep 5', shell=True ) def makefakeparam(param_file, base, nruns, nstart=1): infile = param_file for i in range(nstart, nstart+nruns): fakeparam = "phot.fake_"+np.str(i)+".param" subprocess.call("cp "+infile+" "+fakeparam, shell=True) outfile = fakeparam f1 = open(fakeparam, 'a') f1.write("ACSuseCTE = 1\n") f1.write("WFC3useCTE = 1\n") f1.write("RandomFake = 1\n") f1.write("FakeMatch=3.0\n") f1.write("FakePad=0\n") f1.write("FakeStarPSF = 1.5\n") f1.write("FakeOut="+base+"_fake_"+np.str(i)+".fake\n") f1.write("FakeStars=fake.list_"+np.str(i)+"\n") f1.close() def makerunfake(param_file, base, nruns, nstart=1): for i in range(nstart, nstart+nruns): fakeparam = "phot.fake_"+np.str(i)+".param" outfile = "runfake"+np.str(i) f = open(outfile, 'w') f.write("cd " + os.getcwd()+"\n") f.write("dolphot " + base+ " -p" + fakeparam + " >> fake.log_"+np.str(i)) f.close() subprocess.call("chmod +x " + outfile, shell=True) ''' cd /clusterfs/dweisz/photometry/leop/ dolphot leop_acs.phot_1 -pleop.fake.param_1 >> fake1.log ''' #if __name__ == '__main__': base = sys.argv[1] # e.g., test.phot #rundir = sys.argv[2] #nimages = np.int(sys.argv[3]) #name = sys.argv[3] param_file = sys.argv[2] # name of photometry parameter file nruns = np.int(sys.argv[3]) filters = sys.argv[4] f1min = np.float(sys.argv[5]) f1max = np.float(sys.argv[6]) c1min = np.float(sys.argv[7]) c1max = np.float(sys.argv[8]) #nimages = 12 #nruns = 72 #makephotfiles(base, 1, nruns , nimages) makefakeparam(param_file, base, nruns) makerunfake(param_file, base, nruns) makefakelist(base, filters.split()[0], filters.split()[1], f1min, f1max, c1min, c1max, nruns) #main()
mit
[ 646, 2680, 465, 980, 199, 646, 984, 221, 199, 646, 3873, 221, 199, 646, 747, 199, 199, 2344, 199, 318, 1852, 838, 357, 1725, 8, 1095, 12, 302, 928, 12, 302, 10802, 12, 302, 4782, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 78, 928, 11, 78, 10802, 304, 507, 198, 509, 1335, 315, 1425, 8, 17, 12, 302, 4782, 11, 17, 304, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 470, 14, 14948, 298, 221, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 470, 14, 14948, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 1190, 70, 14, 14948, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 1190, 70, 14, 14948, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 815, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 815, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 439, 989, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 439, 989, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 1190, 2319, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 1190, 2319, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 3406, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 3406, 401, 5218, 29, 549, 9, 2742, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 435, 298, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 395, 5218, 29, 549, 9, 199, 2344, 421, 199, 318, 1852, 3183, 513, 8, 838, 357, 493, 12, 2457, 17, 12, 2457, 18, 12, 289, 827, 12, 289, 988, 12, 286, 827, 12, 286, 988, 12, 302, 10802, 12, 302, 270, 4291, 29, 1046, 1493, 12, 302, 928, 29, 17, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 5781, 14, 1250, 360, 3183, 513, 6681, 980, 14, 495, 8, 838, 357, 493, 9, 435, 283, 283, 435, 980, 14, 495, 8, 1541, 17, 9, 435, 283, 283, 435, 980, 14, 495, 8, 1541, 18, 9, 435, 283, 283, 435, 980, 14, 495, 8, 70, 827, 9, 435, 283, 283, 435, 980, 14, 495, 8, 70, 988, 9, 435, 283, 283, 435, 980, 14, 495, 8, 67, 827, 9, 435, 283, 283, 435, 980, 14, 495, 8, 67, 988, 9, 435, 283, 283, 435, 3905, 78, 7848, 628, 435, 980, 14, 495, 8, 78, 270, 4291, 9, 435, 15281, 4026, 14, 513, 12172, 435, 980, 14, 495, 8, 73, 395, 5218, 29, 549, 9, 507, 198, 5781, 14, 1250, 360, 4532, 959, 297, 5218, 29, 549, 776, 199, 199, 318, 1852, 3183, 635, 8, 635, 63, 493, 12, 1300, 12, 302, 10802, 12, 302, 928, 29, 17, 304, 199, 198, 13880, 275, 1215, 63, 493, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 3183, 635, 275, 298, 838, 357, 14, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 635, 2, 507, 198, 5781, 14, 1250, 480, 1850, 7210, 13880, 5207, 7210, 3183, 635, 12, 5218, 29, 549, 9, 507, 198, 4984, 275, 4026, 635, 507, 198, 70, 17, 275, 1551, 8, 3183, 635, 12, 283, 65, 358, 507, 198, 70, 17, 14, 952, 480, 1348, 51, 1180, 1028, 37, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 55, 4161, 19, 1180, 1028, 37, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 3883, 8249, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 4486, 29, 19, 14, 16, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 18584, 29, 16, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 23197, 5067, 38, 275, 413, 14, 21, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 2204, 16368, 1095, 30056, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 3183, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 933, 4291, 29, 3183, 14, 513, 63, 7709, 1590, 14, 495, 8, 73, 6393, 3212, 78, 531, 507, 198, 70, 17, 14, 1600, 342, 199, 199, 318, 610, 2570, 324, 3183, 8, 635, 63, 493, 12, 1300, 12, 302, 10802, 12, 302, 928, 29, 17, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 3183, 635, 275, 298, 838, 357, 14, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 635, 2, 507, 198, 4984, 275, 298, 1065, 3183, 7709, 1590, 14, 495, 8, 73, 9, 507, 198, 70, 275, 1551, 8, 4984, 12, 283, 87, 358, 507, 198, 70, 14, 952, 480, 2866, 298, 435, 747, 14, 9458, 24543, 3212, 78, 531, 507, 198, 70, 14, 952, 480, 68, 393, 838, 357, 298, 435, 1300, 11, 298, 446, 80, 2, 435, 4026, 635, 435, 298, 4331, 4026, 14, 793, 63, 7709, 1590, 14, 495, 8, 73, 430, 507, 198, 70, 14, 1600, 342, 507, 198, 5781, 14, 1250, 480, 11693, 435, 88, 298, 435, 4386, 12, 5218, 29, 549, 9, 28154, 199, 2344, 199, 2866, 1182, 4201, 2319, 15, 68, 1129, 374, 90, 15, 838, 357, 2358, 15, 274, 411, 15, 199, 68, 393, 838, 357, 1026, 411, 63, 645, 83, 14, 838, 357, 63, 17, 446, 11045, 411, 14, 3183, 14, 635, 63, 17, 4331, 4026, 17, 14, 793, 199, 2344, 199, 199, 3, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 199, 1095, 275, 984, 14, 3020, 59, 17, 61, 221, 327, 325, 14, 71, 2020, 511, 14, 838, 357, 199, 3, 1065, 694, 275, 984, 14 ]
[ 2680, 465, 980, 199, 646, 984, 221, 199, 646, 3873, 221, 199, 646, 747, 199, 199, 2344, 199, 318, 1852, 838, 357, 1725, 8, 1095, 12, 302, 928, 12, 302, 10802, 12, 302, 4782, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 78, 928, 11, 78, 10802, 304, 507, 198, 509, 1335, 315, 1425, 8, 17, 12, 302, 4782, 11, 17, 304, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 470, 14, 14948, 298, 221, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 470, 14, 14948, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 1190, 70, 14, 14948, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 7709, 1590, 14, 495, 8, 74, 6393, 1674, 1190, 70, 14, 14948, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 815, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 815, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 439, 989, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 439, 989, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 1190, 2319, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 1190, 2319, 401, 5218, 29, 549, 9, 686, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 24878, 3406, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 3406, 401, 5218, 29, 549, 9, 2742, 198, 5781, 14, 1250, 480, 6066, 446, 83, 7210, 1095, 435, 298, 298, 435, 1300, 30056, 7709, 1590, 14, 495, 8, 73, 395, 5218, 29, 549, 9, 199, 2344, 421, 199, 318, 1852, 3183, 513, 8, 838, 357, 493, 12, 2457, 17, 12, 2457, 18, 12, 289, 827, 12, 289, 988, 12, 286, 827, 12, 286, 988, 12, 302, 10802, 12, 302, 270, 4291, 29, 1046, 1493, 12, 302, 928, 29, 17, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 5781, 14, 1250, 360, 3183, 513, 6681, 980, 14, 495, 8, 838, 357, 493, 9, 435, 283, 283, 435, 980, 14, 495, 8, 1541, 17, 9, 435, 283, 283, 435, 980, 14, 495, 8, 1541, 18, 9, 435, 283, 283, 435, 980, 14, 495, 8, 70, 827, 9, 435, 283, 283, 435, 980, 14, 495, 8, 70, 988, 9, 435, 283, 283, 435, 980, 14, 495, 8, 67, 827, 9, 435, 283, 283, 435, 980, 14, 495, 8, 67, 988, 9, 435, 283, 283, 435, 3905, 78, 7848, 628, 435, 980, 14, 495, 8, 78, 270, 4291, 9, 435, 15281, 4026, 14, 513, 12172, 435, 980, 14, 495, 8, 73, 395, 5218, 29, 549, 9, 507, 198, 5781, 14, 1250, 360, 4532, 959, 297, 5218, 29, 549, 776, 199, 199, 318, 1852, 3183, 635, 8, 635, 63, 493, 12, 1300, 12, 302, 10802, 12, 302, 928, 29, 17, 304, 199, 198, 13880, 275, 1215, 63, 493, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 3183, 635, 275, 298, 838, 357, 14, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 635, 2, 507, 198, 5781, 14, 1250, 480, 1850, 7210, 13880, 5207, 7210, 3183, 635, 12, 5218, 29, 549, 9, 507, 198, 4984, 275, 4026, 635, 507, 198, 70, 17, 275, 1551, 8, 3183, 635, 12, 283, 65, 358, 507, 198, 70, 17, 14, 952, 480, 1348, 51, 1180, 1028, 37, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 55, 4161, 19, 1180, 1028, 37, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 3883, 8249, 275, 413, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 4486, 29, 19, 14, 16, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 18584, 29, 16, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 23197, 5067, 38, 275, 413, 14, 21, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 2204, 16368, 1095, 30056, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 3183, 60, 78, 531, 507, 198, 70, 17, 14, 952, 480, 8249, 933, 4291, 29, 3183, 14, 513, 63, 7709, 1590, 14, 495, 8, 73, 6393, 3212, 78, 531, 507, 198, 70, 17, 14, 1600, 342, 199, 199, 318, 610, 2570, 324, 3183, 8, 635, 63, 493, 12, 1300, 12, 302, 10802, 12, 302, 928, 29, 17, 304, 199, 198, 509, 284, 315, 1425, 8, 78, 928, 12, 302, 928, 11, 78, 10802, 304, 507, 198, 3183, 635, 275, 298, 838, 357, 14, 3183, 63, 7709, 1590, 14, 495, 8, 73, 6393, 1674, 635, 2, 507, 198, 4984, 275, 298, 1065, 3183, 7709, 1590, 14, 495, 8, 73, 9, 507, 198, 70, 275, 1551, 8, 4984, 12, 283, 87, 358, 507, 198, 70, 14, 952, 480, 2866, 298, 435, 747, 14, 9458, 24543, 3212, 78, 531, 507, 198, 70, 14, 952, 480, 68, 393, 838, 357, 298, 435, 1300, 11, 298, 446, 80, 2, 435, 4026, 635, 435, 298, 4331, 4026, 14, 793, 63, 7709, 1590, 14, 495, 8, 73, 430, 507, 198, 70, 14, 1600, 342, 507, 198, 5781, 14, 1250, 480, 11693, 435, 88, 298, 435, 4386, 12, 5218, 29, 549, 9, 28154, 199, 2344, 199, 2866, 1182, 4201, 2319, 15, 68, 1129, 374, 90, 15, 838, 357, 2358, 15, 274, 411, 15, 199, 68, 393, 838, 357, 1026, 411, 63, 645, 83, 14, 838, 357, 63, 17, 446, 11045, 411, 14, 3183, 14, 635, 63, 17, 4331, 4026, 17, 14, 793, 199, 2344, 199, 199, 3, 692, 636, 354, 363, 508, 2560, 973, 3706, 199, 199, 1095, 275, 984, 14, 3020, 59, 17, 61, 221, 327, 325, 14, 71, 2020, 511, 14, 838, 357, 199, 3, 1065, 694, 275, 984, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
garthomp/ruby_blog
node_modules/grunt-docker/node_modules/docker/node_modules/pygmentize-bundled/vendor/pygments/build-2.7/pygments/styles/vs.py
364
1073
# -*- coding: utf-8 -*- """ pygments.styles.vs ~~~~~~~~~~~~~~~~~~ Simple style with MS Visual Studio colors. :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Operator, Generic class VisualStudioStyle(Style): background_color = "#ffffff" default_style = "" styles = { Comment: "#008000", Comment.Preproc: "#0000ff", Keyword: "#0000ff", Operator.Word: "#0000ff", Keyword.Type: "#2b91af", Name.Class: "#2b91af", String: "#a31515", Generic.Heading: "bold", Generic.Subheading: "bold", Generic.Emph: "italic", Generic.Strong: "bold", Generic.Prompt: "bold", Error: "border:#FF0000" }
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12955, 14, 3122, 272, 18294, 1714, 339, 5870, 3449, 543, 14282, 14702, 13225, 9229, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 11013, 12, 8307, 421, 199, 533, 14702, 21025, 6609, 8, 6609, 304, 339, 8020, 63, 2326, 275, 5426, 12596, 2, 272, 849, 63, 2487, 275, 3087, 339, 15725, 275, 469, 267, 6819, 26, 7861, 5426, 8662, 1493, 401, 267, 6819, 14, 19285, 26, 3698, 5426, 993, 556, 401, 267, 6431, 26, 7861, 5426, 993, 556, 401, 267, 11013, 14, 10155, 26, 3777, 5426, 993, 556, 401, 267, 6431, 14, 804, 26, 4519, 5426, 18, 66, 3328, 2756, 401, 267, 2812, 14, 2543, 26, 4483, 5426, 18, 66, 3328, 2756, 401, 267, 2624, 26, 8540, 5426, 65, 9927, 1046, 401, 398, 8307, 14, 23818, 26, 3698, 298, 9771, 401, 267, 8307, 14, 2610, 13983, 26, 263, 298, 9771, 401, 267, 8307, 14, 37, 311, 72, 26, 4519, 298, 21843, 401, 267, 8307, 14, 2848, 951, 26, 3322, 298, 9771, 401, 267, 8307, 14, 20430, 26, 3322, 298, 9771, 401, 398, 4520, 26, 9326, 298, 8665, 15596, 1665, 993, 2, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12955, 14, 3122, 272, 18294, 1714, 339, 5870, 3449, 543, 14282, 14702, 13225, 9229, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 504, 13277, 14, 2487, 492, 19442, 199, 504, 13277, 14, 1418, 492, 6431, 12, 2812, 12, 6819, 12, 2624, 12, 4520, 12, 971, 1362, 11013, 12, 8307, 421, 199, 533, 14702, 21025, 6609, 8, 6609, 304, 339, 8020, 63, 2326, 275, 5426, 12596, 2, 272, 849, 63, 2487, 275, 3087, 339, 15725, 275, 469, 267, 6819, 26, 7861, 5426, 8662, 1493, 401, 267, 6819, 14, 19285, 26, 3698, 5426, 993, 556, 401, 267, 6431, 26, 7861, 5426, 993, 556, 401, 267, 11013, 14, 10155, 26, 3777, 5426, 993, 556, 401, 267, 6431, 14, 804, 26, 4519, 5426, 18, 66, 3328, 2756, 401, 267, 2812, 14, 2543, 26, 4483, 5426, 18, 66, 3328, 2756, 401, 267, 2624, 26, 8540, 5426, 65, 9927, 1046, 401, 398, 8307, 14, 23818, 26, 3698, 298, 9771, 401, 267, 8307, 14, 2610, 13983, 26, 263, 298, 9771, 401, 267, 8307, 14, 37, 311, 72, 26, 4519, 298, 21843, 401, 267, 8307, 14, 2848, 951, 26, 3322, 298, 9771, 401, 267, 8307, 14, 20430, 26, 3322, 298, 9771, 401, 398, 4520, 26, 9326, 298, 8665, 15596, 1665, 993, 2, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
geopython/QGIS
tests/src/python/test_qgsreadwritecontext.py
14
1935
# -*- coding: utf-8 -*- """QGIS Unit tests for QgsReadWriteContext. .. note:: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. """ __author__ = 'Denis Rouzaud' __date__ = '28.02.2018' __copyright__ = 'Copyright 2017, The QGIS Project' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' import qgis # NOQA from qgis.core import Qgis, QgsReadWriteContext from qgis.testing import unittest class TestQgsReadWriteContext(unittest.TestCase): def testEnterCategory(self): context = QgsReadWriteContext() context.pushMessage('msg0', Qgis.Critical) with QgsReadWriteContext.enterCategory(context, 'cat1'): context.pushMessage('msg1', Qgis.Warning) with QgsReadWriteContext.enterCategory(context, 'cat2', "detail2"): context.pushMessage('msg2') context.pushMessage('msg3') context.pushMessage('msg4') messages = context.takeMessages() self.assertEqual(messages[0].message(), 'msg0') self.assertEqual(messages[0].level(), Qgis.Critical) self.assertEqual(messages[0].categories(), []) self.assertEqual(messages[1].message(), 'msg1') self.assertEqual(messages[1].level(), Qgis.Warning) self.assertEqual(messages[1].categories(), ['cat1']) self.assertEqual(messages[2].message(), 'msg2') self.assertEqual(messages[2].categories(), ['cat1', 'cat2 :: detail2']) self.assertEqual(messages[3].message(), 'msg3') self.assertEqual(messages[3].categories(), ['cat1']) self.assertEqual(messages[4].message(), 'msg4') self.assertEqual(messages[4].categories(), []) if __name__ == '__main__': unittest.main()
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 4888, 3284, 3534, 2998, 14, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 10655, 374, 19776, 8076, 1181, 7, 199, 363, 602, 363, 275, 283, 1651, 14, 996, 14, 12682, 7, 199, 363, 7307, 363, 275, 283, 7384, 9708, 12, 710, 27024, 7290, 7, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 15640, 221, 327, 20432, 421, 199, 504, 15640, 14, 1018, 492, 1413, 5668, 12, 4888, 3284, 3534, 2998, 199, 504, 15640, 14, 4776, 492, 2882, 421, 199, 533, 1379, 7350, 3284, 3534, 2998, 8, 2796, 14, 1746, 304, 339, 347, 511, 8468, 7841, 8, 277, 304, 267, 1067, 275, 4888, 3284, 3534, 2998, 342, 267, 1067, 14, 5335, 2209, 360, 1328, 16, 297, 1413, 5668, 14, 27677, 9, 267, 543, 4888, 3284, 3534, 2998, 14, 4200, 7841, 8, 1100, 12, 283, 3385, 17, 735, 288, 1067, 14, 5335, 2209, 360, 1328, 17, 297, 1413, 5668, 14, 3849, 9, 288, 543, 4888, 3284, 3534, 2998, 14, 4200, 7841, 8, 1100, 12, 283, 3385, 18, 297, 298, 5506, 18, 2349, 355, 1067, 14, 5335, 2209, 360, 1328, 18, 358, 288, 1067, 14, 5335, 2209, 360, 1328, 19, 358, 267, 1067, 14, 5335, 2209, 360, 1328, 20, 358, 398, 3788, 275, 1067, 14, 11066, 14508, 342, 398, 291, 14, 629, 8, 3431, 59, 16, 1055, 1188, 1062, 283, 1328, 16, 358, 267, 291, 14, 629, 8, 3431, 59, 16, 1055, 1896, 1062, 1413, 5668, 14, 27677, 9, 267, 291, 14, 629, 8, 3431, 59, 16, 1055, 8906, 1062, 3073, 398, 291, 14, 629, 8, 3431, 59, 17, 1055, 1188, 1062, 283, 1328, 17, 358, 267, 291, 14, 629, 8, 3431, 59, 17, 1055, 1896, 1062, 1413, 5668, 14, 3849, 9, 267, 291, 14, 629, 8, 3431, 59, 17, 1055, 8906, 1062, 788, 3385, 17, 1105, 398, 291, 14, 629, 8, 3431, 59, 18, 1055, 1188, 1062, 283, 1328, 18, 358, 267, 291, 14, 629, 8, 3431, 59, 18, 1055, 8906, 1062, 788, 3385, 17, 297, 283, 3385, 18, 3800, 10093, 18, 1105, 398, 291, 14, 629, 8, 3431, 59, 19, 1055, 1188, 1062, 283, 1328, 19, 358, 267, 291, 14, 629, 8, 3431, 59, 19, 1055, 8906, 1062, 788, 3385, 17, 1105, 398, 291, 14, 629, 8, 3431, 59, 20, 1055, 1188, 1062, 283, 1328, 20, 358, 267, 291, 14, 629, 8, 3431, 59, 20, 1055, 8906, 1062, 3073, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 4888, 3284, 3534, 2998, 14, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 10655, 374, 19776, 8076, 1181, 7, 199, 363, 602, 363, 275, 283, 1651, 14, 996, 14, 12682, 7, 199, 363, 7307, 363, 275, 283, 7384, 9708, 12, 710, 27024, 7290, 7, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 15640, 221, 327, 20432, 421, 199, 504, 15640, 14, 1018, 492, 1413, 5668, 12, 4888, 3284, 3534, 2998, 199, 504, 15640, 14, 4776, 492, 2882, 421, 199, 533, 1379, 7350, 3284, 3534, 2998, 8, 2796, 14, 1746, 304, 339, 347, 511, 8468, 7841, 8, 277, 304, 267, 1067, 275, 4888, 3284, 3534, 2998, 342, 267, 1067, 14, 5335, 2209, 360, 1328, 16, 297, 1413, 5668, 14, 27677, 9, 267, 543, 4888, 3284, 3534, 2998, 14, 4200, 7841, 8, 1100, 12, 283, 3385, 17, 735, 288, 1067, 14, 5335, 2209, 360, 1328, 17, 297, 1413, 5668, 14, 3849, 9, 288, 543, 4888, 3284, 3534, 2998, 14, 4200, 7841, 8, 1100, 12, 283, 3385, 18, 297, 298, 5506, 18, 2349, 355, 1067, 14, 5335, 2209, 360, 1328, 18, 358, 288, 1067, 14, 5335, 2209, 360, 1328, 19, 358, 267, 1067, 14, 5335, 2209, 360, 1328, 20, 358, 398, 3788, 275, 1067, 14, 11066, 14508, 342, 398, 291, 14, 629, 8, 3431, 59, 16, 1055, 1188, 1062, 283, 1328, 16, 358, 267, 291, 14, 629, 8, 3431, 59, 16, 1055, 1896, 1062, 1413, 5668, 14, 27677, 9, 267, 291, 14, 629, 8, 3431, 59, 16, 1055, 8906, 1062, 3073, 398, 291, 14, 629, 8, 3431, 59, 17, 1055, 1188, 1062, 283, 1328, 17, 358, 267, 291, 14, 629, 8, 3431, 59, 17, 1055, 1896, 1062, 1413, 5668, 14, 3849, 9, 267, 291, 14, 629, 8, 3431, 59, 17, 1055, 8906, 1062, 788, 3385, 17, 1105, 398, 291, 14, 629, 8, 3431, 59, 18, 1055, 1188, 1062, 283, 1328, 18, 358, 267, 291, 14, 629, 8, 3431, 59, 18, 1055, 8906, 1062, 788, 3385, 17, 297, 283, 3385, 18, 3800, 10093, 18, 1105, 398, 291, 14, 629, 8, 3431, 59, 19, 1055, 1188, 1062, 283, 1328, 19, 358, 267, 291, 14, 629, 8, 3431, 59, 19, 1055, 8906, 1062, 788, 3385, 17, 1105, 398, 291, 14, 629, 8, 3431, 59, 20, 1055, 1188, 1062, 283, 1328, 20, 358, 267, 291, 14, 629, 8, 3431, 59, 20, 1055, 8906, 1062, 3073, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Biomechanical-ToolKit/BTKCore
Testing/Python/_TDDCommon.py
4
1078
import unittest import EventTest import AnalogTest import PointTest import ForcePlatformTypesTest import EventCollectionTest import PointCollectionTest import MetaDataInfoTest import MetaDataTest import AcquisitionTest import WrenchTest import IMUTypesTest def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(EventTest.EventTest)) suite.addTest(unittest.makeSuite(AnalogTest.AnalogTest)) suite.addTest(unittest.makeSuite(PointTest.PointTest)) suite.addTest(unittest.makeSuite(ForcePlatformTypesTest.ForcePlatformTypesTest)) suite.addTest(unittest.makeSuite(EventCollectionTest.EventCollectionTest)) suite.addTest(unittest.makeSuite(PointCollectionTest.PointCollectionTest)) suite.addTest(unittest.makeSuite(MetaDataInfoTest.MetaDataInfoTest)) suite.addTest(unittest.makeSuite(MetaDataTest.MetaDataTest)) suite.addTest(unittest.makeSuite(AcquisitionTest.AcquisitionTest)) suite.addTest(unittest.makeSuite(WrenchTest.WrenchTest)) suite.addTest(unittest.makeSuite(IMUTypesTest.IMUTypesTest)) return suite
bsd-3-clause
[ 646, 2882, 199, 199, 646, 6763, 774, 199, 646, 1626, 2548, 774, 199, 646, 7584, 774, 199, 646, 18771, 10397, 4100, 774, 199, 646, 6763, 7768, 774, 199, 646, 7584, 7768, 774, 199, 646, 24905, 2354, 774, 199, 646, 24905, 774, 199, 646, 4473, 21523, 774, 199, 646, 644, 15148, 774, 199, 646, 18211, 53, 4100, 774, 199, 199, 318, 5241, 837, 272, 5241, 275, 2882, 14, 10591, 342, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2390, 774, 14, 2390, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2493, 2548, 774, 14, 2493, 2548, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3428, 774, 14, 3428, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 13606, 10397, 4100, 774, 14, 13606, 10397, 4100, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2390, 7768, 774, 14, 2390, 7768, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3428, 7768, 774, 14, 3428, 7768, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 25285, 2354, 774, 14, 25285, 2354, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 25285, 774, 14, 25285, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 1945, 21523, 774, 14, 1945, 21523, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 55, 15148, 774, 14, 55, 15148, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 1469, 53, 4100, 774, 14, 1469, 53, 4100, 774, 430, 272, 372, 5241, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 199, 199, 646, 6763, 774, 199, 646, 1626, 2548, 774, 199, 646, 7584, 774, 199, 646, 18771, 10397, 4100, 774, 199, 646, 6763, 7768, 774, 199, 646, 7584, 7768, 774, 199, 646, 24905, 2354, 774, 199, 646, 24905, 774, 199, 646, 4473, 21523, 774, 199, 646, 644, 15148, 774, 199, 646, 18211, 53, 4100, 774, 199, 199, 318, 5241, 837, 272, 5241, 275, 2882, 14, 10591, 342, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2390, 774, 14, 2390, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2493, 2548, 774, 14, 2493, 2548, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3428, 774, 14, 3428, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 13606, 10397, 4100, 774, 14, 13606, 10397, 4100, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 2390, 7768, 774, 14, 2390, 7768, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 3428, 7768, 774, 14, 3428, 7768, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 25285, 2354, 774, 14, 25285, 2354, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 25285, 774, 14, 25285, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 1945, 21523, 774, 14, 1945, 21523, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 55, 15148, 774, 14, 55, 15148, 774, 430, 272, 5241, 14, 15714, 8, 2796, 14, 18275, 8, 1469, 53, 4100, 774, 14, 1469, 53, 4100, 774, 430, 272, 372, 5241, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
defcello/Children-of-Eden-Synth-Server
src/data/webpages/rolandfantomxr/SRX05.py
4
17998
#################################################################################################### # Copyright 2013 John Crawford # # This file is part of PatchCorral. # # PatchCorral is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # PatchCorral is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with PatchCorral. If not, see <http://www.gnu.org/licenses/>. #################################################################################################### ## @file # Module Information. # @date 3/10/2013 Created file. -jc # @author John Crawford NAME = 'XP-D - SRX-05 - Supreme Dance' PATCHES = [ ('SecretDancer', 93, 4, 0, 'BEAT&GROOVE', 'XP-D 001'), ('Mean Streets', 93, 4, 1, 'BEAT&GROOVE', 'XP-D 002'), ('E-tronic', 93, 4, 2, 'BEAT&GROOVE', 'XP-D 003'), ('License2chil', 93, 4, 3, 'BRIGHT PAD', 'XP-D 004'), ('Scratch Menu', 93, 4, 4, 'SOUND FX', 'XP-D 005'), ('Hit Specials', 93, 4, 5, 'HIT&STAB', 'XP-D 006'), ('Motivation', 93, 4, 6, 'STRINGS', 'XP-D 007'), ('Sine Vibrato', 93, 4, 7, 'SOFT LEAD', 'XP-D 008'), ('Acid Punch', 93, 4, 8, 'SYNTH BASS', 'XP-D 009'), ('E.Gtr Menu', 93, 4, 9, 'EL.GUITAR', 'XP-D 010'), ('Brite Flange', 93, 4, 10, 'BRIGHT PAD', 'XP-D 011'), ('Dance Vibes', 93, 4, 11, 'TECHNO SYNTH', 'XP-D 012'), ('N-Trance', 93, 4, 12, 'PULSATING', 'XP-D 013'), ('Phatt', 93, 4, 13, 'BEAT&GROOVE', 'XP-D 014'), ('DoubleDown', 93, 4, 14, 'BEAT&GROOVE', 'XP-D 015'), ('LoopFX Dark', 93, 4, 15, 'BEAT&GROOVE', 'XP-D 016'), ('Yo DJ', 93, 4, 16, 'BEAT&GROOVE', 'XP-D 017'), ('HH Piledrivr', 93, 4, 17, 'BEAT&GROOVE', 'XP-D 018'), ('Trush Head', 93, 4, 18, 'BEAT&GROOVE', 'XP-D 019'), ('Rap 21', 93, 4, 19, 'BEAT&GROOVE', 'XP-D 020'), ('Teknobeat', 93, 4, 20, 'BEAT&GROOVE', 'XP-D 021'), ('Filter Beat', 93, 4, 21, 'BEAT&GROOVE', 'XP-D 022'), ('FashionStyle', 93, 4, 22, 'BEAT&GROOVE', 'XP-D 023'), ('Strobobeat', 93, 4, 23, 'BEAT&GROOVE', 'XP-D 024'), ('SpaceGroove2', 93, 4, 24, 'BEAT&GROOVE', 'XP-D 025'), ('Underground', 93, 4, 25, 'BEAT&GROOVE', 'XP-D 026'), ('Extra Drive', 93, 4, 26, 'BEAT&GROOVE', 'XP-D 027'), ('NakedPrey', 93, 4, 27, 'BEAT&GROOVE', 'XP-D 028'), ('Mod It!', 93, 4, 28, 'BEAT&GROOVE', 'XP-D 029'), ('Broken\'Roll', 93, 4, 29, 'COMBINATION', 'XP-D 030'), ('Drew Groove', 93, 4, 30, 'COMBINATION', 'XP-D 031'), ('Beat Menu', 93, 4, 31, 'BEAT&GROOVE', 'XP-D 032'), ('Sinewave Bs', 93, 4, 32, 'SYNTH BASS', 'XP-D 033'), ('808 Bass', 93, 4, 33, 'SYNTH BASS', 'XP-D 034'), ('Low Bass 2', 93, 4, 34, 'SYNTH BASS', 'XP-D 035'), ('Low Bass 3', 93, 4, 35, 'SYNTH BASS', 'XP-D 036'), ('Low Bass 4', 93, 4, 36, 'SYNTH BASS', 'XP-D 037'), ('Hood Bass 2', 93, 4, 37, 'SYNTH BASS', 'XP-D 038'), ('Rubber Bs 21', 93, 4, 38, 'SYNTH BASS', 'XP-D 039'), ('Cheezee Bass', 93, 4, 39, 'SYNTH BASS', 'XP-D 040'), ('Bend Bs /sw', 93, 4, 40, 'SYNTH BASS', 'XP-D 041'), ('Saws Bass', 93, 4, 41, 'SYNTH BASS', 'XP-D 042'), ('Bass Kadett', 93, 4, 42, 'SYNTH BASS', 'XP-D 043'), ('Qube Bass', 93, 4, 43, 'SYNTH BASS', 'XP-D 044'), ('LegatoSynBs', 93, 4, 44, 'SYNTH BASS', 'XP-D 045'), ('15inch Bass', 93, 4, 45, 'SYNTH BASS', 'XP-D 046'), ('MG Filter Bs', 93, 4, 46, 'SYNTH BASS', 'XP-D 047'), ('Plk Bass', 93, 4, 47, 'SYNTH BASS', 'XP-D 048'), ('Flat SawBass', 93, 4, 48, 'SYNTH BASS', 'XP-D 049'), ('SH-101 Bass', 93, 4, 49, 'SYNTH BASS', 'XP-D 050'), ('Pulsing Bs', 93, 4, 50, 'SYNTH BASS', 'XP-D 051'), ('Arrpy', 93, 4, 51, 'SYNTH BASS', 'XP-D 052'), ('Acid Bass 2', 93, 4, 52, 'SYNTH BASS', 'XP-D 053'), ('Euro Bass 21', 93, 4, 53, 'SYNTH BASS', 'XP-D 054'), ('DarkEchoBass', 93, 4, 54, 'SYNTH BASS', 'XP-D 055'), ('UnisonSwBass', 93, 4, 55, 'SYNTH BASS', 'XP-D 056'), ('Dirty Bass', 93, 4, 56, 'SYNTH BASS', 'XP-D 057'), ('Comp NzBass', 93, 4, 57, 'SYNTH BASS', 'XP-D 058'), ('JunoDistBass', 93, 4, 58, 'SYNTH BASS', 'XP-D 059'), ('TB Dist Bs 1', 93, 4, 59, 'SYNTH BASS', 'XP-D 060'), ('TB Dist Bs 2', 93, 4, 60, 'SYNTH BASS', 'XP-D 061'), ('TB Dist Bs 3', 93, 4, 61, 'SYNTH BASS', 'XP-D 062'), ('Human Bass', 93, 4, 62, 'SYNTH BASS', 'XP-D 063'), ('Interferenz', 93, 4, 63, 'SYNTH BASS', 'XP-D 064'), ('16th SeqBass', 93, 4, 64, 'SYNTH BASS', 'XP-D 065'), ('Woofer Blow', 93, 4, 65, 'BASS', 'XP-D 066'), ('Guitaron Oct', 93, 4, 66, 'BASS', 'XP-D 067'), ('Finger Bass6', 93, 4, 67, 'BASS', 'XP-D 068'), ('Noisy P.Bass', 93, 4, 68, 'BASS', 'XP-D 069'), ('FeelBass', 93, 4, 69, 'BASS', 'XP-D 070'), ('Ethno Bass 3', 93, 4, 70, 'BASS', 'XP-D 071'), ('FAT Rave', 93, 4, 71, 'OTHER SYNTH', 'XP-D 072'), ('JUNO Rave', 93, 4, 72, 'OTHER SYNTH', 'XP-D 073'), ('4 x Saws', 93, 4, 73, 'OTHER SYNTH', 'XP-D 074'), ('Euro Saws', 93, 4, 74, 'OTHER SYNTH', 'XP-D 075'), ('Super Sawz', 93, 4, 75, 'OTHER SYNTH', 'XP-D 076'), ('Step Phaser', 93, 4, 76, 'OTHER SYNTH', 'XP-D 077'), ('Vade Retro', 93, 4, 77, 'OTHER SYNTH', 'XP-D 078'), ('Pulse Keys', 93, 4, 78, 'OTHER SYNTH', 'XP-D 079'), ('P5 Pluck', 93, 4, 79, 'OTHER SYNTH', 'XP-D 080'), ('Alpha Waves', 93, 4, 80, 'OTHER SYNTH', 'XP-D 081'), ('Andes', 93, 4, 81, 'OTHER SYNTH', 'XP-D 082'), ('Northern Pls', 93, 4, 82, 'OTHER SYNTH', 'XP-D 083'), ('R&B Pluck 2', 93, 4, 83, 'OTHER SYNTH', 'XP-D 084'), ('SynHarpsi', 93, 4, 84, 'OTHER SYNTH', 'XP-D 085'), ('Saw Wave HQ', 93, 4, 85, 'OTHER SYNTH', 'XP-D 086'), ('Sqr Wave HQ', 93, 4, 86, 'OTHER SYNTH', 'XP-D 087'), ('JU2 Wave 1', 93, 4, 87, 'OTHER SYNTH', 'XP-D 088'), ('JU2 Wave 2', 93, 4, 88, 'OTHER SYNTH', 'XP-D 089'), ('Pulse Wave 1', 93, 4, 89, 'OTHER SYNTH', 'XP-D 090'), ('Pulse Wave 2', 93, 4, 90, 'OTHER SYNTH', 'XP-D 091'), ('SpectrumWave', 93, 4, 91, 'OTHER SYNTH', 'XP-D 092'), ('Pure Sine 2', 93, 4, 92, 'OTHER SYNTH', 'XP-D 093'), ('Slippers', 93, 4, 93, 'OTHER SYNTH', 'XP-D 094'), ('Climb Maj7th', 93, 4, 94, 'OTHER SYNTH', 'XP-D 095'), ('Return2Minor', 93, 4, 95, 'OTHER SYNTH', 'XP-D 096'), ('FallingStar', 93, 4, 96, 'OTHER SYNTH', 'XP-D 097'), ('Convulsions', 93, 4, 97, 'PULSATING', 'XP-D 098'), ('CrazZzeee', 93, 4, 98, 'PULSATING', 'XP-D 099'), ('Creative', 93, 4, 99, 'PULSATING', 'XP-D 100'), ('Juno Slice', 93, 4, 100, 'PULSATING', 'XP-D 101'), ('Epic Slice', 93, 4, 101, 'PULSATING', 'XP-D 102'), ('Klang Werk', 93, 4, 102, 'PULSATING', 'XP-D 103'), ('Ouverture', 93, 4, 103, 'PULSATING', 'XP-D 104'), ('Tropic Slice', 93, 4, 104, 'PULSATING', 'XP-D 105'), ('Strained', 93, 4, 105, 'PULSATING', 'XP-D 106'), ('Wicked DJ 2', 93, 4, 106, 'PULSATING', 'XP-D 107'), ('Ultra Noise', 93, 4, 107, 'PULSATING', 'XP-D 108'), ('JunoArpeggio', 93, 4, 108, 'PULSATING', 'XP-D 109'), ('Autoarpeggio', 93, 4, 109, 'PULSATING', 'XP-D 110'), ('SeqOctarveEP', 93, 4, 110, 'PULSATING', 'XP-D 111'), ('Sync Vox', 93, 4, 111, 'PULSATING', 'XP-D 112'), ('Stack Clavi', 93, 4, 112, 'PULSATING', 'XP-D 113'), ('Pump up', 93, 4, 113, 'PULSATING', 'XP-D 114'), ('Sine Seq', 93, 4, 114, 'PULSATING', 'XP-D 115'), ('Seq Saws', 93, 4, 115, 'PULSATING', 'XP-D 116'), ('Finale Hit', 93, 4, 116, 'HIT&STAB', 'XP-D 117'), ('Big Hit 3', 93, 4, 117, 'HIT&STAB', 'XP-D 118'), ('AnswerMe!Hit', 93, 4, 118, 'HIT&STAB', 'XP-D 119'), ('LoungeLizard', 93, 4, 119, 'HIT&STAB', 'XP-D 120'), ('Disco Stabs', 93, 4, 120, 'HIT&STAB', 'XP-D 121'), ('12x12\'sDisco', 93, 4, 121, 'HIT&STAB', 'XP-D 122'), ('LittleDots', 93, 4, 122, 'HIT&STAB', 'XP-D 123'), ('TribalTechno', 93, 4, 123, 'HIT&STAB', 'XP-D 124'), ('Minor Bumwah', 93, 4, 124, 'HIT&STAB', 'XP-D 125'), ('Bobs Slide', 93, 4, 125, 'HIT&STAB', 'XP-D 126'), ('BrassHit 1', 93, 4, 126, 'HIT&STAB', 'XP-D 127'), ('BrassHit 2', 93, 4, 127, 'HIT&STAB', 'XP-D 128'), ('BrassHit 3', 93, 5, 0, 'HIT&STAB', 'XP-D 129'), ('BrassHit 4', 93, 5, 1, 'HIT&STAB', 'XP-D 130'), ('BrassHit 5', 93, 5, 2, 'HIT&STAB', 'XP-D 131'), ('BrassHit 6', 93, 5, 3, 'HIT&STAB', 'XP-D 132'), ('BrassHit 7', 93, 5, 4, 'HIT&STAB', 'XP-D 133'), ('SymphHit 1', 93, 5, 5, 'HIT&STAB', 'XP-D 134'), ('SymphHit 2', 93, 5, 6, 'HIT&STAB', 'XP-D 135'), ('SymphHit 3', 93, 5, 7, 'HIT&STAB', 'XP-D 136'), ('OrgTrnsplnt', 93, 5, 8, 'HIT&STAB', 'XP-D 137'), ('Organ Hit 3', 93, 5, 9, 'HIT&STAB', 'XP-D 138'), ('Organ Hit 4', 93, 5, 10, 'HIT&STAB', 'XP-D 139'), ('Chord Hit 1', 93, 5, 11, 'HIT&STAB', 'XP-D 140'), ('Chord Hit 2', 93, 5, 12, 'HIT&STAB', 'XP-D 141'), ('Chord Hit 3', 93, 5, 13, 'HIT&STAB', 'XP-D 142'), ('Chord Hit 4', 93, 5, 14, 'HIT&STAB', 'XP-D 143'), ('Crystal Hit', 93, 5, 15, 'HIT&STAB', 'XP-D 144'), ('Stamp Hit', 93, 5, 16, 'HIT&STAB', 'XP-D 145'), ('ThousandHit', 93, 5, 17, 'HIT&STAB', 'XP-D 146'), ('9th Hit', 93, 5, 18, 'HIT&STAB', 'XP-D 147'), ('Slap Hit 1', 93, 5, 19, 'HIT&STAB', 'XP-D 148'), ('Slap Hit 2', 93, 5, 20, 'HIT&STAB', 'XP-D 149'), ('Dust Hit', 93, 5, 21, 'HIT&STAB', 'XP-D 150'), ('Dist Hit 1', 93, 5, 22, 'HIT&STAB', 'XP-D 151'), ('Dist Hit 2', 93, 5, 23, 'HIT&STAB', 'XP-D 152'), ('Wah Hit', 93, 5, 24, 'HIT&STAB', 'XP-D 153'), ('Tremble Hit', 93, 5, 25, 'HIT&STAB', 'XP-D 154'), ('Dah Hit', 93, 5, 26, 'HIT&STAB', 'XP-D 155'), ('Pretty Hit', 93, 5, 27, 'HIT&STAB', 'XP-D 156'), ('Smoky Hit', 93, 5, 28, 'HIT&STAB', 'XP-D 157'), ('Fist Hit', 93, 5, 29, 'HIT&STAB', 'XP-D 158'), ('Clavy Hit', 93, 5, 30, 'HIT&STAB', 'XP-D 159'), ('Tread Hit', 93, 5, 31, 'HIT&STAB', 'XP-D 160'), ('Old Org Hit', 93, 5, 32, 'HIT&STAB', 'XP-D 161'), ('Cave Hit', 93, 5, 33, 'HIT&STAB', 'XP-D 162'), ('Thru Hit', 93, 5, 34, 'HIT&STAB', 'XP-D 163'), ('Mull Hit', 93, 5, 35, 'HIT&STAB', 'XP-D 164'), ('Electronica', 93, 5, 36, 'HIT&STAB', 'XP-D 165'), ('Ripper', 93, 5, 37, 'HIT&STAB', 'XP-D 166'), ('Bounce Hit1', 93, 5, 38, 'HIT&STAB', 'XP-D 167'), ('Bounce Hit2', 93, 5, 39, 'HIT&STAB', 'XP-D 168'), ('Hit OneShots', 93, 5, 40, 'HIT&STAB', 'XP-D 169'), ('Brass Stab', 93, 5, 41, 'TECHNO SYNTH', 'XP-D 170'), ('Null Zone', 93, 5, 42, 'TECHNO SYNTH', 'XP-D 171'), ('Loop Techno', 93, 5, 43, 'TECHNO SYNTH', 'XP-D 172'), ('Tribal RaveX', 93, 5, 44, 'TECHNO SYNTH', 'XP-D 173'), ('Raverlisious', 93, 5, 45, 'TECHNO SYNTH', 'XP-D 174'), ('2FingerRifff', 93, 5, 46, 'TECHNO SYNTH', 'XP-D 175'), ('UK Garage 01', 93, 5, 47, 'TECHNO SYNTH', 'XP-D 176'), ('UKgarage2002', 93, 5, 48, 'TECHNO SYNTH', 'XP-D 177'), ('XV-303', 93, 5, 49, 'TECHNO SYNTH', 'XP-D 178'), ('Psy-Tron', 93, 5, 50, 'TECHNO SYNTH', 'XP-D 179'), ('House128bpm', 93, 5, 51, 'TECHNO SYNTH', 'XP-D 180'), ('NewAcid Line', 93, 5, 52, 'TECHNO SYNTH', 'XP-D 181'), ('Raver Saws', 93, 5, 53, 'TECHNO SYNTH', 'XP-D 182'), ('Dist Saws', 93, 5, 54, 'TECHNO SYNTH', 'XP-D 183'), ('BoosterBips2', 93, 5, 55, 'TECHNO SYNTH', 'XP-D 184'), ('Auto 101', 93, 5, 56, 'TECHNO SYNTH', 'XP-D 185'), ('BPF Sweep', 93, 5, 57, 'TECHNO SYNTH', 'XP-D 186'), ('Elektrico', 93, 5, 58, 'TECHNO SYNTH', 'XP-D 187'), ('What The ??', 93, 5, 59, 'TECHNO SYNTH', 'XP-D 188'), ('PlayEuroRiff', 93, 5, 60, 'TECHNO SYNTH', 'XP-D 189'), ('MayhemAppegi', 93, 5, 61, 'TECHNO SYNTH', 'XP-D 190'), ('AmbientTranz', 93, 5, 62, 'TECHNO SYNTH', 'XP-D 191'), ('DanceStrSect', 93, 5, 63, 'TECHNO SYNTH', 'XP-D 192'), ('5thIn4th Tri', 93, 5, 64, 'TECHNO SYNTH', 'XP-D 193'), ('5th Vox', 93, 5, 65, 'TECHNO SYNTH', 'XP-D 194'), ('Kompakt Voic', 93, 5, 66, 'TECHNO SYNTH', 'XP-D 195'), ('Resound', 93, 5, 67, 'TECHNO SYNTH', 'XP-D 196'), ('StrikeWhstle', 93, 5, 68, 'TECHNO SYNTH', 'XP-D 197'), ('Rocket Blast', 93, 5, 69, 'TECHNO SYNTH', 'XP-D 198'), ('Future Drain', 93, 5, 70, 'BRIGHT PAD', 'XP-D 199'), ('Foilage', 93, 5, 71, 'BRIGHT PAD', 'XP-D 200'), ('JP-8000 Pad', 93, 5, 72, 'BRIGHT PAD', 'XP-D 201'), ('SynthChord01', 93, 5, 73, 'BRIGHT PAD', 'XP-D 202'), ('PWM', 93, 5, 74, 'BRIGHT PAD', 'XP-D 203'), ('Introductory', 93, 5, 75, 'BRIGHT PAD', 'XP-D 204'), ('Miracle Pad', 93, 5, 76, 'BRIGHT PAD', 'XP-D 205'), ('5th Sweep 2', 93, 5, 77, 'BRIGHT PAD', 'XP-D 206'), ('Choir Sweep', 93, 5, 78, 'BRIGHT PAD', 'XP-D 207'), ('Retro Pad', 93, 5, 79, 'SOFT PAD', 'XP-D 208'), ('Beautiful:-]', 93, 5, 80, 'SOFT PAD', 'XP-D 209'), ('Steam Pad', 93, 5, 81, 'SOFT PAD', 'XP-D 210'), ('AggressiveLd', 93, 5, 82, 'HARD LEAD', 'XP-D 211'), ('I know Juno', 93, 5, 83, 'HARD LEAD', 'XP-D 212'), ('Def Lead 21', 93, 5, 84, 'HARD LEAD', 'XP-D 213'), ('HiPass', 93, 5, 85, 'HARD LEAD', 'XP-D 214'), ('DynaPulseLd', 93, 5, 86, 'HARD LEAD', 'XP-D 215'), ('Dist Lead', 93, 5, 87, 'HARD LEAD', 'XP-D 216'), ('80\'s Memory', 93, 5, 88, 'HARD LEAD', 'XP-D 217'), ('OD SyncLead', 93, 5, 89, 'HARD LEAD', 'XP-D 218'), ('80\'sTechLead', 93, 5, 90, 'HARD LEAD', 'XP-D 219'), ('3-SquareLead', 93, 5, 91, 'HARD LEAD', 'XP-D 220'), ('PortaSynLead', 93, 5, 92, 'SOFT LEAD', 'XP-D 221'), ('Tri Lead', 93, 5, 93, 'SOFT LEAD', 'XP-D 222'), ('Corrupt Sine', 93, 5, 94, 'SOFT LEAD', 'XP-D 223'), ('Neonlight', 93, 5, 95, 'SOFT LEAD', 'XP-D 224'), ('Higher&Highr', 93, 5, 96, 'SOFT LEAD', 'XP-D 225'), ('Waspy Solo1', 93, 5, 97, 'SOFT LEAD', 'XP-D 226'), ('Waspy Solo2', 93, 5, 98, 'SOFT LEAD', 'XP-D 227'), ('Vib Sine', 93, 5, 99, 'SOFT LEAD', 'XP-D 228'), ('Legato Saw', 93, 5, 100, 'SOFT LEAD', 'XP-D 229'), ('Wet Saw Ld', 93, 5, 101, 'SOFT LEAD', 'XP-D 230'), ('Dry BassLead', 93, 5, 102, 'SOFT LEAD', 'XP-D 231'), ('PluckLead', 93, 5, 103, 'SOFT LEAD', 'XP-D 232'), ('Comp Piano 2', 93, 5, 104, 'AC.PIANO', 'XP-D 233'), ('a Tack Piano', 93, 5, 105, 'AC.PIANO', 'XP-D 234'), ('Analog Piano', 93, 5, 106, 'AC.PIANO', 'XP-D 235'), ('Tri EP', 93, 5, 107, 'EL.PIANO', 'XP-D 236'), ('Pulsing EP', 93, 5, 108, 'EL.PIANO', 'XP-D 237'), ('Cool EP 2', 93, 5, 109, 'EL.PIANO', 'XP-D 238'), ('EP Chd Menu', 93, 5, 110, 'EL.PIANO', 'XP-D 239'), ('EP Maj 9th', 93, 5, 111, 'EL.PIANO', 'XP-D 240'), ('EP Maj 11th', 93, 5, 112, 'EL.PIANO', 'XP-D 241'), ('EP Min 11th', 93, 5, 113, 'EL.PIANO', 'XP-D 242'), ('NoisySynthEP', 93, 5, 114, 'EL.PIANO', 'XP-D 243'), ('CompClav/Rls', 93, 5, 115, 'KEYBOARDS', 'XP-D 244'), ('Comp Clavi', 93, 5, 116, 'KEYBOARDS', 'XP-D 245'), ('HarmoOrg/Mod', 93, 5, 117, 'ORGAN', 'XP-D 246'), ('ZigZag Organ', 93, 5, 118, 'ORGAN', 'XP-D 247'), ('Notre Organ', 93, 5, 119, 'ORGAN', 'XP-D 248'), ('SpectrumBell', 93, 5, 120, 'BELL', 'XP-D 249'), ('Square Bell1', 93, 5, 121, 'BELL', 'XP-D 250'), ('Square Bell2', 93, 5, 122, 'BELL', 'XP-D 251'), ('ClnGtr Slide', 93, 5, 123, 'EL.GUITAR', 'XP-D 252'), ('Gtr TrmDown', 93, 5, 124, 'EL.GUITAR', 'XP-D 253'), ('Waw Chord', 93, 5, 125, 'EL.GUITAR', 'XP-D 254'), ('Wha Wha Wha', 93, 5, 126, 'EL.GUITAR', 'XP-D 255'), ('Wha De Da', 93, 5, 127, 'EL.GUITAR', 'XP-D 256'), ('Fuzz Phaze', 93, 6, 0, 'DIST.GUITAR', 'XP-D 257'), ('Ringmod Ting', 93, 6, 1, 'DIST.GUITAR', 'XP-D 258'), ('BPF Strings', 93, 6, 2, 'STRINGS', 'XP-D 259'), ('LoFiStringz', 93, 6, 3, 'STRINGS', 'XP-D 260'), ('LightStrings', 93, 6, 4, 'STRINGS', 'XP-D 261'), ('Flange Str', 93, 6, 5, 'STRINGS', 'XP-D 262'), ('4th-LayerStr', 93, 6, 6, 'STRINGS', 'XP-D 263'), ('LA Pizz', 93, 6, 7, 'STRINGS', 'XP-D 264'), ('DanceClustor', 93, 6, 8, 'STRINGS', 'XP-D 265'), ('CaveStrHit', 93, 6, 9, 'STRINGS', 'XP-D 266'), ('StrChd Menu', 93, 6, 10, 'STRINGS', 'XP-D 267'), ('StrScaleMaj', 93, 6, 11, 'STRINGS', 'XP-D 268'), ('StrSpread', 93, 6, 12, 'STRINGS', 'XP-D 269'), ('EuroBeat Brs', 93, 6, 13, 'SYNTH BRASS', 'XP-D 270'), ('OB Brass 2', 93, 6, 14, 'SYNTH BRASS', 'XP-D 271'), ('Funny Brass', 93, 6, 15, 'SYNTH BRASS', 'XP-D 272'), ('Saws Brass', 93, 6, 16, 'SYNTH BRASS', 'XP-D 273'), ('AnalogMaster', 93, 6, 17, 'SYNTH BRASS', 'XP-D 274'), ('OneKeyMajor', 93, 6, 18, 'AC.BRASS', 'XP-D 275'), ('Danz Braz', 93, 6, 19, 'AC.BRASS', 'XP-D 276'), ('WindFX Menu', 93, 6, 20, 'WIND', 'XP-D 277'), ('Flute FX 1', 93, 6, 21, 'WIND', 'XP-D 278'), ('Flute FX 2', 93, 6, 22, 'WIND', 'XP-D 279'), ('Flute FX 3', 93, 6, 23, 'WIND', 'XP-D 280'), ('Sax FX 1', 93, 6, 24, 'WIND', 'XP-D 281'), ('Sax FX 2', 93, 6, 25, 'WIND', 'XP-D 282'), ('Sax FX 3', 93, 6, 26, 'WIND', 'XP-D 283'), ('VINYL VOX', 93, 6, 27, 'VOX', 'XP-D 284'), ('PsycheVocals', 93, 6, 28, 'VOX', 'XP-D 285'), ('Vox Menu', 93, 6, 29, 'VOX', 'XP-D 286'), ('Yeah F', 93, 6, 30, 'VOX', 'XP-D 287'), ('Ho F', 93, 6, 31, 'VOX', 'XP-D 288'), ('Oh F', 93, 6, 32, 'VOX', 'XP-D 289'), ('Wow Yeah F', 93, 6, 33, 'VOX', 'XP-D 290'), ('Ring Mod', 93, 6, 34, 'SYNTH FX', 'XP-D 291'), ('Hydrolyze', 93, 6, 35, 'SYNTH FX', 'XP-D 292'), ('Hydrolyze 2', 93, 6, 36, 'SYNTH FX', 'XP-D 293'), ('Danger Zone', 93, 6, 37, 'SYNTH FX', 'XP-D 294'), ('Danger Zone2', 93, 6, 38, 'SYNTH FX', 'XP-D 295'), ('Horror', 93, 6, 39, 'SYNTH FX', 'XP-D 296'), ('Space Scrach', 93, 6, 40, 'SYNTH FX', 'XP-D 297'), ('OldSkool FX', 93, 6, 41, 'SYNTH FX', 'XP-D 298'), ('Snare Bomb', 93, 6, 42, 'SYNTH FX', 'XP-D 299'), ('CymbalMusic', 93, 6, 43, 'SYNTH FX', 'XP-D 300'), ('Recollection', 93, 6, 44, 'SYNTH FX', 'XP-D 301'), ('Dive Start !', 93, 6, 45, 'SOUND FX', 'XP-D 302'), ('DJ Mayhem', 93, 6, 46, 'SOUND FX', 'XP-D 303'), ('TurnOff>Rev', 93, 6, 47, 'SOUND FX', 'XP-D 304'), ('Scratch 4', 93, 6, 48, 'SOUND FX', 'XP-D 305'), ('Scratch 5', 93, 6, 49, 'SOUND FX', 'XP-D 306'), ('Scratch 6', 93, 6, 50, 'SOUND FX', 'XP-D 307'), ('Scratch 7', 93, 6, 51, 'SOUND FX', 'XP-D 308'), ('Scratch 8', 93, 6, 52, 'SOUND FX', 'XP-D 309'), ('Scratch 9', 93, 6, 53, 'SOUND FX', 'XP-D 310'), ('Scratch 10', 93, 6, 54, 'SOUND FX', 'XP-D 311'), ('Vinyl Nz', 93, 6, 55, 'SOUND FX', 'XP-D 312'), ]
gpl-3.0
[ 172, 120, 124, 3060, 1371, 381, 199, 3, 1898, 6171, 17815, 445, 1773, 18090, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 19292, 8380, 13984, 14, 199, 3, 199, 3, 19292, 8380, 13984, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 19292, 8380, 13984, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 19292, 8380, 13984, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3060, 1371, 381, 199, 199, 309, 768, 493, 199, 3, 221, 5673, 17064, 14, 199, 3, 221, 768, 602, 650, 15, 709, 15, 6965, 18208, 570, 14, 221, 446, 22760, 199, 3, 221, 768, 2502, 17815, 445, 1773, 18090, 4388, 199, 2339, 275, 283, 20168, 13, 36, 446, 12765, 56, 13, 1717, 446, 6820, 17817, 577, 554, 7, 199, 199, 17073, 654, 275, 359, 523, 661, 13790, 36, 7716, 297, 18969, 12, 841, 12, 378, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 614, 659, 523, 661, 14825, 14259, 83, 297, 18969, 12, 841, 12, 413, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 996, 659, 523, 661, 37, 13, 454, 12732, 297, 18969, 12, 841, 12, 499, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1644, 659, 523, 661, 3761, 18, 335, 382, 297, 18969, 12, 841, 12, 650, 12, 283, 30976, 510, 1554, 297, 283, 20168, 13, 36, 378, 966, 659, 523, 661, 51, 1556, 693, 18281, 297, 18969, 12, 841, 12, 841, 12, 283, 4118, 6131, 481, 56, 297, 283, 20168, 13, 36, 378, 1717, 659, 523, 661, 26852, 5367, 2551, 297, 18969, 12, 841, 12, 959, 12, 283, 40, 649, 6, 840, 1217, 297, 283, 20168, 13, 36, 378, 1690, 659, 523, 661, 3716, 280, 4255, 297, 18969, 12, 841, 12, 1227, 12, 283, 31271, 297, 283, 20168, 13, 36, 378, 1780, 659, 523, 661, 51, 1132, 812, 1892, 82, 11318, 297, 18969, 12, 841, 12, 1520, 12, 283, 26999, 6124, 1554, 297, 283, 20168, 13, 36, 378, 2036, 659, 523, 661, 1945, 344, 510, 4689, 297, 18969, 12, 841, 12, 1695, 12, 283, 31802, 2080, 699, 3755, 297, 283, 20168, 13, 36, 378, 1643, 659, 523, 661, 37, 14, 39, 454, 18281, 297, 18969, 12, 841, 12, 1749, 12, 283, 2901, 14, 17188, 649, 689, 297, 283, 20168, 13, 36, 378, 709, 659, 523, 661, 34, 752, 11040, 618, 297, 18969, 12, 841, 12, 1616, 12, 283, 30976, 510, 1554, 297, 283, 20168, 13, 36, 378, 845, 659, 523, 661, 36, 554, 812, 1892, 397, 297, 18969, 12, 841, 12, 4119, 12, 283, 3727, 1244, 2826, 10046, 46, 2080, 297, 283, 20168, 13, 36, 378, 713, 659, 523, 661, 46, 13, 14064, 554, 297, 18969, 12, 841, 12, 3144, 12, 283, 48, 1293, 51, 27186, 297, 283, 20168, 13, 36, 378, 969, 659, 523, 661, 5663, 6796, 297, 18969, 12, 841, 12, 4944, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1079, 659, 523, 661, 7281, 3514, 297, 18969, 12, 841, 12, 4329, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1046, 659, 523, 661, 7382, 22322, 577, 1096, 297, 18969, 12, 841, 12, 4114, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 975, 659, 523, 661, 32154, 577, 42, 297, 18969, 12, 841, 12, 3193, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1196, 659, 523, 661, 10213, 510, 1672, 322, 10922, 297, 18969, 12, 841, 12, 5557, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1085, 659, 523, 661, 14064, 2084, 5311, 350, 297, 18969, 12, 841, 12, 6155, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1167, 659, 523, 661, 50, 439, 7829, 297, 18969, 12, 841, 12, 5851, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1165, 659, 523, 661, 52, 5711, 889, 12522, 297, 18969, 12, 841, 12, 3388, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 2025, 659, 523, 661, 4131, 6423, 292, 297, 18969, 12, 841, 12, 7829, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1081, 659, 523, 661, 38, 29059, 6609, 297, 18969, 12, 841, 12, 6928, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1789, 659, 523, 661, 933, 293, 656, 12522, 297, 18969, 12, 841, 12, 6546, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1194, 659, 523, 661, 7643, 39, 293, 79, 432, 18, 297, 18969, 12, 841, 12, 5504, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 821, 659, 523, 661, 16001, 3928, 297, 18969, 12, 841, 12, 5661, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1479, 659, 523, 661, 7426, 577, 6053, 297, 18969, 12, 841, 12, 7875, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1465, 659, 523, 661, 46, 16702, 2398, 89, 297, 18969, 12, 841, 12, 8087, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1651, 659, 523, 661, 9871, 2779, 12389, 18969 ]
[ 120, 124, 3060, 1371, 381, 199, 3, 1898, 6171, 17815, 445, 1773, 18090, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 19292, 8380, 13984, 14, 199, 3, 199, 3, 19292, 8380, 13984, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 19292, 8380, 13984, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 19292, 8380, 13984, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3060, 1371, 381, 199, 199, 309, 768, 493, 199, 3, 221, 5673, 17064, 14, 199, 3, 221, 768, 602, 650, 15, 709, 15, 6965, 18208, 570, 14, 221, 446, 22760, 199, 3, 221, 768, 2502, 17815, 445, 1773, 18090, 4388, 199, 2339, 275, 283, 20168, 13, 36, 446, 12765, 56, 13, 1717, 446, 6820, 17817, 577, 554, 7, 199, 199, 17073, 654, 275, 359, 523, 661, 13790, 36, 7716, 297, 18969, 12, 841, 12, 378, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 614, 659, 523, 661, 14825, 14259, 83, 297, 18969, 12, 841, 12, 413, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 996, 659, 523, 661, 37, 13, 454, 12732, 297, 18969, 12, 841, 12, 499, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1644, 659, 523, 661, 3761, 18, 335, 382, 297, 18969, 12, 841, 12, 650, 12, 283, 30976, 510, 1554, 297, 283, 20168, 13, 36, 378, 966, 659, 523, 661, 51, 1556, 693, 18281, 297, 18969, 12, 841, 12, 841, 12, 283, 4118, 6131, 481, 56, 297, 283, 20168, 13, 36, 378, 1717, 659, 523, 661, 26852, 5367, 2551, 297, 18969, 12, 841, 12, 959, 12, 283, 40, 649, 6, 840, 1217, 297, 283, 20168, 13, 36, 378, 1690, 659, 523, 661, 3716, 280, 4255, 297, 18969, 12, 841, 12, 1227, 12, 283, 31271, 297, 283, 20168, 13, 36, 378, 1780, 659, 523, 661, 51, 1132, 812, 1892, 82, 11318, 297, 18969, 12, 841, 12, 1520, 12, 283, 26999, 6124, 1554, 297, 283, 20168, 13, 36, 378, 2036, 659, 523, 661, 1945, 344, 510, 4689, 297, 18969, 12, 841, 12, 1695, 12, 283, 31802, 2080, 699, 3755, 297, 283, 20168, 13, 36, 378, 1643, 659, 523, 661, 37, 14, 39, 454, 18281, 297, 18969, 12, 841, 12, 1749, 12, 283, 2901, 14, 17188, 649, 689, 297, 283, 20168, 13, 36, 378, 709, 659, 523, 661, 34, 752, 11040, 618, 297, 18969, 12, 841, 12, 1616, 12, 283, 30976, 510, 1554, 297, 283, 20168, 13, 36, 378, 845, 659, 523, 661, 36, 554, 812, 1892, 397, 297, 18969, 12, 841, 12, 4119, 12, 283, 3727, 1244, 2826, 10046, 46, 2080, 297, 283, 20168, 13, 36, 378, 713, 659, 523, 661, 46, 13, 14064, 554, 297, 18969, 12, 841, 12, 3144, 12, 283, 48, 1293, 51, 27186, 297, 283, 20168, 13, 36, 378, 969, 659, 523, 661, 5663, 6796, 297, 18969, 12, 841, 12, 4944, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1079, 659, 523, 661, 7281, 3514, 297, 18969, 12, 841, 12, 4329, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1046, 659, 523, 661, 7382, 22322, 577, 1096, 297, 18969, 12, 841, 12, 4114, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 975, 659, 523, 661, 32154, 577, 42, 297, 18969, 12, 841, 12, 3193, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1196, 659, 523, 661, 10213, 510, 1672, 322, 10922, 297, 18969, 12, 841, 12, 5557, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1085, 659, 523, 661, 14064, 2084, 5311, 350, 297, 18969, 12, 841, 12, 6155, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1167, 659, 523, 661, 50, 439, 7829, 297, 18969, 12, 841, 12, 5851, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1165, 659, 523, 661, 52, 5711, 889, 12522, 297, 18969, 12, 841, 12, 3388, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 2025, 659, 523, 661, 4131, 6423, 292, 297, 18969, 12, 841, 12, 7829, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1081, 659, 523, 661, 38, 29059, 6609, 297, 18969, 12, 841, 12, 6928, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1789, 659, 523, 661, 933, 293, 656, 12522, 297, 18969, 12, 841, 12, 6546, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1194, 659, 523, 661, 7643, 39, 293, 79, 432, 18, 297, 18969, 12, 841, 12, 5504, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 821, 659, 523, 661, 16001, 3928, 297, 18969, 12, 841, 12, 5661, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1479, 659, 523, 661, 7426, 577, 6053, 297, 18969, 12, 841, 12, 7875, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1465, 659, 523, 661, 46, 16702, 2398, 89, 297, 18969, 12, 841, 12, 8087, 12, 283, 6773, 619, 6, 39, 1092, 47, 2524, 297, 283, 20168, 13, 36, 378, 1651, 659, 523, 661, 9871, 2779, 12389, 18969, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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visualiser.exceptions.PyPomExceptions import PomParseError class PomParser(object): ''' classdocs ''' def __init__(self): self.popos = [] self.current = None ''' Constructor ''' def parseFilesToPomPOPO(self, listOfFileLocs): try: for file in listOfFileLocs: current = file tmpDom = parse(file) if tmpDom: self.popos.append(self.DomToPOPO(tmpDom, file)) tmpDom.unlink() return self.popos except Exception: raise PomParseError("Parser was unable to parse from file location: " + current) def DomToPOPO(self, dom, file): pomDeps = [] parent = None par = dom.getElementsByTagName("parent") if par: grp = None art = None ver = None relPath = None for child in par[0].childNodes: local = child.localName if local == "groupId": grp = child.firstChild.nodeValue elif local == "artifactId": art = child.firstChild.nodeValue elif local == "version": ver = child.firstChild.nodeValue elif local == "relativePath": relPath = child.firstChild.nodeValue parent = Pom(grp, art, ver, relPath) pomGrp = None pomArt = None pomVer = None for child in dom.getElementsByTagName("project")[0].childNodes: local = child.localName if local == "groupId": pomGrp = child.firstChild.nodeValue elif local == "artifactId": pomArt = child.firstChild.nodeValue elif local == "version": pomVer = child.firstChild.nodeValue depMan = dom.getElementsByTagName("dependencyManagement") if depMan: deps = depMan.getElementsByTagName("dependencies") else: deps = dom.getElementsByTagName("dependencies") for no in deps: tmps = no.getElementsByTagName("dependency") for dep in tmps: if dep: depGrp = self.getNodeValue(dep.getElementsByTagName("groupId")) depArt = self.getNodeValue(dep.getElementsByTagName("artifactId")) depVer = self.getNodeValue(dep.getElementsByTagName("version")) pomDeps.append(PomDependency(depGrp, depArt, depVer)) mods = dom.getElementsByTagName("modules") pomMods = [] for mod in mods: pomMods.append(self.getNodeValue(mod.getElementsByTagName("module"))) return Pom(pomGrp, pomArt, pomVer, file, parent, pomDeps, pomMods) def getNodeValue(self, elementByTag): if elementByTag: if len(elementByTag) > 0: elementByTag = elementByTag[0] if len(elementByTag.childNodes) > 0: elementByTag = elementByTag.childNodes[0] return elementByTag.nodeValue
mit
[ 2344, 202, 199, 10502, 641, 7105, 16794, 6900, 2999, 199, 32, 2502, 26, 644, 2679, 726, 2979, 53, 202, 199, 2344, 2999, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 202, 199, 504, 1134, 555, 77, 16948, 25696, 14, 555, 77, 14, 48, 676, 492, 510, 676, 12, 510, 676, 14403, 202, 199, 504, 1134, 555, 77, 16948, 25696, 14, 3924, 14, 2713, 48, 676, 16836, 492, 510, 676, 9123, 2999, 199, 533, 510, 676, 2842, 8, 785, 304, 1128, 1449, 1128, 1021, 4757, 1128, 1449, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 1935, 736, 275, 942, 1039, 291, 14, 1818, 275, 488, 1039, 1449, 1039, 20297, 1039, 1449, 26016, 347, 2198, 5535, 1378, 48, 676, 1512, 1512, 8, 277, 12, 769, 3466, 1173, 3040, 83, 304, 1039, 862, 26, 1675, 367, 570, 315, 769, 3466, 1173, 3040, 83, 26, 2628, 1453, 275, 570, 2628, 3529, 20106, 275, 2198, 8, 493, 9, 2628, 340, 3529, 20106, 26, 4906, 291, 14, 1935, 736, 14, 740, 8, 277, 14, 20106, 1378, 1512, 1512, 8, 2791, 20106, 12, 570, 430, 4906, 3529, 20106, 14, 7162, 342, 1675, 372, 291, 14, 1935, 736, 259, 1039, 871, 2186, 26, 1675, 746, 510, 676, 9123, 480, 2842, 1990, 17329, 370, 2198, 687, 570, 2909, 26, 298, 435, 1453, 9, 11787, 347, 577, 676, 1378, 1512, 1512, 8, 277, 12, 8266, 12, 570, 304, 1039, 299, 676, 27683, 275, 942, 1039, 1676, 275, 488, 1039, 623, 275, 8266, 14, 15045, 480, 1708, 531, 1039, 340, 623, 26, 1675, 18598, 275, 488, 1675, 24701, 275, 488, 1675, 809, 275, 488, 1675, 4668, 2042, 275, 488, 1675, 367, 1982, 315, 623, 59, 16, 1055, 10626, 26, 2628, 2257, 275, 1982, 14, 31317, 2628, 340, 2257, 508, 298, 923, 1304, 582, 4906, 18598, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 16154, 1304, 582, 4906, 24701, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 1023, 582, 4906, 809, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 6188, 2042, 582, 4906, 4668, 2042, 275, 1982, 14, 22262, 14, 17240, 1675, 1676, 275, 510, 676, 8, 12599, 12, 24701, 12, 809, 12, 4668, 2042, 9, 13594, 299, 676, 39, 4599, 275, 488, 1039, 299, 676, 28922, 275, 488, 1039, 299, 676, 3673, 275, 488, 13594, 367, 1982, 315, 8266, 14, 15045, 480, 1715, 9981, 16, 1055, 10626, 26, 1675, 2257, 275, 1982, 14, 31317, 1675, 340, 2257, 508, 298, 923, 1304, 582, 2628, 299, 676, 39, 4599, 275, 1982, 14, 22262, 14, 17240, 1675, 916, 2257, 508, 298, 16154, 1304, 582, 2628, 299, 676, 28922, 275, 1982, 14, 22262, 14, 17240, 1675, 916, 2257, 508, 298, 1023, 582, 2628, 299, 676, 3673, 275, 1982, 14, 22262, 14, 17240, 13594, 2657, 2395, 275, 8266, 14, 15045, 480, 8575, 14552, 531, 1039, 340, 2657, 2395, 26, 1675, 10140, 275, 2657, 2395, 14, 15045, 480, 5714, 531, 1039, 587, 26, 1675, 10140, 275, 8266, 14, 15045, 480, 5714, 531, 13594, 367, 949, 315, 10140, 26, 1675, 3529, 83, 275, 949, 14, 15045, 480, 8575, 531, 1675, 367, 2657, 315, 3529, 83, 26, 2628, 340, 2657, 26, 4906, 2657, 39, 4599, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 923, 1304, 2237, 4906, 2657, 28922, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 16154, 1304, 2237, 4906, 2657, 3673, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 1023, 2237, 4906, 299, 676, 27683, 14, 740, 8, 48, 676, 14403, 8, 2601, 39, 4599, 12, 2657, 28922, 12, 2657, 3673, 430, 17554, 1039, 24496, 275, 8266, 14, 15045, 480, 3112, 531, 1039, 299, 676, 9871, 83, 275, 942, 1039, 367, 3413, 315, 24496, 26, 1675, 299, 676, 9871, 83, 14, 740, 8, 277, 14, 362, 1716, 1110, 8, 1494, 14, 15045, 480, 578, 13324, 17554, 1039, 372, 510, 676, 8, 555, 77, 39, 4599, 12, 299, 676, 28922, 12, 299, 676, 3673, 12, 570, 12, 1676, 12, 299, 676, 27683, 12, 299, 676, 9871, 83, 9, 11787, 347, 664, 1716, 1110, 8, 277, 12, 1819, 2175, 1931, 304, 1039, 340, 1819, 2175, 1931, 26, 1675, 340, 822, 8, 2108, 2175, 1931, 9, 690, 378, 26, 2628, 1819, 2175, 1931, 275, 1819, 2175, 1931, 59, 16, 61, 2628, 340, 822, 8, 2108, 2175, 1931, 14, 10626, 9, 690, 378, 26, 4906, 1819, 2175, 1931, 275, 1819, 2175, 1931, 14, 10626, 59, 16, 61, 4906, 372, 1819, 2175, 1931, 14, 17240, 8740, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 202, 199, 10502, 641, 7105, 16794, 6900, 2999, 199, 32, 2502, 26, 644, 2679, 726, 2979, 53, 202, 199, 2344, 2999, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 202, 199, 504, 1134, 555, 77, 16948, 25696, 14, 555, 77, 14, 48, 676, 492, 510, 676, 12, 510, 676, 14403, 202, 199, 504, 1134, 555, 77, 16948, 25696, 14, 3924, 14, 2713, 48, 676, 16836, 492, 510, 676, 9123, 2999, 199, 533, 510, 676, 2842, 8, 785, 304, 1128, 1449, 1128, 1021, 4757, 1128, 1449, 1128, 347, 636, 826, 721, 277, 304, 1039, 291, 14, 1935, 736, 275, 942, 1039, 291, 14, 1818, 275, 488, 1039, 1449, 1039, 20297, 1039, 1449, 26016, 347, 2198, 5535, 1378, 48, 676, 1512, 1512, 8, 277, 12, 769, 3466, 1173, 3040, 83, 304, 1039, 862, 26, 1675, 367, 570, 315, 769, 3466, 1173, 3040, 83, 26, 2628, 1453, 275, 570, 2628, 3529, 20106, 275, 2198, 8, 493, 9, 2628, 340, 3529, 20106, 26, 4906, 291, 14, 1935, 736, 14, 740, 8, 277, 14, 20106, 1378, 1512, 1512, 8, 2791, 20106, 12, 570, 430, 4906, 3529, 20106, 14, 7162, 342, 1675, 372, 291, 14, 1935, 736, 259, 1039, 871, 2186, 26, 1675, 746, 510, 676, 9123, 480, 2842, 1990, 17329, 370, 2198, 687, 570, 2909, 26, 298, 435, 1453, 9, 11787, 347, 577, 676, 1378, 1512, 1512, 8, 277, 12, 8266, 12, 570, 304, 1039, 299, 676, 27683, 275, 942, 1039, 1676, 275, 488, 1039, 623, 275, 8266, 14, 15045, 480, 1708, 531, 1039, 340, 623, 26, 1675, 18598, 275, 488, 1675, 24701, 275, 488, 1675, 809, 275, 488, 1675, 4668, 2042, 275, 488, 1675, 367, 1982, 315, 623, 59, 16, 1055, 10626, 26, 2628, 2257, 275, 1982, 14, 31317, 2628, 340, 2257, 508, 298, 923, 1304, 582, 4906, 18598, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 16154, 1304, 582, 4906, 24701, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 1023, 582, 4906, 809, 275, 1982, 14, 22262, 14, 17240, 2628, 916, 2257, 508, 298, 6188, 2042, 582, 4906, 4668, 2042, 275, 1982, 14, 22262, 14, 17240, 1675, 1676, 275, 510, 676, 8, 12599, 12, 24701, 12, 809, 12, 4668, 2042, 9, 13594, 299, 676, 39, 4599, 275, 488, 1039, 299, 676, 28922, 275, 488, 1039, 299, 676, 3673, 275, 488, 13594, 367, 1982, 315, 8266, 14, 15045, 480, 1715, 9981, 16, 1055, 10626, 26, 1675, 2257, 275, 1982, 14, 31317, 1675, 340, 2257, 508, 298, 923, 1304, 582, 2628, 299, 676, 39, 4599, 275, 1982, 14, 22262, 14, 17240, 1675, 916, 2257, 508, 298, 16154, 1304, 582, 2628, 299, 676, 28922, 275, 1982, 14, 22262, 14, 17240, 1675, 916, 2257, 508, 298, 1023, 582, 2628, 299, 676, 3673, 275, 1982, 14, 22262, 14, 17240, 13594, 2657, 2395, 275, 8266, 14, 15045, 480, 8575, 14552, 531, 1039, 340, 2657, 2395, 26, 1675, 10140, 275, 2657, 2395, 14, 15045, 480, 5714, 531, 1039, 587, 26, 1675, 10140, 275, 8266, 14, 15045, 480, 5714, 531, 13594, 367, 949, 315, 10140, 26, 1675, 3529, 83, 275, 949, 14, 15045, 480, 8575, 531, 1675, 367, 2657, 315, 3529, 83, 26, 2628, 340, 2657, 26, 4906, 2657, 39, 4599, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 923, 1304, 2237, 4906, 2657, 28922, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 16154, 1304, 2237, 4906, 2657, 3673, 275, 291, 14, 362, 1716, 1110, 8, 2601, 14, 15045, 480, 1023, 2237, 4906, 299, 676, 27683, 14, 740, 8, 48, 676, 14403, 8, 2601, 39, 4599, 12, 2657, 28922, 12, 2657, 3673, 430, 17554, 1039, 24496, 275, 8266, 14, 15045, 480, 3112, 531, 1039, 299, 676, 9871, 83, 275, 942, 1039, 367, 3413, 315, 24496, 26, 1675, 299, 676, 9871, 83, 14, 740, 8, 277, 14, 362, 1716, 1110, 8, 1494, 14, 15045, 480, 578, 13324, 17554, 1039, 372, 510, 676, 8, 555, 77, 39, 4599, 12, 299, 676, 28922, 12, 299, 676, 3673, 12, 570, 12, 1676, 12, 299, 676, 27683, 12, 299, 676, 9871, 83, 9, 11787, 347, 664, 1716, 1110, 8, 277, 12, 1819, 2175, 1931, 304, 1039, 340, 1819, 2175, 1931, 26, 1675, 340, 822, 8, 2108, 2175, 1931, 9, 690, 378, 26, 2628, 1819, 2175, 1931, 275, 1819, 2175, 1931, 59, 16, 61, 2628, 340, 822, 8, 2108, 2175, 1931, 14, 10626, 9, 690, 378, 26, 4906, 1819, 2175, 1931, 275, 1819, 2175, 1931, 14, 10626, 59, 16, 61, 4906, 372, 1819, 2175, 1931, 14, 17240, 8740, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
collab-project/luma.cryptocurrency
luma/cryptocurrency/endpoint/coinmarketcap.py
1
1134
# -*- coding: utf-8 -*- # Copyright (c) 2017 Thijs Triemstra and contributors # See LICENSE.rst for details. """ Endpoint for coinmarketcap.com :see: https://coinmarketcap.com/api/ """ from datetime import datetime from dateutil.tz.tz import tzutc from . import Endpoint, EndpointResponse class CoinmarketcapResponse(EndpointResponse): @property def data(self): return self.json_data[0] def parse_price(self): return float(self.data.get('price_{}'.format( self.currency_code.lower()))) def parse_price_in_btc(self): return float(self.data.get('price_btc')) def parse_timestamp(self): return datetime.fromtimestamp( int(self.data.get('last_updated')), tz=tzutc()) class Coinmarketcap(Endpoint): responseType = CoinmarketcapResponse def get_url(self): base = 'https://api.coinmarketcap.com/{api_version}/ticker/{coin}/' if self.currency_code != 'USD': base += '?convert={}'.format(self.currency_code) return base.format( api_version=self.api_version, coin=self.coin )
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 9708, 3868, 73, 3596, 12480, 5633, 14183, 436, 8417, 199, 3, 1666, 5113, 14, 8332, 367, 2436, 14, 199, 199, 624, 199, 11442, 367, 21914, 22270, 2874, 14, 957, 199, 199, 26, 3239, 26, 4178, 921, 9061, 22270, 2874, 14, 957, 15, 1246, 15, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 22208, 14, 3903, 14, 3903, 492, 5823, 5834, 199, 199, 504, 1275, 492, 9599, 1403, 12, 9599, 1403, 2364, 421, 199, 533, 1849, 262, 22270, 2874, 2364, 8, 11442, 2364, 304, 339, 768, 1829, 272, 347, 666, 8, 277, 304, 267, 372, 291, 14, 1001, 63, 576, 59, 16, 61, 339, 347, 2198, 63, 4777, 8, 277, 304, 267, 372, 2069, 8, 277, 14, 576, 14, 362, 360, 4777, 63, 11123, 908, 8, 288, 291, 14, 4968, 63, 600, 14, 2325, 16890, 339, 347, 2198, 63, 4777, 63, 262, 63, 66, 3641, 8, 277, 304, 267, 372, 2069, 8, 277, 14, 576, 14, 362, 360, 4777, 63, 66, 3641, 1333, 339, 347, 2198, 63, 3954, 8, 277, 304, 267, 372, 2197, 14, 18531, 8, 288, 1109, 8, 277, 14, 576, 14, 362, 360, 2019, 63, 5334, 3855, 5823, 29, 3903, 5834, 1012, 421, 199, 533, 1849, 262, 22270, 2874, 8, 11442, 304, 272, 1177, 804, 275, 1849, 262, 22270, 2874, 2364, 339, 347, 664, 63, 633, 8, 277, 304, 267, 1300, 275, 283, 2859, 921, 1246, 14, 9061, 22270, 2874, 14, 957, 5321, 1246, 63, 1023, 5995, 28572, 5321, 9061, 93, 4805, 398, 340, 291, 14, 4968, 63, 600, 1137, 283, 1668, 36, 356, 288, 1300, 847, 8720, 3916, 27244, 908, 8, 277, 14, 4968, 63, 600, 9, 398, 372, 1300, 14, 908, 8, 288, 2986, 63, 1023, 29, 277, 14, 1246, 63, 1023, 12, 288, 21914, 29, 277, 14, 9061, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 9708, 3868, 73, 3596, 12480, 5633, 14183, 436, 8417, 199, 3, 1666, 5113, 14, 8332, 367, 2436, 14, 199, 199, 624, 199, 11442, 367, 21914, 22270, 2874, 14, 957, 199, 199, 26, 3239, 26, 4178, 921, 9061, 22270, 2874, 14, 957, 15, 1246, 15, 199, 624, 199, 199, 504, 2197, 492, 2197, 199, 199, 504, 22208, 14, 3903, 14, 3903, 492, 5823, 5834, 199, 199, 504, 1275, 492, 9599, 1403, 12, 9599, 1403, 2364, 421, 199, 533, 1849, 262, 22270, 2874, 2364, 8, 11442, 2364, 304, 339, 768, 1829, 272, 347, 666, 8, 277, 304, 267, 372, 291, 14, 1001, 63, 576, 59, 16, 61, 339, 347, 2198, 63, 4777, 8, 277, 304, 267, 372, 2069, 8, 277, 14, 576, 14, 362, 360, 4777, 63, 11123, 908, 8, 288, 291, 14, 4968, 63, 600, 14, 2325, 16890, 339, 347, 2198, 63, 4777, 63, 262, 63, 66, 3641, 8, 277, 304, 267, 372, 2069, 8, 277, 14, 576, 14, 362, 360, 4777, 63, 66, 3641, 1333, 339, 347, 2198, 63, 3954, 8, 277, 304, 267, 372, 2197, 14, 18531, 8, 288, 1109, 8, 277, 14, 576, 14, 362, 360, 2019, 63, 5334, 3855, 5823, 29, 3903, 5834, 1012, 421, 199, 533, 1849, 262, 22270, 2874, 8, 11442, 304, 272, 1177, 804, 275, 1849, 262, 22270, 2874, 2364, 339, 347, 664, 63, 633, 8, 277, 304, 267, 1300, 275, 283, 2859, 921, 1246, 14, 9061, 22270, 2874, 14, 957, 5321, 1246, 63, 1023, 5995, 28572, 5321, 9061, 93, 4805, 398, 340, 291, 14, 4968, 63, 600, 1137, 283, 1668, 36, 356, 288, 1300, 847, 8720, 3916, 27244, 908, 8, 277, 14, 4968, 63, 600, 9, 398, 372, 1300, 14, 908, 8, 288, 2986, 63, 1023, 29, 277, 14, 1246, 63, 1023, 12, 288, 21914, 29, 277, 14, 9061, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rohitwaghchaure/New_Theme_Erp
erpnext/stock/doctype/stock_entry/stock_entry.py
1
34617
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe import frappe.defaults from frappe.utils import cstr, cint, flt, comma_or, nowdate from frappe import _ from erpnext.stock.utils import get_incoming_rate from erpnext.stock.stock_ledger import get_previous_sle from erpnext.controllers.queries import get_match_cond from erpnext.stock.get_item_details import get_available_qty class NotUpdateStockError(frappe.ValidationError): pass class StockOverReturnError(frappe.ValidationError): pass class IncorrectValuationRateError(frappe.ValidationError): pass class DuplicateEntryForProductionOrderError(frappe.ValidationError): pass from erpnext.controllers.stock_controller import StockController form_grid_templates = { "mtn_details": "templates/form_grid/stock_entry_grid.html" } class StockEntry(StockController): fname = 'mtn_details' def onload(self): if self.docstatus==1: for item in self.get(self.fname): item.update(get_available_qty(item.item_code, item.s_warehouse)) def validate(self): self.validate_posting_time() self.validate_purpose() pro_obj = self.production_order and \ frappe.get_doc('Production Order', self.production_order) or None self.set_transfer_qty() self.validate_item() self.validate_uom_is_integer("uom", "qty") self.validate_uom_is_integer("stock_uom", "transfer_qty") self.validate_warehouse(pro_obj) self.validate_production_order(pro_obj) self.get_stock_and_rate() self.validate_incoming_rate() self.validate_bom() self.validate_finished_goods() self.validate_return_reference_doc() self.validate_with_material_request() self.validate_fiscal_year() self.validate_valuation_rate() self.set_total_amount() def on_submit(self): from erpnext.stock.stock_custom_methods import validate_for_si_submitted validate_for_si_submitted(self) self.update_stock_ledger() from erpnext.stock.doctype.serial_no.serial_no import update_serial_nos_after_submit update_serial_nos_after_submit(self, "mtn_details") self.update_production_order() self.make_gl_entries() def on_cancel(self): self.update_stock_ledger() self.update_production_order() self.make_gl_entries_on_cancel() def validate_fiscal_year(self): from erpnext.accounts.utils import validate_fiscal_year validate_fiscal_year(self.posting_date, self.fiscal_year, self.meta.get_label("posting_date")) def validate_purpose(self): valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Manufacture/Repack", "Subcontract", "Sales Return", "Purchase Return"] if self.purpose not in valid_purposes: frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes))) def set_transfer_qty(self): for item in self.get("mtn_details"): if not flt(item.qty): frappe.throw(_("Row {0}: Qty is mandatory").format(item.idx)) item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item)) def validate_item(self): stock_items = self.get_stock_items() serialized_items = self.get_serialized_items() for item in self.get("mtn_details"): if item.item_code not in stock_items: frappe.throw(_("{0} is not a stock Item").format(item.item_code)) if not item.stock_uom: item.stock_uom = frappe.db.get_value("Item", item.item_code, "stock_uom") if not item.uom: item.uom = item.stock_uom if not item.conversion_factor: item.conversion_factor = 1 if not item.transfer_qty: item.transfer_qty = item.qty * item.conversion_factor if (self.purpose in ("Material Transfer", "Sales Return", "Purchase Return") and not item.serial_no and item.item_code in serialized_items): frappe.throw(_("Row #{0}: Please specify Serial No for Item {1}").format(item.idx, item.item_code), frappe.MandatoryError) def validate_warehouse(self, pro_obj): """perform various (sometimes conditional) validations on warehouse""" source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return"] target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return"] validate_for_manufacture_repack = any([d.bom_no for d in self.get("mtn_details")]) if self.purpose in source_mandatory and self.purpose not in target_mandatory: self.to_warehouse = None for d in self.get('mtn_details'): d.t_warehouse = None elif self.purpose in target_mandatory and self.purpose not in source_mandatory: self.from_warehouse = None for d in self.get('mtn_details'): d.s_warehouse = None for d in self.get('mtn_details'): if not d.s_warehouse and not d.t_warehouse: d.s_warehouse = self.from_warehouse d.t_warehouse = self.to_warehouse if not (d.s_warehouse or d.t_warehouse): frappe.throw(_("Atleast one warehouse is mandatory")) if self.purpose in source_mandatory and not d.s_warehouse: frappe.throw(_("Source warehouse is mandatory for row {0}").format(d.idx)) if self.purpose in target_mandatory and not d.t_warehouse: frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx)) if self.purpose == "Manufacture/Repack": if validate_for_manufacture_repack: if d.bom_no: d.s_warehouse = None if not d.t_warehouse: frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx)) elif pro_obj and cstr(d.t_warehouse) != pro_obj.fg_warehouse: frappe.throw(_("Target warehouse in row {0} must be same as Production Order").format(d.idx)) else: d.t_warehouse = None if not d.s_warehouse: frappe.throw(_("Source warehouse is mandatory for row {0}").format(d.idx)) if cstr(d.s_warehouse) == cstr(d.t_warehouse): frappe.throw(_("Source and target warehouse cannot be same for row {0}").format(d.idx)) def validate_production_order(self, pro_obj=None): if not pro_obj: if self.production_order: pro_obj = frappe.get_doc('Production Order', self.production_order) else: return if self.purpose == "Manufacture/Repack": # check for double entry self.check_duplicate_entry_for_production_order() elif self.purpose != "Material Transfer": self.production_order = None def check_duplicate_entry_for_production_order(self): other_ste = [t[0] for t in frappe.db.get_values("Stock Entry", { "production_order": self.production_order, "purpose": self.purpose, "docstatus": ["!=", 2], "name": ["!=", self.name] }, "name")] if other_ste: production_item, qty = frappe.db.get_value("Production Order", self.production_order, ["production_item", "qty"]) args = other_ste + [production_item] fg_qty_already_entered = frappe.db.sql("""select sum(transfer_qty) from `tabStock Entry Detail` where parent in (%s) and item_code = %s and ifnull(s_warehouse,'')='' """ % (", ".join(["%s" * len(other_ste)]), "%s"), args)[0][0] if fg_qty_already_entered >= qty: frappe.throw(_("Stock Entries already created for Production Order ") + self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError) def validate_valuation_rate(self): if self.purpose == "Manufacture/Repack": valuation_at_source, valuation_at_target = 0, 0 for d in self.get("mtn_details"): if d.s_warehouse and not d.t_warehouse: valuation_at_source += flt(d.amount) if d.t_warehouse and not d.s_warehouse: valuation_at_target += flt(d.amount) if valuation_at_target < valuation_at_source: frappe.throw(_("Total valuation for manufactured or repacked item(s) can not be less than total valuation of raw materials")) def set_total_amount(self): self.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")]) def get_stock_and_rate(self, force=False): """get stock and incoming rate on posting date""" raw_material_cost = 0.0 if not self.posting_date or not self.posting_time: frappe.throw(_("Posting date and posting time is mandatory")) allow_negative_stock = cint(frappe.db.get_default("allow_negative_stock")) for d in self.get('mtn_details'): args = frappe._dict({ "item_code": d.item_code, "warehouse": d.s_warehouse or d.t_warehouse, "posting_date": self.posting_date, "posting_time": self.posting_time, "qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty, "serial_no": d.serial_no }) # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 # validate qty during submit if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty: frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}. Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) # get incoming rate if not d.bom_no: if not flt(d.incoming_rate) or d.s_warehouse or self.purpose == "Sales Return" or force: incoming_rate = flt(self.get_incoming_rate(args), self.precision("incoming_rate", d)) if incoming_rate > 0: d.incoming_rate = incoming_rate d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) if not d.t_warehouse: raw_material_cost += flt(d.amount) # set incoming rate for fg item if self.purpose == "Manufacture/Repack": number_of_fg_items = len([t.t_warehouse for t in self.get("mtn_details") if t.t_warehouse]) for d in self.get("mtn_details"): if d.bom_no or (d.t_warehouse and number_of_fg_items == 1): if not flt(d.incoming_rate) or force: operation_cost_per_unit = 0 if d.bom_no: bom = frappe.db.get_value("BOM", d.bom_no, ["operating_cost", "quantity"], as_dict=1) operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity) d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty)) d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) break def get_incoming_rate(self, args): incoming_rate = 0 if self.purpose == "Sales Return": incoming_rate = self.get_incoming_rate_for_sales_return(args) else: incoming_rate = get_incoming_rate(args) return incoming_rate def get_incoming_rate_for_sales_return(self, args): incoming_rate = 0.0 if (self.delivery_note_no or self.sales_invoice_no) and args.get("item_code"): incoming_rate = frappe.db.sql("""select abs(ifnull(stock_value_difference, 0) / actual_qty) from `tabStock Ledger Entry` where voucher_type = %s and voucher_no = %s and item_code = %s limit 1""", ((self.delivery_note_no and "Delivery Note" or "Sales Invoice"), self.delivery_note_no or self.sales_invoice_no, args.item_code)) incoming_rate = incoming_rate[0][0] if incoming_rate else 0.0 return incoming_rate def validate_incoming_rate(self): for d in self.get('mtn_details'): if d.t_warehouse: self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError) def validate_bom(self): for d in self.get('mtn_details'): if d.bom_no and not frappe.db.sql("""select name from `tabBOM` where item = %s and name = %s and docstatus = 1 and is_active = 1""", (d.item_code, d.bom_no)): frappe.throw(_("BOM {0} is not submitted or inactive BOM for Item {1}").format(d.bom_no, d.item_code)) def validate_finished_goods(self): """validation: finished good quantity should be same as manufacturing quantity""" for d in self.get('mtn_details'): if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty): frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}").format(d.idx, d.transfer_qty, self.fg_completed_qty)) def validate_return_reference_doc(self): """validate item with reference doc""" ref = get_return_doc_and_details(self) if ref.doc: # validate docstatus if ref.doc.docstatus != 1: frappe.throw(_("{0} {1} must be submitted").format(ref.doc.doctype, ref.doc.name), frappe.InvalidStatusError) # update stock check if ref.doc.doctype == "Sales Invoice" and cint(ref.doc.update_stock) != 1: frappe.throw(_("'Update Stock' for Sales Invoice {0} must be set").format(ref.doc.name), NotUpdateStockError) # posting date check ref_posting_datetime = "%s %s" % (cstr(ref.doc.posting_date), cstr(ref.doc.posting_time) or "00:00:00") this_posting_datetime = "%s %s" % (cstr(self.posting_date), cstr(self.posting_time)) if this_posting_datetime < ref_posting_datetime: from frappe.utils.dateutils import datetime_in_user_format frappe.throw(_("Posting timestamp must be after {0}").format(datetime_in_user_format(ref_posting_datetime))) stock_items = get_stock_items_for_return(ref.doc, ref.parentfields) already_returned_item_qty = self.get_already_returned_item_qty(ref.fieldname) for item in self.get("mtn_details"): # validate if item exists in the ref doc and that it is a stock item if item.item_code not in stock_items: frappe.throw(_("Item {0} does not exist in {1} {2}").format(item.item_code, ref.doc.doctype, ref.doc.name), frappe.DoesNotExistError) # validate quantity <= ref item's qty - qty already returned if self.purpose == "Purchase Return": ref_item_qty = sum([flt(d.qty)*flt(d.conversion_factor) for d in ref.doc.get({"item_code": item.item_code})]) elif self.purpose == "Sales Return": ref_item_qty = sum([flt(d.qty) for d in ref.doc.get({"item_code": item.item_code})]) returnable_qty = ref_item_qty - flt(already_returned_item_qty.get(item.item_code)) if not returnable_qty: frappe.throw(_("Item {0} has already been returned").format(item.item_code), StockOverReturnError) elif item.transfer_qty > returnable_qty: frappe.throw(_("Cannot return more than {0} for Item {1}").format(returnable_qty, item.item_code), StockOverReturnError) def get_already_returned_item_qty(self, ref_fieldname): return dict(frappe.db.sql("""select item_code, sum(transfer_qty) as qty from `tabStock Entry Detail` where parent in ( select name from `tabStock Entry` where `%s`=%s and docstatus=1) group by item_code""" % (ref_fieldname, "%s"), (self.get(ref_fieldname),))) def update_stock_ledger(self): sl_entries = [] for d in self.get('mtn_details'): if cstr(d.s_warehouse) and self.docstatus == 1: sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.s_warehouse), "actual_qty": -flt(d.transfer_qty), "incoming_rate": 0 })) if cstr(d.t_warehouse): sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.t_warehouse), "actual_qty": flt(d.transfer_qty), "incoming_rate": flt(d.incoming_rate) })) # On cancellation, make stock ledger entry for # target warehouse first, to update serial no values properly if cstr(d.s_warehouse) and self.docstatus == 2: sl_entries.append(self.get_sl_entries(d, { "warehouse": cstr(d.s_warehouse), "actual_qty": -flt(d.transfer_qty), "incoming_rate": 0 })) self.make_sl_entries(sl_entries, self.amended_from and 'Yes' or 'No') def update_production_order(self): def _validate_production_order(pro_doc): if flt(pro_doc.docstatus) != 1: frappe.throw(_("Production Order {0} must be submitted").format(self.production_order)) if pro_doc.status == 'Stopped': frappe.throw(_("Transaction not allowed against stopped Production Order {0}").format(self.production_order)) if self.production_order: pro_doc = frappe.get_doc("Production Order", self.production_order) _validate_production_order(pro_doc) pro_doc.run_method("update_status") if self.purpose == "Manufacture/Repack": pro_doc.run_method("update_produced_qty") self.update_planned_qty(pro_doc) def update_planned_qty(self, pro_doc): from erpnext.stock.utils import update_bin update_bin({ "item_code": pro_doc.production_item, "warehouse": pro_doc.fg_warehouse, "posting_date": self.posting_date, "planned_qty": (self.docstatus==1 and -1 or 1 ) * flt(self.fg_completed_qty) }) def get_item_details(self, args): item = frappe.db.sql("""select stock_uom, description, item_name, expense_account, buying_cost_center from `tabItem` where name = %s and (ifnull(end_of_life,'0000-00-00')='0000-00-00' or end_of_life > now())""", (args.get('item_code')), as_dict = 1) if not item: frappe.throw(_("Item {0} is not active or end of life has been reached").format(args.get("item_code"))) ret = { 'uom' : item and item[0]['stock_uom'] or '', 'stock_uom' : item and item[0]['stock_uom'] or '', 'description' : item and item[0]['description'] or '', 'item_name' : item and item[0]['item_name'] or '', 'expense_account' : args.get("expense_account") \ or frappe.db.get_value("Company", args.get("company"), "stock_adjustment_account"), 'cost_center' : item and item[0]['buying_cost_center'] or args.get("cost_center"), 'qty' : 0, 'transfer_qty' : 0, 'conversion_factor' : 1, 'batch_no' : '', 'actual_qty' : 0, 'incoming_rate' : 0 } stock_and_rate = args.get('warehouse') and self.get_warehouse_details(args) or {} ret.update(stock_and_rate) return ret def get_uom_details(self, args): conversion_factor = frappe.db.get_value("UOM Conversion Detail", {"parent": args.get("item_code"), "uom": args.get("uom")}, "conversion_factor") if not conversion_factor: frappe.msgprint(_("UOM coversion factor required for UOM: {0} in Item: {1}") .format(args.get("uom"), args.get("item_code"))) ret = {'uom' : ''} else: ret = { 'conversion_factor' : flt(conversion_factor), 'transfer_qty' : flt(args.get("qty")) * flt(conversion_factor) } return ret def get_warehouse_details(self, args): ret = {} if args.get('warehouse') and args.get('item_code'): args.update({ "posting_date": self.posting_date, "posting_time": self.posting_time, }) args = frappe._dict(args) ret = { "actual_qty" : get_previous_sle(args).get("qty_after_transaction") or 0, "incoming_rate" : self.get_incoming_rate(args) } return ret def get_items(self): self.set('mtn_details', []) pro_obj = None if self.production_order: # common validations pro_obj = frappe.get_doc('Production Order', self.production_order) if pro_obj: self.validate_production_order(pro_obj) self.bom_no = pro_obj.bom_no else: # invalid production order self.production_order = None if self.bom_no: if self.purpose in ["Material Issue", "Material Transfer", "Manufacture/Repack", "Subcontract"]: if self.production_order and self.purpose == "Material Transfer": item_dict = self.get_pending_raw_materials(pro_obj) else: if not self.fg_completed_qty: frappe.throw(_("Manufacturing Quantity is mandatory")) item_dict = self.get_bom_raw_materials(self.fg_completed_qty) for item in item_dict.values(): if pro_obj: item["from_warehouse"] = pro_obj.wip_warehouse item["to_warehouse"] = "" # add raw materials to Stock Entry Detail table self.add_to_stock_entry_detail(item_dict) # add finished good item to Stock Entry Detail table -- along with bom_no if self.production_order and self.purpose == "Manufacture/Repack": item = frappe.db.get_value("Item", pro_obj.production_item, ["item_name", "description", "stock_uom", "expense_account", "buying_cost_center"], as_dict=1) self.add_to_stock_entry_detail({ cstr(pro_obj.production_item): { "to_warehouse": pro_obj.fg_warehouse, "from_warehouse": "", "qty": self.fg_completed_qty, "item_name": item.item_name, "description": item.description, "stock_uom": item.stock_uom, "expense_account": item.expense_account, "cost_center": item.buying_cost_center, } }, bom_no=pro_obj.bom_no) elif self.purpose in ["Material Receipt", "Manufacture/Repack"]: if self.purpose=="Material Receipt": self.from_warehouse = "" item = frappe.db.sql("""select name, item_name, description, stock_uom, expense_account, buying_cost_center from `tabItem` where name=(select item from tabBOM where name=%s)""", self.bom_no, as_dict=1) self.add_to_stock_entry_detail({ item[0]["name"] : { "qty": self.fg_completed_qty, "item_name": item[0].item_name, "description": item[0]["description"], "stock_uom": item[0]["stock_uom"], "from_warehouse": "", "expense_account": item[0].expense_account, "cost_center": item[0].buying_cost_center, } }, bom_no=self.bom_no) self.get_stock_and_rate() def get_bom_raw_materials(self, qty): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict # item dict = { item_code: {qty, description, stock_uom} } item_dict = get_bom_items_as_dict(self.bom_no, qty=qty, fetch_exploded = self.use_multi_level_bom) for item in item_dict.values(): item.from_warehouse = item.default_warehouse return item_dict def get_pending_raw_materials(self, pro_obj): """ issue (item quantity) that is pending to issue or desire to transfer, whichever is less """ item_dict = self.get_bom_raw_materials(1) issued_item_qty = self.get_issued_qty() max_qty = flt(pro_obj.qty) only_pending_fetched = [] for item in item_dict: pending_to_issue = (max_qty * item_dict[item]["qty"]) - issued_item_qty.get(item, 0) desire_to_transfer = flt(self.fg_completed_qty) * item_dict[item]["qty"] if desire_to_transfer <= pending_to_issue: item_dict[item]["qty"] = desire_to_transfer else: item_dict[item]["qty"] = pending_to_issue if pending_to_issue: only_pending_fetched.append(item) # delete items with 0 qty for item in item_dict.keys(): if not item_dict[item]["qty"]: del item_dict[item] # show some message if not len(item_dict): frappe.msgprint(_("""All items have already been transferred for this Production Order.""")) elif only_pending_fetched: frappe.msgprint(_("Pending Items {0} updated").format(only_pending_fetched)) return item_dict def get_issued_qty(self): issued_item_qty = {} result = frappe.db.sql("""select t1.item_code, sum(t1.qty) from `tabStock Entry Detail` t1, `tabStock Entry` t2 where t1.parent = t2.name and t2.production_order = %s and t2.docstatus = 1 and t2.purpose = 'Material Transfer' group by t1.item_code""", self.production_order) for t in result: issued_item_qty[t[0]] = flt(t[1]) return issued_item_qty def add_to_stock_entry_detail(self, item_dict, bom_no=None): expense_account, cost_center = frappe.db.get_values("Company", self.company, \ ["default_expense_account", "cost_center"])[0] for d in item_dict: se_child = self.append('mtn_details') se_child.s_warehouse = item_dict[d].get("from_warehouse", self.from_warehouse) se_child.t_warehouse = item_dict[d].get("to_warehouse", self.to_warehouse) se_child.item_code = cstr(d) se_child.item_name = item_dict[d]["item_name"] se_child.description = item_dict[d]["description"] se_child.uom = item_dict[d]["stock_uom"] se_child.stock_uom = item_dict[d]["stock_uom"] se_child.qty = flt(item_dict[d]["qty"]) se_child.expense_account = item_dict[d]["expense_account"] or expense_account se_child.cost_center = item_dict[d]["cost_center"] or cost_center # in stock uom se_child.transfer_qty = flt(item_dict[d]["qty"]) se_child.conversion_factor = 1.00 # to be assigned for finished item se_child.bom_no = bom_no def validate_with_material_request(self): for item in self.get("mtn_details"): if item.material_request: mreq_item = frappe.db.get_value("Material Request Item", {"name": item.material_request_item, "parent": item.material_request}, ["item_code", "warehouse", "idx"], as_dict=True) if mreq_item.item_code != item.item_code or mreq_item.warehouse != item.t_warehouse: frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx), frappe.MappingMismatchError) def get_work_orderDetails(self, work_order): WO_details = frappe.db.get_value('Work Order', work_order, '*', as_dict=1, debug=1) if WO_details: return { 'sales_invoice_no' : WO_details.sales_invoice_no, 'customer_name' : WO_details.customer_name, 'trial_date' : WO_details.trial_date, 'delivery_date' : WO_details.delivery_date, 'trials' : WO_details.trial_no } else: return None @frappe.whitelist() def get_party_details(ref_dt, ref_dn): if ref_dt in ["Delivery Note", "Sales Invoice"]: res = frappe.db.get_value(ref_dt, ref_dn, ["customer", "customer_name", "address_display as customer_address"], as_dict=1) else: res = frappe.db.get_value(ref_dt, ref_dn, ["supplier", "supplier_name", "address_display as supplier_address"], as_dict=1) return res or {} @frappe.whitelist() def get_production_order_details(production_order): result = frappe.db.sql("""select bom_no, ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom, wip_warehouse from `tabProduction Order` where name = %s""", production_order, as_dict=1) return result and result[0] or {} def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters): conditions = "" if doctype == "Sales Invoice": conditions = "and update_stock=1" return frappe.db.sql("""select name, customer, customer_name from `tab%s` where docstatus = 1 and (`%s` like %%(txt)s or `customer` like %%(txt)s) %s %s order by name, customer, customer_name limit %s""" % (doctype, searchfield, conditions, get_match_cond(doctype), "%(start)s, %(page_len)s"), {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, as_list=True) def query_purchase_return_doc(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select name, supplier, supplier_name from `tab%s` where docstatus = 1 and (`%s` like %%(txt)s or `supplier` like %%(txt)s) %s order by name, supplier, supplier_name limit %s""" % (doctype, searchfield, get_match_cond(doctype), "%(start)s, %(page_len)s"), {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, as_list=True) def query_return_item(doctype, txt, searchfield, start, page_len, filters): txt = txt.replace("%", "") ref = get_return_doc_and_details(filters) stock_items = get_stock_items_for_return(ref.doc, ref.parentfields) result = [] for item in ref.doc.get_all_children(): if getattr(item, "item_code", None) in stock_items: item.item_name = cstr(item.item_name) item.description = cstr(item.description) if (txt in item.item_code) or (txt in item.item_name) or (txt in item.description): val = [ item.item_code, (len(item.item_name) > 40) and (item.item_name[:40] + "...") or item.item_name, (len(item.description) > 40) and (item.description[:40] + "...") or \ item.description ] if val not in result: result.append(val) return result[start:start+page_len] def get_batch_no(doctype, txt, searchfield, start, page_len, filters): if not filters.get("posting_date"): filters["posting_date"] = nowdate() batch_nos = None args = { 'item_code': filters.get("item_code"), 's_warehouse': filters.get('s_warehouse'), 'posting_date': filters.get('posting_date'), 'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype), "start": start, "page_len": page_len } if filters.get("s_warehouse"): batch_nos = frappe.db.sql("""select batch_no from `tabStock Ledger Entry` sle where item_code = '%(item_code)s' and warehouse = '%(s_warehouse)s' and batch_no like '%(txt)s' and exists(select * from `tabBatch` where name = sle.batch_no and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s or expiry_date = '') and docstatus != 2) %(mcond)s group by batch_no having sum(actual_qty) > 0 order by batch_no desc limit %(start)s, %(page_len)s """ % args) if batch_nos: return batch_nos else: return frappe.db.sql("""select name from `tabBatch` where item = '%(item_code)s' and docstatus < 2 and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s or expiry_date = '' or expiry_date = "0000-00-00") %(mcond)s order by name desc limit %(start)s, %(page_len)s """ % args) def get_stock_items_for_return(ref_doc, parentfields): """return item codes filtered from doc, which are stock items""" if isinstance(parentfields, basestring): parentfields = [parentfields] all_items = list(set([d.item_code for d in ref_doc.get_all_children() if d.get("item_code")])) stock_items = frappe.db.sql_list("""select name from `tabItem` where is_stock_item='Yes' and name in (%s)""" % (", ".join(["%s"] * len(all_items))), tuple(all_items)) return stock_items def get_return_doc_and_details(args): ref = frappe._dict() # get ref_doc if args.get("purpose") in return_map: for fieldname, val in return_map[args.get("purpose")].items(): if args.get(fieldname): ref.fieldname = fieldname ref.doc = frappe.get_doc(val[0], args.get(fieldname)) ref.parentfields = val[1] break return ref return_map = { "Sales Return": { # [Ref DocType, [Item tables' parentfields]] "delivery_note_no": ["Delivery Note", ["delivery_note_details", "packing_details"]], "sales_invoice_no": ["Sales Invoice", ["entries", "packing_details"]] }, "Purchase Return": { "purchase_receipt_no": ["Purchase Receipt", ["purchase_receipt_details"]] } } @frappe.whitelist() def make_return_jv(stock_entry): se = frappe.get_doc("Stock Entry", stock_entry) if not se.purpose in ["Sales Return", "Purchase Return"]: return ref = get_return_doc_and_details(se) if ref.doc.doctype == "Delivery Note": result = make_return_jv_from_delivery_note(se, ref) elif ref.doc.doctype == "Sales Invoice": result = make_return_jv_from_sales_invoice(se, ref) elif ref.doc.doctype == "Purchase Receipt": result = make_return_jv_from_purchase_receipt(se, ref) # create jv doc and fetch balance for each unique row item jv = frappe.new_doc("Journal Voucher") jv.update({ "posting_date": se.posting_date, "voucher_type": se.purpose == "Sales Return" and "Credit Note" or "Debit Note", "fiscal_year": se.fiscal_year, "company": se.company }) from erpnext.accounts.utils import get_balance_on for r in result: jv.append("entries", { "account": r.get("account"), "against_invoice": r.get("against_invoice"), "against_voucher": r.get("against_voucher"), "balance": get_balance_on(r.get("account"), se.posting_date) if r.get("account") else 0 }) return jv def make_return_jv_from_sales_invoice(se, ref): # customer account entry parent = { "account": ref.doc.debit_to, "against_invoice": ref.doc.name, } # income account entries children = [] for se_item in se.get("mtn_details"): # find item in ref.doc ref_item = ref.doc.get({"item_code": se_item.item_code})[0] account = get_sales_account_from_item(ref.doc, ref_item) if account not in children: children.append(account) return [parent] + [{"account": account} for account in children] def get_sales_account_from_item(doc, ref_item): account = None if not getattr(ref_item, "income_account", None): if ref_item.parent_item: parent_item = doc.get(doc.fname, {"item_code": ref_item.parent_item})[0] account = parent_item.income_account else: account = ref_item.income_account return account def make_return_jv_from_delivery_note(se, ref): invoices_against_delivery = get_invoice_list("Sales Invoice Item", "delivery_note", ref.doc.name) if not invoices_against_delivery: sales_orders_against_delivery = [d.against_sales_order for d in ref.doc.get_all_children() if getattr(d, "against_sales_order", None)] if sales_orders_against_delivery: invoices_against_delivery = get_invoice_list("Sales Invoice Item", "sales_order", sales_orders_against_delivery) if not invoices_against_delivery: return [] packing_item_parent_map = dict([[d.item_code, d.parent_item] for d in ref.doc.get(ref.parentfields[1])]) parent = {} children = [] for se_item in se.get("mtn_details"): for sales_invoice in invoices_against_delivery: si = frappe.get_doc("Sales Invoice", sales_invoice) if se_item.item_code in packing_item_parent_map: ref_item = si.get({"item_code": packing_item_parent_map[se_item.item_code]}) else: ref_item = si.get({"item_code": se_item.item_code}) if not ref_item: continue ref_item = ref_item[0] account = get_sales_account_from_item(si, ref_item) if account not in children: children.append(account) if not parent: parent = {"account": si.debit_to} break if len(invoices_against_delivery) == 1: parent["against_invoice"] = invoices_against_delivery[0] result = [parent] + [{"account": account} for account in children] return result def get_invoice_list(doctype, link_field, value): if isinstance(value, basestring): value = [value] return frappe.db.sql_list("""select distinct parent from `tab%s` where docstatus = 1 and `%s` in (%s)""" % (doctype, link_field, ", ".join(["%s"]*len(value))), tuple(value)) def make_return_jv_from_purchase_receipt(se, ref): invoice_against_receipt = get_invoice_list("Purchase Invoice Item", "purchase_receipt", ref.doc.name) if not invoice_against_receipt: purchase_orders_against_receipt = [d.prevdoc_docname for d in ref.doc.get(ref.doc.fname, {"prevdoc_doctype": "Purchase Order"}) if getattr(d, "prevdoc_docname", None)] if purchase_orders_against_receipt: invoice_against_receipt = get_invoice_list("Purchase Invoice Item", "purchase_order", purchase_orders_against_receipt) if not invoice_against_receipt: return [] parent = {} children = [] for se_item in se.get("mtn_details"): for purchase_invoice in invoice_against_receipt: pi = frappe.get_doc("Purchase Invoice", purchase_invoice) ref_item = pi.get({"item_code": se_item.item_code}) if not ref_item: continue ref_item = ref_item[0] account = ref_item.expense_account if account not in children: children.append(account) if not parent: parent = {"account": pi.credit_to} break if len(invoice_against_receipt) == 1: parent["against_voucher"] = invoice_against_receipt[0] result = [parent] + [{"account": account} for account in children] return result
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 646, 6950, 14, 4322, 199, 199, 504, 6950, 14, 1208, 492, 286, 495, 12, 286, 442, 12, 17166, 12, 10029, 63, 269, 12, 3063, 602, 199, 199, 504, 6950, 492, 485, 199, 504, 29106, 14, 6088, 14, 1208, 492, 664, 63, 15994, 63, 1866, 199, 504, 29106, 14, 6088, 14, 6088, 63, 28771, 492, 664, 63, 6352, 63, 23042, 199, 504, 29106, 14, 20531, 14, 10590, 492, 664, 63, 1431, 63, 2067, 199, 504, 29106, 14, 6088, 14, 362, 63, 1053, 63, 5087, 492, 664, 63, 4561, 63, 5643, 199, 199, 533, 2832, 4152, 17103, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 28406, 5674, 1767, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 1010, 4525, 7562, 4086, 6621, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 23942, 3900, 1858, 26432, 4738, 547, 8, 9098, 14, 8172, 304, 986, 199, 199, 504, 29106, 14, 20531, 14, 6088, 63, 5538, 492, 28406, 7506, 199, 199, 964, 63, 3825, 63, 5876, 275, 469, 199, 198, 2, 2037, 78, 63, 5087, 582, 298, 5876, 15, 964, 63, 3825, 15, 6088, 63, 2373, 63, 3825, 14, 1360, 2, 199, 93, 199, 199, 533, 28406, 3900, 8, 17103, 7506, 304, 199, 198, 5252, 275, 283, 2037, 78, 63, 5087, 7, 199, 198, 318, 641, 912, 8, 277, 304, 507, 198, 692, 291, 14, 30461, 389, 17, 26, 686, 198, 509, 1242, 315, 291, 14, 362, 8, 277, 14, 5252, 304, 1585, 198, 1053, 14, 873, 8, 362, 63, 4561, 63, 5643, 8, 1053, 14, 1053, 63, 600, 12, 1871, 198, 1053, 14, 83, 63, 12806, 430, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 23980, 63, 521, 342, 507, 198, 277, 14, 3502, 63, 22615, 342, 507, 198, 496, 63, 1113, 275, 291, 14, 10777, 63, 1648, 436, 971, 686, 198, 9098, 14, 362, 63, 1301, 360, 26432, 9240, 297, 291, 14, 10777, 63, 1648, 9, 503, 488, 2742, 198, 277, 14, 409, 63, 9609, 63, 5643, 342, 507, 198, 277, 14, 3502, 63, 1053, 342, 507, 198, 277, 14, 3502, 63, 7519, 63, 374, 63, 4115, 480, 7519, 401, 298, 5643, 531, 507, 198, 277, 14, 3502, 63, 7519, 63, 374, 63, 4115, 480, 6088, 63, 7519, 401, 298, 9609, 63, 5643, 531, 507, 198, 277, 14, 3502, 63, 12806, 8, 496, 63, 1113, 9, 507, 198, 277, 14, 3502, 63, 10777, 63, 1648, 8, 496, 63, 1113, 9, 507, 198, 277, 14, 362, 63, 6088, 63, 460, 63, 1866, 342, 507, 198, 277, 14, 3502, 63, 15994, 63, 1866, 342, 507, 198, 277, 14, 3502, 63, 16302, 342, 507, 198, 277, 14, 3502, 63, 8669, 63, 8302, 83, 342, 507, 198, 277, 14, 3502, 63, 1107, 63, 4443, 63, 1301, 342, 507, 198, 277, 14, 3502, 63, 1045, 63, 9820, 63, 1069, 342, 507, 198, 277, 14, 3502, 63, 18646, 63, 3403, 342, 507, 198, 277, 14, 3502, 63, 27456, 63, 1866, 342, 507, 198, 277, 14, 409, 63, 2923, 63, 4606, 342, 421, 198, 318, 641, 63, 7275, 8, 277, 304, 507, 198, 504, 29106, 14, 6088, 14, 6088, 63, 4229, 63, 2474, 492, 4107, 63, 509, 63, 338, 63, 23736, 507, 198, 3502, 63, 509, 63, 338, 63, 23736, 8, 277, 9, 507, 198, 277, 14, 873, 63, 6088, 63, 28771, 342, 507, 198, 504, 29106, 14, 6088, 14, 6356, 14, 2171, 63, 889, 14, 2171, 63, 889, 492, 1678, 63, 2171, 63, 12712, 63, 4399, 63, 7275, 507, 198, 873, 63, 2171, 63, 12712, 63, 4399, 63, 7275, 8, 277, 12, 298, 2037, 78, 63, 5087, 531, 507, 198, 277, 14, 873, 63, 10777, 63, 1648, 342, 507, 198, 277, 14, 1875, 63, 3528, 63, 3189, 342, 421, 198, 318, 641, 63, 6406, 8, 277, 304, 507, 198, 277, 14, 873, 63, 6088, 63, 28771, 342, 507, 198, 277, 14, 873, 63, 10777, 63, 1648, 342, 507, 198, 277, 14, 1875, 63, 3528, 63, 3189, 63, 265, 63, 6406, 342, 421, 198, 318, 4107, 63, 18646, 63, 3403, 8, 277, 304, 507, 198, 504, 29106, 14, 8370, 14, 1208, 492, 4107, 63, 18646, 63, 3403, 507, 198, 3502, 63, 18646, 63, 3403, 8, 277, 14, 23980, 63, 602, 12, 291, 14, 18646, 63, 3403, 12, 686, 198, 277, 14, 2024, 14, 362, 63, 1302, 480, 23980, 63, 602, 2237, 421, 198, 318, 4107, 63, 22615, 8, 277, 304, 507, 198, 1078, 63, 6653, 10553, 275, 2097, 15787, 13383, 401, 298, 15787, 799, 13866, 401, 298, 15787, 27507, 401, 686, 198, 2, 2395, 17391, 15, 497, 1389, 401, 298, 2610, 14624, 401, 298, 18220, 1432, 401, 298, 20486, 1432, 937, 507, 198, 692, 291, 14, 22615, 440, 315, 1686, 63, 6653, 10553, 26, 686, 198, 9098, 14, 11964, 6115, 14959, 4070, 1471, 506, 1373, 402, 469, 16, 30273, 908, 8, 13184, 63, 269, 8, 1078, 63, 6653, 10553, 1724, 421, 198, 318, 663, 63, 9609, 63, 5643, 8, 277, 304, 507, 198, 509, 1242, 315, 291, 14, 362, 480, 2037, 78, 63, 5087, 2349, 686, 198, 692, 440, 17166, 8, 1053, 14, 5643, 304, 1585, 198, 9098, 14, 11964, 6115, 5810, 469, 16, 9160, 1413, 369, 365, 15230, 3471, 908, 8, 1053, 14, 2996, 430, 6319, 198, 1053, 14, 9609, 63, 5643, 275, 17166, 8, 1053, 14, 5643, 627, 1242, 14, 15083, 63, 4778, 12, 291, 14, 6833, 480, 9609, 63, 5643, 401, 1242, 430, 421, 198, 318, 4107, 63, 1053, 8, 277, 304, 507, 198, 6088, 63, 1744, 275, 291, 14, 362, 63, 6088, 63, 1744, 342, 507, 198, 8397, 63, 1744, 275, 291, 14, 362, 63, 8397, 63, 1744, 342, 507, 198, 509, 1242, 315, 291, 14, 362, 480, 2037, 78, 63, 5087, 2349, 686, 198, 692, 1242, 14, 1053, 63, 600, 440, 315, 10952, 63, 1744, 26, 1585, 198, 9098, 14, 11964, 6115, 91, 16, 93, 365, 440, 282, 10952, 7020, 3471, 908, 8, 1053, 14, 1053, 63, 600 ]
[ 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 646, 6950, 14, 4322, 199, 199, 504, 6950, 14, 1208, 492, 286, 495, 12, 286, 442, 12, 17166, 12, 10029, 63, 269, 12, 3063, 602, 199, 199, 504, 6950, 492, 485, 199, 504, 29106, 14, 6088, 14, 1208, 492, 664, 63, 15994, 63, 1866, 199, 504, 29106, 14, 6088, 14, 6088, 63, 28771, 492, 664, 63, 6352, 63, 23042, 199, 504, 29106, 14, 20531, 14, 10590, 492, 664, 63, 1431, 63, 2067, 199, 504, 29106, 14, 6088, 14, 362, 63, 1053, 63, 5087, 492, 664, 63, 4561, 63, 5643, 199, 199, 533, 2832, 4152, 17103, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 28406, 5674, 1767, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 1010, 4525, 7562, 4086, 6621, 547, 8, 9098, 14, 8172, 304, 986, 199, 533, 23942, 3900, 1858, 26432, 4738, 547, 8, 9098, 14, 8172, 304, 986, 199, 199, 504, 29106, 14, 20531, 14, 6088, 63, 5538, 492, 28406, 7506, 199, 199, 964, 63, 3825, 63, 5876, 275, 469, 199, 198, 2, 2037, 78, 63, 5087, 582, 298, 5876, 15, 964, 63, 3825, 15, 6088, 63, 2373, 63, 3825, 14, 1360, 2, 199, 93, 199, 199, 533, 28406, 3900, 8, 17103, 7506, 304, 199, 198, 5252, 275, 283, 2037, 78, 63, 5087, 7, 199, 198, 318, 641, 912, 8, 277, 304, 507, 198, 692, 291, 14, 30461, 389, 17, 26, 686, 198, 509, 1242, 315, 291, 14, 362, 8, 277, 14, 5252, 304, 1585, 198, 1053, 14, 873, 8, 362, 63, 4561, 63, 5643, 8, 1053, 14, 1053, 63, 600, 12, 1871, 198, 1053, 14, 83, 63, 12806, 430, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 23980, 63, 521, 342, 507, 198, 277, 14, 3502, 63, 22615, 342, 507, 198, 496, 63, 1113, 275, 291, 14, 10777, 63, 1648, 436, 971, 686, 198, 9098, 14, 362, 63, 1301, 360, 26432, 9240, 297, 291, 14, 10777, 63, 1648, 9, 503, 488, 2742, 198, 277, 14, 409, 63, 9609, 63, 5643, 342, 507, 198, 277, 14, 3502, 63, 1053, 342, 507, 198, 277, 14, 3502, 63, 7519, 63, 374, 63, 4115, 480, 7519, 401, 298, 5643, 531, 507, 198, 277, 14, 3502, 63, 7519, 63, 374, 63, 4115, 480, 6088, 63, 7519, 401, 298, 9609, 63, 5643, 531, 507, 198, 277, 14, 3502, 63, 12806, 8, 496, 63, 1113, 9, 507, 198, 277, 14, 3502, 63, 10777, 63, 1648, 8, 496, 63, 1113, 9, 507, 198, 277, 14, 362, 63, 6088, 63, 460, 63, 1866, 342, 507, 198, 277, 14, 3502, 63, 15994, 63, 1866, 342, 507, 198, 277, 14, 3502, 63, 16302, 342, 507, 198, 277, 14, 3502, 63, 8669, 63, 8302, 83, 342, 507, 198, 277, 14, 3502, 63, 1107, 63, 4443, 63, 1301, 342, 507, 198, 277, 14, 3502, 63, 1045, 63, 9820, 63, 1069, 342, 507, 198, 277, 14, 3502, 63, 18646, 63, 3403, 342, 507, 198, 277, 14, 3502, 63, 27456, 63, 1866, 342, 507, 198, 277, 14, 409, 63, 2923, 63, 4606, 342, 421, 198, 318, 641, 63, 7275, 8, 277, 304, 507, 198, 504, 29106, 14, 6088, 14, 6088, 63, 4229, 63, 2474, 492, 4107, 63, 509, 63, 338, 63, 23736, 507, 198, 3502, 63, 509, 63, 338, 63, 23736, 8, 277, 9, 507, 198, 277, 14, 873, 63, 6088, 63, 28771, 342, 507, 198, 504, 29106, 14, 6088, 14, 6356, 14, 2171, 63, 889, 14, 2171, 63, 889, 492, 1678, 63, 2171, 63, 12712, 63, 4399, 63, 7275, 507, 198, 873, 63, 2171, 63, 12712, 63, 4399, 63, 7275, 8, 277, 12, 298, 2037, 78, 63, 5087, 531, 507, 198, 277, 14, 873, 63, 10777, 63, 1648, 342, 507, 198, 277, 14, 1875, 63, 3528, 63, 3189, 342, 421, 198, 318, 641, 63, 6406, 8, 277, 304, 507, 198, 277, 14, 873, 63, 6088, 63, 28771, 342, 507, 198, 277, 14, 873, 63, 10777, 63, 1648, 342, 507, 198, 277, 14, 1875, 63, 3528, 63, 3189, 63, 265, 63, 6406, 342, 421, 198, 318, 4107, 63, 18646, 63, 3403, 8, 277, 304, 507, 198, 504, 29106, 14, 8370, 14, 1208, 492, 4107, 63, 18646, 63, 3403, 507, 198, 3502, 63, 18646, 63, 3403, 8, 277, 14, 23980, 63, 602, 12, 291, 14, 18646, 63, 3403, 12, 686, 198, 277, 14, 2024, 14, 362, 63, 1302, 480, 23980, 63, 602, 2237, 421, 198, 318, 4107, 63, 22615, 8, 277, 304, 507, 198, 1078, 63, 6653, 10553, 275, 2097, 15787, 13383, 401, 298, 15787, 799, 13866, 401, 298, 15787, 27507, 401, 686, 198, 2, 2395, 17391, 15, 497, 1389, 401, 298, 2610, 14624, 401, 298, 18220, 1432, 401, 298, 20486, 1432, 937, 507, 198, 692, 291, 14, 22615, 440, 315, 1686, 63, 6653, 10553, 26, 686, 198, 9098, 14, 11964, 6115, 14959, 4070, 1471, 506, 1373, 402, 469, 16, 30273, 908, 8, 13184, 63, 269, 8, 1078, 63, 6653, 10553, 1724, 421, 198, 318, 663, 63, 9609, 63, 5643, 8, 277, 304, 507, 198, 509, 1242, 315, 291, 14, 362, 480, 2037, 78, 63, 5087, 2349, 686, 198, 692, 440, 17166, 8, 1053, 14, 5643, 304, 1585, 198, 9098, 14, 11964, 6115, 5810, 469, 16, 9160, 1413, 369, 365, 15230, 3471, 908, 8, 1053, 14, 2996, 430, 6319, 198, 1053, 14, 9609, 63, 5643, 275, 17166, 8, 1053, 14, 5643, 627, 1242, 14, 15083, 63, 4778, 12, 291, 14, 6833, 480, 9609, 63, 5643, 401, 1242, 430, 421, 198, 318, 4107, 63, 1053, 8, 277, 304, 507, 198, 6088, 63, 1744, 275, 291, 14, 362, 63, 6088, 63, 1744, 342, 507, 198, 8397, 63, 1744, 275, 291, 14, 362, 63, 8397, 63, 1744, 342, 507, 198, 509, 1242, 315, 291, 14, 362, 480, 2037, 78, 63, 5087, 2349, 686, 198, 692, 1242, 14, 1053, 63, 600, 440, 315, 10952, 63, 1744, 26, 1585, 198, 9098, 14, 11964, 6115, 91, 16, 93, 365, 440, 282, 10952, 7020, 3471, 908, 8, 1053, 14, 1053, 63, 600, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
notforhire/Yup
src/test/bctest.py
169
1476
# Copyright 2014 BitPay, Inc. # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. import subprocess import os import json import sys def bctest(testDir, testObj, exeext): execprog = testObj['exec'] + exeext execargs = testObj['args'] execrun = [execprog] + execargs stdinCfg = None inputData = None if "input" in testObj: filename = testDir + "/" + testObj['input'] inputData = open(filename).read() stdinCfg = subprocess.PIPE outputFn = None outputData = None if "output_cmp" in testObj: outputFn = testObj['output_cmp'] outputData = open(testDir + "/" + outputFn).read() proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE,universal_newlines=True) try: outs = proc.communicate(input=inputData) except OSError: print("OSError, Failed to execute " + execprog) sys.exit(1) if outputData and (outs[0] != outputData): print("Output data mismatch for " + outputFn) sys.exit(1) wantRC = 0 if "return_code" in testObj: wantRC = testObj['return_code'] if proc.returncode != wantRC: print("Return code mismatch for " + outputFn) sys.exit(1) def bctester(testDir, input_basename, buildenv): input_filename = testDir + "/" + input_basename raw_data = open(input_filename).read() input_data = json.loads(raw_data) for testObj in input_data: bctest(testDir, testObj, buildenv.exeext) sys.exit(0)
mit
[ 3, 1898, 6927, 10199, 10517, 12, 3277, 14, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 2022, 199, 646, 984, 199, 199, 318, 16604, 396, 8, 396, 3567, 12, 511, 5665, 12, 14778, 832, 304, 421, 198, 1628, 6595, 275, 511, 5665, 459, 1628, 418, 435, 14778, 832, 199, 198, 1628, 589, 275, 511, 5665, 459, 589, 418, 199, 198, 1628, 1065, 275, 359, 1628, 6595, 61, 435, 2146, 589, 199, 198, 6626, 22457, 275, 488, 199, 198, 1210, 1451, 275, 488, 199, 198, 692, 298, 1210, 2, 315, 511, 5665, 26, 507, 198, 1501, 275, 511, 3567, 435, 10609, 435, 511, 5665, 459, 1210, 418, 507, 198, 1210, 1451, 275, 1551, 8, 1501, 680, 739, 342, 507, 198, 6626, 22457, 275, 3873, 14, 6089, 421, 198, 1199, 9656, 275, 488, 199, 198, 1199, 1451, 275, 488, 199, 198, 692, 298, 1199, 63, 5730, 2, 315, 511, 5665, 26, 507, 198, 1199, 9656, 275, 511, 5665, 459, 1199, 63, 5730, 418, 507, 198, 1199, 1451, 275, 1551, 8, 396, 3567, 435, 10609, 435, 1072, 9656, 680, 739, 342, 199, 198, 4687, 275, 3873, 14, 7942, 8, 1628, 1065, 12, 9009, 29, 6626, 22457, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 24866, 63, 13839, 29, 549, 9, 199, 198, 893, 26, 507, 198, 16816, 275, 6499, 14, 10664, 8, 1210, 29, 1210, 1451, 9, 199, 198, 2590, 6440, 26, 507, 198, 1361, 480, 16719, 12, 16277, 370, 5341, 298, 435, 2146, 6595, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 421, 198, 692, 1072, 1451, 436, 334, 16816, 59, 16, 61, 1137, 1072, 1451, 304, 507, 198, 1361, 480, 2959, 666, 15015, 367, 298, 435, 1072, 9656, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 421, 198, 7051, 8205, 275, 378, 199, 198, 692, 298, 1107, 63, 600, 2, 315, 511, 5665, 26, 507, 198, 7051, 8205, 275, 511, 5665, 459, 1107, 63, 600, 418, 199, 198, 692, 6499, 14, 9913, 1137, 2934, 8205, 26, 507, 198, 1361, 480, 1767, 1233, 15015, 367, 298, 435, 1072, 9656, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 16604, 8234, 8, 396, 3567, 12, 1324, 63, 4846, 12, 1032, 382, 848, 86, 304, 199, 198, 1210, 63, 1501, 275, 511, 3567, 435, 10609, 435, 1324, 63, 4846, 199, 198, 1773, 63, 576, 275, 1551, 8, 1210, 63, 1501, 680, 739, 342, 199, 198, 1210, 63, 576, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 421, 198, 509, 511, 5665, 315, 1324, 63, 576, 26, 507, 198, 3776, 396, 8, 396, 3567, 12, 511, 5665, 12, 1032, 382, 848, 86, 14, 5803, 832, 9, 421, 198, 1274, 14, 2224, 8, 16, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 10199, 10517, 12, 3277, 14, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 199, 646, 3873, 199, 646, 747, 199, 646, 2022, 199, 646, 984, 199, 199, 318, 16604, 396, 8, 396, 3567, 12, 511, 5665, 12, 14778, 832, 304, 421, 198, 1628, 6595, 275, 511, 5665, 459, 1628, 418, 435, 14778, 832, 199, 198, 1628, 589, 275, 511, 5665, 459, 589, 418, 199, 198, 1628, 1065, 275, 359, 1628, 6595, 61, 435, 2146, 589, 199, 198, 6626, 22457, 275, 488, 199, 198, 1210, 1451, 275, 488, 199, 198, 692, 298, 1210, 2, 315, 511, 5665, 26, 507, 198, 1501, 275, 511, 3567, 435, 10609, 435, 511, 5665, 459, 1210, 418, 507, 198, 1210, 1451, 275, 1551, 8, 1501, 680, 739, 342, 507, 198, 6626, 22457, 275, 3873, 14, 6089, 421, 198, 1199, 9656, 275, 488, 199, 198, 1199, 1451, 275, 488, 199, 198, 692, 298, 1199, 63, 5730, 2, 315, 511, 5665, 26, 507, 198, 1199, 9656, 275, 511, 5665, 459, 1199, 63, 5730, 418, 507, 198, 1199, 1451, 275, 1551, 8, 396, 3567, 435, 10609, 435, 1072, 9656, 680, 739, 342, 199, 198, 4687, 275, 3873, 14, 7942, 8, 1628, 1065, 12, 9009, 29, 6626, 22457, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 12, 24866, 63, 13839, 29, 549, 9, 199, 198, 893, 26, 507, 198, 16816, 275, 6499, 14, 10664, 8, 1210, 29, 1210, 1451, 9, 199, 198, 2590, 6440, 26, 507, 198, 1361, 480, 16719, 12, 16277, 370, 5341, 298, 435, 2146, 6595, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 421, 198, 692, 1072, 1451, 436, 334, 16816, 59, 16, 61, 1137, 1072, 1451, 304, 507, 198, 1361, 480, 2959, 666, 15015, 367, 298, 435, 1072, 9656, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 421, 198, 7051, 8205, 275, 378, 199, 198, 692, 298, 1107, 63, 600, 2, 315, 511, 5665, 26, 507, 198, 7051, 8205, 275, 511, 5665, 459, 1107, 63, 600, 418, 199, 198, 692, 6499, 14, 9913, 1137, 2934, 8205, 26, 507, 198, 1361, 480, 1767, 1233, 15015, 367, 298, 435, 1072, 9656, 9, 507, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 16604, 8234, 8, 396, 3567, 12, 1324, 63, 4846, 12, 1032, 382, 848, 86, 304, 199, 198, 1210, 63, 1501, 275, 511, 3567, 435, 10609, 435, 1324, 63, 4846, 199, 198, 1773, 63, 576, 275, 1551, 8, 1210, 63, 1501, 680, 739, 342, 199, 198, 1210, 63, 576, 275, 2022, 14, 3640, 8, 1773, 63, 576, 9, 421, 198, 509, 511, 5665, 315, 1324, 63, 576, 26, 507, 198, 3776, 396, 8, 396, 3567, 12, 511, 5665, 12, 1032, 382, 848, 86, 14, 5803, 832, 9, 421, 198, 1274, 14, 2224, 8, 16, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sirioz/python-digitalocean
digitalocean/tests/test_certficate.py
2
2679
import json import unittest import responses import digitalocean from .BaseTest import BaseTest class TestCertificate(BaseTest): def setUp(self): super(TestCertificate, self).setUp() self.cert_id = '892071a0-bb95-49bc-8021-3afd67a210bf' self.cert = digitalocean.Certificate(id=self.cert_id, token=self.token) @responses.activate def test_load(self): data = self.load_from_file('certificate/single.json') url = self.base_url + 'certificates/' + self.cert_id responses.add(responses.GET, url, body=data, status=200, content_type='application/json') self.cert.load() self.assert_get_url_equal(responses.calls[0].request.url, url) self.assertEqual(self.cert.id, self.cert_id) self.assertEqual(self.cert.name, 'web-cert-01') self.assertEqual(self.cert.sha1_fingerprint, 'dfcc9f57d86bf58e321c2c6c31c7a971be244ac7') self.assertEqual(self.cert.not_after, '2017-02-22T00:23:00Z') self.assertEqual(self.cert.created_at, '2017-02-08T16:02:37Z') @responses.activate def test_create_ids(self): data = self.load_from_file('certificate/single.json') url = self.base_url + 'certificates/' responses.add(responses.POST, url, body=data, status=201, content_type='application/json') cert = digitalocean.Certificate(name='web-cert-01', private_key = "a-b-c", leaf_certificate = "e-f-g", certificate_chain = "a-b-c\ne-f-g", token=self.token).create() self.assertEqual(responses.calls[0].request.url, url) self.assertEqual(cert.id, '892071a0-bb95-49bc-8021-3afd67a210bf') self.assertEqual(cert.name, 'web-cert-01') self.assertEqual(cert.sha1_fingerprint, 'dfcc9f57d86bf58e321c2c6c31c7a971be244ac7') self.assertEqual(cert.not_after, '2017-02-22T00:23:00Z') self.assertEqual(cert.created_at, '2017-02-08T16:02:37Z') @responses.activate def test_destroy(self): url = self.base_url + 'certificates/' + self.cert_id responses.add(responses.DELETE, url, status=204, content_type='application/json') self.cert.destroy() self.assertEqual(responses.calls[0].request.url, url) if __name__ == '__main__': unittest.main()
lgpl-3.0
[ 646, 2022, 199, 646, 2882, 199, 646, 9320, 199, 646, 10964, 12201, 20867, 199, 199, 504, 1275, 23170, 492, 3523, 774, 421, 199, 533, 1379, 11414, 8, 23170, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11414, 12, 291, 680, 5996, 342, 267, 291, 14, 4736, 63, 344, 275, 283, 1407, 1165, 3172, 65, 16, 13, 2501, 2720, 13, 1887, 3776, 13, 11366, 17, 13, 19, 65, 2592, 1822, 65, 12725, 4361, 7, 267, 291, 14, 4736, 275, 10964, 12201, 20867, 14, 11414, 8, 344, 29, 277, 14, 4736, 63, 344, 12, 1526, 29, 277, 14, 1418, 9, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 912, 8, 277, 304, 267, 666, 275, 291, 14, 912, 63, 504, 63, 493, 360, 6999, 15, 4780, 14, 1001, 358, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 435, 291, 14, 4736, 63, 344, 398, 9320, 14, 525, 8, 10360, 14, 2970, 12, 1993, 1166, 12, 1993, 2396, 29, 576, 12, 1993, 2004, 29, 1840, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 291, 14, 4736, 14, 912, 342, 398, 291, 14, 479, 63, 362, 63, 633, 63, 1452, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 344, 12, 291, 14, 4736, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 354, 12, 283, 2520, 13, 4736, 13, 614, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 4835, 17, 63, 15077, 12, 288, 283, 1587, 2055, 25, 70, 1641, 68, 1184, 4361, 2010, 69, 12638, 67, 18, 67, 22, 67, 2192, 67, 23, 65, 27622, 1235, 11603, 645, 23, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 1397, 63, 4399, 12, 283, 10680, 13, 996, 13, 1081, 52, 383, 26, 1789, 26, 383, 58, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 3966, 63, 292, 12, 283, 10680, 13, 996, 13, 2036, 52, 975, 26, 996, 26, 1401, 58, 358, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 981, 63, 1580, 8, 277, 304, 267, 666, 275, 291, 14, 912, 63, 504, 63, 493, 360, 6999, 15, 4780, 14, 1001, 358, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 398, 9320, 14, 525, 8, 10360, 14, 4030, 12, 1993, 1166, 12, 1993, 2396, 29, 576, 12, 1993, 2004, 29, 1797, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 6250, 275, 10964, 12201, 20867, 14, 11414, 8, 354, 534, 2520, 13, 4736, 13, 614, 297, 3147, 5726, 63, 498, 275, 298, 65, 13, 66, 13, 67, 401, 3147, 11747, 63, 6999, 275, 298, 69, 13, 70, 13, 71, 401, 3147, 5897, 63, 4429, 275, 298, 65, 13, 66, 13, 67, 60, 685, 13, 70, 13, 71, 401, 3147, 1526, 29, 277, 14, 1418, 680, 981, 342, 398, 291, 14, 629, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 267, 291, 14, 629, 8, 4736, 14, 344, 12, 283, 1407, 1165, 3172, 65, 16, 13, 2501, 2720, 13, 1887, 3776, 13, 11366, 17, 13, 19, 65, 2592, 1822, 65, 12725, 4361, 358, 267, 291, 14, 629, 8, 4736, 14, 354, 12, 283, 2520, 13, 4736, 13, 614, 358, 267, 291, 14, 629, 8, 4736, 14, 4835, 17, 63, 15077, 12, 288, 283, 1587, 2055, 25, 70, 1641, 68, 1184, 4361, 2010, 69, 12638, 67, 18, 67, 22, 67, 2192, 67, 23, 65, 27622, 1235, 11603, 645, 23, 358, 267, 291, 14, 629, 8, 4736, 14, 1397, 63, 4399, 12, 283, 10680, 13, 996, 13, 1081, 52, 383, 26, 1789, 26, 383, 58, 358, 267, 291, 14, 629, 8, 4736, 14, 3966, 63, 292, 12, 283, 10680, 13, 996, 13, 2036, 52, 975, 26, 996, 26, 1401, 58, 358, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 7237, 8, 277, 304, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 435, 291, 14, 4736, 63, 344, 267, 9320, 14, 525, 8, 10360, 14, 7014, 12, 1993, 1166, 12, 1993, 2004, 29, 6686, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 291, 14, 4736, 14, 7237, 342, 398, 291, 14, 629, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2022, 199, 646, 2882, 199, 646, 9320, 199, 646, 10964, 12201, 20867, 199, 199, 504, 1275, 23170, 492, 3523, 774, 421, 199, 533, 1379, 11414, 8, 23170, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11414, 12, 291, 680, 5996, 342, 267, 291, 14, 4736, 63, 344, 275, 283, 1407, 1165, 3172, 65, 16, 13, 2501, 2720, 13, 1887, 3776, 13, 11366, 17, 13, 19, 65, 2592, 1822, 65, 12725, 4361, 7, 267, 291, 14, 4736, 275, 10964, 12201, 20867, 14, 11414, 8, 344, 29, 277, 14, 4736, 63, 344, 12, 1526, 29, 277, 14, 1418, 9, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 912, 8, 277, 304, 267, 666, 275, 291, 14, 912, 63, 504, 63, 493, 360, 6999, 15, 4780, 14, 1001, 358, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 435, 291, 14, 4736, 63, 344, 398, 9320, 14, 525, 8, 10360, 14, 2970, 12, 1993, 1166, 12, 1993, 2396, 29, 576, 12, 1993, 2004, 29, 1840, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 291, 14, 4736, 14, 912, 342, 398, 291, 14, 479, 63, 362, 63, 633, 63, 1452, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 344, 12, 291, 14, 4736, 63, 344, 9, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 354, 12, 283, 2520, 13, 4736, 13, 614, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 4835, 17, 63, 15077, 12, 288, 283, 1587, 2055, 25, 70, 1641, 68, 1184, 4361, 2010, 69, 12638, 67, 18, 67, 22, 67, 2192, 67, 23, 65, 27622, 1235, 11603, 645, 23, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 1397, 63, 4399, 12, 283, 10680, 13, 996, 13, 1081, 52, 383, 26, 1789, 26, 383, 58, 358, 267, 291, 14, 629, 8, 277, 14, 4736, 14, 3966, 63, 292, 12, 283, 10680, 13, 996, 13, 2036, 52, 975, 26, 996, 26, 1401, 58, 358, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 981, 63, 1580, 8, 277, 304, 267, 666, 275, 291, 14, 912, 63, 504, 63, 493, 360, 6999, 15, 4780, 14, 1001, 358, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 398, 9320, 14, 525, 8, 10360, 14, 4030, 12, 1993, 1166, 12, 1993, 2396, 29, 576, 12, 1993, 2004, 29, 1797, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 6250, 275, 10964, 12201, 20867, 14, 11414, 8, 354, 534, 2520, 13, 4736, 13, 614, 297, 3147, 5726, 63, 498, 275, 298, 65, 13, 66, 13, 67, 401, 3147, 11747, 63, 6999, 275, 298, 69, 13, 70, 13, 71, 401, 3147, 5897, 63, 4429, 275, 298, 65, 13, 66, 13, 67, 60, 685, 13, 70, 13, 71, 401, 3147, 1526, 29, 277, 14, 1418, 680, 981, 342, 398, 291, 14, 629, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 267, 291, 14, 629, 8, 4736, 14, 344, 12, 283, 1407, 1165, 3172, 65, 16, 13, 2501, 2720, 13, 1887, 3776, 13, 11366, 17, 13, 19, 65, 2592, 1822, 65, 12725, 4361, 358, 267, 291, 14, 629, 8, 4736, 14, 354, 12, 283, 2520, 13, 4736, 13, 614, 358, 267, 291, 14, 629, 8, 4736, 14, 4835, 17, 63, 15077, 12, 288, 283, 1587, 2055, 25, 70, 1641, 68, 1184, 4361, 2010, 69, 12638, 67, 18, 67, 22, 67, 2192, 67, 23, 65, 27622, 1235, 11603, 645, 23, 358, 267, 291, 14, 629, 8, 4736, 14, 1397, 63, 4399, 12, 283, 10680, 13, 996, 13, 1081, 52, 383, 26, 1789, 26, 383, 58, 358, 267, 291, 14, 629, 8, 4736, 14, 3966, 63, 292, 12, 283, 10680, 13, 996, 13, 2036, 52, 975, 26, 996, 26, 1401, 58, 358, 339, 768, 10360, 14, 8222, 272, 347, 511, 63, 7237, 8, 277, 304, 267, 1166, 275, 291, 14, 1095, 63, 633, 435, 283, 16159, 4805, 435, 291, 14, 4736, 63, 344, 267, 9320, 14, 525, 8, 10360, 14, 7014, 12, 1993, 1166, 12, 1993, 2004, 29, 6686, 12, 1993, 1564, 63, 466, 534, 3578, 15, 1001, 358, 398, 291, 14, 4736, 14, 7237, 342, 398, 291, 14, 629, 8, 10360, 14, 5352, 59, 16, 1055, 1069, 14, 633, 12, 1166, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
localprojects/Change-By-Us
giveaminute/migrations/versions/002_Update_Need_table_with_quanitity_and_address_and_whatnot.py
4
2489
""" :copyright: (c) 2011 Local Projects, all rights reserved :license: Affero GNU GPL v3, see LICENSE for more details. """ from sqlalchemy import * from migrate import * def upgrade(migrate_engine): # Upgrade operations go here. Don't create your own engine; bind migrate_engine # to your metadata meta = MetaData(migrate_engine) # Create the project place table place = Table('project_place', meta, Column('id', Integer, primary_key=True), Column('name', String(256)), Column('street', String(256)), Column('city', String(256)), ) place.create() # Rename the project_needs table to project_need need = Table('project_needs', meta, autoload=True) need.rename('project_need') # Rename the project_need_volunteers table to project_need_volunteer volunteer = Table('project_need_volunteers', meta, autoload=True) volunteer.rename('project_need_volunteer') # The above renames are to be consistent with the other table naming. We're # using singular nouns for tables. The table is the schema for the table # (the model of what's in the table) more than it is the rows, in this view. # Modify/add columns alter_column('item_needed', name='request', table=need) alter_column('num_needed', name='quantity', table=need) create_column(Column('address_id', Integer, ForeignKey('project_place.id')), need) create_column(Column('date', Date), need) create_column(Column('time', String(32)), need) create_column(Column('duration', String(64)), need) def downgrade(migrate_engine): # Operations to reverse the above upgrade go here. meta = MetaData(migrate_engine) # Rename the project_need_volunteer table back to project_need_volunteers volunteer = Table('project_need_volunteer', meta, autoload=True) volunteer.rename('project_need_volunteers') # Rename the project_need table back to project_needs need = Table('project_need', meta, autoload=True) need.rename('project_needs') # Modify/remove columns alter_column('request', name='item_needed', table=need) alter_column('quantity', name='num_needed', table=need) drop_column('address_id', need) drop_column('date', need) drop_column('time', need) drop_column('duration', need) # Get rid of the project place table place = Table('project_place', meta, autoload=True) place.drop()
agpl-3.0
[ 624, 272, 520, 7307, 26, 334, 67, 9, 7760, 10111, 7290, 83, 12, 1006, 4481, 4644, 272, 520, 1682, 26, 4265, 1664, 14629, 373, 19, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 8335, 492, 627, 199, 504, 12810, 492, 627, 199, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 327, 4949, 4523, 5331, 2621, 2348, 14, 7529, 1133, 1218, 2195, 5705, 6869, 27, 5398, 12810, 63, 3908, 272, 327, 370, 2195, 3341, 2286, 3404, 275, 24905, 8, 8462, 63, 3908, 9, 2286, 327, 2790, 314, 2199, 4192, 1817, 272, 4192, 275, 6957, 360, 1715, 63, 2778, 297, 3404, 12, 4960, 4996, 360, 344, 297, 7225, 12, 5062, 63, 498, 29, 549, 395, 267, 4996, 360, 354, 297, 2624, 8, 3912, 1826, 267, 4996, 360, 20451, 297, 2624, 8, 3912, 1826, 267, 4996, 360, 3690, 297, 2624, 8, 3912, 1826, 272, 776, 272, 4192, 14, 981, 342, 2286, 327, 22756, 314, 2199, 63, 10065, 1817, 370, 2199, 63, 9321, 272, 1929, 275, 6957, 360, 1715, 63, 10065, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 1929, 14, 8165, 360, 1715, 63, 9321, 358, 2286, 327, 22756, 314, 2199, 63, 9321, 63, 5650, 22190, 1192, 1817, 370, 2199, 63, 9321, 63, 5650, 27929, 272, 5236, 27929, 275, 6957, 360, 1715, 63, 9321, 63, 5650, 22190, 1192, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 5236, 27929, 14, 8165, 360, 1715, 63, 9321, 63, 5650, 27929, 358, 2286, 327, 710, 3432, 295, 1247, 787, 370, 506, 12137, 543, 314, 1163, 1817, 19720, 14, 2136, 3984, 272, 327, 1808, 15823, 949, 324, 83, 367, 6716, 14, 710, 1817, 365, 314, 4177, 367, 314, 1817, 272, 327, 334, 1589, 1402, 402, 4052, 1159, 315, 314, 1817, 9, 1655, 2419, 652, 365, 314, 4730, 12, 315, 642, 2455, 14, 2286, 327, 22520, 15, 525, 4362, 272, 17355, 63, 2301, 360, 1053, 63, 11368, 297, 536, 534, 1069, 297, 1817, 29, 9321, 9, 272, 17355, 63, 2301, 360, 1507, 63, 11368, 297, 536, 534, 10577, 297, 1817, 29, 9321, 9, 272, 1218, 63, 2301, 8, 4547, 360, 1562, 63, 344, 297, 7225, 12, 12718, 360, 1715, 63, 2778, 14, 344, 3855, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 602, 297, 6148, 395, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 521, 297, 2624, 8, 708, 1826, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 5553, 297, 2624, 8, 772, 1826, 1929, 9, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 327, 29474, 370, 3837, 314, 3432, 10754, 2621, 2348, 14, 2286, 3404, 275, 24905, 8, 8462, 63, 3908, 9, 2286, 327, 22756, 314, 2199, 63, 9321, 63, 5650, 27929, 1817, 1771, 370, 2199, 63, 9321, 63, 5650, 22190, 1192, 272, 5236, 27929, 275, 6957, 360, 1715, 63, 9321, 63, 5650, 27929, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 5236, 27929, 14, 8165, 360, 1715, 63, 9321, 63, 5650, 22190, 1192, 358, 2286, 327, 22756, 314, 2199, 63, 9321, 1817, 1771, 370, 2199, 63, 10065, 272, 1929, 275, 6957, 360, 1715, 63, 9321, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 1929, 14, 8165, 360, 1715, 63, 10065, 358, 2286, 327, 22520, 15, 2168, 4362, 272, 17355, 63, 2301, 360, 1069, 297, 536, 534, 1053, 63, 11368, 297, 1817, 29, 9321, 9, 272, 17355, 63, 2301, 360, 10577, 297, 536, 534, 1507, 63, 11368, 297, 1817, 29, 9321, 9, 272, 5978, 63, 2301, 360, 1562, 63, 344, 297, 1929, 9, 272, 5978, 63, 2301, 360, 602, 297, 1929, 9, 272, 5978, 63, 2301, 360, 521, 297, 1929, 9, 272, 5978, 63, 2301, 360, 5553, 297, 1929, 9, 2286, 327, 2372, 16146, 402, 314, 2199, 4192, 1817, 272, 4192, 275, 6957, 360, 1715, 63, 2778, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 4192, 14, 4824, 342, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 272, 520, 7307, 26, 334, 67, 9, 7760, 10111, 7290, 83, 12, 1006, 4481, 4644, 272, 520, 1682, 26, 4265, 1664, 14629, 373, 19, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 8335, 492, 627, 199, 504, 12810, 492, 627, 199, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 327, 4949, 4523, 5331, 2621, 2348, 14, 7529, 1133, 1218, 2195, 5705, 6869, 27, 5398, 12810, 63, 3908, 272, 327, 370, 2195, 3341, 2286, 3404, 275, 24905, 8, 8462, 63, 3908, 9, 2286, 327, 2790, 314, 2199, 4192, 1817, 272, 4192, 275, 6957, 360, 1715, 63, 2778, 297, 3404, 12, 4960, 4996, 360, 344, 297, 7225, 12, 5062, 63, 498, 29, 549, 395, 267, 4996, 360, 354, 297, 2624, 8, 3912, 1826, 267, 4996, 360, 20451, 297, 2624, 8, 3912, 1826, 267, 4996, 360, 3690, 297, 2624, 8, 3912, 1826, 272, 776, 272, 4192, 14, 981, 342, 2286, 327, 22756, 314, 2199, 63, 10065, 1817, 370, 2199, 63, 9321, 272, 1929, 275, 6957, 360, 1715, 63, 10065, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 1929, 14, 8165, 360, 1715, 63, 9321, 358, 2286, 327, 22756, 314, 2199, 63, 9321, 63, 5650, 22190, 1192, 1817, 370, 2199, 63, 9321, 63, 5650, 27929, 272, 5236, 27929, 275, 6957, 360, 1715, 63, 9321, 63, 5650, 22190, 1192, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 5236, 27929, 14, 8165, 360, 1715, 63, 9321, 63, 5650, 27929, 358, 2286, 327, 710, 3432, 295, 1247, 787, 370, 506, 12137, 543, 314, 1163, 1817, 19720, 14, 2136, 3984, 272, 327, 1808, 15823, 949, 324, 83, 367, 6716, 14, 710, 1817, 365, 314, 4177, 367, 314, 1817, 272, 327, 334, 1589, 1402, 402, 4052, 1159, 315, 314, 1817, 9, 1655, 2419, 652, 365, 314, 4730, 12, 315, 642, 2455, 14, 2286, 327, 22520, 15, 525, 4362, 272, 17355, 63, 2301, 360, 1053, 63, 11368, 297, 536, 534, 1069, 297, 1817, 29, 9321, 9, 272, 17355, 63, 2301, 360, 1507, 63, 11368, 297, 536, 534, 10577, 297, 1817, 29, 9321, 9, 272, 1218, 63, 2301, 8, 4547, 360, 1562, 63, 344, 297, 7225, 12, 12718, 360, 1715, 63, 2778, 14, 344, 3855, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 602, 297, 6148, 395, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 521, 297, 2624, 8, 708, 1826, 1929, 9, 272, 1218, 63, 2301, 8, 4547, 360, 5553, 297, 2624, 8, 772, 1826, 1929, 9, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 327, 29474, 370, 3837, 314, 3432, 10754, 2621, 2348, 14, 2286, 3404, 275, 24905, 8, 8462, 63, 3908, 9, 2286, 327, 22756, 314, 2199, 63, 9321, 63, 5650, 27929, 1817, 1771, 370, 2199, 63, 9321, 63, 5650, 22190, 1192, 272, 5236, 27929, 275, 6957, 360, 1715, 63, 9321, 63, 5650, 27929, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 5236, 27929, 14, 8165, 360, 1715, 63, 9321, 63, 5650, 22190, 1192, 358, 2286, 327, 22756, 314, 2199, 63, 9321, 1817, 1771, 370, 2199, 63, 10065, 272, 1929, 275, 6957, 360, 1715, 63, 9321, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 1929, 14, 8165, 360, 1715, 63, 10065, 358, 2286, 327, 22520, 15, 2168, 4362, 272, 17355, 63, 2301, 360, 1069, 297, 536, 534, 1053, 63, 11368, 297, 1817, 29, 9321, 9, 272, 17355, 63, 2301, 360, 10577, 297, 536, 534, 1507, 63, 11368, 297, 1817, 29, 9321, 9, 272, 5978, 63, 2301, 360, 1562, 63, 344, 297, 1929, 9, 272, 5978, 63, 2301, 360, 602, 297, 1929, 9, 272, 5978, 63, 2301, 360, 521, 297, 1929, 9, 272, 5978, 63, 2301, 360, 5553, 297, 1929, 9, 2286, 327, 2372, 16146, 402, 314, 2199, 4192, 1817, 272, 4192, 275, 6957, 360, 1715, 63, 2778, 297, 3404, 12, 2599, 912, 29, 549, 9, 272, 4192, 14, 4824, 342, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
reyrodrigues/EU-SMS
temba/contacts/migrations/0031_contactfield_audit_fields.py
2
1975
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models from django.utils.timezone import utc import datetime from django.conf import settings class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('contacts', '0030_auto_20160202_1931'), ] operations = [ migrations.AddField( model_name='contactfield', name='created_by', field=models.ForeignKey(related_name='contacts_contactfield_creations', default=settings.ANONYMOUS_USER_ID, to=settings.AUTH_USER_MODEL, help_text='The user which originally created this item'), preserve_default=False, ), migrations.AddField( model_name='contactfield', name='created_on', field=models.DateTimeField(default=datetime.datetime(2014, 1, 1, 0, 0, 0, 0, tzinfo=utc), help_text='When this item was originally created', auto_now_add=True), preserve_default=False, ), migrations.AddField( model_name='contactfield', name='modified_by', field=models.ForeignKey(related_name='contacts_contactfield_modifications', default=settings.ANONYMOUS_USER_ID, to=settings.AUTH_USER_MODEL, help_text='The user which last modified this item'), preserve_default=False, ), migrations.AddField( model_name='contactfield', name='modified_on', field=models.DateTimeField(default=datetime.datetime(2014, 1, 1, 0, 0, 0, 0, tzinfo=utc), help_text='When this item was last modified', auto_now=True), preserve_default=False, ), migrations.AlterField( model_name='contactfield', name='is_active', field=models.BooleanField(default=True, help_text='Whether this item is active, use this instead of deleting'), ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 504, 1639, 14, 1208, 14, 7145, 492, 19314, 199, 646, 2197, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 18147, 297, 283, 24281, 63, 2495, 63, 9261, 996, 996, 63, 1167, 2192, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 3966, 63, 991, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 18147, 63, 7811, 698, 63, 1353, 1298, 297, 849, 29, 1751, 14, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 1720, 63, 505, 534, 1918, 922, 1314, 20657, 2737, 642, 1242, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 3966, 63, 265, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 2083, 14, 2083, 8, 7280, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 10313, 29, 5834, 395, 1720, 63, 505, 534, 11423, 642, 1242, 1990, 20657, 2737, 297, 2599, 63, 2131, 63, 525, 29, 549, 395, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 5540, 63, 991, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 18147, 63, 7811, 698, 63, 20945, 83, 297, 849, 29, 1751, 14, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 1720, 63, 505, 534, 1918, 922, 1314, 2061, 6042, 642, 1242, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 5540, 63, 265, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 2083, 14, 2083, 8, 7280, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 10313, 29, 5834, 395, 1720, 63, 505, 534, 11423, 642, 1242, 1990, 2061, 6042, 297, 2599, 63, 2131, 29, 549, 395, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 374, 63, 2682, 297, 288, 901, 29, 992, 14, 5036, 8, 885, 29, 549, 12, 1720, 63, 505, 534, 26625, 642, 1242, 365, 4702, 12, 675, 642, 3140, 402, 13794, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 504, 1639, 14, 1208, 14, 7145, 492, 19314, 199, 646, 2197, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 18147, 297, 283, 24281, 63, 2495, 63, 9261, 996, 996, 63, 1167, 2192, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 3966, 63, 991, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 18147, 63, 7811, 698, 63, 1353, 1298, 297, 849, 29, 1751, 14, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 1720, 63, 505, 534, 1918, 922, 1314, 20657, 2737, 642, 1242, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 3966, 63, 265, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 2083, 14, 2083, 8, 7280, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 10313, 29, 5834, 395, 1720, 63, 505, 534, 11423, 642, 1242, 1990, 20657, 2737, 297, 2599, 63, 2131, 63, 525, 29, 549, 395, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 5540, 63, 991, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 18147, 63, 7811, 698, 63, 20945, 83, 297, 849, 29, 1751, 14, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 1720, 63, 505, 534, 1918, 922, 1314, 2061, 6042, 642, 1242, 659, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 5540, 63, 265, 297, 288, 901, 29, 992, 14, 4626, 8, 885, 29, 2083, 14, 2083, 8, 7280, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 10313, 29, 5834, 395, 1720, 63, 505, 534, 11423, 642, 1242, 1990, 2061, 6042, 297, 2599, 63, 2131, 29, 549, 395, 288, 11211, 63, 885, 29, 797, 12, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 7811, 698, 297, 288, 536, 534, 374, 63, 2682, 297, 288, 901, 29, 992, 14, 5036, 8, 885, 29, 549, 12, 1720, 63, 505, 534, 26625, 642, 1242, 365, 4702, 12, 675, 642, 3140, 402, 13794, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kyroskoh/phantomjs
src/breakpad/src/tools/gyp/pylib/gyp/MSVSNew.py
138
11514
#!/usr/bin/python2.4 # Copyright (c) 2009 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """New implementation of Visual Studio project generation for SCons.""" import common import os import random # hashlib is supplied as of Python 2.5 as the replacement interface for md5 # and other secure hashes. In 2.6, md5 is deprecated. Import hashlib if # available, avoiding a deprecation warning under 2.6. Import md5 otherwise, # preserving 2.4 compatibility. try: import hashlib _new_md5 = hashlib.md5 except ImportError: import md5 _new_md5 = md5.new # Initialize random number generator random.seed() # GUIDs for project types ENTRY_TYPE_GUIDS = { 'project': '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}', 'folder': '{2150E333-8FDC-42A3-9474-1A3956D46DE8}', } #------------------------------------------------------------------------------ # Helper functions def MakeGuid(name, seed='msvs_new'): """Returns a GUID for the specified target name. Args: name: Target name. seed: Seed for MD5 hash. Returns: A GUID-line string calculated from the name and seed. This generates something which looks like a GUID, but depends only on the name and seed. This means the same name/seed will always generate the same GUID, so that projects and solutions which refer to each other can explicitly determine the GUID to refer to explicitly. It also means that the GUID will not change when the project for a target is rebuilt. """ # Calculate a MD5 signature for the seed and name. d = _new_md5(str(seed) + str(name)).hexdigest().upper() # Convert most of the signature to GUID form (discard the rest) guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20] + '-' + d[20:32] + '}') return guid #------------------------------------------------------------------------------ class MSVSFolder: """Folder in a Visual Studio project or solution.""" def __init__(self, path, name = None, entries = None, guid = None, items = None): """Initializes the folder. Args: path: Full path to the folder. name: Name of the folder. entries: List of folder entries to nest inside this folder. May contain Folder or Project objects. May be None, if the folder is empty. guid: GUID to use for folder, if not None. items: List of solution items to include in the folder project. May be None, if the folder does not directly contain items. """ if name: self.name = name else: # Use last layer. self.name = os.path.basename(path) self.path = path self.guid = guid # Copy passed lists (or set to empty lists) self.entries = list(entries or []) self.items = list(items or []) self.entry_type_guid = ENTRY_TYPE_GUIDS['folder'] def get_guid(self): if self.guid is None: # Use consistent guids for folders (so things don't regenerate). self.guid = MakeGuid(self.path, seed='msvs_folder') return self.guid #------------------------------------------------------------------------------ class MSVSProject: """Visual Studio project.""" def __init__(self, path, name = None, dependencies = None, guid = None, config_platform_overrides = None): """Initializes the project. Args: path: Relative path to project file. name: Name of project. If None, the name will be the same as the base name of the project file. dependencies: List of other Project objects this project is dependent upon, if not None. guid: GUID to use for project, if not None. config_platform_overrides: optional dict of configuration platforms to used in place of the default for this target. """ self.path = path self.guid = guid if name: self.name = name else: # Use project filename self.name = os.path.splitext(os.path.basename(path))[0] # Copy passed lists (or set to empty lists) self.dependencies = list(dependencies or []) self.entry_type_guid = ENTRY_TYPE_GUIDS['project'] if config_platform_overrides: self.config_platform_overrides = config_platform_overrides else: self.config_platform_overrides = {} def get_guid(self): if self.guid is None: # Set GUID from path # TODO(rspangler): This is fragile. # 1. We can't just use the project filename sans path, since there could # be multiple projects with the same base name (for example, # foo/unittest.vcproj and bar/unittest.vcproj). # 2. The path needs to be relative to $SOURCE_ROOT, so that the project # GUID is the same whether it's included from base/base.sln or # foo/bar/baz/baz.sln. # 3. The GUID needs to be the same each time this builder is invoked, so # that we don't need to rebuild the solution when the project changes. # 4. We should be able to handle pre-built project files by reading the # GUID from the files. self.guid = MakeGuid(self.name) return self.guid #------------------------------------------------------------------------------ class MSVSSolution: """Visual Studio solution.""" def __init__(self, path, version, entries=None, variants=None, websiteProperties=True): """Initializes the solution. Args: path: Path to solution file. version: Format version to emit. entries: List of entries in solution. May contain Folder or Project objects. May be None, if the folder is empty. variants: List of build variant strings. If none, a default list will be used. websiteProperties: Flag to decide if the website properties section is generated. """ self.path = path self.websiteProperties = websiteProperties self.version = version # Copy passed lists (or set to empty lists) self.entries = list(entries or []) if variants: # Copy passed list self.variants = variants[:] else: # Use default self.variants = ['Debug|Win32', 'Release|Win32'] # TODO(rspangler): Need to be able to handle a mapping of solution config # to project config. Should we be able to handle variants being a dict, # or add a separate variant_map variable? If it's a dict, we can't # guarantee the order of variants since dict keys aren't ordered. # TODO(rspangler): Automatically write to disk for now; should delay until # node-evaluation time. self.Write() def Write(self, writer=common.WriteOnDiff): """Writes the solution file to disk. Raises: IndexError: An entry appears multiple times. """ # Walk the entry tree and collect all the folders and projects. all_entries = [] entries_to_check = self.entries[:] while entries_to_check: # Pop from the beginning of the list to preserve the user's order. e = entries_to_check.pop(0) # A project or folder can only appear once in the solution's folder tree. # This also protects from cycles. if e in all_entries: #raise IndexError('Entry "%s" appears more than once in solution' % # e.name) continue all_entries.append(e) # If this is a folder, check its entries too. if isinstance(e, MSVSFolder): entries_to_check += e.entries # Sort by name then guid (so things are in order on vs2008). def NameThenGuid(a, b): if a.name < b.name: return -1 if a.name > b.name: return 1 if a.get_guid() < b.get_guid(): return -1 if a.get_guid() > b.get_guid(): return 1 return 0 all_entries = sorted(all_entries, NameThenGuid) # Open file and print header f = writer(self.path) f.write('Microsoft Visual Studio Solution File, ' 'Format Version %s\r\n' % self.version.SolutionVersion()) f.write('# %s\r\n' % self.version.Description()) # Project entries for e in all_entries: f.write('Project("%s") = "%s", "%s", "%s"\r\n' % ( e.entry_type_guid, # Entry type GUID e.name, # Folder name e.path.replace('/', '\\'), # Folder name (again) e.get_guid(), # Entry GUID )) # TODO(rspangler): Need a way to configure this stuff if self.websiteProperties: f.write('\tProjectSection(WebsiteProperties) = preProject\r\n' '\t\tDebug.AspNetCompiler.Debug = "True"\r\n' '\t\tRelease.AspNetCompiler.Debug = "False"\r\n' '\tEndProjectSection\r\n') if isinstance(e, MSVSFolder): if e.items: f.write('\tProjectSection(SolutionItems) = preProject\r\n') for i in e.items: f.write('\t\t%s = %s\r\n' % (i, i)) f.write('\tEndProjectSection\r\n') if isinstance(e, MSVSProject): if e.dependencies: f.write('\tProjectSection(ProjectDependencies) = postProject\r\n') for d in e.dependencies: f.write('\t\t%s = %s\r\n' % (d.get_guid(), d.get_guid())) f.write('\tEndProjectSection\r\n') f.write('EndProject\r\n') # Global section f.write('Global\r\n') # Configurations (variants) f.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n') for v in self.variants: f.write('\t\t%s = %s\r\n' % (v, v)) f.write('\tEndGlobalSection\r\n') # Sort config guids for easier diffing of solution changes. config_guids = [] config_guids_overrides = {} for e in all_entries: if isinstance(e, MSVSProject): config_guids.append(e.get_guid()) config_guids_overrides[e.get_guid()] = e.config_platform_overrides config_guids.sort() f.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n') for g in config_guids: for v in self.variants: nv = config_guids_overrides[g].get(v, v) # Pick which project configuration to build for this solution # configuration. f.write('\t\t%s.%s.ActiveCfg = %s\r\n' % ( g, # Project GUID v, # Solution build configuration nv, # Project build config for that solution config )) # Enable project in this solution configuration. f.write('\t\t%s.%s.Build.0 = %s\r\n' % ( g, # Project GUID v, # Solution build configuration nv, # Project build config for that solution config )) f.write('\tEndGlobalSection\r\n') # TODO(rspangler): Should be able to configure this stuff too (though I've # never seen this be any different) f.write('\tGlobalSection(SolutionProperties) = preSolution\r\n') f.write('\t\tHideSolutionNode = FALSE\r\n') f.write('\tEndGlobalSection\r\n') # Folder mappings # TODO(rspangler): Should omit this section if there are no folders f.write('\tGlobalSection(NestedProjects) = preSolution\r\n') for e in all_entries: if not isinstance(e, MSVSFolder): continue # Does not apply to projects, only folders for subentry in e.entries: f.write('\t\t%s = %s\r\n' % (subentry.get_guid(), e.get_guid())) f.write('\tEndGlobalSection\r\n') f.write('EndGlobal\r\n') f.close()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 199, 3, 1898, 334, 67, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 4665, 4514, 402, 14702, 13225, 2199, 10152, 367, 8218, 1041, 199, 199, 646, 2863, 199, 646, 747, 199, 646, 2196, 199, 199, 3, 8337, 365, 6841, 465, 402, 2018, 499, 14, 21, 465, 314, 8343, 3217, 367, 6128, 21, 199, 3, 436, 1163, 11153, 14647, 14, 221, 1010, 499, 14, 22, 12, 6128, 21, 365, 5906, 14, 221, 3161, 8337, 340, 199, 3, 2808, 12, 5126, 316, 282, 17831, 5721, 1334, 499, 14, 22, 14, 221, 3161, 6128, 21, 4257, 12, 199, 3, 876, 14717, 499, 14, 20, 7163, 14, 199, 893, 26, 523, 492, 8337, 523, 485, 1222, 63, 1064, 21, 275, 8337, 14, 1064, 21, 199, 2590, 3545, 26, 523, 492, 6128, 21, 523, 485, 1222, 63, 1064, 21, 275, 6128, 21, 14, 1222, 421, 199, 3, 11578, 2196, 1329, 4306, 199, 2355, 14, 5176, 342, 199, 199, 3, 21645, 83, 367, 2199, 2943, 199, 7285, 63, 2711, 63, 17856, 51, 275, 469, 272, 283, 1715, 356, 5041, 24, 6265, 25, 2089, 34, 24, 13, 24, 34, 20, 33, 13, 845, 36, 16, 13, 24, 36, 845, 13, 383, 33, 16, 35, 3328, 6265, 25, 2260, 7293, 272, 283, 3741, 356, 5041, 7842, 16, 37, 11769, 13, 24, 38, 5196, 13, 2260, 33, 19, 13, 2635, 1342, 13, 17, 33, 1355, 1367, 36, 2466, 1093, 24, 7293, 199, 93, 199, 199, 20974, 199, 3, 11642, 3423, 421, 199, 318, 4155, 18834, 8, 354, 12, 6347, 534, 8338, 63, 1222, 735, 523, 408, 3407, 282, 21645, 367, 314, 2013, 1347, 536, 14, 819, 3033, 26, 272, 536, 26, 10256, 536, 14, 272, 6347, 26, 3240, 379, 367, 15830, 21, 2631, 14, 523, 1803, 26, 272, 437, 21645, 13, 604, 1059, 12950, 687, 314, 536, 436, 6347, 14, 819, 961, 12821, 6020, 1314, 10734, 2839, 282, 21645, 12, 1325, 8350, 1454, 641, 314, 523, 536, 436, 6347, 14, 221, 961, 4910, 314, 2011, 536, 15, 5176, 911, 3544, 3550, 314, 2011, 523, 21645, 12, 880, 626, 11336, 436, 24886, 1314, 10618, 370, 1924, 1163, 883, 7662, 523, 6705, 314, 21645, 370, 10618, 370, 7662, 14, 221, 2779, 2597, 4910, 626, 314, 21645, 911, 523, 440, 1570, 1380, 314, 2199, 367, 282, 1347, 365, 295, 11730, 14, 523, 408, 523, 327, 12707, 282, 15830, 21, 4955, 367, 314, 6347, 436, 536, 14, 523, 366, 275, 485, 1222, 63, 1064, 21, 8, 495, 8, 5176, 9, 435, 620, 8, 354, 4992, 11453, 1252, 4142, 342, 523, 327, 7905, 4750, 402, 314, 4955, 370, 21645, 1824, 334, 14394, 314, 4618, 9, 523, 15593, 275, 661, 1445, 435, 366, 1491, 24, 61, 435, 10791, 435, 366, 59, 24, 26, 713, 61, 435, 10791, 435, 366, 59, 713, 26, 975, 61, 435, 10791, 435, 366, 59, 975, 26, 1165, 61, 881, 435, 10791, 435, 366, 59, 1165, 26, 708, 61, 435, 283, 12216, 523, 372, 15593, 199, 199, 20974, 421, 199, 533, 13828, 7850, 26, 523, 408, 7850, 315, 282, 14702, 13225, 2199, 503, 8744, 1041, 819, 347, 636, 826, 721, 277, 12, 931, 12, 536, 275, 488, 12, 4811, 275, 488, 12, 2049, 15593, 275, 488, 12, 2974, 275, 488, 304, 272, 408, 23489, 314, 4922, 14, 339, 3033, 26, 489, 931, 26, 16579, 931, 370, 314, 4922, 14, 489, 536, 26, 2812, 402, 314, 4922, 14, 489, 4811, 26, 3820, 402, 4922, 4811, 370, 10715, 6272, 642, 4922, 14, 221, 10162, 1395, 881, 29121, 503, 7290, 2251, 14, 221, 10162, 506, 488, 12, 340, 314, 4922, 365, 2701, 14, 489, 15593, 26, 21645, 370, 675, 367, 4922, 12, 340, 440, 488, 14, 489, 2974, 26, 3820, 402, 8744, 2974, 370, 2387, 315, 314, 4922, 2199, 14, 221, 10162, 506, 881, 488, 12, 340, 314, 4922, 1630, 440, 5370, 1395, 2974, 14, 272, 408, 272, 340, 536, 26, 489, 291, 14, 354, 275, 536, 272, 587, 26, 489, 327, 3645, 2061, 4045, 14, 489, 291, 14, 354, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 339, 291, 14, 515, 275, 931, 272, 291, 14, 9473, 275, 15593, 339, 327, 11247, 3032, 5548, 334, 269, 663, 370, 2701, 5548, 9, 272, 291, 14, 3189, 275, 769, 8, 3189, 503, 3073, 272, 291, 14, 1744, 275, 769, 8, 1744, 503, 3073, 339, 291, 14, 2373, 63, 466, 63, 9473, 275, 5070, 21177, 63, 2711, 63, 17856, 51, 459, 3741, 418, 819, 347, 664, 63, 9473, 8, 277, 304, 272, 340, 291, 14, 9473, 365, 488, 26, 489, 327, 3645, 12137, 15593, 83, 367, 16533, 334, 1152, 7645, 2793, 1133, 30943, 680, 489, 291, 14, 9473, 275, 4155, 18834, 8, 277, 14, 515, 12, 6347, 534, 8338, 63, 3741, 358, 272, 372, 291, 14, 9473, 421, 199, 20974, 421, 199, 533, 13828, 4761, 26, 523, 408, 15039, 13225, 2199, 1041, 819, 347, 636, 826, 721, 277, 12, 931, 12, 536, 275, 488, 12, 5124, 275, 488, 12, 15593, 275, 488, 12, 2049, 1101, 63, 3246, 63, 12867, 275, 488, 304, 272, 408, 23489, 314, 2199, 14, 339, 3033, 26, 489, 931, 26, 22419, 931, 370, 2199, 570, 14, 489, 536, 26, 2812, 402, 2199, 14, 221, 982, 488, 12, 314, 536, 911, 506, 314, 2011, 465, 314, 1300, 881, 536, 402, 314, 2199, 570, 14, 489, 5124, 26, 3820, 402, 1163, 7290, 2251, 642, 2199, 365, 11410, 881, 12188, 12, 340, 440, 488, 14, 489, 15593, 26, 21645, 370, 675, 367, 2199, 12, 340, 440, 488, 14, 489, 1101, 63, 3246, 63, 12867, 26, 2716, 1211, 402, 2897, 10677, 370, 881, 1202, 315, 4192, 402, 314, 849, 367, 642, 1347, 14, 272, 408, 272, 291, 14, 515, 275, 931, 272, 291, 14, 9473, 275, 15593, 339, 340, 536, 26, 489, 291, 14, 354, 275, 536, 272, 587, 26, 489, 327, 3645, 2199, 1788, 489, 291, 14, 354, 275, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 8, 515, 11515, 16, 61, 339, 327, 11247 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 199, 3, 1898, 334, 67, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 4665, 4514, 402, 14702, 13225, 2199, 10152, 367, 8218, 1041, 199, 199, 646, 2863, 199, 646, 747, 199, 646, 2196, 199, 199, 3, 8337, 365, 6841, 465, 402, 2018, 499, 14, 21, 465, 314, 8343, 3217, 367, 6128, 21, 199, 3, 436, 1163, 11153, 14647, 14, 221, 1010, 499, 14, 22, 12, 6128, 21, 365, 5906, 14, 221, 3161, 8337, 340, 199, 3, 2808, 12, 5126, 316, 282, 17831, 5721, 1334, 499, 14, 22, 14, 221, 3161, 6128, 21, 4257, 12, 199, 3, 876, 14717, 499, 14, 20, 7163, 14, 199, 893, 26, 523, 492, 8337, 523, 485, 1222, 63, 1064, 21, 275, 8337, 14, 1064, 21, 199, 2590, 3545, 26, 523, 492, 6128, 21, 523, 485, 1222, 63, 1064, 21, 275, 6128, 21, 14, 1222, 421, 199, 3, 11578, 2196, 1329, 4306, 199, 2355, 14, 5176, 342, 199, 199, 3, 21645, 83, 367, 2199, 2943, 199, 7285, 63, 2711, 63, 17856, 51, 275, 469, 272, 283, 1715, 356, 5041, 24, 6265, 25, 2089, 34, 24, 13, 24, 34, 20, 33, 13, 845, 36, 16, 13, 24, 36, 845, 13, 383, 33, 16, 35, 3328, 6265, 25, 2260, 7293, 272, 283, 3741, 356, 5041, 7842, 16, 37, 11769, 13, 24, 38, 5196, 13, 2260, 33, 19, 13, 2635, 1342, 13, 17, 33, 1355, 1367, 36, 2466, 1093, 24, 7293, 199, 93, 199, 199, 20974, 199, 3, 11642, 3423, 421, 199, 318, 4155, 18834, 8, 354, 12, 6347, 534, 8338, 63, 1222, 735, 523, 408, 3407, 282, 21645, 367, 314, 2013, 1347, 536, 14, 819, 3033, 26, 272, 536, 26, 10256, 536, 14, 272, 6347, 26, 3240, 379, 367, 15830, 21, 2631, 14, 523, 1803, 26, 272, 437, 21645, 13, 604, 1059, 12950, 687, 314, 536, 436, 6347, 14, 819, 961, 12821, 6020, 1314, 10734, 2839, 282, 21645, 12, 1325, 8350, 1454, 641, 314, 523, 536, 436, 6347, 14, 221, 961, 4910, 314, 2011, 536, 15, 5176, 911, 3544, 3550, 314, 2011, 523, 21645, 12, 880, 626, 11336, 436, 24886, 1314, 10618, 370, 1924, 1163, 883, 7662, 523, 6705, 314, 21645, 370, 10618, 370, 7662, 14, 221, 2779, 2597, 4910, 626, 314, 21645, 911, 523, 440, 1570, 1380, 314, 2199, 367, 282, 1347, 365, 295, 11730, 14, 523, 408, 523, 327, 12707, 282, 15830, 21, 4955, 367, 314, 6347, 436, 536, 14, 523, 366, 275, 485, 1222, 63, 1064, 21, 8, 495, 8, 5176, 9, 435, 620, 8, 354, 4992, 11453, 1252, 4142, 342, 523, 327, 7905, 4750, 402, 314, 4955, 370, 21645, 1824, 334, 14394, 314, 4618, 9, 523, 15593, 275, 661, 1445, 435, 366, 1491, 24, 61, 435, 10791, 435, 366, 59, 24, 26, 713, 61, 435, 10791, 435, 366, 59, 713, 26, 975, 61, 435, 10791, 435, 366, 59, 975, 26, 1165, 61, 881, 435, 10791, 435, 366, 59, 1165, 26, 708, 61, 435, 283, 12216, 523, 372, 15593, 199, 199, 20974, 421, 199, 533, 13828, 7850, 26, 523, 408, 7850, 315, 282, 14702, 13225, 2199, 503, 8744, 1041, 819, 347, 636, 826, 721, 277, 12, 931, 12, 536, 275, 488, 12, 4811, 275, 488, 12, 2049, 15593, 275, 488, 12, 2974, 275, 488, 304, 272, 408, 23489, 314, 4922, 14, 339, 3033, 26, 489, 931, 26, 16579, 931, 370, 314, 4922, 14, 489, 536, 26, 2812, 402, 314, 4922, 14, 489, 4811, 26, 3820, 402, 4922, 4811, 370, 10715, 6272, 642, 4922, 14, 221, 10162, 1395, 881, 29121, 503, 7290, 2251, 14, 221, 10162, 506, 488, 12, 340, 314, 4922, 365, 2701, 14, 489, 15593, 26, 21645, 370, 675, 367, 4922, 12, 340, 440, 488, 14, 489, 2974, 26, 3820, 402, 8744, 2974, 370, 2387, 315, 314, 4922, 2199, 14, 221, 10162, 506, 881, 488, 12, 340, 314, 4922, 1630, 440, 5370, 1395, 2974, 14, 272, 408, 272, 340, 536, 26, 489, 291, 14, 354, 275, 536, 272, 587, 26, 489, 327, 3645, 2061, 4045, 14, 489, 291, 14, 354, 275, 747, 14, 515, 14, 4846, 8, 515, 9, 339, 291, 14, 515, 275, 931, 272, 291, 14, 9473, 275, 15593, 339, 327, 11247, 3032, 5548, 334, 269, 663, 370, 2701, 5548, 9, 272, 291, 14, 3189, 275, 769, 8, 3189, 503, 3073, 272, 291, 14, 1744, 275, 769, 8, 1744, 503, 3073, 339, 291, 14, 2373, 63, 466, 63, 9473, 275, 5070, 21177, 63, 2711, 63, 17856, 51, 459, 3741, 418, 819, 347, 664, 63, 9473, 8, 277, 304, 272, 340, 291, 14, 9473, 365, 488, 26, 489, 327, 3645, 12137, 15593, 83, 367, 16533, 334, 1152, 7645, 2793, 1133, 30943, 680, 489, 291, 14, 9473, 275, 4155, 18834, 8, 277, 14, 515, 12, 6347, 534, 8338, 63, 3741, 358, 272, 372, 291, 14, 9473, 421, 199, 20974, 421, 199, 533, 13828, 4761, 26, 523, 408, 15039, 13225, 2199, 1041, 819, 347, 636, 826, 721, 277, 12, 931, 12, 536, 275, 488, 12, 5124, 275, 488, 12, 15593, 275, 488, 12, 2049, 1101, 63, 3246, 63, 12867, 275, 488, 304, 272, 408, 23489, 314, 2199, 14, 339, 3033, 26, 489, 931, 26, 22419, 931, 370, 2199, 570, 14, 489, 536, 26, 2812, 402, 2199, 14, 221, 982, 488, 12, 314, 536, 911, 506, 314, 2011, 465, 314, 1300, 881, 536, 402, 314, 2199, 570, 14, 489, 5124, 26, 3820, 402, 1163, 7290, 2251, 642, 2199, 365, 11410, 881, 12188, 12, 340, 440, 488, 14, 489, 15593, 26, 21645, 370, 675, 367, 2199, 12, 340, 440, 488, 14, 489, 1101, 63, 3246, 63, 12867, 26, 2716, 1211, 402, 2897, 10677, 370, 881, 1202, 315, 4192, 402, 314, 849, 367, 642, 1347, 14, 272, 408, 272, 291, 14, 515, 275, 931, 272, 291, 14, 9473, 275, 15593, 339, 340, 536, 26, 489, 291, 14, 354, 275, 536, 272, 587, 26, 489, 327, 3645, 2199, 1788, 489, 291, 14, 354, 275, 747, 14, 515, 14, 7973, 8, 736, 14, 515, 14, 4846, 8, 515, 11515, 16, 61, 339, 327, 11247, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
FlaPer87/django-nonrel
django/contrib/sessions/tests.py
27
9749
r""" >>> from django.conf import settings >>> from django.contrib.sessions.backends.db import SessionStore as DatabaseSession >>> from django.contrib.sessions.backends.cache import SessionStore as CacheSession >>> from django.contrib.sessions.backends.cached_db import SessionStore as CacheDBSession >>> from django.contrib.sessions.backends.file import SessionStore as FileSession >>> from django.contrib.sessions.backends.base import SessionBase >>> from django.contrib.sessions.models import Session >>> db_session = DatabaseSession() >>> db_session.modified False >>> db_session.get('cat') >>> db_session['cat'] = "dog" >>> db_session.modified True >>> db_session.pop('cat') 'dog' >>> db_session.pop('some key', 'does not exist') 'does not exist' >>> db_session.save() >>> db_session.exists(db_session.session_key) True >>> db_session.delete(db_session.session_key) >>> db_session.exists(db_session.session_key) False >>> db_session['foo'] = 'bar' >>> db_session.save() >>> db_session.exists(db_session.session_key) True >>> prev_key = db_session.session_key >>> db_session.flush() >>> db_session.exists(prev_key) False >>> db_session.session_key == prev_key False >>> db_session.modified, db_session.accessed (True, True) >>> db_session['a'], db_session['b'] = 'c', 'd' >>> db_session.save() >>> prev_key = db_session.session_key >>> prev_data = db_session.items() >>> db_session.cycle_key() >>> db_session.session_key == prev_key False >>> db_session.items() == prev_data True # Submitting an invalid session key (either by guessing, or if the db has # removed the key) results in a new key being generated. >>> Session.objects.filter(pk=db_session.session_key).delete() >>> db_session = DatabaseSession(db_session.session_key) >>> db_session.save() >>> DatabaseSession('1').get('cat') # # Cached DB session tests # >>> cdb_session = CacheDBSession() >>> cdb_session.modified False >>> cdb_session['cat'] = "dog" >>> cdb_session.modified True >>> cdb_session.pop('cat') 'dog' >>> cdb_session.pop('some key', 'does not exist') 'does not exist' >>> cdb_session.save() >>> cdb_session.exists(cdb_session.session_key) True >>> cdb_session.delete(cdb_session.session_key) >>> cdb_session.exists(cdb_session.session_key) False # # File session tests. # # Do file session tests in an isolated directory, and kill it after we're done. >>> original_session_file_path = settings.SESSION_FILE_PATH >>> import tempfile >>> temp_session_store = settings.SESSION_FILE_PATH = tempfile.mkdtemp() >>> file_session = FileSession() >>> file_session.modified False >>> file_session['cat'] = "dog" >>> file_session.modified True >>> file_session.pop('cat') 'dog' >>> file_session.pop('some key', 'does not exist') 'does not exist' >>> file_session.save() >>> file_session.exists(file_session.session_key) True >>> file_session.delete(file_session.session_key) >>> file_session.exists(file_session.session_key) False >>> FileSession('1').get('cat') >>> file_session['foo'] = 'bar' >>> file_session.save() >>> file_session.exists(file_session.session_key) True >>> prev_key = file_session.session_key >>> file_session.flush() >>> file_session.exists(prev_key) False >>> file_session.session_key == prev_key False >>> file_session.modified, file_session.accessed (True, True) >>> file_session['a'], file_session['b'] = 'c', 'd' >>> file_session.save() >>> prev_key = file_session.session_key >>> prev_data = file_session.items() >>> file_session.cycle_key() >>> file_session.session_key == prev_key False >>> file_session.items() == prev_data True >>> Session.objects.filter(pk=file_session.session_key).delete() >>> file_session = FileSession(file_session.session_key) >>> file_session.save() # Make sure the file backend checks for a good storage dir >>> settings.SESSION_FILE_PATH = "/if/this/directory/exists/you/have/a/weird/computer" >>> FileSession() Traceback (innermost last): ... ImproperlyConfigured: The session storage path '/if/this/directory/exists/you/have/a/weird/computer' doesn't exist. Please set your SESSION_FILE_PATH setting to an existing directory in which Django can store session data. # Clean up after the file tests >>> settings.SESSION_FILE_PATH = original_session_file_path >>> import shutil >>> shutil.rmtree(temp_session_store) # # Cache-based tests # NB: be careful to delete any sessions created; stale sessions fill up the # /tmp and eventually overwhelm it after lots of runs (think buildbots) # >>> cache_session = CacheSession() >>> cache_session.modified False >>> cache_session['cat'] = "dog" >>> cache_session.modified True >>> cache_session.pop('cat') 'dog' >>> cache_session.pop('some key', 'does not exist') 'does not exist' >>> cache_session.save() >>> cache_session.delete(cache_session.session_key) >>> cache_session.exists(cache_session.session_key) False >>> cache_session['foo'] = 'bar' >>> cache_session.save() >>> cache_session.exists(cache_session.session_key) True >>> prev_key = cache_session.session_key >>> cache_session.flush() >>> cache_session.exists(prev_key) False >>> cache_session.session_key == prev_key False >>> cache_session.modified, cache_session.accessed (True, True) >>> cache_session['a'], cache_session['b'] = 'c', 'd' >>> cache_session.save() >>> prev_key = cache_session.session_key >>> prev_data = cache_session.items() >>> cache_session.cycle_key() >>> cache_session.session_key == prev_key False >>> cache_session.items() == prev_data True >>> cache_session = CacheSession() >>> cache_session.save() >>> key = cache_session.session_key >>> cache_session.exists(key) True >>> Session.objects.filter(pk=cache_session.session_key).delete() >>> cache_session = CacheSession(cache_session.session_key) >>> cache_session.save() >>> cache_session.delete(cache_session.session_key) >>> s = SessionBase() >>> s._session['some key'] = 'exists' # Pre-populate the session with some data >>> s.accessed = False # Reset to pretend this wasn't accessed previously >>> s.accessed, s.modified (False, False) >>> s.pop('non existant key', 'does not exist') 'does not exist' >>> s.accessed, s.modified (True, False) >>> s.setdefault('foo', 'bar') 'bar' >>> s.setdefault('foo', 'baz') 'bar' >>> s.accessed = False # Reset the accessed flag >>> s.pop('some key') 'exists' >>> s.accessed, s.modified (True, True) >>> s.pop('some key', 'does not exist') 'does not exist' >>> s.get('update key', None) # test .update() >>> s.modified = s.accessed = False # Reset to pretend this wasn't accessed previously >>> s.update({'update key':1}) >>> s.accessed, s.modified (True, True) >>> s.get('update key', None) 1 # test .has_key() >>> s.modified = s.accessed = False # Reset to pretend this wasn't accessed previously >>> s.has_key('update key') True >>> s.accessed, s.modified (True, False) # test .values() >>> s = SessionBase() >>> s.values() [] >>> s.accessed True >>> s['x'] = 1 >>> s.values() [1] # test .iterkeys() >>> s.accessed = False >>> i = s.iterkeys() >>> hasattr(i,'__iter__') True >>> s.accessed True >>> list(i) ['x'] # test .itervalues() >>> s.accessed = False >>> i = s.itervalues() >>> hasattr(i,'__iter__') True >>> s.accessed True >>> list(i) [1] # test .iteritems() >>> s.accessed = False >>> i = s.iteritems() >>> hasattr(i,'__iter__') True >>> s.accessed True >>> list(i) [('x', 1)] # test .clear() >>> s.modified = s.accessed = False >>> s.items() [('x', 1)] >>> s.clear() >>> s.items() [] >>> s.accessed, s.modified (True, True) ######################### # Custom session expiry # ######################### >>> from django.conf import settings >>> from datetime import datetime, timedelta >>> td10 = timedelta(seconds=10) # A normal session has a max age equal to settings >>> s.get_expiry_age() == settings.SESSION_COOKIE_AGE True # So does a custom session with an idle expiration time of 0 (but it'll expire # at browser close) >>> s.set_expiry(0) >>> s.get_expiry_age() == settings.SESSION_COOKIE_AGE True # Custom session idle expiration time >>> s.set_expiry(10) >>> delta = s.get_expiry_date() - datetime.now() >>> delta.seconds in (9, 10) True >>> age = s.get_expiry_age() >>> age in (9, 10) True # Custom session fixed expiry date (timedelta) >>> s.set_expiry(td10) >>> delta = s.get_expiry_date() - datetime.now() >>> delta.seconds in (9, 10) True >>> age = s.get_expiry_age() >>> age in (9, 10) True # Custom session fixed expiry date (fixed datetime) >>> s.set_expiry(datetime.now() + td10) >>> delta = s.get_expiry_date() - datetime.now() >>> delta.seconds in (9, 10) True >>> age = s.get_expiry_age() >>> age in (9, 10) True # Set back to default session age >>> s.set_expiry(None) >>> s.get_expiry_age() == settings.SESSION_COOKIE_AGE True # Allow to set back to default session age even if no alternate has been set >>> s.set_expiry(None) # We're changing the setting then reverting back to the original setting at the # end of these tests. >>> original_expire_at_browser_close = settings.SESSION_EXPIRE_AT_BROWSER_CLOSE >>> settings.SESSION_EXPIRE_AT_BROWSER_CLOSE = False # Custom session age >>> s.set_expiry(10) >>> s.get_expire_at_browser_close() False # Custom expire-at-browser-close >>> s.set_expiry(0) >>> s.get_expire_at_browser_close() True # Default session age >>> s.set_expiry(None) >>> s.get_expire_at_browser_close() False >>> settings.SESSION_EXPIRE_AT_BROWSER_CLOSE = True # Custom session age >>> s.set_expiry(10) >>> s.get_expire_at_browser_close() False # Custom expire-at-browser-close >>> s.set_expiry(0) >>> s.get_expire_at_browser_close() True # Default session age >>> s.set_expiry(None) >>> s.get_expire_at_browser_close() True >>> settings.SESSION_EXPIRE_AT_BROWSER_CLOSE = original_expire_at_browser_close """ if __name__ == '__main__': import doctest doctest.testmod()
bsd-3-clause
[ 82, 624, 199, 199, 6071, 687, 1639, 14, 2190, 492, 2202, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 697, 492, 8596, 5502, 465, 8692, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1637, 492, 8596, 5502, 465, 11977, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 5245, 63, 697, 492, 8596, 5502, 465, 11977, 2846, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 493, 492, 8596, 5502, 465, 3814, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1095, 492, 8596, 1563, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 992, 492, 8596, 199, 199, 6071, 1592, 63, 1730, 275, 8692, 4434, 342, 199, 6071, 1592, 63, 1730, 14, 5540, 199, 797, 199, 6071, 1592, 63, 1730, 14, 362, 360, 3385, 358, 199, 6071, 1592, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 1592, 63, 1730, 14, 5540, 199, 549, 199, 6071, 1592, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 1592, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 1592, 63, 1730, 14, 1807, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 199, 6071, 1592, 63, 1730, 459, 1421, 418, 275, 283, 1700, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 5071, 63, 498, 275, 1592, 63, 1730, 14, 1730, 63, 498, 199, 6071, 1592, 63, 1730, 14, 4939, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 5701, 63, 498, 9, 199, 797, 199, 6071, 1592, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 1592, 63, 1730, 14, 5540, 12, 1592, 63, 1730, 14, 29433, 199, 8, 549, 12, 715, 9, 199, 6071, 1592, 63, 1730, 459, 65, 995, 1592, 63, 1730, 459, 66, 418, 275, 283, 67, 297, 283, 68, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 5071, 63, 498, 275, 1592, 63, 1730, 14, 1730, 63, 498, 199, 6071, 5071, 63, 576, 275, 1592, 63, 1730, 14, 1744, 342, 199, 6071, 1592, 63, 1730, 14, 7612, 63, 498, 342, 199, 6071, 1592, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 1592, 63, 1730, 14, 1744, 342, 508, 5071, 63, 576, 199, 549, 199, 199, 3, 28295, 1337, 376, 3866, 2351, 790, 334, 22051, 701, 9519, 316, 12, 503, 340, 314, 1592, 965, 199, 3, 4829, 314, 790, 9, 2058, 315, 282, 892, 790, 3769, 4046, 14, 199, 6071, 8596, 14, 1462, 14, 1541, 8, 2051, 29, 697, 63, 1730, 14, 1730, 63, 498, 680, 1807, 342, 199, 6071, 1592, 63, 1730, 275, 8692, 4434, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 8692, 4434, 360, 17, 1959, 362, 360, 3385, 358, 199, 199, 3, 199, 3, 445, 4583, 6249, 2351, 2295, 199, 3, 199, 199, 6071, 286, 697, 63, 1730, 275, 11977, 2846, 4434, 342, 199, 6071, 286, 697, 63, 1730, 14, 5540, 199, 797, 199, 6071, 286, 697, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 286, 697, 63, 1730, 14, 5540, 199, 549, 199, 6071, 286, 697, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 286, 697, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 286, 697, 63, 1730, 14, 2117, 342, 199, 6071, 286, 697, 63, 1730, 14, 2444, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 286, 697, 63, 1730, 14, 1807, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 286, 697, 63, 1730, 14, 2444, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 199, 3, 199, 3, 3814, 2351, 2295, 14, 199, 3, 199, 199, 3, 4226, 570, 2351, 2295, 315, 376, 23348, 2082, 12, 436, 14561, 652, 2410, 781, 3984, 4224, 14, 199, 6071, 3379, 63, 1730, 63, 493, 63, 515, 275, 2202, 14, 12763, 63, 3817, 63, 3243, 199, 6071, 492, 5549, 199, 6071, 2388, 63, 1730, 63, 1617, 275, 2202, 14, 12763, 63, 3817, 63, 3243, 275, 5549, 14, 11983, 342, 199, 199, 6071, 570, 63, 1730, 275, 3814, 4434, 342, 199, 6071, 570, 63, 1730, 14, 5540, 199, 797, 199, 6071, 570, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 570, 63, 1730, 14, 5540, 199, 549, 199, 6071, 570, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 570, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 570, 63, 1730, 14, 2117, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 570, 63, 1730, 14, 1807, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 6071, 3814, 4434, 360, 17, 1959, 362, 360, 3385, 358, 199, 199, 6071, 570, 63, 1730, 459, 1421, 418, 275, 283, 1700, 7, 199, 6071, 570, 63, 1730, 14, 2117, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 5071, 63, 498, 275, 570, 63, 1730, 14, 1730, 63, 498, 199, 6071, 570, 63, 1730, 14, 4939, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 5701, 63, 498, 9, 199, 797, 199, 6071, 570, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 570, 63 ]
[ 624, 199, 199, 6071, 687, 1639, 14, 2190, 492, 2202, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 697, 492, 8596, 5502, 465, 8692, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1637, 492, 8596, 5502, 465, 11977, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 5245, 63, 697, 492, 8596, 5502, 465, 11977, 2846, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 493, 492, 8596, 5502, 465, 3814, 4434, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1095, 492, 8596, 1563, 199, 6071, 687, 1639, 14, 2828, 14, 11676, 14, 992, 492, 8596, 199, 199, 6071, 1592, 63, 1730, 275, 8692, 4434, 342, 199, 6071, 1592, 63, 1730, 14, 5540, 199, 797, 199, 6071, 1592, 63, 1730, 14, 362, 360, 3385, 358, 199, 6071, 1592, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 1592, 63, 1730, 14, 5540, 199, 549, 199, 6071, 1592, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 1592, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 1592, 63, 1730, 14, 1807, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 199, 6071, 1592, 63, 1730, 459, 1421, 418, 275, 283, 1700, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 5071, 63, 498, 275, 1592, 63, 1730, 14, 1730, 63, 498, 199, 6071, 1592, 63, 1730, 14, 4939, 342, 199, 6071, 1592, 63, 1730, 14, 2444, 8, 5701, 63, 498, 9, 199, 797, 199, 6071, 1592, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 1592, 63, 1730, 14, 5540, 12, 1592, 63, 1730, 14, 29433, 199, 8, 549, 12, 715, 9, 199, 6071, 1592, 63, 1730, 459, 65, 995, 1592, 63, 1730, 459, 66, 418, 275, 283, 67, 297, 283, 68, 7, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 5071, 63, 498, 275, 1592, 63, 1730, 14, 1730, 63, 498, 199, 6071, 5071, 63, 576, 275, 1592, 63, 1730, 14, 1744, 342, 199, 6071, 1592, 63, 1730, 14, 7612, 63, 498, 342, 199, 6071, 1592, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 1592, 63, 1730, 14, 1744, 342, 508, 5071, 63, 576, 199, 549, 199, 199, 3, 28295, 1337, 376, 3866, 2351, 790, 334, 22051, 701, 9519, 316, 12, 503, 340, 314, 1592, 965, 199, 3, 4829, 314, 790, 9, 2058, 315, 282, 892, 790, 3769, 4046, 14, 199, 6071, 8596, 14, 1462, 14, 1541, 8, 2051, 29, 697, 63, 1730, 14, 1730, 63, 498, 680, 1807, 342, 199, 6071, 1592, 63, 1730, 275, 8692, 4434, 8, 697, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 1592, 63, 1730, 14, 2117, 342, 199, 6071, 8692, 4434, 360, 17, 1959, 362, 360, 3385, 358, 199, 199, 3, 199, 3, 445, 4583, 6249, 2351, 2295, 199, 3, 199, 199, 6071, 286, 697, 63, 1730, 275, 11977, 2846, 4434, 342, 199, 6071, 286, 697, 63, 1730, 14, 5540, 199, 797, 199, 6071, 286, 697, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 286, 697, 63, 1730, 14, 5540, 199, 549, 199, 6071, 286, 697, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 286, 697, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 286, 697, 63, 1730, 14, 2117, 342, 199, 6071, 286, 697, 63, 1730, 14, 2444, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 286, 697, 63, 1730, 14, 1807, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 286, 697, 63, 1730, 14, 2444, 8, 24035, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 199, 3, 199, 3, 3814, 2351, 2295, 14, 199, 3, 199, 199, 3, 4226, 570, 2351, 2295, 315, 376, 23348, 2082, 12, 436, 14561, 652, 2410, 781, 3984, 4224, 14, 199, 6071, 3379, 63, 1730, 63, 493, 63, 515, 275, 2202, 14, 12763, 63, 3817, 63, 3243, 199, 6071, 492, 5549, 199, 6071, 2388, 63, 1730, 63, 1617, 275, 2202, 14, 12763, 63, 3817, 63, 3243, 275, 5549, 14, 11983, 342, 199, 199, 6071, 570, 63, 1730, 275, 3814, 4434, 342, 199, 6071, 570, 63, 1730, 14, 5540, 199, 797, 199, 6071, 570, 63, 1730, 459, 3385, 418, 275, 298, 13889, 2, 199, 6071, 570, 63, 1730, 14, 5540, 199, 549, 199, 6071, 570, 63, 1730, 14, 1935, 360, 3385, 358, 199, 5121, 974, 7, 199, 6071, 570, 63, 1730, 14, 1935, 360, 3972, 790, 297, 283, 9105, 440, 2187, 358, 199, 5121, 79, 397, 440, 2187, 7, 199, 6071, 570, 63, 1730, 14, 2117, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 570, 63, 1730, 14, 1807, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 797, 199, 6071, 3814, 4434, 360, 17, 1959, 362, 360, 3385, 358, 199, 199, 6071, 570, 63, 1730, 459, 1421, 418, 275, 283, 1700, 7, 199, 6071, 570, 63, 1730, 14, 2117, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 493, 63, 1730, 14, 1730, 63, 498, 9, 199, 549, 199, 6071, 5071, 63, 498, 275, 570, 63, 1730, 14, 1730, 63, 498, 199, 6071, 570, 63, 1730, 14, 4939, 342, 199, 6071, 570, 63, 1730, 14, 2444, 8, 5701, 63, 498, 9, 199, 797, 199, 6071, 570, 63, 1730, 14, 1730, 63, 498, 508, 5071, 63, 498, 199, 797, 199, 6071, 570, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
laonawuli/addrest
web2py/gluon/contrib/login_methods/oneall_account.py
33
4559
#!/usr/bin/env python # coding: utf8 """ Oneall Authentication for web2py Developed by Nathan Freeze (Copyright © 2013) Email <nathan@freezable.com> This file contains code to allow using onall.com authentication services with web2py """ import os import base64 from gluon import * from gluon.storage import Storage from gluon.contrib.simplejson import JSONDecodeError from gluon.tools import fetch import gluon.contrib.simplejson as json class OneallAccount(object): """ from gluon.contrib.login_methods.oneall_account import OneallAccount auth.settings.actions_disabled=['register','change_password', 'request_reset_password'] auth.settings.login_form = OneallAccount(request, public_key="...", private_key="...", domain="...", url = "http://localhost:8000/%s/default/user/login" % request.application) """ def __init__(self, request, public_key="", private_key="", domain="", url=None, providers=None, on_login_failure=None): self.request = request self.public_key = public_key self.private_key = private_key self.url = url self.domain = domain self.profile = None self.on_login_failure = on_login_failure self.providers = providers or ["facebook", "google", "yahoo", "openid"] self.mappings = Storage() def defaultmapping(profile): name = profile.get('name',{}) dname = name.get('formatted',profile.get('displayName')) email=profile.get('emails', [{}])[0].get('value') reg_id=profile.get('identity_token','') username=profile.get('preferredUsername',email) first_name=name.get('givenName', dname.split(' ')[0]) last_name=profile.get('familyName',dname.split(' ')[1]) return dict(registration_id=reg_id,username=username,email=email, first_name=first_name,last_name=last_name) self.mappings.default = defaultmapping def get_user(self): request = self.request user = None if request.vars.connection_token: auth_url = "https://%s.api.oneall.com/connections/%s.json" % \ (self.domain, request.vars.connection_token) auth_pw = "%s:%s" % (self.public_key,self.private_key) auth_pw = base64.b64encode(auth_pw) headers = dict(Authorization="Basic %s" % auth_pw) try: auth_info_json = fetch(auth_url,headers=headers) auth_info = json.loads(auth_info_json) data = auth_info['response']['result']['data'] if data['plugin']['key'] == 'social_login': if data['plugin']['data']['status'] == 'success': userdata = data['user'] self.profile = userdata['identity'] source = self.profile['source']['key'] mapping = self.mappings.get(source,self.mappings['default']) user = mapping(self.profile) except (JSONDecodeError, KeyError): pass if user is None and self.on_login_failure: redirect(self.on_login_failure) return user def login_form(self): scheme = self.request.env.wsgi_url_scheme oneall_url = scheme + "://%s.api.oneall.com/socialize/library.js" % self.domain oneall_lib = SCRIPT(_src=oneall_url,_type='text/javascript') container = DIV(_id="oa_social_login_container") widget = SCRIPT('oneall.api.plugins.social_login.build("oa_social_login_container",', '{providers : %s,' % self.providers, 'callback_uri: "%s"});' % self.url, _type="text/javascript") form = DIV(oneall_lib,container,widget) return form def use_oneall(auth, filename='private/oneall.key', **kwargs): path = os.path.join(current.request.folder, filename) if os.path.exists(path): request = current.request domain, public_key, private_key = open(path, 'r').read().strip().split(':') url = URL('default', 'user', args='login', scheme=True) auth.settings.actions_disabled =\ ['register', 'change_password', 'request_reset_password'] auth.settings.login_form = OneallAccount( request, public_key=public_key,private_key=private_key, domain=domain, url=url, **kwargs)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 26, 2774, 24, 199, 199, 624, 2043, 7309, 452, 15995, 367, 3330, 18, 647, 2043, 1487, 27813, 701, 653, 1619, 290, 2868, 806, 334, 7384, 22405, 103, 6171, 9, 2043, 11426, 665, 78, 1619, 290, 32, 4624, 90, 461, 14, 957, 30, 8410, 961, 570, 3509, 1233, 370, 2040, 1808, 641, 452, 14, 957, 2043, 6299, 8500, 543, 3330, 18, 647, 199, 624, 199, 199, 646, 747, 199, 646, 1300, 772, 199, 504, 26752, 492, 627, 199, 504, 26752, 14, 3494, 492, 10533, 199, 504, 26752, 14, 2828, 14, 4129, 1001, 492, 4840, 12620, 199, 504, 26752, 14, 2537, 492, 5267, 199, 646, 26752, 14, 2828, 14, 4129, 1001, 465, 2022, 199, 199, 533, 7309, 452, 6009, 8, 785, 304, 339, 408, 272, 687, 26752, 14, 2828, 14, 2886, 63, 2474, 14, 368, 452, 63, 2048, 492, 7309, 452, 6009, 272, 1790, 14, 1751, 14, 3723, 63, 7011, 2968, 2683, 1673, 1461, 63, 2060, 297, 267, 283, 1069, 63, 3958, 63, 2060, 418, 272, 1790, 14, 1751, 14, 2886, 63, 964, 275, 7309, 452, 6009, 8, 1069, 12, 1598, 4575, 63, 498, 628, 23966, 1598, 5726, 63, 498, 628, 23966, 1598, 2881, 628, 23966, 1598, 1166, 275, 298, 1014, 921, 5967, 26, 15214, 3149, 83, 15, 885, 15, 751, 15, 2886, 2, 450, 1056, 14, 3578, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 4575, 63, 498, 8772, 5726, 63, 498, 8772, 221, 2881, 8772, 2432, 1166, 29, 403, 12, 18032, 29, 403, 12, 641, 63, 2886, 63, 5328, 29, 403, 304, 398, 291, 14, 1069, 275, 1056, 267, 291, 14, 3455, 63, 498, 275, 4575, 63, 498, 267, 291, 14, 4239, 63, 498, 275, 5726, 63, 498, 267, 291, 14, 633, 275, 1166, 267, 291, 14, 2261, 275, 2881, 267, 291, 14, 2913, 275, 488, 267, 291, 14, 265, 63, 2886, 63, 5328, 275, 641, 63, 2886, 63, 5328, 267, 291, 14, 9710, 275, 18032, 503, 2097, 16652, 401, 298, 3098, 401, 298, 27231, 401, 298, 15403, 937, 398, 291, 14, 14632, 275, 10533, 342, 267, 347, 849, 4745, 8, 2913, 304, 288, 536, 275, 4690, 14, 362, 360, 354, 297, 91, 1552, 288, 366, 354, 275, 536, 14, 362, 360, 15317, 297, 2913, 14, 362, 360, 2918, 985, 1333, 288, 3031, 29, 2913, 14, 362, 360, 14170, 297, 359, 2440, 11057, 16, 1055, 362, 360, 585, 358, 288, 1295, 63, 344, 29, 2913, 14, 362, 360, 5582, 63, 1418, 20944, 288, 3434, 29, 2913, 14, 362, 360, 17477, 13355, 297, 2123, 9, 288, 1642, 63, 354, 29, 354, 14, 362, 360, 11809, 985, 297, 366, 354, 14, 1294, 360, 27618, 16, 566, 288, 2061, 63, 354, 29, 2913, 14, 362, 360, 6606, 985, 297, 68, 354, 14, 1294, 360, 27618, 17, 566, 288, 372, 1211, 8, 8054, 63, 344, 29, 1135, 63, 344, 12, 2473, 29, 2473, 12, 2123, 29, 2123, 12, 717, 1642, 63, 354, 29, 2246, 63, 354, 12, 2019, 63, 354, 29, 2019, 63, 354, 9, 267, 291, 14, 14632, 14, 885, 275, 849, 4745, 339, 347, 664, 63, 751, 8, 277, 304, 267, 1056, 275, 291, 14, 1069, 267, 922, 275, 488, 267, 340, 1056, 14, 2936, 14, 2105, 63, 1418, 26, 288, 1790, 63, 633, 275, 298, 2859, 13827, 83, 14, 1246, 14, 368, 452, 14, 957, 15, 7995, 3149, 83, 14, 1001, 2, 221, 450, 971, 2432, 334, 277, 14, 2261, 12, 1056, 14, 2936, 14, 2105, 63, 1418, 9, 288, 1790, 63, 8796, 275, 2071, 83, 2689, 83, 2, 450, 334, 277, 14, 3455, 63, 498, 12, 277, 14, 4239, 63, 498, 9, 288, 1790, 63, 8796, 275, 1300, 772, 14, 66, 772, 2143, 8, 1178, 63, 8796, 9, 288, 2323, 275, 1211, 8, 11626, 628, 6845, 450, 83, 2, 450, 1790, 63, 8796, 9, 288, 862, 26, 355, 1790, 63, 815, 63, 1001, 275, 5267, 8, 1178, 63, 633, 12, 2139, 29, 2139, 9, 355, 1790, 63, 815, 275, 2022, 14, 3640, 8, 1178, 63, 815, 63, 1001, 9, 355, 666, 275, 1790, 63, 815, 459, 1310, 2545, 1099, 2545, 576, 418, 355, 340, 666, 459, 2718, 2545, 498, 418, 508, 283, 13574, 63, 2886, 356, 490, 340, 666, 459, 2718, 2545, 576, 2545, 1205, 418, 508, 283, 3742, 356, 717, 922, 576, 275, 666, 459, 751, 418, 717, 291, 14, 2913, 275, 922, 576, 459, 5582, 418, 717, 1350, 275, 291, 14, 2913, 459, 1365, 2545, 498, 418, 717, 4412, 275, 291, 14, 14632, 14, 362, 8, 1365, 12, 277, 14, 14632, 459, 885, 1105, 717, 922, 275, 4412, 8, 277, 14, 2913, 9, 288, 871, 334, 6243, 12620, 12, 4067, 304, 355, 986, 288, 340, 922, 365, 488, 436, 291, 14, 265, 63, 2886, 63, 5328, 26, 490, 4660, 8, 277, 14, 265, 63, 2886, 63, 5328, 9, 267, 372, 922, 339, 347, 4676, 63, 964, 8, 277, 304, 267, 5687, 275, 291, 14, 1069, 14, 1813, 14, 6508, 63, 633, 63, 5512, 267, 1373, 452, 63, 633, 275, 5687, 435, 298, 13827, 83, 14, 1246, 14, 368, 452, 14, 957, 15, 13574, 794, 15, 4342, 14, 3596, 2, 221, 450, 291, 14, 2261, 267, 1373, 452, 63, 773, 275, 30203, 1547, 2164, 29, 368, 452, 63, 633, 16987, 466, 534, 505, 15, 9554, 358, 267, 3970, 275, 5266, 54, 1547, 344, 628, 20047, 63, 13574, 63, 2886, 63, 3600, 531, 267, 3938, 275, 30203, 360, 368, 452, 14, 1246, 14, 5265, 14, 13574, 63, 2886, 14, 1506, 480, 20047, 63, 13574, 63, 2886, 63, 3600, 401, 297, 717, 5041, 9710, 520, 450, 83, 2584, 450, 291, 14, 9710, 12, 717, 283, 3058, 63, 2302, 26, 2071, 83, 5984, 8942, 450, 291, 14, 633, 12, 355, 485, 466, 628, 505, 15, 9554, 531, 267, 1824, 275, 5266, 54, 8, 368, 452, 63, 773, 12, 3600, 12, 3440, 9, 267, 372, 1824, 199, 199, 318, 675, 63, 368, 452, 8, 1178, 12, 1788, 534, 4239, 15, 368, 452, 14, 498, 297, 1011, 958, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 1818, 14, 1069, 14, 3741, 12, 1788, 9, 272, 340, 747, 14, 515, 14, 2444, 8 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 26, 2774, 24, 199, 199, 624, 2043, 7309, 452, 15995, 367, 3330, 18, 647, 2043, 1487, 27813, 701, 653, 1619, 290, 2868, 806, 334, 7384, 22405, 103, 6171, 9, 2043, 11426, 665, 78, 1619, 290, 32, 4624, 90, 461, 14, 957, 30, 8410, 961, 570, 3509, 1233, 370, 2040, 1808, 641, 452, 14, 957, 2043, 6299, 8500, 543, 3330, 18, 647, 199, 624, 199, 199, 646, 747, 199, 646, 1300, 772, 199, 504, 26752, 492, 627, 199, 504, 26752, 14, 3494, 492, 10533, 199, 504, 26752, 14, 2828, 14, 4129, 1001, 492, 4840, 12620, 199, 504, 26752, 14, 2537, 492, 5267, 199, 646, 26752, 14, 2828, 14, 4129, 1001, 465, 2022, 199, 199, 533, 7309, 452, 6009, 8, 785, 304, 339, 408, 272, 687, 26752, 14, 2828, 14, 2886, 63, 2474, 14, 368, 452, 63, 2048, 492, 7309, 452, 6009, 272, 1790, 14, 1751, 14, 3723, 63, 7011, 2968, 2683, 1673, 1461, 63, 2060, 297, 267, 283, 1069, 63, 3958, 63, 2060, 418, 272, 1790, 14, 1751, 14, 2886, 63, 964, 275, 7309, 452, 6009, 8, 1069, 12, 1598, 4575, 63, 498, 628, 23966, 1598, 5726, 63, 498, 628, 23966, 1598, 2881, 628, 23966, 1598, 1166, 275, 298, 1014, 921, 5967, 26, 15214, 3149, 83, 15, 885, 15, 751, 15, 2886, 2, 450, 1056, 14, 3578, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 4575, 63, 498, 8772, 5726, 63, 498, 8772, 221, 2881, 8772, 2432, 1166, 29, 403, 12, 18032, 29, 403, 12, 641, 63, 2886, 63, 5328, 29, 403, 304, 398, 291, 14, 1069, 275, 1056, 267, 291, 14, 3455, 63, 498, 275, 4575, 63, 498, 267, 291, 14, 4239, 63, 498, 275, 5726, 63, 498, 267, 291, 14, 633, 275, 1166, 267, 291, 14, 2261, 275, 2881, 267, 291, 14, 2913, 275, 488, 267, 291, 14, 265, 63, 2886, 63, 5328, 275, 641, 63, 2886, 63, 5328, 267, 291, 14, 9710, 275, 18032, 503, 2097, 16652, 401, 298, 3098, 401, 298, 27231, 401, 298, 15403, 937, 398, 291, 14, 14632, 275, 10533, 342, 267, 347, 849, 4745, 8, 2913, 304, 288, 536, 275, 4690, 14, 362, 360, 354, 297, 91, 1552, 288, 366, 354, 275, 536, 14, 362, 360, 15317, 297, 2913, 14, 362, 360, 2918, 985, 1333, 288, 3031, 29, 2913, 14, 362, 360, 14170, 297, 359, 2440, 11057, 16, 1055, 362, 360, 585, 358, 288, 1295, 63, 344, 29, 2913, 14, 362, 360, 5582, 63, 1418, 20944, 288, 3434, 29, 2913, 14, 362, 360, 17477, 13355, 297, 2123, 9, 288, 1642, 63, 354, 29, 354, 14, 362, 360, 11809, 985, 297, 366, 354, 14, 1294, 360, 27618, 16, 566, 288, 2061, 63, 354, 29, 2913, 14, 362, 360, 6606, 985, 297, 68, 354, 14, 1294, 360, 27618, 17, 566, 288, 372, 1211, 8, 8054, 63, 344, 29, 1135, 63, 344, 12, 2473, 29, 2473, 12, 2123, 29, 2123, 12, 717, 1642, 63, 354, 29, 2246, 63, 354, 12, 2019, 63, 354, 29, 2019, 63, 354, 9, 267, 291, 14, 14632, 14, 885, 275, 849, 4745, 339, 347, 664, 63, 751, 8, 277, 304, 267, 1056, 275, 291, 14, 1069, 267, 922, 275, 488, 267, 340, 1056, 14, 2936, 14, 2105, 63, 1418, 26, 288, 1790, 63, 633, 275, 298, 2859, 13827, 83, 14, 1246, 14, 368, 452, 14, 957, 15, 7995, 3149, 83, 14, 1001, 2, 221, 450, 971, 2432, 334, 277, 14, 2261, 12, 1056, 14, 2936, 14, 2105, 63, 1418, 9, 288, 1790, 63, 8796, 275, 2071, 83, 2689, 83, 2, 450, 334, 277, 14, 3455, 63, 498, 12, 277, 14, 4239, 63, 498, 9, 288, 1790, 63, 8796, 275, 1300, 772, 14, 66, 772, 2143, 8, 1178, 63, 8796, 9, 288, 2323, 275, 1211, 8, 11626, 628, 6845, 450, 83, 2, 450, 1790, 63, 8796, 9, 288, 862, 26, 355, 1790, 63, 815, 63, 1001, 275, 5267, 8, 1178, 63, 633, 12, 2139, 29, 2139, 9, 355, 1790, 63, 815, 275, 2022, 14, 3640, 8, 1178, 63, 815, 63, 1001, 9, 355, 666, 275, 1790, 63, 815, 459, 1310, 2545, 1099, 2545, 576, 418, 355, 340, 666, 459, 2718, 2545, 498, 418, 508, 283, 13574, 63, 2886, 356, 490, 340, 666, 459, 2718, 2545, 576, 2545, 1205, 418, 508, 283, 3742, 356, 717, 922, 576, 275, 666, 459, 751, 418, 717, 291, 14, 2913, 275, 922, 576, 459, 5582, 418, 717, 1350, 275, 291, 14, 2913, 459, 1365, 2545, 498, 418, 717, 4412, 275, 291, 14, 14632, 14, 362, 8, 1365, 12, 277, 14, 14632, 459, 885, 1105, 717, 922, 275, 4412, 8, 277, 14, 2913, 9, 288, 871, 334, 6243, 12620, 12, 4067, 304, 355, 986, 288, 340, 922, 365, 488, 436, 291, 14, 265, 63, 2886, 63, 5328, 26, 490, 4660, 8, 277, 14, 265, 63, 2886, 63, 5328, 9, 267, 372, 922, 339, 347, 4676, 63, 964, 8, 277, 304, 267, 5687, 275, 291, 14, 1069, 14, 1813, 14, 6508, 63, 633, 63, 5512, 267, 1373, 452, 63, 633, 275, 5687, 435, 298, 13827, 83, 14, 1246, 14, 368, 452, 14, 957, 15, 13574, 794, 15, 4342, 14, 3596, 2, 221, 450, 291, 14, 2261, 267, 1373, 452, 63, 773, 275, 30203, 1547, 2164, 29, 368, 452, 63, 633, 16987, 466, 534, 505, 15, 9554, 358, 267, 3970, 275, 5266, 54, 1547, 344, 628, 20047, 63, 13574, 63, 2886, 63, 3600, 531, 267, 3938, 275, 30203, 360, 368, 452, 14, 1246, 14, 5265, 14, 13574, 63, 2886, 14, 1506, 480, 20047, 63, 13574, 63, 2886, 63, 3600, 401, 297, 717, 5041, 9710, 520, 450, 83, 2584, 450, 291, 14, 9710, 12, 717, 283, 3058, 63, 2302, 26, 2071, 83, 5984, 8942, 450, 291, 14, 633, 12, 355, 485, 466, 628, 505, 15, 9554, 531, 267, 1824, 275, 5266, 54, 8, 368, 452, 63, 773, 12, 3600, 12, 3440, 9, 267, 372, 1824, 199, 199, 318, 675, 63, 368, 452, 8, 1178, 12, 1788, 534, 4239, 15, 368, 452, 14, 498, 297, 1011, 958, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 1818, 14, 1069, 14, 3741, 12, 1788, 9, 272, 340, 747, 14, 515, 14, 2444, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
antivirtel/Flexget
flexget/plugins/urlrewrite_torrentleech.py
6
6852
from __future__ import unicode_literals, division, absolute_import import re import urllib import logging from flexget import plugin from flexget.config_schema import one_or_more from flexget.entry import Entry from flexget.event import event from flexget.plugins.plugin_urlrewriting import UrlRewritingError from flexget.utils import requests from flexget.utils.soup import get_soup from flexget.utils.search import torrent_availability, normalize_unicode log = logging.getLogger('torrentleech') CATEGORIES = { 'all': 0, # Movies 'Cam': 8, 'TS': 9, 'R5': 10, 'DVDRip': 11, 'DVDR': 12, 'HD': 13, 'BDRip': 14, 'Movie Boxsets': 15, 'Documentaries': 29, # TV 'Episodes': 26, 'TV Boxsets': 27, 'Episodes HD': 32 } class UrlRewriteTorrentleech(object): """ Torrentleech urlrewriter and search plugin. torrentleech: rss_key: xxxxxxxxx (required) username: xxxxxxxx (required) password: xxxxxxxx (required) category: HD Category is any combination of: all, Cam, TS, R5, DVDRip, DVDR, HD, BDRip, Movie Boxsets, Documentaries, Episodes, TV BoxSets, Episodes HD """ schema = { 'type': 'object', 'properties': { 'rss_key': {'type': 'string'}, 'username': {'type': 'string'}, 'password': {'type': 'string'}, 'category': one_or_more({ 'oneOf': [ {'type': 'integer'}, {'type': 'string', 'enum': list(CATEGORIES)}, ] }), }, 'required': ['rss_key', 'username', 'password'], 'additionalProperties': False } # urlrewriter API def url_rewritable(self, task, entry): url = entry['url'] if url.endswith('.torrent'): return False if url.startswith('http://torrentleech.org/'): return True return False # urlrewriter API def url_rewrite(self, task, entry): if 'url' not in entry: log.error("Didn't actually get a URL...") else: log.debug("Got the URL: %s" % entry['url']) if entry['url'].startswith('http://torrentleech.org/torrents/browse/index/query/'): # use search results = self.search(task, entry) if not results: raise UrlRewritingError("No search results found") # TODO: Search doesn't enforce close match to title, be more picky entry['url'] = results[0]['url'] @plugin.internet(log) def search(self, task, entry, config=None): """ Search for name from torrentleech. """ rss_key = config['rss_key'] # build the form request: data = {'username': config['username'], 'password': config['password'], 'remember_me': 'on', 'submit': 'submit'} # POST the login form: login = requests.post('https://torrentleech.org/', data=data) if not isinstance(config, dict): config = {} # sort = SORT.get(config.get('sort_by', 'seeds')) # if config.get('sort_reverse'): # sort += 1 categories = config.get('category', 'all') # Make sure categories is a list if not isinstance(categories, list): categories = [categories] # If there are any text categories, turn them into their id number categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories] filter_url = '/categories/%s' % ','.join(str(c) for c in categories) entries = set() for search_string in entry.get('search_strings', [entry['title']]): query = normalize_unicode(search_string).replace(":", "") # urllib.quote will crash if the unicode string has non ascii characters, so encode in utf-8 beforehand url = ('http://torrentleech.org/torrents/browse/index/query/' + urllib.quote(query.encode('utf-8')) + filter_url) log.debug('Using %s as torrentleech search url' % url) page = requests.get(url, cookies=login.cookies).content soup = get_soup(page) for tr in soup.find_all("tr", ["even", "odd"]): # within each even or odd row, find the torrent names link = tr.find("a", attrs={'href': re.compile('/torrent/\d+')}) log.debug('link phase: %s' % link.contents[0]) entry = Entry() # extracts the contents of the <a>titlename/<a> tag entry['title'] = link.contents[0] # find download link torrent_url = tr.find("a", attrs={'href': re.compile('/download/\d+/.*')}).get('href') # parse link and split along /download/12345 and /name.torrent download_url = re.search('(/download/\d+)/(.+\.torrent)', torrent_url) # change link to rss and splice in rss_key torrent_url = 'http://torrentleech.org/rss' + download_url.group(1) + '/' \ + rss_key + '/' + download_url.group(2) log.debug('RSS-ified download link: %s' % torrent_url) entry['url'] = torrent_url # us tr object for seeders/leechers seeders, leechers = tr.find_all('td', ["seeders", "leechers"]) entry['torrent_seeds'] = int(seeders.contents[0]) entry['torrent_leeches'] = int(leechers.contents[0]) entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches']) # use tr object for size size = tr.find("td", text=re.compile('([\.\d]+) ([TGMK]?)B')).contents[0] size = re.search('([\.\d]+) ([TGMK]?)B', size) if size: if size.group(2) == 'T': entry['content_size'] = int(float(size.group(1)) * 1000 ** 4 / 1024 ** 2) elif size.group(2) == 'G': entry['content_size'] = int(float(size.group(1)) * 1000 ** 3 / 1024 ** 2) elif size.group(2) == 'M': entry['content_size'] = int(float(size.group(1)) * 1000 ** 2 / 1024 ** 2) elif size.group(2) == 'K': entry['content_size'] = int(float(size.group(1)) * 1000 / 1024 ** 2) else: entry['content_size'] = int(float(size.group(1)) / 1024 ** 2) entries.add(entry) return sorted(entries, reverse=True, key=lambda x: x.get('search_sort')) @event('plugin.register') def register_plugin(): plugin.register(UrlRewriteTorrentleech, 'torrentleech', groups=['urlrewriter', 'search'], api_ver=2)
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 295, 199, 646, 4011, 199, 646, 2050, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 504, 20758, 362, 14, 2373, 492, 11855, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 5265, 14, 2718, 63, 633, 264, 14827, 492, 20503, 497, 14827, 547, 199, 504, 20758, 362, 14, 1208, 492, 4145, 199, 504, 20758, 362, 14, 1208, 14, 9317, 492, 664, 63, 9317, 199, 504, 20758, 362, 14, 1208, 14, 1733, 492, 17671, 63, 11856, 12, 7666, 63, 2975, 199, 199, 793, 275, 2050, 14, 5572, 360, 14101, 274, 12736, 358, 199, 199, 35, 12649, 28743, 275, 469, 272, 283, 452, 356, 378, 12, 339, 327, 3930, 14484, 272, 283, 30524, 356, 1695, 12, 272, 283, 9730, 356, 1749, 12, 272, 283, 50, 21, 356, 1616, 12, 272, 283, 6741, 4564, 711, 356, 4119, 12, 272, 283, 6741, 4564, 356, 3144, 12, 272, 283, 14903, 356, 4944, 12, 272, 283, 34, 4564, 711, 356, 4329, 12, 272, 283, 19088, 20783, 2193, 356, 4114, 12, 272, 283, 5564, 3433, 356, 7349, 12, 339, 327, 26990, 272, 283, 22887, 83, 356, 7875, 12, 272, 283, 12764, 20783, 2193, 356, 8087, 12, 272, 283, 22887, 83, 869, 36, 356, 4337, 199, 93, 421, 199, 533, 20503, 497, 952, 32004, 274, 12736, 8, 785, 304, 272, 408, 267, 29659, 640, 274, 12736, 1166, 264, 5491, 436, 2754, 3589, 14, 398, 17671, 274, 12736, 26, 881, 32291, 63, 498, 26, 671, 9505, 221, 334, 2427, 9, 881, 3434, 26, 671, 5336, 10013, 221, 334, 2427, 9, 881, 2505, 26, 671, 5336, 10013, 221, 334, 2427, 9, 881, 4637, 26, 869, 36, 8592, 13573, 365, 1263, 14665, 402, 26, 1006, 12, 445, 455, 12, 29642, 12, 820, 21, 12, 881, 577, 54, 4564, 711, 12, 577, 54, 4564, 12, 869, 36, 12, 699, 4564, 711, 12, 31248, 20783, 2193, 12, 7543, 3433, 12, 881, 27255, 6045, 83, 12, 26990, 20783, 9899, 12, 27255, 6045, 83, 869, 36, 272, 408, 339, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 13614, 63, 498, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 2473, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 2060, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 3710, 356, 1373, 63, 269, 63, 6878, 2561, 355, 283, 368, 3466, 356, 359, 490, 791, 466, 356, 283, 4115, 2267, 490, 791, 466, 356, 283, 875, 297, 283, 4869, 356, 769, 8, 35, 12649, 28743, 16658, 355, 1622, 288, 9998, 267, 1660, 267, 283, 2427, 356, 788, 13614, 63, 498, 297, 283, 2473, 297, 283, 2060, 995, 267, 283, 8460, 8516, 356, 756, 272, 789, 339, 327, 1166, 264, 5491, 3261, 272, 347, 1166, 63, 264, 15053, 8, 277, 12, 2120, 12, 2397, 304, 267, 1166, 275, 2397, 459, 633, 418, 267, 340, 1166, 14, 4130, 5175, 14101, 735, 288, 372, 756, 267, 340, 1166, 14, 2460, 360, 1014, 921, 14101, 274, 12736, 14, 1308, 26985, 288, 372, 715, 267, 372, 756, 339, 327, 1166, 264, 5491, 3261, 272, 347, 1166, 63, 14366, 8, 277, 12, 2120, 12, 2397, 304, 267, 340, 283, 633, 7, 440, 315, 2397, 26, 288, 943, 14, 705, 480, 17366, 78, 1133, 5965, 664, 282, 2851, 12594, 267, 587, 26, 288, 943, 14, 1757, 480, 13662, 314, 2851, 26, 450, 83, 2, 450, 2397, 459, 633, 1105, 267, 340, 2397, 459, 633, 2278, 2460, 360, 1014, 921, 14101, 274, 12736, 14, 1308, 15, 14101, 83, 15, 4570, 15, 1080, 15, 1131, 26985, 288, 327, 675, 2754, 288, 2058, 275, 291, 14, 1733, 8, 1765, 12, 2397, 9, 288, 340, 440, 2058, 26, 355, 746, 20503, 497, 14827, 547, 480, 1944, 2754, 2058, 1911, 531, 288, 327, 3254, 26, 8730, 3181, 1133, 15814, 4002, 1336, 370, 2538, 12, 506, 1655, 3732, 89, 288, 2397, 459, 633, 418, 275, 2058, 59, 16, 2733, 633, 418, 339, 768, 2718, 14, 4901, 8, 793, 9, 272, 347, 2754, 8, 277, 12, 2120, 12, 2397, 12, 1101, 29, 403, 304, 267, 408, 267, 8730, 367, 536, 687, 17671, 274, 12736, 14, 267, 408, 267, 32291, 63, 498, 275, 1101, 459, 13614, 63, 498, 418, 398, 327, 1900, 314, 1824, 1056, 26, 267, 666, 275, 791, 2473, 356, 1101, 459, 2473, 995, 283, 2060, 356, 1101, 459, 2060, 995, 283, 264, 1114, 63, 278, 356, 283, 265, 297, 283, 7275, 356, 283, 7275, 936, 267, 327, 8761, 314, 4676, 1824, 26, 267, 4676, 275, 4145, 14, 1932, 360, 2859, 921, 14101, 274, 12736, 14, 1308, 3678, 666, 29, 576, 9, 398, 340, 440, 1228, 8, 888, 12, 1211, 304, 288, 1101, 275, 1052, 267, 327, 4069, 275, 428, 2596, 14, 362, 8, 888, 14, 362, 360, 3191, 63, 991, 297, 283, 5176, 83, 1333, 267, 327, 340, 1101, 14, 362, 360, 3191, 63, 4471, 735, 288, 327, 4069, 847, 413, 267, 9695, 275, 1101, 14, 362, 360, 3710, 297, 283, 452, 358, 267, 327, 4155, 3238, 9695, 365, 282, 769, 267, 340, 440, 1228, 8, 8906, 12, 769, 304, 288, 9695, 275, 359, 8906, 61, 267, 327, 982, 2337, 787, 1263, 1318, 9695, 12, 7485, 3062, 1901, 3932, 1305, 1329, 267, 9695, 275, 359, 67, 340, 1228, 8, 67, 12, 1109, 9, 587, 445, 12649, 28743, 59, 67, 61, 367, 286, 315, 9695, 61, 267, 2457, 63, 633, 275, 1994, 8906, 3149, 83, 7, 450, 12814, 904, 8, 495, 8, 67, 9, 367, 286, 315, 9695, 9, 267, 4811, 275, 663, 342, 267, 367, 2754, 63, 875, 315, 2397, 14, 362, 360, 1733, 63, 5465, 297, 359, 2373, 459, 1213, 418, 4682, 288, 1827, 275, 7666, 63, 2975, 8, 1733, 63, 875, 680, 1814, 480, 6783, 6899, 288, 327, 4011, 14, 3513, 911, 12420, 340, 314, 2649, 1059, 965, 2222, 13294, 4110, 12, 880, 3752, 315, 2774, 13, 24, 2544, 6868, 288, 1166, 275, 661, 1014, 921, 14101, 274, 12736, 14, 1308, 15, 14101, 83, 15, 4570, 15, 1080, 15, 1131, 4805, 435, 673, 4011, 14, 3513 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 295, 199, 646, 4011, 199, 646, 2050, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 504, 20758, 362, 14, 2373, 492, 11855, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 5265, 14, 2718, 63, 633, 264, 14827, 492, 20503, 497, 14827, 547, 199, 504, 20758, 362, 14, 1208, 492, 4145, 199, 504, 20758, 362, 14, 1208, 14, 9317, 492, 664, 63, 9317, 199, 504, 20758, 362, 14, 1208, 14, 1733, 492, 17671, 63, 11856, 12, 7666, 63, 2975, 199, 199, 793, 275, 2050, 14, 5572, 360, 14101, 274, 12736, 358, 199, 199, 35, 12649, 28743, 275, 469, 272, 283, 452, 356, 378, 12, 339, 327, 3930, 14484, 272, 283, 30524, 356, 1695, 12, 272, 283, 9730, 356, 1749, 12, 272, 283, 50, 21, 356, 1616, 12, 272, 283, 6741, 4564, 711, 356, 4119, 12, 272, 283, 6741, 4564, 356, 3144, 12, 272, 283, 14903, 356, 4944, 12, 272, 283, 34, 4564, 711, 356, 4329, 12, 272, 283, 19088, 20783, 2193, 356, 4114, 12, 272, 283, 5564, 3433, 356, 7349, 12, 339, 327, 26990, 272, 283, 22887, 83, 356, 7875, 12, 272, 283, 12764, 20783, 2193, 356, 8087, 12, 272, 283, 22887, 83, 869, 36, 356, 4337, 199, 93, 421, 199, 533, 20503, 497, 952, 32004, 274, 12736, 8, 785, 304, 272, 408, 267, 29659, 640, 274, 12736, 1166, 264, 5491, 436, 2754, 3589, 14, 398, 17671, 274, 12736, 26, 881, 32291, 63, 498, 26, 671, 9505, 221, 334, 2427, 9, 881, 3434, 26, 671, 5336, 10013, 221, 334, 2427, 9, 881, 2505, 26, 671, 5336, 10013, 221, 334, 2427, 9, 881, 4637, 26, 869, 36, 8592, 13573, 365, 1263, 14665, 402, 26, 1006, 12, 445, 455, 12, 29642, 12, 820, 21, 12, 881, 577, 54, 4564, 711, 12, 577, 54, 4564, 12, 869, 36, 12, 699, 4564, 711, 12, 31248, 20783, 2193, 12, 7543, 3433, 12, 881, 27255, 6045, 83, 12, 26990, 20783, 9899, 12, 27255, 6045, 83, 869, 36, 272, 408, 339, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 13614, 63, 498, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 2473, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 2060, 356, 791, 466, 356, 283, 875, 2267, 288, 283, 3710, 356, 1373, 63, 269, 63, 6878, 2561, 355, 283, 368, 3466, 356, 359, 490, 791, 466, 356, 283, 4115, 2267, 490, 791, 466, 356, 283, 875, 297, 283, 4869, 356, 769, 8, 35, 12649, 28743, 16658, 355, 1622, 288, 9998, 267, 1660, 267, 283, 2427, 356, 788, 13614, 63, 498, 297, 283, 2473, 297, 283, 2060, 995, 267, 283, 8460, 8516, 356, 756, 272, 789, 339, 327, 1166, 264, 5491, 3261, 272, 347, 1166, 63, 264, 15053, 8, 277, 12, 2120, 12, 2397, 304, 267, 1166, 275, 2397, 459, 633, 418, 267, 340, 1166, 14, 4130, 5175, 14101, 735, 288, 372, 756, 267, 340, 1166, 14, 2460, 360, 1014, 921, 14101, 274, 12736, 14, 1308, 26985, 288, 372, 715, 267, 372, 756, 339, 327, 1166, 264, 5491, 3261, 272, 347, 1166, 63, 14366, 8, 277, 12, 2120, 12, 2397, 304, 267, 340, 283, 633, 7, 440, 315, 2397, 26, 288, 943, 14, 705, 480, 17366, 78, 1133, 5965, 664, 282, 2851, 12594, 267, 587, 26, 288, 943, 14, 1757, 480, 13662, 314, 2851, 26, 450, 83, 2, 450, 2397, 459, 633, 1105, 267, 340, 2397, 459, 633, 2278, 2460, 360, 1014, 921, 14101, 274, 12736, 14, 1308, 15, 14101, 83, 15, 4570, 15, 1080, 15, 1131, 26985, 288, 327, 675, 2754, 288, 2058, 275, 291, 14, 1733, 8, 1765, 12, 2397, 9, 288, 340, 440, 2058, 26, 355, 746, 20503, 497, 14827, 547, 480, 1944, 2754, 2058, 1911, 531, 288, 327, 3254, 26, 8730, 3181, 1133, 15814, 4002, 1336, 370, 2538, 12, 506, 1655, 3732, 89, 288, 2397, 459, 633, 418, 275, 2058, 59, 16, 2733, 633, 418, 339, 768, 2718, 14, 4901, 8, 793, 9, 272, 347, 2754, 8, 277, 12, 2120, 12, 2397, 12, 1101, 29, 403, 304, 267, 408, 267, 8730, 367, 536, 687, 17671, 274, 12736, 14, 267, 408, 267, 32291, 63, 498, 275, 1101, 459, 13614, 63, 498, 418, 398, 327, 1900, 314, 1824, 1056, 26, 267, 666, 275, 791, 2473, 356, 1101, 459, 2473, 995, 283, 2060, 356, 1101, 459, 2060, 995, 283, 264, 1114, 63, 278, 356, 283, 265, 297, 283, 7275, 356, 283, 7275, 936, 267, 327, 8761, 314, 4676, 1824, 26, 267, 4676, 275, 4145, 14, 1932, 360, 2859, 921, 14101, 274, 12736, 14, 1308, 3678, 666, 29, 576, 9, 398, 340, 440, 1228, 8, 888, 12, 1211, 304, 288, 1101, 275, 1052, 267, 327, 4069, 275, 428, 2596, 14, 362, 8, 888, 14, 362, 360, 3191, 63, 991, 297, 283, 5176, 83, 1333, 267, 327, 340, 1101, 14, 362, 360, 3191, 63, 4471, 735, 288, 327, 4069, 847, 413, 267, 9695, 275, 1101, 14, 362, 360, 3710, 297, 283, 452, 358, 267, 327, 4155, 3238, 9695, 365, 282, 769, 267, 340, 440, 1228, 8, 8906, 12, 769, 304, 288, 9695, 275, 359, 8906, 61, 267, 327, 982, 2337, 787, 1263, 1318, 9695, 12, 7485, 3062, 1901, 3932, 1305, 1329, 267, 9695, 275, 359, 67, 340, 1228, 8, 67, 12, 1109, 9, 587, 445, 12649, 28743, 59, 67, 61, 367, 286, 315, 9695, 61, 267, 2457, 63, 633, 275, 1994, 8906, 3149, 83, 7, 450, 12814, 904, 8, 495, 8, 67, 9, 367, 286, 315, 9695, 9, 267, 4811, 275, 663, 342, 267, 367, 2754, 63, 875, 315, 2397, 14, 362, 360, 1733, 63, 5465, 297, 359, 2373, 459, 1213, 418, 4682, 288, 1827, 275, 7666, 63, 2975, 8, 1733, 63, 875, 680, 1814, 480, 6783, 6899, 288, 327, 4011, 14, 3513, 911, 12420, 340, 314, 2649, 1059, 965, 2222, 13294, 4110, 12, 880, 3752, 315, 2774, 13, 24, 2544, 6868, 288, 1166, 275, 661, 1014, 921, 14101, 274, 12736, 14, 1308, 15, 14101, 83, 15, 4570, 15, 1080, 15, 1131, 4805, 435, 673, 4011, 14, 3513, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TheTypoMaster/chromium-crosswalk
third_party/cython/src/Cython/Compiler/TreeFragment.py
96
8733
# # TreeFragments - parsing of strings to trees # import re from StringIO import StringIO from Scanning import PyrexScanner, StringSourceDescriptor from Symtab import ModuleScope import PyrexTypes from Visitor import VisitorTransform from Nodes import Node, StatListNode from ExprNodes import NameNode import Parsing import Main import UtilNodes """ Support for parsing strings into code trees. """ class StringParseContext(Main.Context): def __init__(self, name, include_directories=None): if include_directories is None: include_directories = [] Main.Context.__init__(self, include_directories, {}, create_testscope=False) self.module_name = name def find_module(self, module_name, relative_to = None, pos = None, need_pxd = 1): if module_name not in (self.module_name, 'cython'): raise AssertionError("Not yet supporting any cimports/includes from string code snippets") return ModuleScope(module_name, parent_module = None, context = self) def parse_from_strings(name, code, pxds={}, level=None, initial_pos=None, context=None, allow_struct_enum_decorator=False): """ Utility method to parse a (unicode) string of code. This is mostly used for internal Cython compiler purposes (creating code snippets that transforms should emit, as well as unit testing). code - a unicode string containing Cython (module-level) code name - a descriptive name for the code source (to use in error messages etc.) RETURNS The tree, i.e. a ModuleNode. The ModuleNode's scope attribute is set to the scope used when parsing. """ if context is None: context = StringParseContext(name) # Since source files carry an encoding, it makes sense in this context # to use a unicode string so that code fragments don't have to bother # with encoding. This means that test code passed in should not have an # encoding header. assert isinstance(code, unicode), "unicode code snippets only please" encoding = "UTF-8" module_name = name if initial_pos is None: initial_pos = (name, 1, 0) code_source = StringSourceDescriptor(name, code) scope = context.find_module(module_name, pos = initial_pos, need_pxd = 0) buf = StringIO(code) scanner = PyrexScanner(buf, code_source, source_encoding = encoding, scope = scope, context = context, initial_pos = initial_pos) ctx = Parsing.Ctx(allow_struct_enum_decorator=allow_struct_enum_decorator) if level is None: tree = Parsing.p_module(scanner, 0, module_name, ctx=ctx) tree.scope = scope tree.is_pxd = False else: tree = Parsing.p_code(scanner, level=level, ctx=ctx) tree.scope = scope return tree class TreeCopier(VisitorTransform): def visit_Node(self, node): if node is None: return node else: c = node.clone_node() self.visitchildren(c) return c class ApplyPositionAndCopy(TreeCopier): def __init__(self, pos): super(ApplyPositionAndCopy, self).__init__() self.pos = pos def visit_Node(self, node): copy = super(ApplyPositionAndCopy, self).visit_Node(node) copy.pos = self.pos return copy class TemplateTransform(VisitorTransform): """ Makes a copy of a template tree while doing substitutions. A dictionary "substitutions" should be passed in when calling the transform; mapping names to replacement nodes. Then replacement happens like this: - If an ExprStatNode contains a single NameNode, whose name is a key in the substitutions dictionary, the ExprStatNode is replaced with a copy of the tree given in the dictionary. It is the responsibility of the caller that the replacement node is a valid statement. - If a single NameNode is otherwise encountered, it is replaced if its name is listed in the substitutions dictionary in the same way. It is the responsibility of the caller to make sure that the replacement nodes is a valid expression. Also a list "temps" should be passed. Any names listed will be transformed into anonymous, temporary names. Currently supported for tempnames is: NameNode (various function and class definition nodes etc. should be added to this) Each replacement node gets the position of the substituted node recursively applied to every member node. """ temp_name_counter = 0 def __call__(self, node, substitutions, temps, pos): self.substitutions = substitutions self.pos = pos tempmap = {} temphandles = [] for temp in temps: TemplateTransform.temp_name_counter += 1 handle = UtilNodes.TempHandle(PyrexTypes.py_object_type) tempmap[temp] = handle temphandles.append(handle) self.tempmap = tempmap result = super(TemplateTransform, self).__call__(node) if temps: result = UtilNodes.TempsBlockNode(self.get_pos(node), temps=temphandles, body=result) return result def get_pos(self, node): if self.pos: return self.pos else: return node.pos def visit_Node(self, node): if node is None: return None else: c = node.clone_node() if self.pos is not None: c.pos = self.pos self.visitchildren(c) return c def try_substitution(self, node, key): sub = self.substitutions.get(key) if sub is not None: pos = self.pos if pos is None: pos = node.pos return ApplyPositionAndCopy(pos)(sub) else: return self.visit_Node(node) # make copy as usual def visit_NameNode(self, node): temphandle = self.tempmap.get(node.name) if temphandle: # Replace name with temporary return temphandle.ref(self.get_pos(node)) else: return self.try_substitution(node, node.name) def visit_ExprStatNode(self, node): # If an expression-as-statement consists of only a replaceable # NameNode, we replace the entire statement, not only the NameNode if isinstance(node.expr, NameNode): return self.try_substitution(node, node.expr.name) else: return self.visit_Node(node) def copy_code_tree(node): return TreeCopier()(node) INDENT_RE = re.compile(ur"^ *") def strip_common_indent(lines): "Strips empty lines and common indentation from the list of strings given in lines" # TODO: Facilitate textwrap.indent instead lines = [x for x in lines if x.strip() != u""] minindent = min([len(INDENT_RE.match(x).group(0)) for x in lines]) lines = [x[minindent:] for x in lines] return lines class TreeFragment(object): def __init__(self, code, name="(tree fragment)", pxds={}, temps=[], pipeline=[], level=None, initial_pos=None): if isinstance(code, unicode): def fmt(x): return u"\n".join(strip_common_indent(x.split(u"\n"))) fmt_code = fmt(code) fmt_pxds = {} for key, value in pxds.iteritems(): fmt_pxds[key] = fmt(value) mod = t = parse_from_strings(name, fmt_code, fmt_pxds, level=level, initial_pos=initial_pos) if level is None: t = t.body # Make sure a StatListNode is at the top if not isinstance(t, StatListNode): t = StatListNode(pos=mod.pos, stats=[t]) for transform in pipeline: if transform is None: continue t = transform(t) self.root = t elif isinstance(code, Node): if pxds != {}: raise NotImplementedError() self.root = code else: raise ValueError("Unrecognized code format (accepts unicode and Node)") self.temps = temps def copy(self): return copy_code_tree(self.root) def substitute(self, nodes={}, temps=[], pos = None): return TemplateTransform()(self.root, substitutions = nodes, temps = self.temps + temps, pos = pos) class SetPosTransform(VisitorTransform): def __init__(self, pos): super(SetPosTransform, self).__init__() self.pos = pos def visit_Node(self, node): node.pos = self.pos self.visitchildren(node) return node
bsd-3-clause
[ 3, 199, 3, 12178, 24552, 1470, 446, 6057, 402, 3326, 370, 14416, 199, 3, 199, 199, 646, 295, 199, 504, 5228, 492, 5228, 199, 504, 13916, 11495, 492, 1611, 15063, 20843, 12, 2624, 2980, 4311, 199, 504, 5515, 2037, 371, 492, 5673, 7812, 199, 646, 27298, 199, 504, 29614, 269, 492, 29614, 269, 6939, 199, 504, 23836, 492, 5013, 12, 27673, 1296, 1716, 199, 504, 28489, 492, 2812, 1716, 199, 646, 28747, 199, 646, 11298, 199, 646, 21248, 6300, 199, 199, 624, 199, 11532, 367, 6057, 3326, 1901, 1233, 14416, 14, 199, 624, 199, 199, 533, 2624, 4003, 2998, 8, 6756, 14, 2998, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2387, 63, 12629, 29, 403, 304, 267, 340, 2387, 63, 12629, 365, 488, 26, 2387, 63, 12629, 275, 942, 267, 11298, 14, 2998, 855, 826, 721, 277, 12, 2387, 63, 12629, 12, 5479, 2892, 1218, 63, 2219, 1859, 29, 797, 9, 267, 291, 14, 578, 63, 354, 275, 536, 339, 347, 2342, 63, 578, 8, 277, 12, 859, 63, 354, 12, 3847, 63, 475, 275, 488, 12, 2086, 275, 488, 12, 1929, 63, 80, 2207, 275, 413, 304, 267, 340, 859, 63, 354, 440, 315, 334, 277, 14, 578, 63, 354, 12, 283, 20747, 735, 288, 746, 9070, 480, 1763, 5966, 21038, 1263, 286, 12775, 15, 9441, 687, 1059, 1233, 19484, 531, 267, 372, 5673, 7812, 8, 578, 63, 354, 12, 1676, 63, 578, 275, 488, 12, 1067, 275, 291, 9, 199, 199, 318, 2198, 63, 504, 63, 5465, 8, 354, 12, 1233, 12, 21162, 795, 10324, 2166, 29, 403, 12, 2536, 63, 1712, 29, 403, 12, 2432, 1067, 29, 403, 12, 2040, 63, 1820, 63, 4869, 63, 11547, 29, 797, 304, 272, 408, 272, 20511, 1083, 370, 2198, 282, 334, 2975, 9, 1059, 402, 1233, 14, 961, 365, 19762, 272, 1202, 367, 5007, 26741, 6365, 12901, 334, 20358, 1233, 19484, 272, 626, 18501, 1077, 8689, 12, 465, 5521, 465, 4137, 5343, 680, 339, 1233, 446, 282, 2649, 1059, 3035, 26741, 334, 578, 13, 1896, 9, 1233, 272, 536, 446, 282, 30262, 536, 367, 314, 1233, 1350, 334, 475, 675, 315, 1125, 3788, 5423, 4959, 339, 17409, 1230, 2709, 339, 710, 3123, 12, 284, 14, 69, 14, 282, 5673, 1716, 14, 710, 5673, 1716, 1159, 4194, 2225, 365, 272, 663, 370, 314, 4194, 1202, 1380, 6057, 14, 272, 408, 272, 340, 1067, 365, 488, 26, 267, 1067, 275, 2624, 4003, 2998, 8, 354, 9, 272, 327, 9336, 1350, 1584, 25176, 376, 2644, 12, 652, 7704, 12249, 315, 642, 1067, 272, 327, 370, 675, 282, 2649, 1059, 880, 626, 1233, 21495, 2793, 1133, 1172, 370, 26962, 272, 327, 543, 2644, 14, 961, 4910, 626, 511, 1233, 3032, 315, 1077, 440, 1172, 376, 272, 327, 2644, 1406, 14, 272, 702, 1228, 8, 600, 12, 2649, 395, 298, 2975, 1233, 19484, 1454, 8749, 2, 272, 2644, 275, 298, 6610, 13, 24, 2, 339, 859, 63, 354, 275, 536, 272, 340, 2536, 63, 1712, 365, 488, 26, 267, 2536, 63, 1712, 275, 334, 354, 12, 413, 12, 378, 9, 272, 1233, 63, 1365, 275, 2624, 2980, 4311, 8, 354, 12, 1233, 9, 339, 4194, 275, 1067, 14, 1623, 63, 578, 8, 578, 63, 354, 12, 2086, 275, 2536, 63, 1712, 12, 1929, 63, 80, 2207, 275, 378, 9, 339, 4123, 275, 5228, 8, 600, 9, 339, 19121, 275, 1611, 15063, 20843, 8, 1436, 12, 1233, 63, 1365, 12, 1350, 63, 2991, 275, 2644, 12, 2151, 4194, 275, 4194, 12, 1067, 275, 1067, 12, 2536, 63, 1712, 275, 2536, 63, 1712, 9, 272, 4027, 275, 28747, 14, 35, 2347, 8, 3306, 63, 1820, 63, 4869, 63, 11547, 29, 3306, 63, 1820, 63, 4869, 63, 11547, 9, 339, 340, 2166, 365, 488, 26, 267, 3123, 275, 28747, 14, 80, 63, 578, 8, 16378, 12, 378, 12, 859, 63, 354, 12, 4027, 29, 3799, 9, 267, 3123, 14, 2645, 275, 4194, 267, 3123, 14, 374, 63, 80, 2207, 275, 756, 272, 587, 26, 267, 3123, 275, 28747, 14, 80, 63, 600, 8, 16378, 12, 2166, 29, 1896, 12, 4027, 29, 3799, 9, 339, 3123, 14, 2645, 275, 4194, 272, 372, 3123, 199, 199, 533, 12178, 18268, 4446, 8, 18324, 6939, 304, 272, 347, 5684, 63, 1716, 8, 277, 12, 1031, 304, 267, 340, 1031, 365, 488, 26, 288, 372, 1031, 267, 587, 26, 288, 286, 275, 1031, 14, 6311, 63, 932, 342, 288, 291, 14, 5427, 3223, 8, 67, 9, 288, 372, 286, 199, 199, 533, 14618, 5625, 3325, 5116, 8, 3987, 18268, 4446, 304, 272, 347, 636, 826, 721, 277, 12, 2086, 304, 267, 1613, 8, 16581, 5625, 3325, 5116, 12, 291, 2843, 826, 4533, 267, 291, 14, 1712, 275, 2086, 339, 347, 5684, 63, 1716, 8, 277, 12, 1031, 304, 267, 1331, 275, 1613, 8, 16581, 5625, 3325, 5116, 12, 291, 680, 5427, 63, 1716, 8, 932, 9, 267, 1331, 14, 1712, 275, 291, 14, 1712, 267, 372, 1331, 199, 199, 533, 5458, 6939, 8, 18324, 6939, 304, 272, 408, 272, 23365, 282, 1331, 402, 282, 1978, 3123, 1830, 9689, 20873, 14, 339, 437, 2600, 298, 14340, 8653, 2, 1077, 506, 3032, 315, 1380, 6358, 272, 314, 5793, 27, 4412, 1561, 370, 8343, 3380, 14, 9442, 8343, 272, 10986, 2839, 642, 26, 1362, 446, 982, 376, 14754, 11232, 1716, 3509, 282, 2849, 2812, 1716, 12, 7447, 536, 365, 2126, 282, 790, 315, 314, 20873, 2600, 12, 314, 14754, 11232, 1716, 365, 2126, 8717, 543, 282, 1331, 402, 314, 3123, 1627, 315, 314, 2600, 14, 2126, 2779, 365, 314, 9163, 4783, 402, 314, 8025, 626, 314, 8343, 2126, 1031, 365, 282, 1686, 5164, 14, 1362, 446, 982, 282, 2849, 2812, 1716, 365, 4257, 14556, 12, 652, 365, 8717, 2126, 340, 2399, 536, 365, 10532, 315, 314, 20873, 2600, 315, 314, 2126, 2011, 4340, 14, 2779, 365, 314, 9163, 4783, 402, 314, 8025, 370, 1852, 3238, 2126, 626, 314, 8343, 3380, 365, 282, 1686, 3965, 14, 339, 6121, 282, 769, 298, 808, 83, 2, 1077, 506, 3032, 14, 6184, 1561, 10532, 911, 272, 506, 14834, 1901, 16535, 12, 7937, 1561, 14, 339, 13550, 3748, 367, 2388, 1247, 365, 26, 272, 2812, 1716, 272, 334, 3808, 1785, 805, 436 ]
[ 199, 3, 12178, 24552, 1470, 446, 6057, 402, 3326, 370, 14416, 199, 3, 199, 199, 646, 295, 199, 504, 5228, 492, 5228, 199, 504, 13916, 11495, 492, 1611, 15063, 20843, 12, 2624, 2980, 4311, 199, 504, 5515, 2037, 371, 492, 5673, 7812, 199, 646, 27298, 199, 504, 29614, 269, 492, 29614, 269, 6939, 199, 504, 23836, 492, 5013, 12, 27673, 1296, 1716, 199, 504, 28489, 492, 2812, 1716, 199, 646, 28747, 199, 646, 11298, 199, 646, 21248, 6300, 199, 199, 624, 199, 11532, 367, 6057, 3326, 1901, 1233, 14416, 14, 199, 624, 199, 199, 533, 2624, 4003, 2998, 8, 6756, 14, 2998, 304, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2387, 63, 12629, 29, 403, 304, 267, 340, 2387, 63, 12629, 365, 488, 26, 2387, 63, 12629, 275, 942, 267, 11298, 14, 2998, 855, 826, 721, 277, 12, 2387, 63, 12629, 12, 5479, 2892, 1218, 63, 2219, 1859, 29, 797, 9, 267, 291, 14, 578, 63, 354, 275, 536, 339, 347, 2342, 63, 578, 8, 277, 12, 859, 63, 354, 12, 3847, 63, 475, 275, 488, 12, 2086, 275, 488, 12, 1929, 63, 80, 2207, 275, 413, 304, 267, 340, 859, 63, 354, 440, 315, 334, 277, 14, 578, 63, 354, 12, 283, 20747, 735, 288, 746, 9070, 480, 1763, 5966, 21038, 1263, 286, 12775, 15, 9441, 687, 1059, 1233, 19484, 531, 267, 372, 5673, 7812, 8, 578, 63, 354, 12, 1676, 63, 578, 275, 488, 12, 1067, 275, 291, 9, 199, 199, 318, 2198, 63, 504, 63, 5465, 8, 354, 12, 1233, 12, 21162, 795, 10324, 2166, 29, 403, 12, 2536, 63, 1712, 29, 403, 12, 2432, 1067, 29, 403, 12, 2040, 63, 1820, 63, 4869, 63, 11547, 29, 797, 304, 272, 408, 272, 20511, 1083, 370, 2198, 282, 334, 2975, 9, 1059, 402, 1233, 14, 961, 365, 19762, 272, 1202, 367, 5007, 26741, 6365, 12901, 334, 20358, 1233, 19484, 272, 626, 18501, 1077, 8689, 12, 465, 5521, 465, 4137, 5343, 680, 339, 1233, 446, 282, 2649, 1059, 3035, 26741, 334, 578, 13, 1896, 9, 1233, 272, 536, 446, 282, 30262, 536, 367, 314, 1233, 1350, 334, 475, 675, 315, 1125, 3788, 5423, 4959, 339, 17409, 1230, 2709, 339, 710, 3123, 12, 284, 14, 69, 14, 282, 5673, 1716, 14, 710, 5673, 1716, 1159, 4194, 2225, 365, 272, 663, 370, 314, 4194, 1202, 1380, 6057, 14, 272, 408, 272, 340, 1067, 365, 488, 26, 267, 1067, 275, 2624, 4003, 2998, 8, 354, 9, 272, 327, 9336, 1350, 1584, 25176, 376, 2644, 12, 652, 7704, 12249, 315, 642, 1067, 272, 327, 370, 675, 282, 2649, 1059, 880, 626, 1233, 21495, 2793, 1133, 1172, 370, 26962, 272, 327, 543, 2644, 14, 961, 4910, 626, 511, 1233, 3032, 315, 1077, 440, 1172, 376, 272, 327, 2644, 1406, 14, 272, 702, 1228, 8, 600, 12, 2649, 395, 298, 2975, 1233, 19484, 1454, 8749, 2, 272, 2644, 275, 298, 6610, 13, 24, 2, 339, 859, 63, 354, 275, 536, 272, 340, 2536, 63, 1712, 365, 488, 26, 267, 2536, 63, 1712, 275, 334, 354, 12, 413, 12, 378, 9, 272, 1233, 63, 1365, 275, 2624, 2980, 4311, 8, 354, 12, 1233, 9, 339, 4194, 275, 1067, 14, 1623, 63, 578, 8, 578, 63, 354, 12, 2086, 275, 2536, 63, 1712, 12, 1929, 63, 80, 2207, 275, 378, 9, 339, 4123, 275, 5228, 8, 600, 9, 339, 19121, 275, 1611, 15063, 20843, 8, 1436, 12, 1233, 63, 1365, 12, 1350, 63, 2991, 275, 2644, 12, 2151, 4194, 275, 4194, 12, 1067, 275, 1067, 12, 2536, 63, 1712, 275, 2536, 63, 1712, 9, 272, 4027, 275, 28747, 14, 35, 2347, 8, 3306, 63, 1820, 63, 4869, 63, 11547, 29, 3306, 63, 1820, 63, 4869, 63, 11547, 9, 339, 340, 2166, 365, 488, 26, 267, 3123, 275, 28747, 14, 80, 63, 578, 8, 16378, 12, 378, 12, 859, 63, 354, 12, 4027, 29, 3799, 9, 267, 3123, 14, 2645, 275, 4194, 267, 3123, 14, 374, 63, 80, 2207, 275, 756, 272, 587, 26, 267, 3123, 275, 28747, 14, 80, 63, 600, 8, 16378, 12, 2166, 29, 1896, 12, 4027, 29, 3799, 9, 339, 3123, 14, 2645, 275, 4194, 272, 372, 3123, 199, 199, 533, 12178, 18268, 4446, 8, 18324, 6939, 304, 272, 347, 5684, 63, 1716, 8, 277, 12, 1031, 304, 267, 340, 1031, 365, 488, 26, 288, 372, 1031, 267, 587, 26, 288, 286, 275, 1031, 14, 6311, 63, 932, 342, 288, 291, 14, 5427, 3223, 8, 67, 9, 288, 372, 286, 199, 199, 533, 14618, 5625, 3325, 5116, 8, 3987, 18268, 4446, 304, 272, 347, 636, 826, 721, 277, 12, 2086, 304, 267, 1613, 8, 16581, 5625, 3325, 5116, 12, 291, 2843, 826, 4533, 267, 291, 14, 1712, 275, 2086, 339, 347, 5684, 63, 1716, 8, 277, 12, 1031, 304, 267, 1331, 275, 1613, 8, 16581, 5625, 3325, 5116, 12, 291, 680, 5427, 63, 1716, 8, 932, 9, 267, 1331, 14, 1712, 275, 291, 14, 1712, 267, 372, 1331, 199, 199, 533, 5458, 6939, 8, 18324, 6939, 304, 272, 408, 272, 23365, 282, 1331, 402, 282, 1978, 3123, 1830, 9689, 20873, 14, 339, 437, 2600, 298, 14340, 8653, 2, 1077, 506, 3032, 315, 1380, 6358, 272, 314, 5793, 27, 4412, 1561, 370, 8343, 3380, 14, 9442, 8343, 272, 10986, 2839, 642, 26, 1362, 446, 982, 376, 14754, 11232, 1716, 3509, 282, 2849, 2812, 1716, 12, 7447, 536, 365, 2126, 282, 790, 315, 314, 20873, 2600, 12, 314, 14754, 11232, 1716, 365, 2126, 8717, 543, 282, 1331, 402, 314, 3123, 1627, 315, 314, 2600, 14, 2126, 2779, 365, 314, 9163, 4783, 402, 314, 8025, 626, 314, 8343, 2126, 1031, 365, 282, 1686, 5164, 14, 1362, 446, 982, 282, 2849, 2812, 1716, 365, 4257, 14556, 12, 652, 365, 8717, 2126, 340, 2399, 536, 365, 10532, 315, 314, 20873, 2600, 315, 314, 2126, 2011, 4340, 14, 2779, 365, 314, 9163, 4783, 402, 314, 8025, 370, 1852, 3238, 2126, 626, 314, 8343, 3380, 365, 282, 1686, 3965, 14, 339, 6121, 282, 769, 298, 808, 83, 2, 1077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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aabbox/kbengine
kbe/src/lib/python/Lib/ctypes/test/test_anon.py
264
2051
import unittest from ctypes import * class AnonTest(unittest.TestCase): def test_anon(self): class ANON(Union): _fields_ = [("a", c_int), ("b", c_int)] class Y(Structure): _fields_ = [("x", c_int), ("_", ANON), ("y", c_int)] _anonymous_ = ["_"] self.assertEqual(Y.a.offset, sizeof(c_int)) self.assertEqual(Y.b.offset, sizeof(c_int)) self.assertEqual(ANON.a.offset, 0) self.assertEqual(ANON.b.offset, 0) def test_anon_nonseq(self): # TypeError: _anonymous_ must be a sequence self.assertRaises(TypeError, lambda: type(Structure)("Name", (Structure,), {"_fields_": [], "_anonymous_": 42})) def test_anon_nonmember(self): # AttributeError: type object 'Name' has no attribute 'x' self.assertRaises(AttributeError, lambda: type(Structure)("Name", (Structure,), {"_fields_": [], "_anonymous_": ["x"]})) def test_nested(self): class ANON_S(Structure): _fields_ = [("a", c_int)] class ANON_U(Union): _fields_ = [("_", ANON_S), ("b", c_int)] _anonymous_ = ["_"] class Y(Structure): _fields_ = [("x", c_int), ("_", ANON_U), ("y", c_int)] _anonymous_ = ["_"] self.assertEqual(Y.x.offset, 0) self.assertEqual(Y.a.offset, sizeof(c_int)) self.assertEqual(Y.b.offset, sizeof(c_int)) self.assertEqual(Y._.offset, sizeof(c_int)) self.assertEqual(Y.y.offset, sizeof(c_int) * 2) if __name__ == "__main__": unittest.main()
lgpl-3.0
[ 646, 2882, 199, 504, 5577, 492, 627, 199, 199, 533, 1626, 265, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 21009, 8, 277, 304, 267, 1021, 1261, 615, 8, 15540, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 717, 1689, 66, 401, 286, 63, 442, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 286, 63, 442, 395, 717, 1689, 29808, 1261, 615, 395, 717, 1689, 89, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 291, 14, 629, 8, 57, 14, 65, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 66, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 398, 291, 14, 629, 8, 879, 615, 14, 65, 14, 2743, 12, 378, 9, 267, 291, 14, 629, 8, 879, 615, 14, 66, 14, 2743, 12, 378, 9, 339, 347, 511, 63, 21009, 63, 2865, 3610, 8, 277, 304, 267, 327, 3146, 26, 485, 12628, 63, 1471, 506, 282, 3414, 267, 291, 14, 1855, 8, 4333, 12, 2892, 2400, 26, 730, 8, 10766, 9, 480, 985, 401, 10028, 334, 10766, 4706, 10028, 2420, 63, 955, 63, 582, 990, 2668, 12628, 63, 582, 5685, 12466, 339, 347, 511, 63, 21009, 63, 2865, 1114, 8, 277, 304, 267, 327, 4281, 26, 730, 909, 283, 985, 7, 965, 949, 2225, 283, 88, 7, 267, 291, 14, 1855, 8, 10227, 12, 2892, 2400, 26, 730, 8, 10766, 9, 480, 985, 401, 10028, 334, 10766, 4706, 10028, 2420, 63, 955, 63, 582, 990, 10940, 2668, 12628, 63, 582, 2097, 88, 937, 12466, 339, 347, 511, 63, 6376, 8, 277, 304, 267, 1021, 1261, 615, 63, 51, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 1874, 398, 1021, 1261, 615, 63, 53, 8, 15540, 304, 288, 485, 955, 63, 275, 10003, 29808, 1261, 615, 63, 51, 395, 717, 1689, 66, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 286, 63, 442, 395, 717, 1689, 29808, 1261, 615, 63, 53, 395, 717, 1689, 89, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 291, 14, 629, 8, 57, 14, 88, 14, 2743, 12, 378, 9, 267, 291, 14, 629, 8, 57, 14, 65, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 66, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 423, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 89, 14, 2743, 12, 13855, 8, 67, 63, 442, 9, 627, 499, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2882, 199, 504, 5577, 492, 627, 199, 199, 533, 1626, 265, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 21009, 8, 277, 304, 267, 1021, 1261, 615, 8, 15540, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 395, 717, 1689, 66, 401, 286, 63, 442, 1874, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 286, 63, 442, 395, 717, 1689, 29808, 1261, 615, 395, 717, 1689, 89, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 291, 14, 629, 8, 57, 14, 65, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 66, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 398, 291, 14, 629, 8, 879, 615, 14, 65, 14, 2743, 12, 378, 9, 267, 291, 14, 629, 8, 879, 615, 14, 66, 14, 2743, 12, 378, 9, 339, 347, 511, 63, 21009, 63, 2865, 3610, 8, 277, 304, 267, 327, 3146, 26, 485, 12628, 63, 1471, 506, 282, 3414, 267, 291, 14, 1855, 8, 4333, 12, 2892, 2400, 26, 730, 8, 10766, 9, 480, 985, 401, 10028, 334, 10766, 4706, 10028, 2420, 63, 955, 63, 582, 990, 2668, 12628, 63, 582, 5685, 12466, 339, 347, 511, 63, 21009, 63, 2865, 1114, 8, 277, 304, 267, 327, 4281, 26, 730, 909, 283, 985, 7, 965, 949, 2225, 283, 88, 7, 267, 291, 14, 1855, 8, 10227, 12, 2892, 2400, 26, 730, 8, 10766, 9, 480, 985, 401, 10028, 334, 10766, 4706, 10028, 2420, 63, 955, 63, 582, 990, 10940, 2668, 12628, 63, 582, 2097, 88, 937, 12466, 339, 347, 511, 63, 6376, 8, 277, 304, 267, 1021, 1261, 615, 63, 51, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 65, 401, 286, 63, 442, 1874, 398, 1021, 1261, 615, 63, 53, 8, 15540, 304, 288, 485, 955, 63, 275, 10003, 29808, 1261, 615, 63, 51, 395, 717, 1689, 66, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 1021, 1488, 8, 10766, 304, 288, 485, 955, 63, 275, 10003, 88, 401, 286, 63, 442, 395, 717, 1689, 29808, 1261, 615, 63, 53, 395, 717, 1689, 89, 401, 286, 63, 442, 1874, 288, 485, 12628, 63, 275, 2097, 63, 937, 398, 291, 14, 629, 8, 57, 14, 88, 14, 2743, 12, 378, 9, 267, 291, 14, 629, 8, 57, 14, 65, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 66, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 423, 14, 2743, 12, 13855, 8, 67, 63, 442, 430, 267, 291, 14, 629, 8, 57, 14, 89, 14, 2743, 12, 13855, 8, 67, 63, 442, 9, 627, 499, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
frankrousseau/weboob
modules/cci/module.py
7
1691
# -*- coding: utf-8 -*- # Copyright(C) 2013 Bezleputh # # This file is part of weboob. # # weboob is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # weboob is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.job import CapJob, BaseJobAdvert from weboob.tools.value import Value from .browser import CciBrowser __all__ = ['CciModule'] class CciModule(Module, CapJob): NAME = 'cci' DESCRIPTION = u'cci website' MAINTAINER = u'Bezleputh' EMAIL = 'carton_ben@yahoo.fr' LICENSE = 'AGPLv3+' VERSION = '1.1' BROWSER = CciBrowser CONFIG = BackendConfig(Value('metier', label='Job name', masked=False, default='')) def search_job(self, pattern=None): return self.browser.search_job(pattern) def advanced_search_job(self): return self.browser.search_job(pattern=self.config['metier'].get()) def get_job_advert(self, _id, advert=None): return self.browser.get_job_advert(_id, advert) def fill_obj(self, advert, fields): return self.get_job_advert(advert.id, advert) OBJECTS = {BaseJobAdvert: fill_obj}
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 420, 6423, 90, 274, 80, 762, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 504, 29896, 14, 2537, 14, 4620, 492, 5673, 12, 25674, 2028, 199, 504, 29896, 14, 10732, 14, 2423, 492, 22516, 6694, 12, 3523, 6694, 2767, 1884, 199, 504, 29896, 14, 2537, 14, 585, 492, 1594, 199, 199, 504, 1275, 5750, 492, 445, 559, 11930, 421, 199, 363, 452, 363, 275, 788, 35, 559, 2377, 418, 421, 199, 533, 445, 559, 2377, 8, 2377, 12, 22516, 6694, 304, 272, 13637, 275, 283, 67, 559, 7, 272, 17410, 1075, 275, 399, 7, 67, 559, 10691, 7, 272, 4828, 2919, 9021, 540, 275, 399, 7, 3655, 90, 274, 80, 762, 7, 272, 32320, 275, 283, 8153, 265, 63, 18486, 32, 27231, 14, 4391, 7, 272, 5113, 275, 283, 1254, 2749, 86, 19, 4786, 272, 15945, 275, 283, 17, 14, 17, 7, 339, 699, 11415, 3279, 275, 445, 559, 11930, 339, 15869, 275, 25674, 2028, 8, 1110, 360, 278, 13949, 297, 1768, 534, 6694, 536, 297, 9742, 29, 797, 12, 849, 534, 1333, 339, 347, 2754, 63, 2423, 8, 277, 12, 3851, 29, 403, 304, 267, 372, 291, 14, 5750, 14, 1733, 63, 2423, 8, 3401, 9, 339, 347, 19472, 63, 1733, 63, 2423, 8, 277, 304, 267, 372, 291, 14, 5750, 14, 1733, 63, 2423, 8, 3401, 29, 277, 14, 888, 459, 278, 13949, 2278, 362, 1012, 339, 347, 664, 63, 2423, 63, 350, 1884, 8, 277, 12, 485, 344, 12, 1503, 1884, 29, 403, 304, 267, 372, 291, 14, 5750, 14, 362, 63, 2423, 63, 350, 1884, 1547, 344, 12, 1503, 1884, 9, 339, 347, 5554, 63, 1113, 8, 277, 12, 1503, 1884, 12, 1504, 304, 267, 372, 291, 14, 362, 63, 2423, 63, 350, 1884, 8, 350, 1884, 14, 344, 12, 1503, 1884, 9, 339, 28652, 5550, 51, 275, 469, 1563, 6694, 2767, 1884, 26, 5554, 63, 1113, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 420, 6423, 90, 274, 80, 762, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 504, 29896, 14, 2537, 14, 4620, 492, 5673, 12, 25674, 2028, 199, 504, 29896, 14, 10732, 14, 2423, 492, 22516, 6694, 12, 3523, 6694, 2767, 1884, 199, 504, 29896, 14, 2537, 14, 585, 492, 1594, 199, 199, 504, 1275, 5750, 492, 445, 559, 11930, 421, 199, 363, 452, 363, 275, 788, 35, 559, 2377, 418, 421, 199, 533, 445, 559, 2377, 8, 2377, 12, 22516, 6694, 304, 272, 13637, 275, 283, 67, 559, 7, 272, 17410, 1075, 275, 399, 7, 67, 559, 10691, 7, 272, 4828, 2919, 9021, 540, 275, 399, 7, 3655, 90, 274, 80, 762, 7, 272, 32320, 275, 283, 8153, 265, 63, 18486, 32, 27231, 14, 4391, 7, 272, 5113, 275, 283, 1254, 2749, 86, 19, 4786, 272, 15945, 275, 283, 17, 14, 17, 7, 339, 699, 11415, 3279, 275, 445, 559, 11930, 339, 15869, 275, 25674, 2028, 8, 1110, 360, 278, 13949, 297, 1768, 534, 6694, 536, 297, 9742, 29, 797, 12, 849, 534, 1333, 339, 347, 2754, 63, 2423, 8, 277, 12, 3851, 29, 403, 304, 267, 372, 291, 14, 5750, 14, 1733, 63, 2423, 8, 3401, 9, 339, 347, 19472, 63, 1733, 63, 2423, 8, 277, 304, 267, 372, 291, 14, 5750, 14, 1733, 63, 2423, 8, 3401, 29, 277, 14, 888, 459, 278, 13949, 2278, 362, 1012, 339, 347, 664, 63, 2423, 63, 350, 1884, 8, 277, 12, 485, 344, 12, 1503, 1884, 29, 403, 304, 267, 372, 291, 14, 5750, 14, 362, 63, 2423, 63, 350, 1884, 1547, 344, 12, 1503, 1884, 9, 339, 347, 5554, 63, 1113, 8, 277, 12, 1503, 1884, 12, 1504, 304, 267, 372, 291, 14, 362, 63, 2423, 63, 350, 1884, 8, 350, 1884, 14, 344, 12, 1503, 1884, 9, 339, 28652, 5550, 51, 275, 469, 1563, 6694, 2767, 1884, 26, 5554, 63, 1113, 93, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
LChristakis/chalice-hunter
lib/python3.4/site-packages/gunicorn/workers/sync.py
54
7036
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # from datetime import datetime import errno import os import select import socket import ssl import sys import gunicorn.http as http import gunicorn.http.wsgi as wsgi import gunicorn.util as util import gunicorn.workers.base as base from gunicorn import six class StopWaiting(Exception): """ exception raised to stop waiting for a connnection """ class SyncWorker(base.Worker): def accept(self, listener): client, addr = listener.accept() client.setblocking(1) util.close_on_exec(client) self.handle(listener, client, addr) def wait(self, timeout): try: self.notify() ret = select.select(self.sockets, [], self.PIPE, timeout) if ret[0]: return ret[0] except select.error as e: if e.args[0] == errno.EINTR: return self.sockets if e.args[0] == errno.EBADF: if self.nr < 0: return self.sockets else: raise StopWaiting raise def is_parent_alive(self): # If our parent changed then we shut down. if self.ppid != os.getppid(): self.log.info("Parent changed, shutting down: %s", self) return False return True def run_for_one(self, timeout): listener = self.sockets[0] while self.alive: self.notify() # Accept a connection. If we get an error telling us # that no connection is waiting we fall down to the # select which is where we'll wait for a bit for new # workers to come give us some love. try: self.accept(listener) # Keep processing clients until no one is waiting. This # prevents the need to select() for every client that we # process. continue except socket.error as e: if e.args[0] not in (errno.EAGAIN, errno.ECONNABORTED, errno.EWOULDBLOCK): raise if not self.is_parent_alive(): return try: self.wait(timeout) except StopWaiting: return def run_for_multiple(self, timeout): while self.alive: self.notify() try: ready = self.wait(timeout) except StopWaiting: return if ready is not None: for listener in ready: try: self.accept(listener) except socket.error as e: if e.args[0] not in (errno.EAGAIN, errno.ECONNABORTED, errno.EWOULDBLOCK): raise if not self.is_parent_alive(): return def run(self): # if no timeout is given the worker will never wait and will # use the CPU for nothing. This minimal timeout prevent it. timeout = self.timeout or 0.5 # self.socket appears to lose its blocking status after # we fork in the arbiter. Reset it here. for s in self.sockets: s.setblocking(0) if len(self.sockets) > 1: self.run_for_multiple(timeout) else: self.run_for_one(timeout) def handle(self, listener, client, addr): req = None try: if self.cfg.is_ssl: client = ssl.wrap_socket(client, server_side=True, **self.cfg.ssl_options) parser = http.RequestParser(self.cfg, client) req = six.next(parser) self.handle_request(listener, req, client, addr) except http.errors.NoMoreData as e: self.log.debug("Ignored premature client disconnection. %s", e) except StopIteration as e: self.log.debug("Closing connection. %s", e) except ssl.SSLError as e: if e.args[0] == ssl.SSL_ERROR_EOF: self.log.debug("ssl connection closed") client.close() else: self.log.debug("Error processing SSL request.") self.handle_error(req, client, addr, e) except socket.error as e: if e.args[0] not in (errno.EPIPE, errno.ECONNRESET): self.log.exception("Socket error processing request.") else: if e.args[0] == errno.ECONNRESET: self.log.debug("Ignoring connection reset") else: self.log.debug("Ignoring EPIPE") except Exception as e: self.handle_error(req, client, addr, e) finally: util.close(client) def handle_request(self, listener, req, client, addr): environ = {} resp = None try: self.cfg.pre_request(self, req) request_start = datetime.now() resp, environ = wsgi.create(req, client, addr, listener.getsockname(), self.cfg) # Force the connection closed until someone shows # a buffering proxy that supports Keep-Alive to # the backend. resp.force_close() self.nr += 1 if self.nr >= self.max_requests: self.log.info("Autorestarting worker after current request.") self.alive = False respiter = self.wsgi(environ, resp.start_response) try: if isinstance(respiter, environ['wsgi.file_wrapper']): resp.write_file(respiter) else: for item in respiter: resp.write(item) resp.close() request_time = datetime.now() - request_start self.log.access(resp, req, environ, request_time) finally: if hasattr(respiter, "close"): respiter.close() except socket.error: exc_info = sys.exc_info() # pass to next try-except level six.reraise(exc_info[0], exc_info[1], exc_info[2]) except Exception: if resp and resp.headers_sent: # If the requests have already been sent, we should close the # connection to indicate the error. self.log.exception("Error handling request") try: client.shutdown(socket.SHUT_RDWR) client.close() except socket.error: pass raise StopIteration() raise finally: try: self.cfg.post_request(self, req, environ, resp) except Exception: self.log.exception("Exception in post_request hook")
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 446, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 486, 29067, 14286, 1334, 314, 10697, 4190, 14, 199, 3, 1666, 314, 12840, 367, 1655, 2556, 14, 199, 3, 199, 199, 504, 2197, 492, 2197, 199, 646, 7554, 199, 646, 747, 199, 646, 3504, 199, 646, 2838, 199, 646, 6149, 199, 646, 984, 199, 199, 646, 486, 29067, 14, 1014, 465, 1455, 199, 646, 486, 29067, 14, 1014, 14, 6508, 465, 12464, 199, 646, 486, 29067, 14, 1974, 465, 4884, 199, 646, 486, 29067, 14, 11009, 14, 1095, 465, 1300, 199, 504, 486, 29067, 492, 3816, 199, 199, 533, 8015, 19189, 8, 1726, 304, 272, 408, 1919, 4915, 370, 3631, 10923, 367, 282, 2557, 1112, 408, 199, 199, 533, 22407, 12678, 8, 1095, 14, 12678, 304, 339, 347, 4729, 8, 277, 12, 11647, 304, 267, 1890, 12, 5552, 275, 11647, 14, 5694, 342, 267, 1890, 14, 409, 13091, 8, 17, 9, 267, 4884, 14, 1600, 63, 265, 63, 1628, 8, 1258, 9, 267, 291, 14, 2479, 8, 9799, 12, 1890, 12, 5552, 9, 339, 347, 3618, 8, 277, 12, 2653, 304, 267, 862, 26, 288, 291, 14, 6814, 342, 288, 2203, 275, 3504, 14, 2416, 8, 277, 14, 20517, 12, 990, 291, 14, 6089, 12, 2653, 9, 288, 340, 2203, 59, 16, 2189, 355, 372, 2203, 59, 16, 61, 398, 871, 3504, 14, 705, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 508, 7554, 14, 37, 19652, 26, 355, 372, 291, 14, 20517, 288, 340, 325, 14, 589, 59, 16, 61, 508, 7554, 14, 37, 9439, 38, 26, 355, 340, 291, 14, 7865, 665, 378, 26, 490, 372, 291, 14, 20517, 355, 587, 26, 490, 746, 8015, 19189, 288, 746, 339, 347, 365, 63, 1708, 63, 9631, 8, 277, 304, 267, 327, 982, 4154, 1676, 2896, 2066, 781, 24761, 3224, 14, 267, 340, 291, 14, 802, 344, 1137, 747, 14, 362, 802, 344, 837, 288, 291, 14, 793, 14, 815, 480, 6652, 2896, 12, 24761, 1337, 3224, 26, 450, 83, 401, 291, 9, 288, 372, 756, 267, 372, 715, 339, 347, 1255, 63, 509, 63, 368, 8, 277, 12, 2653, 304, 267, 11647, 275, 291, 14, 20517, 59, 16, 61, 267, 1830, 291, 14, 9631, 26, 288, 291, 14, 6814, 342, 953, 327, 15506, 282, 1950, 14, 982, 781, 664, 376, 1125, 1565, 10564, 2739, 288, 327, 626, 949, 1950, 365, 10923, 781, 11264, 3224, 370, 314, 288, 327, 3504, 1314, 365, 2382, 781, 7171, 3618, 367, 282, 4546, 367, 892, 288, 327, 14123, 370, 11492, 8120, 2739, 2005, 560, 432, 14, 288, 862, 26, 355, 291, 14, 5694, 8, 9799, 9, 355, 327, 14797, 6661, 13431, 5133, 949, 1373, 365, 10923, 14, 961, 355, 327, 21925, 314, 1929, 370, 3504, 342, 367, 4036, 1890, 626, 781, 355, 327, 2112, 14, 355, 1980, 953, 871, 2838, 14, 705, 465, 325, 26, 355, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 1254, 9021, 12, 7554, 14, 37, 17489, 27113, 1149, 12, 717, 7554, 14, 37, 11325, 1293, 2846, 4406, 304, 490, 746, 953, 340, 440, 291, 14, 374, 63, 1708, 63, 9631, 837, 355, 372, 953, 862, 26, 355, 291, 14, 2573, 8, 2593, 9, 288, 871, 8015, 19189, 26, 355, 372, 339, 347, 1255, 63, 509, 63, 6048, 8, 277, 12, 2653, 304, 267, 1830, 291, 14, 9631, 26, 288, 291, 14, 6814, 342, 953, 862, 26, 355, 10144, 275, 291, 14, 2573, 8, 2593, 9, 288, 871, 8015, 19189, 26, 355, 372, 953, 340, 10144, 365, 440, 488, 26, 355, 367, 11647, 315, 10144, 26, 490, 862, 26, 717, 291, 14, 5694, 8, 9799, 9, 490, 871, 2838, 14, 705, 465, 325, 26, 717, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 1254, 9021, 12, 7554, 14, 37, 17489, 27113, 1149, 12, 1816, 7554, 14, 37, 11325, 1293, 2846, 4406, 304, 1169, 746, 953, 340, 440, 291, 14, 374, 63, 1708, 63, 9631, 837, 355, 372, 339, 347, 1255, 8, 277, 304, 267, 327, 340, 949, 2653, 365, 1627, 314, 7239, 911, 7078, 3618, 436, 911, 267, 327, 675, 314, 11952, 367, 6548, 14, 961, 13460, 2653, 7981, 652, 14, 267, 2653, 275, 291, 14, 2593, 503, 378, 14, 21, 398, 327, 291, 14, 3450, 11337, 370, 27332, 2399, 14592, 2004, 2410, 267, 327, 781, 14926, 315, 314, 601, 66, 1661, 14, 15510, 652, 2348, 14, 267, 367, 308, 315, 291, 14, 20517, 26, 288, 308, 14, 409, 13091, 8, 16, 9, 398, 340, 822, 8, 277, 14, 20517, 9, 690, 413, 26, 288, 291, 14, 1065, 63, 509, 63, 6048, 8, 2593, 9, 267, 587, 26, 288, 291, 14, 1065, 63, 509, 63, 368, 8, 2593, 9, 339, 347, 2429, 8, 277, 12, 11647, 12, 1890, 12, 5552, 304, 267, 2648, 275, 488, 267, 862, 26, 288, 340, 291, 14, 4128, 14, 374, 63, 4266, 26, 355, 1890, 275, 6149, 14, 3823, 63, 3450, 8, 1258, 12, 1654, 63, 2441, 29, 549, 12, 490, 1011, 277, 14, 4128, 14, 4266, 63, 1419, 9, 953, 1798, 275, 1455, 14, 2017, 2842, 8, 277, 14, 4128, 12, 1890, 9, 288, 2648, 275, 3816, 14, 2184, 8, 2087, 9, 288, 291, 14, 2479, 63, 1069, 8, 9799, 12, 2648, 12, 1890, 12, 5552, 9, 267, 871, 1455, 14, 2550, 14, 1944, 11053, 1451, 465, 325, 26, 288, 291, 14, 793, 14, 1757, 480, 19399, 2908, 876, 19925, 1890, 2153, 2105, 14, 450, 83, 401, 325, 9, 267, 871, 10852, 465, 325, 26, 288, 291, 14, 793, 14, 1757, 480, 18433, 1950, 14, 450, 83, 401, 325, 9, 267, 871, 6149, 14, 27102, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 508, 6149, 14, 5413, 63, 3170, 63, 13178, 26, 355, 291, 14, 793, 14, 1757, 480, 4266, 1950, 6876, 531, 355, 1890, 14, 1600, 342, 288, 587, 26, 355, 291, 14, 793, 14, 1757, 480, 547, 6661, 7799, 1056, 2685, 355, 291, 14, 2479, 63, 705, 8, 2103, 12, 1890, 12, 5552, 12, 325, 9, 267, 871, 2838, 14, 705, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 440 ]
[ 1882, 2803, 26, 2774, 13, 24, 446, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 486, 29067, 14286, 1334, 314, 10697, 4190, 14, 199, 3, 1666, 314, 12840, 367, 1655, 2556, 14, 199, 3, 199, 199, 504, 2197, 492, 2197, 199, 646, 7554, 199, 646, 747, 199, 646, 3504, 199, 646, 2838, 199, 646, 6149, 199, 646, 984, 199, 199, 646, 486, 29067, 14, 1014, 465, 1455, 199, 646, 486, 29067, 14, 1014, 14, 6508, 465, 12464, 199, 646, 486, 29067, 14, 1974, 465, 4884, 199, 646, 486, 29067, 14, 11009, 14, 1095, 465, 1300, 199, 504, 486, 29067, 492, 3816, 199, 199, 533, 8015, 19189, 8, 1726, 304, 272, 408, 1919, 4915, 370, 3631, 10923, 367, 282, 2557, 1112, 408, 199, 199, 533, 22407, 12678, 8, 1095, 14, 12678, 304, 339, 347, 4729, 8, 277, 12, 11647, 304, 267, 1890, 12, 5552, 275, 11647, 14, 5694, 342, 267, 1890, 14, 409, 13091, 8, 17, 9, 267, 4884, 14, 1600, 63, 265, 63, 1628, 8, 1258, 9, 267, 291, 14, 2479, 8, 9799, 12, 1890, 12, 5552, 9, 339, 347, 3618, 8, 277, 12, 2653, 304, 267, 862, 26, 288, 291, 14, 6814, 342, 288, 2203, 275, 3504, 14, 2416, 8, 277, 14, 20517, 12, 990, 291, 14, 6089, 12, 2653, 9, 288, 340, 2203, 59, 16, 2189, 355, 372, 2203, 59, 16, 61, 398, 871, 3504, 14, 705, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 508, 7554, 14, 37, 19652, 26, 355, 372, 291, 14, 20517, 288, 340, 325, 14, 589, 59, 16, 61, 508, 7554, 14, 37, 9439, 38, 26, 355, 340, 291, 14, 7865, 665, 378, 26, 490, 372, 291, 14, 20517, 355, 587, 26, 490, 746, 8015, 19189, 288, 746, 339, 347, 365, 63, 1708, 63, 9631, 8, 277, 304, 267, 327, 982, 4154, 1676, 2896, 2066, 781, 24761, 3224, 14, 267, 340, 291, 14, 802, 344, 1137, 747, 14, 362, 802, 344, 837, 288, 291, 14, 793, 14, 815, 480, 6652, 2896, 12, 24761, 1337, 3224, 26, 450, 83, 401, 291, 9, 288, 372, 756, 267, 372, 715, 339, 347, 1255, 63, 509, 63, 368, 8, 277, 12, 2653, 304, 267, 11647, 275, 291, 14, 20517, 59, 16, 61, 267, 1830, 291, 14, 9631, 26, 288, 291, 14, 6814, 342, 953, 327, 15506, 282, 1950, 14, 982, 781, 664, 376, 1125, 1565, 10564, 2739, 288, 327, 626, 949, 1950, 365, 10923, 781, 11264, 3224, 370, 314, 288, 327, 3504, 1314, 365, 2382, 781, 7171, 3618, 367, 282, 4546, 367, 892, 288, 327, 14123, 370, 11492, 8120, 2739, 2005, 560, 432, 14, 288, 862, 26, 355, 291, 14, 5694, 8, 9799, 9, 355, 327, 14797, 6661, 13431, 5133, 949, 1373, 365, 10923, 14, 961, 355, 327, 21925, 314, 1929, 370, 3504, 342, 367, 4036, 1890, 626, 781, 355, 327, 2112, 14, 355, 1980, 953, 871, 2838, 14, 705, 465, 325, 26, 355, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 1254, 9021, 12, 7554, 14, 37, 17489, 27113, 1149, 12, 717, 7554, 14, 37, 11325, 1293, 2846, 4406, 304, 490, 746, 953, 340, 440, 291, 14, 374, 63, 1708, 63, 9631, 837, 355, 372, 953, 862, 26, 355, 291, 14, 2573, 8, 2593, 9, 288, 871, 8015, 19189, 26, 355, 372, 339, 347, 1255, 63, 509, 63, 6048, 8, 277, 12, 2653, 304, 267, 1830, 291, 14, 9631, 26, 288, 291, 14, 6814, 342, 953, 862, 26, 355, 10144, 275, 291, 14, 2573, 8, 2593, 9, 288, 871, 8015, 19189, 26, 355, 372, 953, 340, 10144, 365, 440, 488, 26, 355, 367, 11647, 315, 10144, 26, 490, 862, 26, 717, 291, 14, 5694, 8, 9799, 9, 490, 871, 2838, 14, 705, 465, 325, 26, 717, 340, 325, 14, 589, 59, 16, 61, 440, 315, 334, 7931, 14, 37, 1254, 9021, 12, 7554, 14, 37, 17489, 27113, 1149, 12, 1816, 7554, 14, 37, 11325, 1293, 2846, 4406, 304, 1169, 746, 953, 340, 440, 291, 14, 374, 63, 1708, 63, 9631, 837, 355, 372, 339, 347, 1255, 8, 277, 304, 267, 327, 340, 949, 2653, 365, 1627, 314, 7239, 911, 7078, 3618, 436, 911, 267, 327, 675, 314, 11952, 367, 6548, 14, 961, 13460, 2653, 7981, 652, 14, 267, 2653, 275, 291, 14, 2593, 503, 378, 14, 21, 398, 327, 291, 14, 3450, 11337, 370, 27332, 2399, 14592, 2004, 2410, 267, 327, 781, 14926, 315, 314, 601, 66, 1661, 14, 15510, 652, 2348, 14, 267, 367, 308, 315, 291, 14, 20517, 26, 288, 308, 14, 409, 13091, 8, 16, 9, 398, 340, 822, 8, 277, 14, 20517, 9, 690, 413, 26, 288, 291, 14, 1065, 63, 509, 63, 6048, 8, 2593, 9, 267, 587, 26, 288, 291, 14, 1065, 63, 509, 63, 368, 8, 2593, 9, 339, 347, 2429, 8, 277, 12, 11647, 12, 1890, 12, 5552, 304, 267, 2648, 275, 488, 267, 862, 26, 288, 340, 291, 14, 4128, 14, 374, 63, 4266, 26, 355, 1890, 275, 6149, 14, 3823, 63, 3450, 8, 1258, 12, 1654, 63, 2441, 29, 549, 12, 490, 1011, 277, 14, 4128, 14, 4266, 63, 1419, 9, 953, 1798, 275, 1455, 14, 2017, 2842, 8, 277, 14, 4128, 12, 1890, 9, 288, 2648, 275, 3816, 14, 2184, 8, 2087, 9, 288, 291, 14, 2479, 63, 1069, 8, 9799, 12, 2648, 12, 1890, 12, 5552, 9, 267, 871, 1455, 14, 2550, 14, 1944, 11053, 1451, 465, 325, 26, 288, 291, 14, 793, 14, 1757, 480, 19399, 2908, 876, 19925, 1890, 2153, 2105, 14, 450, 83, 401, 325, 9, 267, 871, 10852, 465, 325, 26, 288, 291, 14, 793, 14, 1757, 480, 18433, 1950, 14, 450, 83, 401, 325, 9, 267, 871, 6149, 14, 27102, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 508, 6149, 14, 5413, 63, 3170, 63, 13178, 26, 355, 291, 14, 793, 14, 1757, 480, 4266, 1950, 6876, 531, 355, 1890, 14, 1600, 342, 288, 587, 26, 355, 291, 14, 793, 14, 1757, 480, 547, 6661, 7799, 1056, 2685, 355, 291, 14, 2479, 63, 705, 8, 2103, 12, 1890, 12, 5552, 12, 325, 9, 267, 871, 2838, 14, 705, 465, 325, 26, 288, 340, 325, 14, 589, 59, 16, 61, 440, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dhanunjaya/neutron
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
3
128050
# Copyright (c) 2012 OpenStack Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import sys import time import mock from oslo_config import cfg from oslo_log import log import oslo_messaging import testtools from neutron.agent.common import ovs_lib from neutron.agent.common import utils from neutron.agent.linux import async_process from neutron.agent.linux import ip_lib from neutron.common import constants as n_const from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_neutron_agent \ as ovs_agent from neutron.tests import base from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \ import ovs_test_base NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi' OVS_LINUX_KERN_VERS_WITHOUT_VXLAN = "3.12.0" FAKE_MAC = '00:11:22:33:44:55' FAKE_IP1 = '10.0.0.1' FAKE_IP2 = '10.0.0.2' TEST_PORT_ID1 = 'port-id-1' TEST_PORT_ID2 = 'port-id-2' TEST_PORT_ID3 = 'port-id-3' TEST_NETWORK_ID1 = 'net-id-1' TEST_NETWORK_ID2 = 'net-id-2' class FakeVif(object): ofport = 99 port_name = 'name' vif_mac = 'aa:bb:cc:11:22:33' class MockFixedIntervalLoopingCall(object): def __init__(self, f): self.f = f def start(self, interval=0): self.f() class CreateAgentConfigMap(ovs_test_base.OVSAgentConfigTestBase): def test_create_agent_config_map_succeeds(self): self.assertTrue(self.mod_agent.create_agent_config_map(cfg.CONF)) def test_create_agent_config_map_fails_for_invalid_tunnel_config(self): # An ip address is required for tunneling but there is no default, # verify this for both gre and vxlan tunnels. cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE], group='AGENT') with testtools.ExpectedException(ValueError): self.mod_agent.create_agent_config_map(cfg.CONF) cfg.CONF.set_override('tunnel_types', [p_const.TYPE_VXLAN], group='AGENT') with testtools.ExpectedException(ValueError): self.mod_agent.create_agent_config_map(cfg.CONF) def test_create_agent_config_map_fails_no_local_ip(self): # An ip address is required for tunneling but there is no default cfg.CONF.set_override('tunnel_types', [p_const.TYPE_VXLAN], group='AGENT') with testtools.ExpectedException(ValueError): self.mod_agent.create_agent_config_map(cfg.CONF) def test_create_agent_config_map_fails_for_invalid_tunnel_type(self): cfg.CONF.set_override('tunnel_types', ['foobar'], group='AGENT') with testtools.ExpectedException(ValueError): self.mod_agent.create_agent_config_map(cfg.CONF) def test_create_agent_config_map_multiple_tunnel_types(self): cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS') cfg.CONF.set_override('tunnel_types', [p_const.TYPE_GRE, p_const.TYPE_VXLAN], group='AGENT') cfgmap = self.mod_agent.create_agent_config_map(cfg.CONF) self.assertEqual(cfgmap['tunnel_types'], [p_const.TYPE_GRE, p_const.TYPE_VXLAN]) def test_create_agent_config_map_enable_distributed_routing(self): self.addCleanup(cfg.CONF.reset) # Verify setting only enable_tunneling will default tunnel_type to GRE cfg.CONF.set_override('enable_distributed_routing', True, group='AGENT') cfgmap = self.mod_agent.create_agent_config_map(cfg.CONF) self.assertEqual(cfgmap['enable_distributed_routing'], True) class TestOvsNeutronAgent(object): def setUp(self): super(TestOvsNeutronAgent, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', group='SECURITYGROUP') cfg.CONF.set_default('quitting_rpc_timeout', 10, 'AGENT') cfg.CONF.set_default('prevent_arp_spoofing', False, 'AGENT') kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.get_ports_attributes', return_value=[]).start() with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'),\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_ancillary_bridges', return_value=[]),\ mock.patch('neutron.agent.linux.utils.get_interface_mac', return_value='00:00:00:00:00:01'),\ mock.patch( 'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'),\ mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall),\ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', return_value=[]): self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **kwargs) # set back to true because initial report state will succeed due # to mocked out RPC calls self.agent.use_call = True self.agent.tun_br = self.br_tun_cls(br_name='br-tun') self.agent.sg_agent = mock.Mock() def _mock_port_bound(self, ofport=None, new_local_vlan=None, old_local_vlan=None): port = mock.Mock() port.ofport = ofport net_uuid = 'my-net-uuid' fixed_ips = [{'subnet_id': 'my-subnet-uuid', 'ip_address': '1.1.1.1'}] if old_local_vlan is not None: self.agent.local_vlan_map[net_uuid] = ( self.mod_agent.LocalVLANMapping( old_local_vlan, None, None, None)) with mock.patch.object(self.agent, 'int_br', autospec=True) as int_br: int_br.db_get_val.return_value = {} int_br.set_db_attribute.return_value = True self.agent.port_bound(port, net_uuid, 'local', None, None, fixed_ips, "compute:None", False) vlan_mapping = {'net_uuid': net_uuid, 'network_type': 'local', 'physical_network': None, 'segmentation_id': None} int_br.set_db_attribute.assert_called_once_with( "Port", mock.ANY, "other_config", vlan_mapping) def _test_restore_local_vlan_maps(self, tag): port = mock.Mock() port.port_name = 'fake_port' local_vlan_map = {'net_uuid': 'fake_network_id', 'network_type': 'vlan', 'physical_network': 'fake_network', 'segmentation_id': 1} with mock.patch.object(self.agent, 'int_br') as int_br, \ mock.patch.object(self.agent, 'provision_local_vlan') as \ provision_local_vlan: int_br.get_vif_ports.return_value = [port] int_br.get_ports_attributes.return_value = [{ 'name': port.port_name, 'other_config': local_vlan_map, 'tag': tag }] self.agent._restore_local_vlan_map() if tag: self.assertTrue(provision_local_vlan.called) else: self.assertFalse(provision_local_vlan.called) def test_datapath_type_system(self): # verify kernel datapath is default expected = constants.OVS_DATAPATH_SYSTEM self.assertEqual(expected, self.agent.int_br.datapath_type) def test_datapath_type_netdev(self): with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'), \ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_ancillary_bridges', return_value=[]), \ mock.patch('neutron.agent.linux.utils.get_interface_mac', return_value='00:00:00:00:00:01'), \ mock.patch( 'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'), \ mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall), \ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', return_value=[]): # validate setting non default datapath expected = constants.OVS_DATAPATH_NETDEV cfg.CONF.set_override('datapath_type', expected, group='OVS') kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **kwargs) self.assertEqual(expected, self.agent.int_br.datapath_type) def test_agent_type_ovs(self): # verify agent_type is default expected = n_const.AGENT_TYPE_OVS self.assertEqual(expected, self.agent.agent_state['agent_type']) def test_agent_type_alt(self): with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'),\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_ancillary_bridges', return_value=[]), \ mock.patch('neutron.agent.linux.utils.get_interface_mac', return_value='00:00:00:00:00:01'), \ mock.patch( 'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'), \ mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall), \ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', return_value=[]): # validate setting non default agent_type expected = 'alt agent type' cfg.CONF.set_override('agent_type', expected, group='AGENT') kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **kwargs) self.assertEqual(expected, self.agent.agent_state['agent_type']) def test_restore_local_vlan_map_with_device_has_tag(self): self._test_restore_local_vlan_maps(2) def test_restore_local_vlan_map_with_device_no_tag(self): self._test_restore_local_vlan_maps([]) def test_check_agent_configurations_for_dvr_raises(self): self.agent.enable_distributed_routing = True self.agent.enable_tunneling = True self.agent.l2_pop = False self.assertRaises(ValueError, self.agent._check_agent_configurations) def test_check_agent_configurations_for_dvr(self): self.agent.enable_distributed_routing = True self.agent.enable_tunneling = True self.agent.l2_pop = True self.assertIsNone(self.agent._check_agent_configurations()) def test_check_agent_configurations_for_dvr_with_vlan(self): self.agent.enable_distributed_routing = True self.agent.enable_tunneling = False self.agent.l2_pop = False self.assertIsNone(self.agent._check_agent_configurations()) def test_port_bound_deletes_flows_for_valid_ofport(self): self._mock_port_bound(ofport=1, new_local_vlan=1) def test_port_bound_ignores_flows_for_invalid_ofport(self): self._mock_port_bound(ofport=-1, new_local_vlan=1) def test_port_bound_does_not_rewire_if_already_bound(self): self._mock_port_bound(ofport=-1, new_local_vlan=1, old_local_vlan=1) def _test_port_dead(self, cur_tag=None): port = mock.Mock() port.ofport = 1 with mock.patch.object(self.agent, 'int_br') as int_br: int_br.db_get_val.return_value = cur_tag self.agent.port_dead(port) if cur_tag == self.mod_agent.DEAD_VLAN_TAG: self.assertFalse(int_br.set_db_attribute.called) self.assertFalse(int_br.drop_port.called) else: int_br.assert_has_calls([ mock.call.set_db_attribute("Port", mock.ANY, "tag", self.mod_agent.DEAD_VLAN_TAG, log_errors=True), mock.call.drop_port(in_port=port.ofport), ]) def test_port_dead(self): self._test_port_dead() def test_port_dead_with_port_already_dead(self): self._test_port_dead(self.mod_agent.DEAD_VLAN_TAG) def mock_scan_ports(self, vif_port_set=None, registered_ports=None, updated_ports=None, port_tags_dict=None, sync=False): if port_tags_dict is None: # Because empty dicts evaluate as False. port_tags_dict = {} with mock.patch.object(self.agent.int_br, 'get_vif_port_set', return_value=vif_port_set),\ mock.patch.object(self.agent.int_br, 'get_port_tag_dict', return_value=port_tags_dict): return self.agent.scan_ports(registered_ports, sync, updated_ports) def test_scan_ports_returns_current_only_for_unchanged_ports(self): vif_port_set = set([1, 3]) registered_ports = set([1, 3]) expected = {'current': vif_port_set} actual = self.mock_scan_ports(vif_port_set, registered_ports) self.assertEqual(expected, actual) def test_scan_ports_returns_port_changes(self): vif_port_set = set([1, 3]) registered_ports = set([1, 2]) expected = dict(current=vif_port_set, added=set([3]), removed=set([2])) actual = self.mock_scan_ports(vif_port_set, registered_ports) self.assertEqual(expected, actual) def test_scan_ports_returns_port_changes_with_sync(self): vif_port_set = set([1, 3]) registered_ports = set([1, 2]) expected = dict(current=vif_port_set, added=vif_port_set, removed=set([2])) actual = self.mock_scan_ports(vif_port_set, registered_ports, sync=True) self.assertEqual(expected, actual) def _test_scan_ports_with_updated_ports(self, updated_ports): vif_port_set = set([1, 3, 4]) registered_ports = set([1, 2, 4]) expected = dict(current=vif_port_set, added=set([3]), removed=set([2]), updated=set([4])) actual = self.mock_scan_ports(vif_port_set, registered_ports, updated_ports) self.assertEqual(expected, actual) def test_scan_ports_finds_known_updated_ports(self): self._test_scan_ports_with_updated_ports(set([4])) def test_scan_ports_ignores_unknown_updated_ports(self): # the port '5' was not seen on current ports. Hence it has either # never been wired or already removed and should be ignored self._test_scan_ports_with_updated_ports(set([4, 5])) def test_scan_ports_ignores_updated_port_if_removed(self): vif_port_set = set([1, 3]) registered_ports = set([1, 2]) updated_ports = set([1, 2]) expected = dict(current=vif_port_set, added=set([3]), removed=set([2]), updated=set([1])) actual = self.mock_scan_ports(vif_port_set, registered_ports, updated_ports) self.assertEqual(expected, actual) def test_scan_ports_no_vif_changes_returns_updated_port_only(self): vif_port_set = set([1, 2, 3]) registered_ports = set([1, 2, 3]) updated_ports = set([2]) expected = dict(current=vif_port_set, updated=set([2])) actual = self.mock_scan_ports(vif_port_set, registered_ports, updated_ports) self.assertEqual(expected, actual) def test_update_ports_returns_changed_vlan(self): br = self.br_int_cls('br-int') mac = "ca:fe:de:ad:be:ef" port = ovs_lib.VifPort(1, 1, 1, mac, br) lvm = self.mod_agent.LocalVLANMapping( 1, '1', None, 1, {port.vif_id: port}) local_vlan_map = {'1': lvm} vif_port_set = set([1, 3]) registered_ports = set([1, 2]) port_tags_dict = {1: []} expected = dict( added=set([3]), current=vif_port_set, removed=set([2]), updated=set([1]) ) with mock.patch.dict(self.agent.local_vlan_map, local_vlan_map),\ mock.patch.object(self.agent, 'tun_br', autospec=True): actual = self.mock_scan_ports( vif_port_set, registered_ports, port_tags_dict=port_tags_dict) self.assertEqual(expected, actual) def test_bind_devices(self): devices_up = ['tap1'] devices_down = ['tap2'] self.agent.local_vlan_map["net1"] = mock.Mock() ovs_db_list = [{'name': 'tap1', 'tag': []}, {'name': 'tap2', 'tag': []}] vif_port1 = mock.Mock() vif_port1.port_name = 'tap1' vif_port2 = mock.Mock() vif_port2.port_name = 'tap2' port_details = [ {'network_id': 'net1', 'vif_port': vif_port1, 'device': devices_up[0], 'admin_state_up': True}, {'network_id': 'net1', 'vif_port': vif_port2, 'device': devices_down[0], 'admin_state_up': False}] with mock.patch.object( self.agent.plugin_rpc, 'update_device_list', return_value={'devices_up': devices_up, 'devices_down': devices_down, 'failed_devices_up': [], 'failed_devices_down': []}) as update_devices, \ mock.patch.object(self.agent, 'int_br') as int_br: int_br.get_ports_attributes.return_value = ovs_db_list self.agent._bind_devices(port_details) update_devices.assert_called_once_with(mock.ANY, devices_up, devices_down, mock.ANY, mock.ANY) def _test_arp_spoofing(self, enable_prevent_arp_spoofing): self.agent.prevent_arp_spoofing = enable_prevent_arp_spoofing ovs_db_list = [{'name': 'fake_device', 'tag': []}] self.agent.local_vlan_map = { 'fake_network': ovs_agent.LocalVLANMapping(1, None, None, 1)} vif_port = mock.Mock() vif_port.port_name = 'fake_device' vif_port.ofport = 1 need_binding_ports = [{'network_id': 'fake_network', 'vif_port': vif_port, 'device': 'fake_device', 'admin_state_up': True}] with mock.patch.object( self.agent.plugin_rpc, 'update_device_list', return_value={'devices_up': [], 'devices_down': [], 'failed_devices_up': [], 'failed_devices_down': []}), \ mock.patch.object(self.agent, 'int_br') as int_br, \ mock.patch.object( self.agent, 'setup_arp_spoofing_protection') as setup_arp: int_br.get_ports_attributes.return_value = ovs_db_list self.agent._bind_devices(need_binding_ports) self.assertEqual(enable_prevent_arp_spoofing, setup_arp.called) def test_setup_arp_spoofing_protection_enable(self): self._test_arp_spoofing(True) def test_setup_arp_spoofing_protection_disabled(self): self._test_arp_spoofing(False) def _mock_treat_devices_added_updated(self, details, port, func_name): """Mock treat devices added or updated. :param details: the details to return for the device :param port: the port that get_vif_port_by_id should return :param func_name: the function that should be called :returns: whether the named function was called """ with mock.patch.object(self.agent.plugin_rpc, 'get_devices_details_list_and_failed_devices', return_value={'devices': [details], 'failed_devices': None}),\ mock.patch.object(self.agent.int_br, 'get_vifs_by_ids', return_value={details['device']: port}),\ mock.patch.object(self.agent.plugin_rpc, 'update_device_list', return_value={'devices_up': [], 'devices_down': details, 'failed_devices_up': [], 'failed_devices_down': []}),\ mock.patch.object(self.agent.int_br, 'get_port_tag_dict', return_value={}),\ mock.patch.object(self.agent, func_name) as func: skip_devs, need_bound_devices, insecure_ports = ( self.agent.treat_devices_added_or_updated([{}], False)) # The function should not raise self.assertFalse(skip_devs) return func.called def test_treat_devices_added_updated_ignores_invalid_ofport(self): port = mock.Mock() port.ofport = -1 self.assertFalse(self._mock_treat_devices_added_updated( mock.MagicMock(), port, 'port_dead')) def test_treat_devices_added_updated_marks_unknown_port_as_dead(self): port = mock.Mock() port.ofport = 1 self.assertTrue(self._mock_treat_devices_added_updated( mock.MagicMock(), port, 'port_dead')) def test_treat_devices_added_does_not_process_missing_port(self): with mock.patch.object( self.agent.plugin_rpc, 'get_devices_details_list_and_failed_devices') as get_dev_fn,\ mock.patch.object(self.agent.int_br, 'get_vif_port_by_id', return_value=None): self.assertFalse(get_dev_fn.called) def test_treat_devices_added_updated_updates_known_port(self): details = mock.MagicMock() details.__contains__.side_effect = lambda x: True self.assertTrue(self._mock_treat_devices_added_updated( details, mock.Mock(), 'treat_vif_port')) def test_treat_devices_added_updated_sends_vif_port_into_extension_manager( self, *args): details = mock.MagicMock() details.__contains__.side_effect = lambda x: True port = mock.MagicMock() def fake_handle_port(context, port): self.assertIn('vif_port', port) with mock.patch.object(self.agent.plugin_rpc, 'get_devices_details_list_and_failed_devices', return_value={'devices': [details], 'failed_devices': None}),\ mock.patch.object(self.agent.ext_manager, 'handle_port', new=fake_handle_port),\ mock.patch.object(self.agent.int_br, 'get_vifs_by_ids', return_value={details['device']: port}),\ mock.patch.object(self.agent, 'treat_vif_port', return_value=False): self.agent.treat_devices_added_or_updated([{}], False) def test_treat_devices_added_updated_skips_if_port_not_found(self): dev_mock = mock.MagicMock() dev_mock.__getitem__.return_value = 'the_skipped_one' with mock.patch.object(self.agent.plugin_rpc, 'get_devices_details_list_and_failed_devices', return_value={'devices': [dev_mock], 'failed_devices': None}),\ mock.patch.object(self.agent.int_br, 'get_port_tag_dict', return_value={}),\ mock.patch.object(self.agent.int_br, 'get_vifs_by_ids', return_value={}),\ mock.patch.object(self.agent, 'treat_vif_port') as treat_vif_port: skip_devs = self.agent.treat_devices_added_or_updated([{}], False) # The function should return False for resync and no device # processed self.assertEqual((['the_skipped_one'], [], []), skip_devs) self.assertFalse(treat_vif_port.called) def test_treat_devices_added_updated_put_port_down(self): fake_details_dict = {'admin_state_up': False, 'port_id': 'xxx', 'device': 'xxx', 'network_id': 'yyy', 'physical_network': 'foo', 'segmentation_id': 'bar', 'network_type': 'baz', 'fixed_ips': [{'subnet_id': 'my-subnet-uuid', 'ip_address': '1.1.1.1'}], 'device_owner': 'compute:None', 'port_security_enabled': True } with mock.patch.object(self.agent.plugin_rpc, 'get_devices_details_list_and_failed_devices', return_value={'devices': [fake_details_dict], 'failed_devices': None}),\ mock.patch.object(self.agent.int_br, 'get_vifs_by_ids', return_value={'xxx': mock.MagicMock()}),\ mock.patch.object(self.agent.int_br, 'get_port_tag_dict', return_value={}),\ mock.patch.object(self.agent, 'treat_vif_port') as treat_vif_port: skip_devs, need_bound_devices, insecure_ports = ( self.agent.treat_devices_added_or_updated([{}], False)) # The function should return False for resync self.assertFalse(skip_devs) self.assertTrue(treat_vif_port.called) def _mock_treat_devices_removed(self, port_exists): details = dict(exists=port_exists) with mock.patch.object(self.agent.plugin_rpc, 'update_device_list', return_value={'devices_up': [], 'devices_down': details, 'failed_devices_up': [], 'failed_devices_down': []}): with mock.patch.object(self.agent, 'port_unbound') as port_unbound: self.assertFalse(self.agent.treat_devices_removed([{}])) self.assertTrue(port_unbound.called) def test_treat_devices_removed_unbinds_port(self): self._mock_treat_devices_removed(True) def test_treat_devices_removed_ignores_missing_port(self): self._mock_treat_devices_removed(False) def test_bind_port_with_missing_network(self): vif_port = mock.Mock() vif_port.name.return_value = 'port' self.agent._bind_devices([{'network_id': 'non-existent', 'vif_port': vif_port}]) def _test_process_network_ports(self, port_info): with mock.patch.object(self.agent.sg_agent, "setup_port_filters") as setup_port_filters,\ mock.patch.object( self.agent, "treat_devices_added_or_updated", return_value=([], [], [])) as device_added_updated,\ mock.patch.object(self.agent.int_br, "get_ports_attributes", return_value=[]),\ mock.patch.object(self.agent, "treat_devices_removed", return_value=False) as device_removed: self.assertFalse(self.agent.process_network_ports(port_info, False)) setup_port_filters.assert_called_once_with( port_info.get('added', set()), port_info.get('updated', set())) devices_added_updated = (port_info.get('added', set()) | port_info.get('updated', set())) if devices_added_updated: device_added_updated.assert_called_once_with( devices_added_updated, False) if port_info.get('removed', set()): device_removed.assert_called_once_with(port_info['removed']) def test_process_network_ports(self): self._test_process_network_ports( {'current': set(['tap0']), 'removed': set(['eth0']), 'added': set(['eth1'])}) def test_process_network_port_with_updated_ports(self): self._test_process_network_ports( {'current': set(['tap0', 'tap1']), 'updated': set(['tap1', 'eth1']), 'removed': set(['eth0']), 'added': set(['eth1'])}) def test_process_network_port_with_empty_port(self): self._test_process_network_ports({}) def test_process_network_ports_with_insecure_ports(self): port_info = {'current': set(['tap0', 'tap1']), 'updated': set(['tap1']), 'removed': set([]), 'added': set(['eth1'])} with mock.patch.object(self.agent.sg_agent, "setup_port_filters") as setup_port_filters,\ mock.patch.object( self.agent, "treat_devices_added_or_updated", return_value=([], [], ['eth1'])) as device_added_updated: self.assertFalse(self.agent.process_network_ports(port_info, False)) device_added_updated.assert_called_once_with( set(['eth1', 'tap1']), False) setup_port_filters.assert_called_once_with( set(), port_info.get('updated', set())) def test_report_state(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: self.agent.int_br_device_count = 5 self.agent._report_state() report_st.assert_called_with(self.agent.context, self.agent.agent_state, True) self.assertNotIn("start_flag", self.agent.agent_state) self.assertFalse(self.agent.use_call) self.assertEqual( self.agent.agent_state["configurations"]["devices"], self.agent.int_br_device_count ) self.agent._report_state() report_st.assert_called_with(self.agent.context, self.agent.agent_state, False) def test_report_state_fail(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: report_st.side_effect = Exception() self.agent._report_state() report_st.assert_called_with(self.agent.context, self.agent.agent_state, True) self.agent._report_state() report_st.assert_called_with(self.agent.context, self.agent.agent_state, True) def test_port_update(self): port = {"id": TEST_PORT_ID1, "network_id": TEST_NETWORK_ID1, "admin_state_up": False} self.agent.port_update("unused_context", port=port, network_type="vlan", segmentation_id="1", physical_network="physnet") self.assertEqual(set([TEST_PORT_ID1]), self.agent.updated_ports) def test_port_delete_after_update(self): """Make sure a port is not marked for delete and update.""" port = {'id': TEST_PORT_ID1} self.agent.port_update(context=None, port=port) self.agent.port_delete(context=None, port_id=port['id']) self.assertEqual(set(), self.agent.updated_ports) self.assertEqual(set([port['id']]), self.agent.deleted_ports) def test_process_deleted_ports_cleans_network_ports(self): self.agent._update_port_network(TEST_PORT_ID1, TEST_NETWORK_ID1) self.agent.port_delete(context=None, port_id=TEST_PORT_ID1) self.agent.sg_agent = mock.Mock() self.agent.int_br = mock.Mock() self.agent.process_deleted_ports(port_info={}) self.assertEqual(set(), self.agent.network_ports[TEST_NETWORK_ID1]) def test_network_update(self): """Network update marks port for update. """ network = {'id': TEST_NETWORK_ID1} port = {'id': TEST_PORT_ID1, 'network_id': network['id']} self.agent._update_port_network(port['id'], port['network_id']) self.agent.network_update(context=None, network=network) self.assertEqual(set([port['id']]), self.agent.updated_ports) def test_network_update_outoforder(self): """Network update arrives later than port_delete. But the main agent loop still didn't process the ports, so we ensure the port is not marked for update. """ network = {'id': TEST_NETWORK_ID1} port = {'id': TEST_PORT_ID1, 'network_id': network['id']} self.agent._update_port_network(port['id'], port['network_id']) self.agent.port_delete(context=None, port_id=port['id']) self.agent.network_update(context=None, network=network) self.assertEqual(set(), self.agent.updated_ports) def test_update_port_network(self): """Ensure ports are associated and moved across networks correctly.""" self.agent._update_port_network(TEST_PORT_ID1, TEST_NETWORK_ID1) self.agent._update_port_network(TEST_PORT_ID2, TEST_NETWORK_ID1) self.agent._update_port_network(TEST_PORT_ID3, TEST_NETWORK_ID2) self.agent._update_port_network(TEST_PORT_ID1, TEST_NETWORK_ID2) self.assertEqual(set([TEST_PORT_ID2]), self.agent.network_ports[TEST_NETWORK_ID1]) self.assertEqual(set([TEST_PORT_ID1, TEST_PORT_ID3]), self.agent.network_ports[TEST_NETWORK_ID2]) def test_port_delete(self): vif = FakeVif() with mock.patch.object(self.agent, 'int_br') as int_br: int_br.get_vif_by_port_id.return_value = vif.port_name int_br.get_vif_port_by_id.return_value = vif self.agent.port_delete("unused_context", port_id='id') self.agent.process_deleted_ports(port_info={}) # the main things we care about are that it gets put in the # dead vlan and gets blocked int_br.set_db_attribute.assert_any_call( 'Port', vif.port_name, 'tag', self.mod_agent.DEAD_VLAN_TAG, log_errors=False) int_br.drop_port.assert_called_once_with(in_port=vif.ofport) def test_port_delete_removed_port(self): with mock.patch.object(self.agent, 'int_br') as int_br: self.agent.port_delete("unused_context", port_id='id') # if it was removed from the bridge, we shouldn't be processing it self.agent.process_deleted_ports(port_info={'removed': {'id', }}) self.assertFalse(int_br.set_db_attribute.called) self.assertFalse(int_br.drop_port.called) def test_setup_physical_bridges(self): with mock.patch.object(ip_lib, "device_exists") as devex_fn,\ mock.patch.object(sys, "exit"),\ mock.patch.object(utils, "execute"),\ mock.patch.object(self.agent, 'br_phys_cls') as phys_br_cls,\ mock.patch.object(self.agent, 'int_br') as int_br: devex_fn.return_value = True parent = mock.MagicMock() phys_br = phys_br_cls() parent.attach_mock(phys_br_cls, 'phys_br_cls') parent.attach_mock(phys_br, 'phys_br') parent.attach_mock(int_br, 'int_br') phys_br.add_patch_port.return_value = "phy_ofport" int_br.add_patch_port.return_value = "int_ofport" self.agent.setup_physical_bridges({"physnet1": "br-eth"}) expected_calls = [ mock.call.phys_br_cls('br-eth'), mock.call.phys_br.setup_controllers(mock.ANY), mock.call.phys_br.setup_default_table(), mock.call.int_br.db_get_val('Interface', 'int-br-eth', 'type'), # Have to use __getattr__ here to avoid mock._Call.__eq__ # method being called mock.call.int_br.db_get_val().__getattr__('__eq__')('veth'), mock.call.int_br.add_patch_port('int-br-eth', constants.NONEXISTENT_PEER), mock.call.phys_br.add_patch_port('phy-br-eth', constants.NONEXISTENT_PEER), mock.call.int_br.drop_port(in_port='int_ofport'), mock.call.phys_br.drop_port(in_port='phy_ofport'), mock.call.int_br.set_db_attribute('Interface', 'int-br-eth', 'options:peer', 'phy-br-eth'), mock.call.phys_br.set_db_attribute('Interface', 'phy-br-eth', 'options:peer', 'int-br-eth'), ] parent.assert_has_calls(expected_calls) self.assertEqual(self.agent.int_ofports["physnet1"], "int_ofport") self.assertEqual(self.agent.phys_ofports["physnet1"], "phy_ofport") def test_setup_physical_bridges_using_veth_interconnection(self): self.agent.use_veth_interconnection = True with mock.patch.object(ip_lib, "device_exists") as devex_fn,\ mock.patch.object(sys, "exit"),\ mock.patch.object(utils, "execute") as utilsexec_fn,\ mock.patch.object(self.agent, 'br_phys_cls') as phys_br_cls,\ mock.patch.object(self.agent, 'int_br') as int_br,\ mock.patch.object(ip_lib.IPWrapper, "add_veth") as addveth_fn,\ mock.patch.object(ip_lib.IpLinkCommand, "delete") as linkdel_fn,\ mock.patch.object(ip_lib.IpLinkCommand, "set_up"),\ mock.patch.object(ip_lib.IpLinkCommand, "set_mtu"),\ mock.patch.object(ovs_lib.BaseOVS, "get_bridges") as get_br_fn: devex_fn.return_value = True parent = mock.MagicMock() parent.attach_mock(utilsexec_fn, 'utils_execute') parent.attach_mock(linkdel_fn, 'link_delete') parent.attach_mock(addveth_fn, 'add_veth') addveth_fn.return_value = (ip_lib.IPDevice("int-br-eth1"), ip_lib.IPDevice("phy-br-eth1")) phys_br = phys_br_cls() phys_br.add_port.return_value = "phys_veth_ofport" int_br.add_port.return_value = "int_veth_ofport" get_br_fn.return_value = ["br-eth"] self.agent.setup_physical_bridges({"physnet1": "br-eth"}) expected_calls = [mock.call.link_delete(), mock.call.utils_execute(['udevadm', 'settle', '--timeout=10']), mock.call.add_veth('int-br-eth', 'phy-br-eth')] parent.assert_has_calls(expected_calls, any_order=False) self.assertEqual(self.agent.int_ofports["physnet1"], "int_veth_ofport") self.assertEqual(self.agent.phys_ofports["physnet1"], "phys_veth_ofport") def test_setup_physical_bridges_change_from_veth_to_patch_conf(self): with mock.patch.object(sys, "exit"),\ mock.patch.object(utils, "execute"),\ mock.patch.object(self.agent, 'br_phys_cls') as phys_br_cls,\ mock.patch.object(self.agent, 'int_br') as int_br,\ mock.patch.object(self.agent.int_br, 'db_get_val', return_value='veth'): phys_br = phys_br_cls() parent = mock.MagicMock() parent.attach_mock(phys_br_cls, 'phys_br_cls') parent.attach_mock(phys_br, 'phys_br') parent.attach_mock(int_br, 'int_br') phys_br.add_patch_port.return_value = "phy_ofport" int_br.add_patch_port.return_value = "int_ofport" self.agent.setup_physical_bridges({"physnet1": "br-eth"}) expected_calls = [ mock.call.phys_br_cls('br-eth'), mock.call.phys_br.setup_controllers(mock.ANY), mock.call.phys_br.setup_default_table(), mock.call.int_br.delete_port('int-br-eth'), mock.call.phys_br.delete_port('phy-br-eth'), mock.call.int_br.add_patch_port('int-br-eth', constants.NONEXISTENT_PEER), mock.call.phys_br.add_patch_port('phy-br-eth', constants.NONEXISTENT_PEER), mock.call.int_br.drop_port(in_port='int_ofport'), mock.call.phys_br.drop_port(in_port='phy_ofport'), mock.call.int_br.set_db_attribute('Interface', 'int-br-eth', 'options:peer', 'phy-br-eth'), mock.call.phys_br.set_db_attribute('Interface', 'phy-br-eth', 'options:peer', 'int-br-eth'), ] parent.assert_has_calls(expected_calls) self.assertEqual(self.agent.int_ofports["physnet1"], "int_ofport") self.assertEqual(self.agent.phys_ofports["physnet1"], "phy_ofport") def test_get_peer_name(self): bridge1 = "A_REALLY_LONG_BRIDGE_NAME1" bridge2 = "A_REALLY_LONG_BRIDGE_NAME2" self.agent.use_veth_interconnection = True self.assertEqual(len(self.agent.get_peer_name('int-', bridge1)), n_const.DEVICE_NAME_MAX_LEN) self.assertEqual(len(self.agent.get_peer_name('int-', bridge2)), n_const.DEVICE_NAME_MAX_LEN) self.assertNotEqual(self.agent.get_peer_name('int-', bridge1), self.agent.get_peer_name('int-', bridge2)) def test_setup_tunnel_br(self): self.tun_br = mock.Mock() with mock.patch.object(self.agent.int_br, "add_patch_port", return_value=1) as int_patch_port,\ mock.patch.object(self.agent.tun_br, "add_patch_port", return_value=1) as tun_patch_port,\ mock.patch.object(self.agent.tun_br, 'bridge_exists', return_value=False),\ mock.patch.object(self.agent.tun_br, 'create') as create_tun,\ mock.patch.object(self.agent.tun_br, 'setup_controllers') as setup_controllers,\ mock.patch.object(self.agent.tun_br, 'port_exists', return_value=False),\ mock.patch.object(self.agent.int_br, 'port_exists', return_value=False),\ mock.patch.object(sys, "exit"): self.agent.setup_tunnel_br(None) self.agent.setup_tunnel_br() self.assertTrue(create_tun.called) self.assertTrue(setup_controllers.called) self.assertTrue(int_patch_port.called) self.assertTrue(tun_patch_port.called) def test_setup_tunnel_br_ports_exits_drop_flows(self): cfg.CONF.set_override('drop_flows_on_start', True, 'AGENT') with mock.patch.object(self.agent.tun_br, 'port_exists', return_value=True),\ mock.patch.object(self.agent, 'tun_br'),\ mock.patch.object(self.agent.int_br, 'port_exists', return_value=True),\ mock.patch.object(self.agent.tun_br, 'setup_controllers'),\ mock.patch.object(self.agent, 'patch_tun_ofport', new=2),\ mock.patch.object(self.agent, 'patch_int_ofport', new=2),\ mock.patch.object(self.agent.tun_br, 'delete_flows') as delete,\ mock.patch.object(self.agent.int_br, "add_patch_port") as int_patch_port,\ mock.patch.object(self.agent.tun_br, "add_patch_port") as tun_patch_port,\ mock.patch.object(sys, "exit"): self.agent.setup_tunnel_br(None) self.agent.setup_tunnel_br() self.assertFalse(int_patch_port.called) self.assertFalse(tun_patch_port.called) self.assertTrue(delete.called) def test_setup_tunnel_port(self): self.agent.tun_br = mock.Mock() self.agent.l2_pop = False self.agent.udp_vxlan_port = 8472 self.agent.tun_br_ofports['vxlan'] = {} with mock.patch.object(self.agent.tun_br, "add_tunnel_port", return_value='6') as add_tun_port_fn,\ mock.patch.object(self.agent.tun_br, "add_flow"): self.agent._setup_tunnel_port(self.agent.tun_br, 'portname', '1.2.3.4', 'vxlan') self.assertTrue(add_tun_port_fn.called) def test_port_unbound(self): with mock.patch.object(self.agent, "reclaim_local_vlan") as reclvl_fn: self.agent.enable_tunneling = True lvm = mock.Mock() lvm.network_type = "gre" lvm.vif_ports = {"vif1": mock.Mock()} self.agent.local_vlan_map["netuid12345"] = lvm self.agent.port_unbound("vif1", "netuid12345") self.assertTrue(reclvl_fn.called) lvm.vif_ports = {} self.agent.port_unbound("vif1", "netuid12345") self.assertEqual(reclvl_fn.call_count, 2) lvm.vif_ports = {"vif1": mock.Mock()} self.agent.port_unbound("vif3", "netuid12345") self.assertEqual(reclvl_fn.call_count, 2) def _prepare_l2_pop_ofports(self): lvm1 = mock.Mock() lvm1.network_type = 'gre' lvm1.vlan = 'vlan1' lvm1.segmentation_id = 'seg1' lvm1.tun_ofports = set(['1']) lvm2 = mock.Mock() lvm2.network_type = 'gre' lvm2.vlan = 'vlan2' lvm2.segmentation_id = 'seg2' lvm2.tun_ofports = set(['1', '2']) self.agent.local_vlan_map = {'net1': lvm1, 'net2': lvm2} self.agent.tun_br_ofports = {'gre': {'1.1.1.1': '1', '2.2.2.2': '2'}} self.agent.arp_responder_enabled = True def test_fdb_ignore_network(self): self._prepare_l2_pop_ofports() fdb_entry = {'net3': {}} with mock.patch.object(self.agent.tun_br, 'add_flow') as add_flow_fn,\ mock.patch.object(self.agent.tun_br, 'delete_flows') as del_flow_fn,\ mock.patch.object(self.agent, '_setup_tunnel_port') as add_tun_fn,\ mock.patch.object(self.agent, 'cleanup_tunnel_port') as clean_tun_fn: self.agent.fdb_add(None, fdb_entry) self.assertFalse(add_flow_fn.called) self.assertFalse(add_tun_fn.called) self.agent.fdb_remove(None, fdb_entry) self.assertFalse(del_flow_fn.called) self.assertFalse(clean_tun_fn.called) def test_fdb_ignore_self(self): self._prepare_l2_pop_ofports() self.agent.local_ip = 'agent_ip' fdb_entry = {'net2': {'network_type': 'gre', 'segment_id': 'tun2', 'ports': {'agent_ip': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1), n_const.FLOODING_ENTRY]}}} with mock.patch.object(self.agent.tun_br, "deferred") as defer_fn: self.agent.fdb_add(None, fdb_entry) self.assertFalse(defer_fn.called) self.agent.fdb_remove(None, fdb_entry) self.assertFalse(defer_fn.called) def test_fdb_add_flows(self): self._prepare_l2_pop_ofports() fdb_entry = {'net1': {'network_type': 'gre', 'segment_id': 'tun1', 'ports': {'2.2.2.2': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1), n_const.FLOODING_ENTRY]}}} with mock.patch.object(self.agent, 'tun_br', autospec=True) as tun_br,\ mock.patch.object(self.agent, '_setup_tunnel_port', autospec=True) as add_tun_fn: self.agent.fdb_add(None, fdb_entry) self.assertFalse(add_tun_fn.called) deferred_br_call = mock.call.deferred().__enter__() expected_calls = [ deferred_br_call.install_arp_responder('vlan1', FAKE_IP1, FAKE_MAC), deferred_br_call.install_unicast_to_tun('vlan1', 'seg1', '2', FAKE_MAC), deferred_br_call.install_flood_to_tun('vlan1', 'seg1', set(['1', '2'])), ] tun_br.assert_has_calls(expected_calls) def test_fdb_del_flows(self): self._prepare_l2_pop_ofports() fdb_entry = {'net2': {'network_type': 'gre', 'segment_id': 'tun2', 'ports': {'2.2.2.2': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1), n_const.FLOODING_ENTRY]}}} with mock.patch.object(self.agent, 'tun_br', autospec=True) as br_tun: self.agent.fdb_remove(None, fdb_entry) deferred_br_call = mock.call.deferred().__enter__() expected_calls = [ mock.call.deferred(), mock.call.deferred().__enter__(), deferred_br_call.delete_arp_responder('vlan2', FAKE_IP1), deferred_br_call.delete_unicast_to_tun('vlan2', FAKE_MAC), deferred_br_call.install_flood_to_tun('vlan2', 'seg2', set(['1'])), deferred_br_call.delete_port('gre-02020202'), deferred_br_call.cleanup_tunnel_port('2'), mock.call.deferred().__exit__(None, None, None), ] br_tun.assert_has_calls(expected_calls) def test_fdb_add_port(self): self._prepare_l2_pop_ofports() fdb_entry = {'net1': {'network_type': 'gre', 'segment_id': 'tun1', 'ports': {'1.1.1.1': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1)]}}} with mock.patch.object(self.agent, 'tun_br', autospec=True) as tun_br,\ mock.patch.object(self.agent, '_setup_tunnel_port') as add_tun_fn: self.agent.fdb_add(None, fdb_entry) self.assertFalse(add_tun_fn.called) fdb_entry['net1']['ports']['10.10.10.10'] = [ l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1)] self.agent.fdb_add(None, fdb_entry) deferred_br = tun_br.deferred().__enter__() add_tun_fn.assert_called_with( deferred_br, 'gre-0a0a0a0a', '10.10.10.10', 'gre') def test_fdb_del_port(self): self._prepare_l2_pop_ofports() fdb_entry = {'net2': {'network_type': 'gre', 'segment_id': 'tun2', 'ports': {'2.2.2.2': [n_const.FLOODING_ENTRY]}}} with mock.patch.object(self.agent.tun_br, 'deferred') as defer_fn,\ mock.patch.object(self.agent.tun_br, 'delete_port') as delete_port_fn: self.agent.fdb_remove(None, fdb_entry) deferred_br = defer_fn().__enter__() deferred_br.delete_port.assert_called_once_with('gre-02020202') self.assertFalse(delete_port_fn.called) def test_fdb_update_chg_ip(self): self._prepare_l2_pop_ofports() fdb_entries = {'chg_ip': {'net1': {'agent_ip': {'before': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1)], 'after': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP2)]}}}} with mock.patch.object(self.agent.tun_br, 'deferred') as deferred_fn: self.agent.fdb_update(None, fdb_entries) deferred_br = deferred_fn().__enter__() deferred_br.assert_has_calls([ mock.call.install_arp_responder('vlan1', FAKE_IP2, FAKE_MAC), mock.call.delete_arp_responder('vlan1', FAKE_IP1) ]) def test_del_fdb_flow_idempotency(self): lvm = mock.Mock() lvm.network_type = 'gre' lvm.vlan = 'vlan1' lvm.segmentation_id = 'seg1' lvm.tun_ofports = set(['1', '2']) with mock.patch.object(self.agent.tun_br, 'mod_flow') as mod_flow_fn,\ mock.patch.object(self.agent.tun_br, 'delete_flows') as delete_flows_fn: self.agent.del_fdb_flow(self.agent.tun_br, n_const.FLOODING_ENTRY, '1.1.1.1', lvm, '3') self.assertFalse(mod_flow_fn.called) self.assertFalse(delete_flows_fn.called) def test_recl_lv_port_to_preserve(self): self._prepare_l2_pop_ofports() self.agent.l2_pop = True self.agent.enable_tunneling = True with mock.patch.object(self.agent, 'tun_br', autospec=True) as tun_br: self.agent.reclaim_local_vlan('net1') self.assertFalse(tun_br.cleanup_tunnel_port.called) def test_recl_lv_port_to_remove(self): self._prepare_l2_pop_ofports() self.agent.l2_pop = True self.agent.enable_tunneling = True with mock.patch.object(self.agent, 'tun_br', autospec=True) as tun_br: self.agent.reclaim_local_vlan('net2') tun_br.delete_port.assert_called_once_with('gre-02020202') def test_daemon_loop_uses_polling_manager(self): with mock.patch( 'neutron.agent.common.polling.get_polling_manager') as mock_get_pm: with mock.patch.object(self.agent, 'rpc_loop') as mock_loop: self.agent.daemon_loop() mock_get_pm.assert_called_with(True, constants.DEFAULT_OVSDBMON_RESPAWN) mock_loop.assert_called_once_with(polling_manager=mock.ANY) def test_setup_tunnel_port_invalid_ofport(self): with mock.patch.object( self.agent.tun_br, 'add_tunnel_port', return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\ mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn: ofport = self.agent._setup_tunnel_port( self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE) add_tunnel_port_fn.assert_called_once_with( 'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE, self.agent.vxlan_udp_port, self.agent.dont_fragment, self.agent.tunnel_csum) log_error_fn.assert_called_once_with( _("Failed to set-up %(type)s tunnel port to %(ip)s"), {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'}) self.assertEqual(ofport, 0) def test_setup_tunnel_port_error_negative_df_disabled(self): with mock.patch.object( self.agent.tun_br, 'add_tunnel_port', return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\ mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn: self.agent.dont_fragment = False self.agent.tunnel_csum = False ofport = self.agent._setup_tunnel_port( self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE) add_tunnel_port_fn.assert_called_once_with( 'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE, self.agent.vxlan_udp_port, self.agent.dont_fragment, self.agent.tunnel_csum) log_error_fn.assert_called_once_with( _("Failed to set-up %(type)s tunnel port to %(ip)s"), {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'}) self.assertEqual(ofport, 0) def test_setup_tunnel_port_error_negative_tunnel_csum(self): with mock.patch.object( self.agent.tun_br, 'add_tunnel_port', return_value=ovs_lib.INVALID_OFPORT) as add_tunnel_port_fn,\ mock.patch.object(self.mod_agent.LOG, 'error') as log_error_fn: self.agent.dont_fragment = True self.agent.tunnel_csum = True ofport = self.agent._setup_tunnel_port( self.agent.tun_br, 'gre-1', 'remote_ip', p_const.TYPE_GRE) add_tunnel_port_fn.assert_called_once_with( 'gre-1', 'remote_ip', self.agent.local_ip, p_const.TYPE_GRE, self.agent.vxlan_udp_port, self.agent.dont_fragment, self.agent.tunnel_csum) log_error_fn.assert_called_once_with( _("Failed to set-up %(type)s tunnel port to %(ip)s"), {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'}) self.assertEqual(ofport, 0) def test_tunnel_sync_with_ml2_plugin(self): fake_tunnel_details = {'tunnels': [{'ip_address': '100.101.31.15'}]} with mock.patch.object(self.agent.plugin_rpc, 'tunnel_sync', return_value=fake_tunnel_details),\ mock.patch.object( self.agent, '_setup_tunnel_port') as _setup_tunnel_port_fn,\ mock.patch.object(self.agent, 'cleanup_stale_flows') as cleanup: self.agent.tunnel_types = ['vxlan'] self.agent.tunnel_sync() expected_calls = [mock.call(self.agent.tun_br, 'vxlan-64651f0f', '100.101.31.15', 'vxlan')] _setup_tunnel_port_fn.assert_has_calls(expected_calls) self.assertEqual([], cleanup.mock_calls) def test_tunnel_sync_invalid_ip_address(self): fake_tunnel_details = {'tunnels': [{'ip_address': '300.300.300.300'}, {'ip_address': '100.100.100.100'}]} with mock.patch.object(self.agent.plugin_rpc, 'tunnel_sync', return_value=fake_tunnel_details),\ mock.patch.object( self.agent, '_setup_tunnel_port') as _setup_tunnel_port_fn,\ mock.patch.object(self.agent, 'cleanup_stale_flows') as cleanup: self.agent.tunnel_types = ['vxlan'] self.agent.tunnel_sync() _setup_tunnel_port_fn.assert_called_once_with(self.agent.tun_br, 'vxlan-64646464', '100.100.100.100', 'vxlan') self.assertEqual([], cleanup.mock_calls) def test_tunnel_update(self): kwargs = {'tunnel_ip': '10.10.10.10', 'tunnel_type': 'gre'} self.agent._setup_tunnel_port = mock.Mock() self.agent.enable_tunneling = True self.agent.tunnel_types = ['gre'] self.agent.l2_pop = False self.agent.tunnel_update(context=None, **kwargs) expected_calls = [ mock.call(self.agent.tun_br, 'gre-0a0a0a0a', '10.10.10.10', 'gre')] self.agent._setup_tunnel_port.assert_has_calls(expected_calls) def test_tunnel_delete(self): kwargs = {'tunnel_ip': '10.10.10.10', 'tunnel_type': 'gre'} self.agent.enable_tunneling = True self.agent.tunnel_types = ['gre'] self.agent.tun_br_ofports = {'gre': {'10.10.10.10': '1'}} with mock.patch.object( self.agent, 'cleanup_tunnel_port' ) as clean_tun_fn: self.agent.tunnel_delete(context=None, **kwargs) self.assertTrue(clean_tun_fn.called) def _test_ovs_status(self, *args): reply2 = {'current': set(['tap0']), 'added': set(['tap2']), 'removed': set([])} reply3 = {'current': set(['tap2']), 'added': set([]), 'removed': set(['tap0'])} with mock.patch.object(async_process.AsyncProcess, "_spawn"),\ mock.patch.object(log.KeywordArgumentAdapter, 'exception') as log_exception,\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'scan_ports') as scan_ports,\ mock.patch.object( self.mod_agent.OVSNeutronAgent, 'process_network_ports') as process_network_ports,\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'check_ovs_status') as check_ovs_status,\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br') as setup_int_br,\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_physical_bridges') as setup_phys_br,\ mock.patch.object(time, 'sleep'),\ mock.patch.object( self.mod_agent.OVSNeutronAgent, 'update_stale_ofport_rules') as update_stale, \ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'cleanup_stale_flows') as cleanup: log_exception.side_effect = Exception( 'Fake exception to get out of the loop') scan_ports.side_effect = [reply2, reply3] process_network_ports.side_effect = [ False, Exception('Fake exception to get out of the loop')] check_ovs_status.side_effect = args try: self.agent.daemon_loop() except Exception: pass scan_ports.assert_has_calls([ mock.call(set(), True, set()), mock.call(set(), False, set()) ]) process_network_ports.assert_has_calls([ mock.call(reply2, False), mock.call(reply3, True) ]) cleanup.assert_called_once_with() self.assertTrue(update_stale.called) # Verify the OVS restart we triggered in the loop # re-setup the bridges setup_int_br.assert_has_calls([mock.call()]) setup_phys_br.assert_has_calls([mock.call({})]) def test_ovs_status(self): self._test_ovs_status(constants.OVS_NORMAL, constants.OVS_DEAD, constants.OVS_RESTARTED) # OVS will not DEAD in some exception, like DBConnectionError. self._test_ovs_status(constants.OVS_NORMAL, constants.OVS_RESTARTED) def test_set_rpc_timeout(self): self.agent._handle_sigterm(None, None) for rpc_client in (self.agent.plugin_rpc.client, self.agent.sg_plugin_rpc.client, self.agent.dvr_plugin_rpc.client, self.agent.state_rpc.client): self.assertEqual(10, rpc_client.timeout) def test_set_rpc_timeout_no_value(self): self.agent.quitting_rpc_timeout = None with mock.patch.object(self.agent, 'set_rpc_timeout') as mock_set_rpc: self.agent._handle_sigterm(None, None) self.assertFalse(mock_set_rpc.called) def test_arp_spoofing_network_port(self): int_br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection( int_br, FakeVif(), {'device_owner': 'network:router_interface'}) self.assertTrue(int_br.delete_arp_spoofing_protection.called) self.assertFalse(int_br.install_arp_spoofing_protection.called) def test_arp_spoofing_port_security_disabled(self): int_br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection( int_br, FakeVif(), {'port_security_enabled': False}) self.assertTrue(int_br.delete_arp_spoofing_protection.called) self.assertFalse(int_br.install_arp_spoofing_protection.called) def test_arp_spoofing_basic_rule_setup(self): vif = FakeVif() fake_details = {'fixed_ips': [], 'device_owner': 'nobody'} self.agent.prevent_arp_spoofing = True int_br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection(int_br, vif, fake_details) self.assertEqual( [mock.call(port=vif.ofport)], int_br.delete_arp_spoofing_protection.mock_calls) self.assertEqual( [mock.call(ip_addresses=set(), port=vif.ofport)], int_br.install_arp_spoofing_protection.mock_calls) def test_arp_spoofing_basic_rule_setup_fixed_ipv6(self): vif = FakeVif() fake_details = {'fixed_ips': [{'ip_address': 'fdf8:f53b:82e4::1'}], 'device_owner': 'nobody'} self.agent.prevent_arp_spoofing = True br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection(br, vif, fake_details) self.assertEqual( [mock.call(port=vif.ofport)], br.delete_arp_spoofing_protection.mock_calls) self.assertTrue(br.install_icmpv6_na_spoofing_protection.called) def test_arp_spoofing_fixed_and_allowed_addresses(self): vif = FakeVif() fake_details = { 'device_owner': 'nobody', 'fixed_ips': [{'ip_address': '192.168.44.100'}, {'ip_address': '192.168.44.101'}], 'allowed_address_pairs': [{'ip_address': '192.168.44.102/32'}, {'ip_address': '192.168.44.103/32'}] } self.agent.prevent_arp_spoofing = True int_br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection(int_br, vif, fake_details) # make sure all addresses are allowed addresses = {'192.168.44.100', '192.168.44.101', '192.168.44.102/32', '192.168.44.103/32'} self.assertEqual( [mock.call(port=vif.ofport, ip_addresses=addresses)], int_br.install_arp_spoofing_protection.mock_calls) def test_arp_spoofing_fixed_and_allowed_addresses_ipv6(self): vif = FakeVif() fake_details = { 'device_owner': 'nobody', 'fixed_ips': [{'ip_address': '2001:db8::1'}, {'ip_address': '2001:db8::2'}], 'allowed_address_pairs': [{'ip_address': '2001:db8::200', 'mac_address': 'aa:22:33:44:55:66'}] } self.agent.prevent_arp_spoofing = True int_br = mock.create_autospec(self.agent.int_br) self.agent.setup_arp_spoofing_protection(int_br, vif, fake_details) # make sure all addresses are allowed including ipv6 LLAs addresses = {'2001:db8::1', '2001:db8::2', '2001:db8::200', 'fe80::a822:33ff:fe44:5566', 'fe80::a8bb:ccff:fe11:2233'} self.assertEqual( [mock.call(port=vif.ofport, ip_addresses=addresses)], int_br.install_icmpv6_na_spoofing_protection.mock_calls) def test__get_ofport_moves(self): previous = {'port1': 1, 'port2': 2} current = {'port1': 5, 'port2': 2} # we expect it to tell us port1 moved expected = ['port1'] self.assertEqual(expected, self.agent._get_ofport_moves(current, previous)) def test_update_stale_ofport_rules_clears_old(self): self.agent.prevent_arp_spoofing = True self.agent.vifname_to_ofport_map = {'port1': 1, 'port2': 2} self.agent.int_br = mock.Mock() # simulate port1 was removed newmap = {'port2': 2} self.agent.int_br.get_vif_port_to_ofport_map.return_value = newmap self.agent.update_stale_ofport_rules() # rules matching port 1 should have been deleted self.assertEqual( [mock.call(port=1)], self.agent.int_br.delete_arp_spoofing_protection.mock_calls) # make sure the state was updated with the new map self.assertEqual(self.agent.vifname_to_ofport_map, newmap) def test_update_stale_ofport_rules_treats_moved(self): self.agent.prevent_arp_spoofing = True self.agent.vifname_to_ofport_map = {'port1': 1, 'port2': 2} self.agent.treat_devices_added_or_updated = mock.Mock() self.agent.int_br = mock.Mock() # simulate port1 was moved newmap = {'port2': 2, 'port1': 90} self.agent.int_br.get_vif_port_to_ofport_map.return_value = newmap ofport_changed_ports = self.agent.update_stale_ofport_rules() self.assertEqual(['port1'], ofport_changed_ports) def test__setup_tunnel_port_while_new_mapping_is_added(self): """ Test that _setup_tunnel_port doesn't fail if new vlan mapping is added in a different coroutine while iterating over existing mappings. See bug 1449944 for more info. """ def add_new_vlan_mapping(*args, **kwargs): self.agent.local_vlan_map['bar'] = ( self.mod_agent.LocalVLANMapping(1, 2, 3, 4)) bridge = mock.Mock() tunnel_type = 'vxlan' self.agent.tun_br_ofports = {tunnel_type: dict()} self.agent.l2_pop = False self.agent.local_vlan_map = { 'foo': self.mod_agent.LocalVLANMapping(4, tunnel_type, 2, 1)} bridge.install_flood_to_tun.side_effect = add_new_vlan_mapping self.agent._setup_tunnel_port(bridge, 1, 2, tunnel_type=tunnel_type) self.assertIn('bar', self.agent.local_vlan_map) def test_setup_entry_for_arp_reply_ignores_ipv6_addresses(self): self.agent.arp_responder_enabled = True ip = '2001:db8::1' br = mock.Mock() self.agent.setup_entry_for_arp_reply( br, 'add', mock.Mock(), mock.Mock(), ip) self.assertFalse(br.install_arp_responder.called) class TestOvsNeutronAgentOFCtl(TestOvsNeutronAgent, ovs_test_base.OVSOFCtlTestBase): def test_cleanup_stale_flows_iter_0(self): with mock.patch.object(self.agent.int_br, 'agent_uuid_stamp', new=1234),\ mock.patch.object(self.agent.int_br, 'dump_flows_all_tables') as dump_flows,\ mock.patch.object(self.agent.int_br, 'delete_flows') as del_flow: dump_flows.return_value = [ 'cookie=0x4d2, duration=50.156s, table=0,actions=drop', 'cookie=0x4321, duration=54.143s, table=2, priority=0', 'cookie=0x2345, duration=50.125s, table=2, priority=0', 'cookie=0x4d2, duration=52.112s, table=3, actions=drop', ] self.agent.cleanup_stale_flows() expected = [ mock.call(cookie='0x4321/-1', table='2'), mock.call(cookie='0x2345/-1', table='2'), ] self.assertEqual(expected, del_flow.mock_calls) class TestOvsNeutronAgentRyu(TestOvsNeutronAgent, ovs_test_base.OVSRyuTestBase): def test_cleanup_stale_flows_iter_0(self): uint64_max = (1 << 64) - 1 with mock.patch.object(self.agent.int_br, 'agent_uuid_stamp', new=1234),\ mock.patch.object(self.agent.int_br, 'dump_flows') as dump_flows,\ mock.patch.object(self.agent.int_br, 'delete_flows') as del_flow: dump_flows.return_value = [ # mock ryu.ofproto.ofproto_v1_3_parser.OFPFlowStats mock.Mock(cookie=1234, table_id=0), mock.Mock(cookie=17185, table_id=2), mock.Mock(cookie=9029, table_id=2), mock.Mock(cookie=1234, table_id=3), ] self.agent.cleanup_stale_flows() expected = [mock.call(cookie=17185, cookie_mask=uint64_max), mock.call(cookie=9029, cookie_mask=uint64_max)] del_flow.assert_has_calls(expected, any_order=True) self.assertEqual(len(expected), len(del_flow.mock_calls)) class AncillaryBridgesTest(object): def setUp(self): super(AncillaryBridgesTest, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', group='SECURITYGROUP') cfg.CONF.set_override('report_interval', 0, 'AGENT') self.kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) def _test_ancillary_bridges(self, bridges, ancillary): device_ids = ancillary[:] def pullup_side_effect(*args): # Check that the device_id exists, if it does return it # if it does not return None try: device_ids.remove(args[0]) return args[0] except Exception: return None with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'),\ mock.patch('neutron.agent.linux.utils.get_interface_mac', return_value='00:00:00:00:00:01'),\ mock.patch('neutron.agent.common.ovs_lib.BaseOVS.get_bridges', return_value=bridges),\ mock.patch('neutron.agent.common.ovs_lib.BaseOVS.' 'get_bridge_external_bridge_id', side_effect=pullup_side_effect),\ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_ports_attributes', return_value=[]),\ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', return_value=[]): self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **self.kwargs) self.assertEqual(len(ancillary), len(self.agent.ancillary_brs)) if ancillary: bridges = [br.br_name for br in self.agent.ancillary_brs] for br in ancillary: self.assertIn(br, bridges) def test_ancillary_bridges_single(self): bridges = ['br-int', 'br-ex'] self._test_ancillary_bridges(bridges, ['br-ex']) def test_ancillary_bridges_none(self): bridges = ['br-int'] self._test_ancillary_bridges(bridges, []) def test_ancillary_bridges_multiple(self): bridges = ['br-int', 'br-ex1', 'br-ex2'] self._test_ancillary_bridges(bridges, ['br-ex1', 'br-ex2']) def mock_scan_ancillary_ports(self, vif_port_set=None, registered_ports=None, sync=False): bridges = ['br-int', 'br-ex'] ancillary = ['br-ex'] with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'), \ mock.patch.object(self.mod_agent.OVSNeutronAgent, '_restore_local_vlan_map'), \ mock.patch('neutron.agent.common.ovs_lib.BaseOVS.get_bridges', return_value=bridges), \ mock.patch('neutron.agent.common.ovs_lib.BaseOVS.' 'get_bridge_external_bridge_id', side_effect=ancillary), \ mock.patch('neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_port_set', return_value=vif_port_set): self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **self.kwargs) return self.agent.scan_ancillary_ports(registered_ports, sync) def test_scan_ancillary_ports_returns_cur_only_for_unchanged_ports(self): vif_port_set = set([1, 2]) registered_ports = set([1, 2]) expected = dict(current=vif_port_set) actual = self.mock_scan_ancillary_ports(vif_port_set, registered_ports) self.assertEqual(expected, actual) def test_scan_ancillary_ports_returns_port_changes(self): vif_port_set = set([1, 3]) registered_ports = set([1, 2]) expected = dict(current=vif_port_set, added=set([3]), removed=set([2])) actual = self.mock_scan_ancillary_ports(vif_port_set, registered_ports) self.assertEqual(expected, actual) def test_scan_ancillary_ports_returns_port_changes_with_sync(self): vif_port_set = set([1, 3]) registered_ports = set([1, 2]) expected = dict(current=vif_port_set, added=vif_port_set, removed=set([2])) actual = self.mock_scan_ancillary_ports(vif_port_set, registered_ports, sync=True) self.assertEqual(expected, actual) class AncillaryBridgesTestOFCtl(AncillaryBridgesTest, ovs_test_base.OVSOFCtlTestBase): pass class AncillaryBridgesTestRyu(AncillaryBridgesTest, ovs_test_base.OVSRyuTestBase): pass class TestOvsDvrNeutronAgent(object): def setUp(self): super(TestOvsDvrNeutronAgent, self).setUp() notifier_p = mock.patch(NOTIFIER) notifier_cls = notifier_p.start() self.notifier = mock.Mock() notifier_cls.return_value = self.notifier cfg.CONF.set_default('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', group='SECURITYGROUP') kwargs = self.mod_agent.create_agent_config_map(cfg.CONF) with mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_integration_br'),\ mock.patch.object(self.mod_agent.OVSNeutronAgent, 'setup_ancillary_bridges', return_value=[]),\ mock.patch('neutron.agent.linux.utils.get_interface_mac', return_value='00:00:00:00:00:01'),\ mock.patch( 'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'),\ mock.patch('oslo_service.loopingcall.' 'FixedIntervalLoopingCall', new=MockFixedIntervalLoopingCall),\ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_ports_attributes', return_value=[]),\ mock.patch( 'neutron.agent.common.ovs_lib.OVSBridge.' 'get_vif_ports', return_value=[]): self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(), **kwargs) # set back to true because initial report state will succeed due # to mocked out RPC calls self.agent.use_call = True self.agent.tun_br = self.br_tun_cls(br_name='br-tun') self.agent.sg_agent = mock.Mock() def _setup_for_dvr_test(self): self._port = mock.Mock() self._port.ofport = 10 self._port.vif_id = "1234-5678-90" self._physical_network = 'physeth1' self._old_local_vlan = None self._segmentation_id = 2001 self.agent.enable_distributed_routing = True self.agent.enable_tunneling = True self.agent.patch_tun_ofport = 1 self.agent.patch_int_ofport = 2 self.agent.dvr_agent.local_ports = {} self.agent.local_vlan_map = {} self.agent.dvr_agent.enable_distributed_routing = True self.agent.dvr_agent.enable_tunneling = True self.agent.dvr_agent.patch_tun_ofport = 1 self.agent.dvr_agent.patch_int_ofport = 2 self.agent.dvr_agent.tun_br = mock.Mock() self.agent.dvr_agent.phys_brs[self._physical_network] = mock.Mock() self.agent.dvr_agent.bridge_mappings = {self._physical_network: 'br-eth1'} self.agent.dvr_agent.int_ofports[self._physical_network] = 30 self.agent.dvr_agent.phys_ofports[self._physical_network] = 40 self.agent.dvr_agent.local_dvr_map = {} self.agent.dvr_agent.registered_dvr_macs = set() self.agent.dvr_agent.dvr_mac_address = 'aa:22:33:44:55:66' self._net_uuid = 'my-net-uuid' self._fixed_ips = [{'subnet_id': 'my-subnet-uuid', 'ip_address': '1.1.1.1'}] self._compute_port = mock.Mock() self._compute_port.ofport = 20 self._compute_port.vif_id = "1234-5678-91" self._compute_fixed_ips = [{'subnet_id': 'my-subnet-uuid', 'ip_address': '1.1.1.3'}] @staticmethod def _expected_port_bound(port, lvid, is_dvr=True): resp = [ mock.call.db_get_val('Port', port.port_name, 'other_config'), mock.call.set_db_attribute('Port', port.port_name, 'other_config', mock.ANY), ] if is_dvr: resp = [mock.call.get_vifs_by_ids([])] + resp return resp def _expected_install_dvr_process(self, lvid, port, ip_version, gateway_ip, gateway_mac): if ip_version == 4: ipvx_calls = [ mock.call.install_dvr_process_ipv4( vlan_tag=lvid, gateway_ip=gateway_ip), ] else: ipvx_calls = [ mock.call.install_dvr_process_ipv6( vlan_tag=lvid, gateway_mac=gateway_mac), ] return ipvx_calls + [ mock.call.install_dvr_process( vlan_tag=lvid, dvr_mac_address=self.agent.dvr_agent.dvr_mac_address, vif_mac=port.vif_mac, ), ] def _test_port_bound_for_dvr_on_vlan_network(self, device_owner, ip_version=4): self._setup_for_dvr_test() if ip_version == 4: gateway_ip = '1.1.1.1' cidr = '1.1.1.0/24' else: gateway_ip = '2001:100::1' cidr = '2001:100::0/64' self._port.vif_mac = gateway_mac = 'aa:bb:cc:11:22:33' self._compute_port.vif_mac = '77:88:99:00:11:22' physical_network = self._physical_network segmentation_id = self._segmentation_id network_type = p_const.TYPE_VLAN int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) phys_br = mock.create_autospec(self.br_phys_cls('br-phys')) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': gateway_ip, 'cidr': cidr, 'ip_version': ip_version, 'gateway_mac': gateway_mac}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.phys_brs, {physical_network: phys_br}),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.dvr_agent.phys_brs, {physical_network: phys_br}): self.agent.port_bound( self._port, self._net_uuid, network_type, physical_network, segmentation_id, self._fixed_ips, n_const.DEVICE_OWNER_DVR_INTERFACE, False) phy_ofp = self.agent.dvr_agent.phys_ofports[physical_network] int_ofp = self.agent.dvr_agent.int_ofports[physical_network] lvid = self.agent.local_vlan_map[self._net_uuid].vlan expected_on_phys_br = [ mock.call.provision_local_vlan( port=phy_ofp, lvid=lvid, segmentation_id=segmentation_id, distributed=True, ), ] + self._expected_install_dvr_process( port=self._port, lvid=lvid, ip_version=ip_version, gateway_ip=gateway_ip, gateway_mac=gateway_mac) expected_on_int_br = [ mock.call.provision_local_vlan( port=int_ofp, lvid=lvid, segmentation_id=segmentation_id, ), ] + self._expected_port_bound(self._port, lvid) self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual([], tun_br.mock_calls) self.assertEqual(expected_on_phys_br, phys_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() phys_br.reset_mock() self.agent.port_bound(self._compute_port, self._net_uuid, network_type, physical_network, segmentation_id, self._compute_fixed_ips, device_owner, False) expected_on_int_br = [ mock.call.install_dvr_to_src_mac( network_type=network_type, gateway_mac=gateway_mac, dst_mac=self._compute_port.vif_mac, dst_port=self._compute_port.ofport, vlan_tag=segmentation_id, ), ] + self._expected_port_bound(self._compute_port, lvid, False) self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertFalse([], tun_br.mock_calls) self.assertFalse([], phys_br.mock_calls) def _test_port_bound_for_dvr_on_vxlan_network(self, device_owner, ip_version=4): self._setup_for_dvr_test() if ip_version == 4: gateway_ip = '1.1.1.1' cidr = '1.1.1.0/24' else: gateway_ip = '2001:100::1' cidr = '2001:100::0/64' network_type = p_const.TYPE_VXLAN self._port.vif_mac = gateway_mac = 'aa:bb:cc:11:22:33' self._compute_port.vif_mac = '77:88:99:00:11:22' physical_network = self._physical_network segmentation_id = self._segmentation_id int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) phys_br = mock.create_autospec(self.br_phys_cls('br-phys')) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': gateway_ip, 'cidr': cidr, 'ip_version': ip_version, 'gateway_mac': gateway_mac}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.phys_brs, {physical_network: phys_br}),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.dvr_agent.phys_brs, {physical_network: phys_br}): self.agent.port_bound( self._port, self._net_uuid, network_type, physical_network, segmentation_id, self._fixed_ips, n_const.DEVICE_OWNER_DVR_INTERFACE, False) lvid = self.agent.local_vlan_map[self._net_uuid].vlan expected_on_int_br = self._expected_port_bound( self._port, lvid) expected_on_tun_br = [ mock.call.provision_local_vlan( network_type=network_type, segmentation_id=segmentation_id, lvid=lvid, distributed=True), ] + self._expected_install_dvr_process( port=self._port, lvid=lvid, ip_version=ip_version, gateway_ip=gateway_ip, gateway_mac=gateway_mac) self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual(expected_on_tun_br, tun_br.mock_calls) self.assertEqual([], phys_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() phys_br.reset_mock() self.agent.port_bound(self._compute_port, self._net_uuid, network_type, physical_network, segmentation_id, self._compute_fixed_ips, device_owner, False) expected_on_int_br = [ mock.call.install_dvr_to_src_mac( network_type=network_type, gateway_mac=gateway_mac, dst_mac=self._compute_port.vif_mac, dst_port=self._compute_port.ofport, vlan_tag=lvid, ), ] + self._expected_port_bound(self._compute_port, lvid, False) self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual([], tun_br.mock_calls) self.assertEqual([], phys_br.mock_calls) def test_port_bound_for_dvr_with_compute_ports(self): self._test_port_bound_for_dvr_on_vlan_network( device_owner="compute:None") self._test_port_bound_for_dvr_on_vlan_network( device_owner="compute:None", ip_version=6) self._test_port_bound_for_dvr_on_vxlan_network( device_owner="compute:None") self._test_port_bound_for_dvr_on_vxlan_network( device_owner="compute:None", ip_version=6) def test_port_bound_for_dvr_with_lbaas_vip_ports(self): self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCER) self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCER, ip_version=6) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCER) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCER, ip_version=6) def test_port_bound_for_dvr_with_lbaasv2_vip_ports(self): self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) def test_port_bound_for_dvr_with_dhcp_ports(self): self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_DHCP) self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_DHCP, ip_version=6) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_DHCP) self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_DHCP, ip_version=6) def test_port_bound_for_dvr_with_csnat_ports(self): self._setup_for_dvr_test() int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': '1.1.1.1', 'cidr': '1.1.1.0/24', 'ip_version': 4, 'gateway_mac': 'aa:bb:cc:11:22:33'}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br): self.agent.port_bound( self._port, self._net_uuid, 'vxlan', None, None, self._fixed_ips, n_const.DEVICE_OWNER_ROUTER_SNAT, False) lvid = self.agent.local_vlan_map[self._net_uuid].vlan expected_on_int_br = [ mock.call.install_dvr_to_src_mac( network_type='vxlan', gateway_mac='aa:bb:cc:11:22:33', dst_mac=self._port.vif_mac, dst_port=self._port.ofport, vlan_tag=lvid, ), ] + self._expected_port_bound(self._port, lvid, is_dvr=False) self.assertEqual(expected_on_int_br, int_br.mock_calls) expected_on_tun_br = [ mock.call.provision_local_vlan( network_type='vxlan', lvid=lvid, segmentation_id=None, distributed=True, ), ] self.assertEqual(expected_on_tun_br, tun_br.mock_calls) def test_treat_devices_removed_for_dvr_interface(self): self._test_treat_devices_removed_for_dvr_interface() self._test_treat_devices_removed_for_dvr_interface(ip_version=6) self._test_treat_devices_removed_for_dvr_interface(network_type='vlan') self._test_treat_devices_removed_for_dvr_interface(ip_version=6, network_type='vlan') def _test_treat_devices_removed_for_dvr_interface( self, ip_version=4, network_type='vxlan'): self._setup_for_dvr_test() if ip_version == 4: gateway_ip = '1.1.1.1' cidr = '1.1.1.0/24' else: gateway_ip = '2001:100::1' cidr = '2001:100::0/64' gateway_mac = 'aa:bb:cc:11:22:33' int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': gateway_ip, 'cidr': cidr, 'ip_version': ip_version, 'gateway_mac': gateway_mac}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port): if network_type == 'vlan': self.agent.port_bound(self._port, self._net_uuid, network_type, self._physical_network, self._segmentation_id, self._compute_fixed_ips, n_const.DEVICE_OWNER_DVR_INTERFACE, False) else: self.agent.port_bound( self._port, self._net_uuid, 'vxlan', None, None, self._fixed_ips, n_const.DEVICE_OWNER_DVR_INTERFACE, False) lvid = self.agent.local_vlan_map[self._net_uuid].vlan self.assertEqual(self._expected_port_bound(self._port, lvid), int_br.mock_calls) expected_on_tun_br = [ mock.call.provision_local_vlan(network_type='vxlan', lvid=lvid, segmentation_id=None, distributed=True), ] + self._expected_install_dvr_process( port=self._port, lvid=lvid, ip_version=ip_version, gateway_ip=gateway_ip, gateway_mac=gateway_mac) self.assertEqual(expected_on_tun_br, tun_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() phys_br = mock.create_autospec(self.br_phys_cls('br-phys')) with mock.patch.object(self.agent, 'reclaim_local_vlan'),\ mock.patch.object(self.agent.plugin_rpc, 'update_device_list', return_value={ 'devices_up': [], 'devices_down': [self._port.vif_id], 'failed_devices_up': [], 'failed_devices_down': []}),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.phys_brs, {self._physical_network: phys_br}),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.dvr_agent.phys_brs, {self._physical_network: phys_br}): self.agent.treat_devices_removed([self._port.vif_id]) lvid = self.agent.local_vlan_map[self._net_uuid].vlan if ip_version == 4: expected = [ mock.call.delete_dvr_process_ipv4( vlan_tag=lvid, gateway_ip=gateway_ip), ] else: expected = [ mock.call.delete_dvr_process_ipv6( vlan_tag=lvid, gateway_mac=gateway_mac), ] expected.extend([ mock.call.delete_dvr_process( vlan_tag=lvid, vif_mac=self._port.vif_mac), ]) if network_type == 'vlan': self.assertEqual([], int_br.mock_calls) self.assertEqual([], tun_br.mock_calls) self.assertEqual(expected, phys_br.mock_calls) self.assertEqual({}, self.agent.dvr_agent.local_ports) else: self.assertEqual([], int_br.mock_calls) self.assertEqual(expected, tun_br.mock_calls) self.assertEqual([], phys_br.mock_calls) def _test_treat_devices_removed_for_dvr(self, device_owner, ip_version=4): self._setup_for_dvr_test() if ip_version == 4: gateway_ip = '1.1.1.1' cidr = '1.1.1.0/24' else: gateway_ip = '2001:100::1' cidr = '2001:100::0/64' gateway_mac = 'aa:bb:cc:11:22:33' int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': gateway_ip, 'cidr': cidr, 'ip_version': ip_version, 'gateway_mac': gateway_mac}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br): self.agent.port_bound( self._port, self._net_uuid, 'vxlan', None, None, self._fixed_ips, n_const.DEVICE_OWNER_DVR_INTERFACE, False) lvid = self.agent.local_vlan_map[self._net_uuid].vlan self.assertEqual( self._expected_port_bound(self._port, lvid), int_br.mock_calls) expected_on_tun_br = [ mock.call.provision_local_vlan( network_type='vxlan', segmentation_id=None, lvid=lvid, distributed=True), ] + self._expected_install_dvr_process( port=self._port, lvid=lvid, ip_version=ip_version, gateway_ip=gateway_ip, gateway_mac=gateway_mac) self.assertEqual(expected_on_tun_br, tun_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() self.agent.port_bound(self._compute_port, self._net_uuid, 'vxlan', None, None, self._compute_fixed_ips, device_owner, False) self.assertEqual( [ mock.call.install_dvr_to_src_mac( network_type='vxlan', gateway_mac='aa:bb:cc:11:22:33', dst_mac=self._compute_port.vif_mac, dst_port=self._compute_port.ofport, vlan_tag=lvid, ), ] + self._expected_port_bound(self._compute_port, lvid, False), int_br.mock_calls) self.assertEqual([], tun_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() with mock.patch.object(self.agent, 'reclaim_local_vlan'),\ mock.patch.object(self.agent.plugin_rpc, 'update_device_list', return_value={ 'devices_up': [], 'devices_down': [ self._compute_port.vif_id], 'failed_devices_up': [], 'failed_devices_down': []}),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br): self.agent.treat_devices_removed([self._compute_port.vif_id]) int_br.assert_has_calls([ mock.call.delete_dvr_to_src_mac( network_type='vxlan', vlan_tag=lvid, dst_mac=self._compute_port.vif_mac, ), ]) self.assertEqual([], tun_br.mock_calls) def test_treat_devices_removed_for_dvr_with_compute_ports(self): self._test_treat_devices_removed_for_dvr( device_owner="compute:None") self._test_treat_devices_removed_for_dvr( device_owner="compute:None", ip_version=6) def test_treat_devices_removed_for_dvr_with_lbaas_vip_ports(self): self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_LOADBALANCER) self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_LOADBALANCER, ip_version=6) def test_treat_devices_removed_for_dvr_with_lbaasv2_vip_ports(self): self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) def test_treat_devices_removed_for_dvr_with_dhcp_ports(self): self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_DHCP) self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_DHCP, ip_version=6) def test_treat_devices_removed_for_dvr_csnat_port(self): self._setup_for_dvr_test() gateway_mac = 'aa:bb:cc:11:22:33' int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) int_br.set_db_attribute.return_value = True int_br.db_get_val.return_value = {} with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_subnet_for_dvr', return_value={'gateway_ip': '1.1.1.1', 'cidr': '1.1.1.0/24', 'ip_version': 4, 'gateway_mac': gateway_mac}),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_ports_on_host_by_subnet', return_value=[]),\ mock.patch.object(self.agent.dvr_agent.int_br, 'get_vif_port_by_id', return_value=self._port),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br): self.agent.port_bound( self._port, self._net_uuid, 'vxlan', None, None, self._fixed_ips, n_const.DEVICE_OWNER_ROUTER_SNAT, False) lvid = self.agent.local_vlan_map[self._net_uuid].vlan expected_on_int_br = [ mock.call.install_dvr_to_src_mac( network_type='vxlan', gateway_mac=gateway_mac, dst_mac=self._port.vif_mac, dst_port=self._port.ofport, vlan_tag=lvid, ), ] + self._expected_port_bound(self._port, lvid, is_dvr=False) self.assertEqual(expected_on_int_br, int_br.mock_calls) expected_on_tun_br = [ mock.call.provision_local_vlan( network_type='vxlan', lvid=lvid, segmentation_id=None, distributed=True, ), ] self.assertEqual(expected_on_tun_br, tun_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() with mock.patch.object(self.agent, 'reclaim_local_vlan'),\ mock.patch.object(self.agent.plugin_rpc, 'update_device_list', return_value={ 'devices_up': [], 'devices_down': [self._port.vif_id], 'failed_devices_up': [], 'failed_devices_down': []}),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br): self.agent.treat_devices_removed([self._port.vif_id]) expected_on_int_br = [ mock.call.delete_dvr_to_src_mac( network_type='vxlan', dst_mac=self._port.vif_mac, vlan_tag=lvid, ), ] self.assertEqual(expected_on_int_br, int_br.mock_calls) expected_on_tun_br = [] self.assertEqual(expected_on_tun_br, tun_br.mock_calls) def test_setup_dvr_flows_on_int_br(self): self._setup_for_dvr_test() int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) with mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_list', return_value=[{'host': 'cn1', 'mac_address': 'aa:bb:cc:dd:ee:ff'}, {'host': 'cn2', 'mac_address': '11:22:33:44:55:66'}]): self.agent.dvr_agent.setup_dvr_flows_on_integ_br() self.assertTrue(self.agent.dvr_agent.in_distributed_mode()) physical_networks = list( self.agent.dvr_agent.bridge_mappings.keys()) ioport = self.agent.dvr_agent.int_ofports[physical_networks[0]] expected_on_int_br = [ # setup_dvr_flows_on_integ_br mock.call.setup_canary_table(), mock.call.install_drop(table_id=constants.DVR_TO_SRC_MAC, priority=1), mock.call.install_drop(table_id=constants.DVR_TO_SRC_MAC_VLAN, priority=1), mock.call.install_normal(table_id=constants.LOCAL_SWITCHING, priority=1), mock.call.install_drop(table_id=constants.LOCAL_SWITCHING, priority=2, in_port=ioport), ] self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual([], tun_br.mock_calls) def test_get_dvr_mac_address(self): self._setup_for_dvr_test() self.agent.dvr_agent.dvr_mac_address = None with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_by_host', return_value={'host': 'cn1', 'mac_address': 'aa:22:33:44:55:66'}): self.agent.dvr_agent.get_dvr_mac_address() self.assertEqual('aa:22:33:44:55:66', self.agent.dvr_agent.dvr_mac_address) self.assertTrue(self.agent.dvr_agent.in_distributed_mode()) def test_get_dvr_mac_address_exception(self): self._setup_for_dvr_test() self.agent.dvr_agent.dvr_mac_address = None int_br = mock.create_autospec(self.agent.int_br) with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_by_host', side_effect=oslo_messaging.RemoteError),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br): self.agent.dvr_agent.get_dvr_mac_address() self.assertIsNone(self.agent.dvr_agent.dvr_mac_address) self.assertFalse(self.agent.dvr_agent.in_distributed_mode()) self.assertEqual([mock.call.install_normal()], int_br.mock_calls) def test_get_dvr_mac_address_retried(self): valid_entry = {'host': 'cn1', 'mac_address': 'aa:22:33:44:55:66'} raise_timeout = oslo_messaging.MessagingTimeout() # Raise a timeout the first 2 times it calls get_dvr_mac_address() self._setup_for_dvr_test() self.agent.dvr_agent.dvr_mac_address = None with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_by_host', side_effect=(raise_timeout, raise_timeout, valid_entry)): self.agent.dvr_agent.get_dvr_mac_address() self.assertEqual('aa:22:33:44:55:66', self.agent.dvr_agent.dvr_mac_address) self.assertTrue(self.agent.dvr_agent.in_distributed_mode()) self.assertEqual(self.agent.dvr_agent.plugin_rpc. get_dvr_mac_address_by_host.call_count, 3) def test_get_dvr_mac_address_retried_max(self): raise_timeout = oslo_messaging.MessagingTimeout() # Raise a timeout every time until we give up, currently 5 tries self._setup_for_dvr_test() self.agent.dvr_agent.dvr_mac_address = None int_br = mock.create_autospec(self.agent.int_br) with mock.patch.object(self.agent.dvr_agent.plugin_rpc, 'get_dvr_mac_address_by_host', side_effect=raise_timeout),\ mock.patch.object(utils, "execute"),\ mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br): self.agent.dvr_agent.get_dvr_mac_address() self.assertIsNone(self.agent.dvr_agent.dvr_mac_address) self.assertFalse(self.agent.dvr_agent.in_distributed_mode()) self.assertEqual(self.agent.dvr_agent.plugin_rpc. get_dvr_mac_address_by_host.call_count, 5) def test_dvr_mac_address_update(self): self._setup_for_dvr_test() newhost = 'cn2' newmac = 'aa:bb:cc:dd:ee:ff' int_br = mock.create_autospec(self.agent.int_br) tun_br = mock.create_autospec(self.agent.tun_br) phys_br = mock.create_autospec(self.br_phys_cls('br-phys')) physical_network = 'physeth1' with mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.phys_brs, {physical_network: phys_br}),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.dvr_agent.phys_brs, {physical_network: phys_br}): self.agent.dvr_agent.\ dvr_mac_address_update( dvr_macs=[{'host': newhost, 'mac_address': newmac}]) expected_on_int_br = [ mock.call.add_dvr_mac_vlan( mac=newmac, port=self.agent.int_ofports[physical_network]), mock.call.add_dvr_mac_tun( mac=newmac, port=self.agent.patch_tun_ofport), ] expected_on_tun_br = [ mock.call.add_dvr_mac_tun( mac=newmac, port=self.agent.patch_int_ofport), ] expected_on_phys_br = [ mock.call.add_dvr_mac_vlan( mac=newmac, port=self.agent.phys_ofports[physical_network]), ] self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual(expected_on_tun_br, tun_br.mock_calls) self.assertEqual(expected_on_phys_br, phys_br.mock_calls) int_br.reset_mock() tun_br.reset_mock() phys_br.reset_mock() with mock.patch.object(self.agent, 'int_br', new=int_br),\ mock.patch.object(self.agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.phys_brs, {physical_network: phys_br}),\ mock.patch.object(self.agent.dvr_agent, 'int_br', new=int_br),\ mock.patch.object(self.agent.dvr_agent, 'tun_br', new=tun_br),\ mock.patch.dict(self.agent.dvr_agent.phys_brs, {physical_network: phys_br}): self.agent.dvr_agent.dvr_mac_address_update(dvr_macs=[]) expected_on_int_br = [ mock.call.remove_dvr_mac_vlan( mac=newmac), mock.call.remove_dvr_mac_tun( mac=newmac, port=self.agent.patch_tun_ofport), ] expected_on_tun_br = [ mock.call.remove_dvr_mac_tun( mac=newmac), ] expected_on_phys_br = [ mock.call.remove_dvr_mac_vlan( mac=newmac), ] self.assertEqual(expected_on_int_br, int_br.mock_calls) self.assertEqual(expected_on_tun_br, tun_br.mock_calls) self.assertEqual(expected_on_phys_br, phys_br.mock_calls) def test_ovs_restart(self): self._setup_for_dvr_test() reset_methods = ( 'reset_ovs_parameters', 'reset_dvr_parameters', 'setup_dvr_flows_on_integ_br', 'setup_dvr_flows_on_tun_br', 'setup_dvr_flows_on_phys_br', 'setup_dvr_mac_flows_on_all_brs') reset_mocks = [mock.patch.object(self.agent.dvr_agent, method).start() for method in reset_methods] tun_br = mock.create_autospec(self.agent.tun_br) with mock.patch.object(self.agent, 'check_ovs_status', return_value=constants.OVS_RESTARTED),\ mock.patch.object(self.agent, '_agent_has_updates', side_effect=TypeError('loop exit')),\ mock.patch.object(self.agent, 'tun_br', new=tun_br): # block RPC calls and bridge calls self.agent.setup_physical_bridges = mock.Mock() self.agent.setup_integration_br = mock.Mock() self.agent.setup_tunnel_br = mock.Mock() self.agent.state_rpc = mock.Mock() try: self.agent.rpc_loop(polling_manager=mock.Mock()) except TypeError: pass self.assertTrue(all([x.called for x in reset_mocks])) def _test_scan_ports_failure(self, scan_method_name): with mock.patch.object(self.agent, 'check_ovs_status', return_value=constants.OVS_RESTARTED),\ mock.patch.object(self.agent, scan_method_name, side_effect=TypeError('broken')),\ mock.patch.object(self.agent, '_agent_has_updates', return_value=True),\ mock.patch.object(self.agent, '_check_and_handle_signal', side_effect=[True, False]): # block RPC calls and bridge calls self.agent.setup_physical_bridges = mock.Mock() self.agent.setup_integration_br = mock.Mock() self.agent.reset_tunnel_br = mock.Mock() self.agent.state_rpc = mock.Mock() self.agent.rpc_loop(polling_manager=mock.Mock()) def test_scan_ports_failure(self): self._test_scan_ports_failure('scan_ports') def test_scan_ancillary_ports_failure(self): with mock.patch.object(self.agent, 'scan_ports'): with mock.patch.object(self.agent, 'update_stale_ofport_rules'): self.agent.ancillary_brs = mock.Mock() self._test_scan_ports_failure('scan_ancillary_ports') class TestOvsDvrNeutronAgentOFCtl(TestOvsDvrNeutronAgent, ovs_test_base.OVSOFCtlTestBase): pass class TestOvsDvrNeutronAgentRyu(TestOvsDvrNeutronAgent, ovs_test_base.OVSRyuTestBase): pass class TestValidateTunnelLocalIP(base.BaseTestCase): def test_validate_local_ip_no_tunneling(self): cfg.CONF.set_override('tunnel_types', [], group='AGENT') # The test will pass simply if no exception is raised by the next call: ovs_agent.validate_local_ip(FAKE_IP1) def test_validate_local_ip_with_valid_ip(self): cfg.CONF.set_override('tunnel_types', ['vxlan'], group='AGENT') mock_get_device_by_ip = mock.patch.object( ip_lib.IPWrapper, 'get_device_by_ip').start() ovs_agent.validate_local_ip(FAKE_IP1) mock_get_device_by_ip.assert_called_once_with(FAKE_IP1) def test_validate_local_ip_with_invalid_ip(self): cfg.CONF.set_override('tunnel_types', ['vxlan'], group='AGENT') mock_get_device_by_ip = mock.patch.object( ip_lib.IPWrapper, 'get_device_by_ip').start() mock_get_device_by_ip.return_value = None with testtools.ExpectedException(SystemExit): ovs_agent.validate_local_ip(FAKE_IP1) mock_get_device_by_ip.assert_called_once_with(FAKE_IP1)
apache-2.0
[ 3, 1898, 334, 67, 9, 6029, 14260, 2752, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 900, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 199, 646, 11258, 63, 27782, 199, 646, 30741, 199, 199, 504, 8224, 14, 4054, 14, 2330, 492, 23671, 63, 773, 199, 504, 8224, 14, 4054, 14, 2330, 492, 3778, 199, 504, 8224, 14, 4054, 14, 5135, 492, 5316, 63, 1412, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3384, 63, 773, 199, 504, 8224, 14, 2330, 492, 5262, 465, 302, 63, 1297, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 465, 299, 63, 1297, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 76, 18, 1935, 492, 8985, 465, 634, 18, 1935, 63, 4354, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 14, 2330, 492, 5262, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 492, 23671, 63, 10271, 63, 4054, 971, 272, 465, 23671, 63, 4054, 199, 504, 8224, 14, 2219, 492, 1300, 199, 504, 8224, 14, 2219, 14, 3248, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 971, 272, 492, 23671, 63, 396, 63, 1095, 421, 199, 4609, 16910, 275, 283, 10271, 14, 5265, 14, 757, 18, 14, 4354, 14, 7788, 26884, 7394, 7, 199, 47, 7428, 63, 26030, 63, 25816, 63, 17223, 63, 29946, 63, 28493, 10825, 275, 298, 19, 14, 713, 14, 16, 2, 199, 199, 14623, 63, 9410, 275, 283, 383, 26, 845, 26, 1081, 26, 1153, 26, 1602, 26, 1229, 7, 199, 14623, 63, 1772, 17, 275, 283, 709, 14, 16, 14, 16, 14, 17, 7, 199, 14623, 63, 1772, 18, 275, 283, 709, 14, 16, 14, 16, 14, 18, 7, 199, 199, 2864, 63, 3657, 63, 998, 17, 275, 283, 719, 13, 344, 13, 17, 7, 199, 2864, 63, 3657, 63, 998, 18, 275, 283, 719, 13, 344, 13, 18, 7, 199, 2864, 63, 3657, 63, 998, 19, 275, 283, 719, 13, 344, 13, 19, 7, 199, 199, 2864, 63, 14560, 63, 998, 17, 275, 283, 846, 13, 344, 13, 17, 7, 199, 2864, 63, 14560, 63, 998, 18, 275, 283, 846, 13, 344, 13, 18, 7, 421, 199, 533, 7777, 54, 692, 8, 785, 304, 272, 402, 719, 275, 8806, 272, 1844, 63, 354, 275, 283, 354, 7, 272, 15205, 63, 3088, 275, 283, 2158, 26, 2501, 26, 2055, 26, 845, 26, 1081, 26, 1153, 7, 421, 199, 533, 4420, 9515, 8227, 7382, 316, 2176, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 289, 304, 267, 291, 14, 70, 275, 289, 339, 347, 1343, 8, 277, 12, 6252, 29, 16, 304, 267, 291, 14, 70, 342, 421, 199, 533, 2790, 7788, 2028, 2956, 8, 22409, 63, 396, 63, 1095, 14, 30692, 4251, 12069, 2028, 14440, 304, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 14301, 5923, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 430, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 509, 63, 3197, 63, 15360, 63, 888, 8, 277, 304, 267, 327, 1626, 3384, 2287, 365, 1415, 367, 21496, 316, 1325, 2337, 365, 949, 849, 12, 267, 327, 4911, 642, 367, 3865, 486, 264, 436, 29922, 1502, 21496, 83, 14, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 39, 907, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 28493, 10825, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 889, 63, 1832, 63, 711, 8, 277, 304, 267, 327, 1626, 3384, 2287, 365, 1415, 367, 21496, 316, 1325, 2337, 365, 949, 849, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 28493, 10825, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 509, 63, 3197, 63, 15360, 63, 466, 8, 277, 304, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 788, 9664, 995, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 6048, 63, 15360, 63, 1313, 8, 277, 304, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 1832, 63, 711, 297, 283 ]
[ 1898, 334, 67, 9, 6029, 14260, 2752, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 900, 199, 199, 646, 1683, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 199, 646, 11258, 63, 27782, 199, 646, 30741, 199, 199, 504, 8224, 14, 4054, 14, 2330, 492, 23671, 63, 773, 199, 504, 8224, 14, 4054, 14, 2330, 492, 3778, 199, 504, 8224, 14, 4054, 14, 5135, 492, 5316, 63, 1412, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3384, 63, 773, 199, 504, 8224, 14, 2330, 492, 5262, 465, 302, 63, 1297, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 465, 299, 63, 1297, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 76, 18, 1935, 492, 8985, 465, 634, 18, 1935, 63, 4354, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 14, 2330, 492, 5262, 199, 504, 8224, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 492, 23671, 63, 10271, 63, 4054, 971, 272, 465, 23671, 63, 4054, 199, 504, 8224, 14, 2219, 492, 1300, 199, 504, 8224, 14, 2219, 14, 3248, 14, 5265, 14, 757, 18, 14, 13337, 14, 1490, 23201, 14, 4054, 971, 272, 492, 23671, 63, 396, 63, 1095, 421, 199, 4609, 16910, 275, 283, 10271, 14, 5265, 14, 757, 18, 14, 4354, 14, 7788, 26884, 7394, 7, 199, 47, 7428, 63, 26030, 63, 25816, 63, 17223, 63, 29946, 63, 28493, 10825, 275, 298, 19, 14, 713, 14, 16, 2, 199, 199, 14623, 63, 9410, 275, 283, 383, 26, 845, 26, 1081, 26, 1153, 26, 1602, 26, 1229, 7, 199, 14623, 63, 1772, 17, 275, 283, 709, 14, 16, 14, 16, 14, 17, 7, 199, 14623, 63, 1772, 18, 275, 283, 709, 14, 16, 14, 16, 14, 18, 7, 199, 199, 2864, 63, 3657, 63, 998, 17, 275, 283, 719, 13, 344, 13, 17, 7, 199, 2864, 63, 3657, 63, 998, 18, 275, 283, 719, 13, 344, 13, 18, 7, 199, 2864, 63, 3657, 63, 998, 19, 275, 283, 719, 13, 344, 13, 19, 7, 199, 199, 2864, 63, 14560, 63, 998, 17, 275, 283, 846, 13, 344, 13, 17, 7, 199, 2864, 63, 14560, 63, 998, 18, 275, 283, 846, 13, 344, 13, 18, 7, 421, 199, 533, 7777, 54, 692, 8, 785, 304, 272, 402, 719, 275, 8806, 272, 1844, 63, 354, 275, 283, 354, 7, 272, 15205, 63, 3088, 275, 283, 2158, 26, 2501, 26, 2055, 26, 845, 26, 1081, 26, 1153, 7, 421, 199, 533, 4420, 9515, 8227, 7382, 316, 2176, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 289, 304, 267, 291, 14, 70, 275, 289, 339, 347, 1343, 8, 277, 12, 6252, 29, 16, 304, 267, 291, 14, 70, 342, 421, 199, 533, 2790, 7788, 2028, 2956, 8, 22409, 63, 396, 63, 1095, 14, 30692, 4251, 12069, 2028, 14440, 304, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 14301, 5923, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 430, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 509, 63, 3197, 63, 15360, 63, 888, 8, 277, 304, 267, 327, 1626, 3384, 2287, 365, 1415, 367, 21496, 316, 1325, 2337, 365, 949, 849, 12, 267, 327, 4911, 642, 367, 3865, 486, 264, 436, 29922, 1502, 21496, 83, 14, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 39, 907, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 28493, 10825, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 889, 63, 1832, 63, 711, 8, 277, 304, 267, 327, 1626, 3384, 2287, 365, 1415, 367, 21496, 316, 1325, 2337, 365, 949, 849, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 359, 80, 63, 1297, 14, 2711, 63, 28493, 10825, 467, 2892, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 15762, 63, 509, 63, 3197, 63, 15360, 63, 466, 8, 277, 304, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 15360, 63, 1313, 297, 788, 9664, 995, 1572, 534, 14565, 358, 267, 543, 30741, 14, 6964, 1726, 8, 3393, 304, 288, 291, 14, 1494, 63, 4054, 14, 981, 63, 4054, 63, 888, 63, 1130, 8, 4128, 14, 3103, 9, 339, 347, 511, 63, 981, 63, 4054, 63, 888, 63, 1130, 63, 6048, 63, 15360, 63, 1313, 8, 277, 304, 267, 4810, 14, 3103, 14, 409, 63, 4415, 360, 1832, 63, 711, 297, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cmelange/ansible
lib/ansible/playbook/helpers.py
31
15606
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os from ansible import constants as C from ansible.compat.six import string_types from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable, AnsibleFileNotFound try: from __main__ import display except ImportError: from ansible.utils.display import Display display = Display() def load_list_of_blocks(ds, play, parent_block=None, role=None, task_include=None, use_handlers=False, variable_manager=None, loader=None): ''' Given a list of mixed task/block data (parsed from YAML), return a list of Block() objects, where implicit blocks are created for each bare Task. ''' # we import here to prevent a circular dependency with imports from ansible.playbook.block import Block from ansible.playbook.task_include import TaskInclude from ansible.playbook.role_include import IncludeRole assert isinstance(ds, (list, type(None))) block_list = [] if ds: for block_ds in ds: b = Block.load( block_ds, play=play, parent_block=parent_block, role=role, task_include=task_include, use_handlers=use_handlers, variable_manager=variable_manager, loader=loader, ) # Implicit blocks are created by bare tasks listed in a play without # an explicit block statement. If we have two implicit blocks in a row, # squash them down to a single block to save processing time later. if b._implicit and len(block_list) > 0 and block_list[-1]._implicit: for t in b.block: if isinstance(t._parent, (TaskInclude, IncludeRole)): t._parent._parent = block_list[-1] else: t._parent = block_list[-1] block_list[-1].block.extend(b.block) else: block_list.append(b) return block_list def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_handlers=False, variable_manager=None, loader=None): ''' Given a list of task datastructures (parsed from YAML), return a list of Task() or TaskInclude() objects. ''' # we import here to prevent a circular dependency with imports from ansible.playbook.block import Block from ansible.playbook.handler import Handler from ansible.playbook.task import Task from ansible.playbook.task_include import TaskInclude from ansible.playbook.role_include import IncludeRole from ansible.playbook.handler_task_include import HandlerTaskInclude from ansible.template import Templar assert isinstance(ds, list) task_list = [] for task_ds in ds: assert isinstance(task_ds, dict) if 'block' in task_ds: t = Block.load( task_ds, play=play, parent_block=block, role=role, task_include=task_include, use_handlers=use_handlers, variable_manager=variable_manager, loader=loader, ) task_list.append(t) else: if 'include' in task_ds: if use_handlers: include_class = HandlerTaskInclude else: include_class = TaskInclude t = include_class.load( task_ds, block=block, role=role, task_include=None, variable_manager=variable_manager, loader=loader ) all_vars = variable_manager.get_vars(loader=loader, play=play, task=t) templar = Templar(loader=loader, variables=all_vars) # check to see if this include is dynamic or static: # 1. the user has set the 'static' option to false or true # 2. one of the appropriate config options was set if t.static is not None: is_static = t.static else: is_static = C.DEFAULT_TASK_INCLUDES_STATIC or \ (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \ (not templar._contains_vars(t.args['_raw_params']) and t.all_parents_static() and not t.loop) if is_static: if t.loop is not None: raise AnsibleParserError("You cannot use 'static' on an include with a loop", obj=task_ds) # we set a flag to indicate this include was static t.statically_loaded = True # handle relative includes by walking up the list of parent include # tasks and checking the relative result to see if it exists parent_include = block cumulative_path = None found = False subdir = 'tasks' if use_handlers: subdir = 'handlers' while parent_include is not None: if not isinstance(parent_include, TaskInclude): parent_include = parent_include._parent continue parent_include_dir = templar.template(os.path.dirname(parent_include.args.get('_raw_params'))) if cumulative_path is None: cumulative_path = parent_include_dir elif not os.path.isabs(cumulative_path): cumulative_path = os.path.join(parent_include_dir, cumulative_path) include_target = templar.template(t.args['_raw_params']) if t._role: new_basedir = os.path.join(t._role._role_path, subdir, cumulative_path) include_file = loader.path_dwim_relative(new_basedir, subdir, include_target) else: include_file = loader.path_dwim_relative(loader.get_basedir(), cumulative_path, include_target) if os.path.exists(include_file): found = True break else: parent_include = parent_include._parent if not found: try: include_target = templar.template(t.args['_raw_params']) except AnsibleUndefinedVariable: raise AnsibleParserError( "Error when evaluating variable in include name: %s.\n\n" \ "When using static includes, ensure that any variables used in their names are defined in vars/vars_files\n" \ "or extra-vars passed in from the command line. Static includes cannot use variables from inventory\n" \ "sources like group or host vars." % t.args['_raw_params'], obj=task_ds, suppress_extended_error=True, ) if t._role: include_file = loader.path_dwim_relative(t._role._role_path, subdir, include_target) else: include_file = loader.path_dwim(include_target) try: data = loader.load_from_file(include_file) if data is None: return [] elif not isinstance(data, list): raise AnsibleParserError("included task files must contain a list of tasks", obj=data) # since we can't send callbacks here, we display a message directly in # the same fashion used by the on_include callback. We also do it here, # because the recursive nature of helper methods means we may be loading # nested includes, and we want the include order printed correctly display.vv("statically included: %s" % include_file) except AnsibleFileNotFound: if t.static or \ C.DEFAULT_TASK_INCLUDES_STATIC or \ C.DEFAULT_HANDLER_INCLUDES_STATIC and use_handlers: raise display.deprecated( "Included file '%s' not found, however since this include is not " \ "explicitly marked as 'static: yes', we will try and include it dynamically " \ "later. In the future, this will be an error unless 'static: no' is used " \ "on the include task. If you do not want missing includes to be considered " \ "dynamic, use 'static: yes' on the include or set the global ansible.cfg " \ "options to make all inclues static for tasks and/or handlers" % include_file, ) task_list.append(t) continue ti_copy = t.copy(exclude_parent=True) ti_copy._parent = block included_blocks = load_list_of_blocks( data, play=play, parent_block=None, task_include=ti_copy, role=role, use_handlers=use_handlers, loader=loader, variable_manager=variable_manager, ) # pop tags out of the include args, if they were specified there, and assign # them to the include. If the include already had tags specified, we raise an # error so that users know not to specify them both ways tags = ti_copy.vars.pop('tags', []) if isinstance(tags, string_types): tags = tags.split(',') if len(tags) > 0: if len(ti_copy.tags) > 0: raise AnsibleParserError( "Include tasks should not specify tags in more than one way (both via args and directly on the task). " \ "Mixing styles in which tags are specified is prohibited for whole import hierarchy, not only for single import statement", obj=task_ds, suppress_extended_error=True, ) display.deprecated("You should not specify tags in the include parameters. All tags should be specified using the task-level option") else: tags = ti_copy.tags[:] # now we extend the tags on each of the included blocks for b in included_blocks: b.tags = list(set(b.tags).union(tags)) # END FIXME # FIXME: handlers shouldn't need this special handling, but do # right now because they don't iterate blocks correctly if use_handlers: for b in included_blocks: task_list.extend(b.block) else: task_list.extend(included_blocks) else: task_list.append(t) elif 'include_role' in task_ds: ir = IncludeRole.load( task_ds, block=block, role=role, task_include=None, variable_manager=variable_manager, loader=loader ) # 1. the user has set the 'static' option to false or true # 2. one of the appropriate config options was set if ir.static is not None: is_static = ir.static else: display.debug('Determine if include_role is static') # Check to see if this include is dynamic or static: all_vars = variable_manager.get_vars(loader=loader, play=play, task=ir) templar = Templar(loader=loader, variables=all_vars) needs_templating = False for param in ir.args: if templar._contains_vars(ir.args[param]): if not templar.templatable(ir.args[param]): needs_templating = True break is_static = C.DEFAULT_TASK_INCLUDES_STATIC or \ (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \ (not needs_templating and ir.all_parents_static() and not ir.loop) display.debug('Determined that if include_role static is %s' % str(is_static)) if is_static: # uses compiled list from object t = task_list.extend(ir.get_block_list(variable_manager=variable_manager, loader=loader)) else: # passes task object itself for latter generation of list t = task_list.append(ir) else: if use_handlers: t = Handler.load(task_ds, block=block, role=role, task_include=task_include, variable_manager=variable_manager, loader=loader) else: t = Task.load(task_ds, block=block, role=role, task_include=task_include, variable_manager=variable_manager, loader=loader) task_list.append(t) return task_list def load_list_of_roles(ds, play, current_role_path=None, variable_manager=None, loader=None): ''' Loads and returns a list of RoleInclude objects from the datastructure list of role definitions ''' # we import here to prevent a circular dependency with imports from ansible.playbook.role.include import RoleInclude assert isinstance(ds, list) roles = [] for role_def in ds: i = RoleInclude.load(role_def, play=play, current_role_path=current_role_path, variable_manager=variable_manager, loader=loader) roles.append(i) return roles
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5819, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 2550, 492, 31775, 12, 2622, 16283, 2773, 12, 2622, 1173, 4667, 199, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 318, 2248, 63, 513, 63, 1618, 63, 4166, 8, 795, 12, 5232, 12, 1676, 63, 1457, 29, 403, 12, 4719, 29, 403, 12, 2120, 63, 2613, 29, 403, 12, 675, 63, 5586, 29, 797, 12, 1750, 63, 2609, 29, 403, 12, 5077, 29, 403, 304, 272, 1449, 272, 9138, 282, 769, 402, 13492, 2120, 15, 1457, 666, 334, 6751, 687, 18916, 395, 272, 372, 282, 769, 402, 8651, 342, 2251, 12, 2382, 9227, 5664, 272, 787, 2737, 367, 1924, 18753, 8495, 14, 272, 1449, 339, 327, 781, 492, 2348, 370, 7981, 282, 15032, 5936, 543, 8925, 272, 687, 3242, 14, 14205, 14, 1457, 492, 8651, 272, 687, 3242, 14, 14205, 14, 1765, 63, 2613, 492, 8495, 7826, 272, 687, 3242, 14, 14205, 14, 3756, 63, 2613, 492, 15783, 7422, 339, 702, 1228, 8, 795, 12, 334, 513, 12, 730, 8, 403, 1724, 339, 1853, 63, 513, 275, 942, 272, 340, 6364, 26, 267, 367, 1853, 63, 795, 315, 6364, 26, 288, 330, 275, 8651, 14, 912, 8, 355, 1853, 63, 795, 12, 355, 5232, 29, 2802, 12, 355, 1676, 63, 1457, 29, 1708, 63, 1457, 12, 355, 4719, 29, 3756, 12, 355, 2120, 63, 2613, 29, 1765, 63, 2613, 12, 355, 675, 63, 5586, 29, 1180, 63, 5586, 12, 355, 1750, 63, 2609, 29, 1975, 63, 2609, 12, 355, 5077, 29, 3422, 12, 288, 776, 288, 327, 8362, 3137, 5664, 787, 2737, 701, 18753, 6527, 10532, 315, 282, 5232, 1928, 288, 327, 376, 5027, 1853, 5164, 14, 982, 781, 1172, 2877, 9227, 5664, 315, 282, 1962, 12, 288, 327, 12345, 1119, 3062, 3224, 370, 282, 2849, 1853, 370, 3354, 6661, 900, 2945, 14, 288, 340, 330, 423, 11886, 436, 822, 8, 1457, 63, 513, 9, 690, 378, 436, 1853, 63, 513, 1988, 17, 18289, 11886, 26, 355, 367, 307, 315, 330, 14, 1457, 26, 490, 340, 1228, 8, 84, 423, 1708, 12, 334, 4476, 7826, 12, 15783, 7422, 2298, 717, 307, 423, 1708, 423, 1708, 275, 1853, 63, 513, 1988, 17, 61, 490, 587, 26, 717, 307, 423, 1708, 275, 1853, 63, 513, 1988, 17, 61, 355, 1853, 63, 513, 1988, 17, 1055, 1457, 14, 2880, 8, 66, 14, 1457, 9, 288, 587, 26, 355, 1853, 63, 513, 14, 740, 8, 66, 9, 339, 372, 1853, 63, 513, 421, 199, 318, 2248, 63, 513, 63, 1618, 63, 5054, 8, 795, 12, 5232, 12, 1853, 29, 403, 12, 4719, 29, 403, 12, 2120, 63, 2613, 29, 403, 12, 675, 63, 5586, 29, 797, 12, 1750, 63, 2609, 29, 403, 12, 5077, 29, 403, 304, 272, 1449, 272, 9138, 282, 769, 402, 2120, 666, 13547, 334, 6751, 687, 18916, 395, 272, 372, 282, 769, 402, 8495, 342, 503, 8495, 7826, 342, 2251, 14, 272, 1449, 339, 327, 781, 492, 2348, 370, 7981, 282, 15032, 5936, 543, 8925, 272, 687, 3242, 14, 14205, 14, 1457, 492, 8651, 272, 687, 3242, 14, 14205, 14, 2232, 492, 18599, 272, 687, 3242, 14, 14205, 14, 1765, 492, 8495, 272, 687, 3242, 14, 14205, 14, 1765, 63, 2613, 492, 8495, 7826, 272, 687, 3242, 14, 14205, 14, 3756, 63, 2613, 492, 15783, 7422, 272, 687, 3242, 14, 14205, 14, 2232, 63, 1765, 63, 2613, 492, 18599, 4476, 7826, 272, 687, 3242, 14, 1160, 492, 12540, 9828, 339, 702, 1228, 8, 795, 12, 769, 9, 339, 2120, 63, 513, 275, 942, 272, 367, 2120, 63, 795, 315, 6364, 26, 267, 702, 1228, 8, 1765, 63, 795, 12, 1211, 9, 398, 340, 283, 1457, 7, 315, 2120, 63, 795, 26, 288, 307, 275, 8651, 14, 912, 8, 355, 2120, 63, 795, 12, 355, 5232, 29, 2802, 12, 355, 1676, 63, 1457, 29, 1457, 12, 355, 4719, 29, 3756, 12, 355, 2120, 63, 2613, 29, 1765, 63, 2613, 12, 355, 675, 63, 5586, 29, 1180, 63, 5586, 12, 355, 1750, 63, 2609, 29, 1975, 63, 2609, 12, 355, 5077, 29, 3422, 12, 288, 776, 288, 2120, 63, 513, 14, 740, 8, 84, 9, 267, 587, 26, 288, 340, 283, 2613, 7, 315, 2120, 63, 795, 26, 355, 340, 675, 63, 5586, 26, 490, 2387, 63, 533, 275, 18599, 4476, 7826, 355, 587, 26, 490, 2387, 63, 533, 275, 8495, 7826, 2234, 307, 275, 2387, 63, 533, 14, 912, 8, 490, 2120, 63, 795, 12, 490, 1853, 29, 1457, 12, 490, 4719, 29, 3756, 12, 490, 2120, 63, 2613, 29, 403, 12, 490, 1750, 63, 2609, 29, 1975, 63, 2609, 12, 490, 5077, 29, 3422, 355, 776, 2234, 1006, 63, 2936, 275, 1750, 63, 2609, 14, 362, 63, 2936, 8, 3422, 29, 3422, 12, 5232 ]
[ 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 747, 199, 199, 504, 3242, 492, 5262, 465, 445, 199, 504, 3242, 14, 5819, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 2550, 492, 31775, 12, 2622, 16283, 2773, 12, 2622, 1173, 4667, 199, 199, 893, 26, 272, 687, 636, 973, 363, 492, 2929, 199, 2590, 3545, 26, 272, 687, 3242, 14, 1208, 14, 2918, 492, 12175, 272, 2929, 275, 12175, 342, 421, 199, 318, 2248, 63, 513, 63, 1618, 63, 4166, 8, 795, 12, 5232, 12, 1676, 63, 1457, 29, 403, 12, 4719, 29, 403, 12, 2120, 63, 2613, 29, 403, 12, 675, 63, 5586, 29, 797, 12, 1750, 63, 2609, 29, 403, 12, 5077, 29, 403, 304, 272, 1449, 272, 9138, 282, 769, 402, 13492, 2120, 15, 1457, 666, 334, 6751, 687, 18916, 395, 272, 372, 282, 769, 402, 8651, 342, 2251, 12, 2382, 9227, 5664, 272, 787, 2737, 367, 1924, 18753, 8495, 14, 272, 1449, 339, 327, 781, 492, 2348, 370, 7981, 282, 15032, 5936, 543, 8925, 272, 687, 3242, 14, 14205, 14, 1457, 492, 8651, 272, 687, 3242, 14, 14205, 14, 1765, 63, 2613, 492, 8495, 7826, 272, 687, 3242, 14, 14205, 14, 3756, 63, 2613, 492, 15783, 7422, 339, 702, 1228, 8, 795, 12, 334, 513, 12, 730, 8, 403, 1724, 339, 1853, 63, 513, 275, 942, 272, 340, 6364, 26, 267, 367, 1853, 63, 795, 315, 6364, 26, 288, 330, 275, 8651, 14, 912, 8, 355, 1853, 63, 795, 12, 355, 5232, 29, 2802, 12, 355, 1676, 63, 1457, 29, 1708, 63, 1457, 12, 355, 4719, 29, 3756, 12, 355, 2120, 63, 2613, 29, 1765, 63, 2613, 12, 355, 675, 63, 5586, 29, 1180, 63, 5586, 12, 355, 1750, 63, 2609, 29, 1975, 63, 2609, 12, 355, 5077, 29, 3422, 12, 288, 776, 288, 327, 8362, 3137, 5664, 787, 2737, 701, 18753, 6527, 10532, 315, 282, 5232, 1928, 288, 327, 376, 5027, 1853, 5164, 14, 982, 781, 1172, 2877, 9227, 5664, 315, 282, 1962, 12, 288, 327, 12345, 1119, 3062, 3224, 370, 282, 2849, 1853, 370, 3354, 6661, 900, 2945, 14, 288, 340, 330, 423, 11886, 436, 822, 8, 1457, 63, 513, 9, 690, 378, 436, 1853, 63, 513, 1988, 17, 18289, 11886, 26, 355, 367, 307, 315, 330, 14, 1457, 26, 490, 340, 1228, 8, 84, 423, 1708, 12, 334, 4476, 7826, 12, 15783, 7422, 2298, 717, 307, 423, 1708, 423, 1708, 275, 1853, 63, 513, 1988, 17, 61, 490, 587, 26, 717, 307, 423, 1708, 275, 1853, 63, 513, 1988, 17, 61, 355, 1853, 63, 513, 1988, 17, 1055, 1457, 14, 2880, 8, 66, 14, 1457, 9, 288, 587, 26, 355, 1853, 63, 513, 14, 740, 8, 66, 9, 339, 372, 1853, 63, 513, 421, 199, 318, 2248, 63, 513, 63, 1618, 63, 5054, 8, 795, 12, 5232, 12, 1853, 29, 403, 12, 4719, 29, 403, 12, 2120, 63, 2613, 29, 403, 12, 675, 63, 5586, 29, 797, 12, 1750, 63, 2609, 29, 403, 12, 5077, 29, 403, 304, 272, 1449, 272, 9138, 282, 769, 402, 2120, 666, 13547, 334, 6751, 687, 18916, 395, 272, 372, 282, 769, 402, 8495, 342, 503, 8495, 7826, 342, 2251, 14, 272, 1449, 339, 327, 781, 492, 2348, 370, 7981, 282, 15032, 5936, 543, 8925, 272, 687, 3242, 14, 14205, 14, 1457, 492, 8651, 272, 687, 3242, 14, 14205, 14, 2232, 492, 18599, 272, 687, 3242, 14, 14205, 14, 1765, 492, 8495, 272, 687, 3242, 14, 14205, 14, 1765, 63, 2613, 492, 8495, 7826, 272, 687, 3242, 14, 14205, 14, 3756, 63, 2613, 492, 15783, 7422, 272, 687, 3242, 14, 14205, 14, 2232, 63, 1765, 63, 2613, 492, 18599, 4476, 7826, 272, 687, 3242, 14, 1160, 492, 12540, 9828, 339, 702, 1228, 8, 795, 12, 769, 9, 339, 2120, 63, 513, 275, 942, 272, 367, 2120, 63, 795, 315, 6364, 26, 267, 702, 1228, 8, 1765, 63, 795, 12, 1211, 9, 398, 340, 283, 1457, 7, 315, 2120, 63, 795, 26, 288, 307, 275, 8651, 14, 912, 8, 355, 2120, 63, 795, 12, 355, 5232, 29, 2802, 12, 355, 1676, 63, 1457, 29, 1457, 12, 355, 4719, 29, 3756, 12, 355, 2120, 63, 2613, 29, 1765, 63, 2613, 12, 355, 675, 63, 5586, 29, 1180, 63, 5586, 12, 355, 1750, 63, 2609, 29, 1975, 63, 2609, 12, 355, 5077, 29, 3422, 12, 288, 776, 288, 2120, 63, 513, 14, 740, 8, 84, 9, 267, 587, 26, 288, 340, 283, 2613, 7, 315, 2120, 63, 795, 26, 355, 340, 675, 63, 5586, 26, 490, 2387, 63, 533, 275, 18599, 4476, 7826, 355, 587, 26, 490, 2387, 63, 533, 275, 8495, 7826, 2234, 307, 275, 2387, 63, 533, 14, 912, 8, 490, 2120, 63, 795, 12, 490, 1853, 29, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
HonzaKral/django
tests/migrations/test_multidb.py
366
6909
import unittest from django.db import connection, migrations, models from django.db.migrations.state import ProjectState from django.test import override_settings from .test_operations import OperationTestBase try: import sqlparse except ImportError: sqlparse = None class AgnosticRouter(object): """ A router that doesn't have an opinion regarding migrating. """ def allow_migrate(self, db, app_label, **hints): return None class MigrateNothingRouter(object): """ A router that doesn't allow migrating. """ def allow_migrate(self, db, app_label, **hints): return False class MigrateEverythingRouter(object): """ A router that always allows migrating. """ def allow_migrate(self, db, app_label, **hints): return True class MigrateWhenFooRouter(object): """ A router that allows migrating depending on a hint. """ def allow_migrate(self, db, app_label, **hints): return hints.get('foo', False) class MultiDBOperationTests(OperationTestBase): multi_db = True def _test_create_model(self, app_label, should_run): """ Tests that CreateModel honours multi-db settings. """ operation = migrations.CreateModel( "Pony", [("id", models.AutoField(primary_key=True))], ) # Test the state alteration project_state = ProjectState() new_state = project_state.clone() operation.state_forwards(app_label, new_state) # Test the database alteration self.assertTableNotExists("%s_pony" % app_label) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) if should_run: self.assertTableExists("%s_pony" % app_label) else: self.assertTableNotExists("%s_pony" % app_label) # And test reversal with connection.schema_editor() as editor: operation.database_backwards(app_label, editor, new_state, project_state) self.assertTableNotExists("%s_pony" % app_label) @override_settings(DATABASE_ROUTERS=[AgnosticRouter()]) def test_create_model(self): """ Test when router doesn't have an opinion (i.e. CreateModel should run). """ self._test_create_model("test_mltdb_crmo", should_run=True) @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_create_model2(self): """ Test when router returns False (i.e. CreateModel shouldn't run). """ self._test_create_model("test_mltdb_crmo2", should_run=False) @override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]) def test_create_model3(self): """ Test when router returns True (i.e. CreateModel should run). """ self._test_create_model("test_mltdb_crmo3", should_run=True) def test_create_model4(self): """ Test multiple routers. """ with override_settings(DATABASE_ROUTERS=[AgnosticRouter(), AgnosticRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=True) with override_settings(DATABASE_ROUTERS=[MigrateNothingRouter(), MigrateEverythingRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=False) with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter(), MigrateNothingRouter()]): self._test_create_model("test_mltdb_crmo4", should_run=True) def _test_run_sql(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) sql = """ INSERT INTO {0}_pony (pink, weight) VALUES (1, 3.55); INSERT INTO {0}_pony (pink, weight) VALUES (3, 5.0); """.format(app_label) operation = migrations.RunSQL(sql, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0) @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse") @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_run_sql(self): self._test_run_sql("test_mltdb_runsql", should_run=False) @unittest.skipIf(sqlparse is None and connection.features.requires_sqlparse_for_splitting, "Missing sqlparse") @override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()]) def test_run_sql2(self): self._test_run_sql("test_mltdb_runsql2", should_run=False) self._test_run_sql("test_mltdb_runsql2", should_run=True, hints={'foo': True}) def _test_run_python(self, app_label, should_run, hints=None): with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]): project_state = self.set_up_test_model(app_label) # Create the operation def inner_method(models, schema_editor): Pony = models.get_model(app_label, "Pony") Pony.objects.create(pink=1, weight=3.55) Pony.objects.create(weight=5) operation = migrations.RunPython(inner_method, hints=hints or {}) # Test the state alteration does nothing new_state = project_state.clone() operation.state_forwards(app_label, new_state) self.assertEqual(new_state, project_state) # Test the database alteration self.assertEqual(project_state.apps.get_model(app_label, "Pony").objects.count(), 0) with connection.schema_editor() as editor: operation.database_forwards(app_label, editor, project_state, new_state) Pony = project_state.apps.get_model(app_label, "Pony") if should_run: self.assertEqual(Pony.objects.count(), 2) else: self.assertEqual(Pony.objects.count(), 0) @override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()]) def test_run_python(self): self._test_run_python("test_mltdb_runpython", should_run=False) @override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()]) def test_run_python2(self): self._test_run_python("test_mltdb_runpython2", should_run=False) self._test_run_python("test_mltdb_runpython2", should_run=True, hints={'foo': True})
bsd-3-clause
[ 646, 2882, 199, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 199, 199, 504, 1275, 396, 63, 8170, 492, 17954, 14440, 199, 199, 893, 26, 272, 492, 3875, 1122, 199, 2590, 3545, 26, 272, 3875, 1122, 275, 488, 421, 199, 533, 437, 784, 941, 530, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 1172, 376, 1687, 262, 1636, 12602, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 488, 421, 199, 533, 28195, 1866, 19627, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 2040, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 756, 421, 199, 533, 28195, 1866, 24527, 2127, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3544, 6127, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 715, 421, 199, 533, 28195, 1866, 11423, 5686, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 6127, 3952, 10417, 10298, 641, 282, 8328, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 18069, 14, 362, 360, 1421, 297, 756, 9, 421, 199, 533, 6879, 2846, 6044, 2925, 8, 6044, 14440, 304, 272, 3510, 63, 697, 275, 715, 339, 347, 485, 396, 63, 981, 63, 1238, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 304, 267, 408, 267, 6496, 626, 2790, 1685, 394, 265, 16363, 3510, 13, 697, 2202, 14, 267, 408, 267, 3439, 275, 6180, 14, 14907, 8, 288, 298, 24442, 401, 288, 10003, 344, 401, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 25106, 267, 776, 267, 327, 1379, 314, 1174, 741, 5388, 267, 2199, 63, 929, 275, 7290, 2223, 342, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 327, 1379, 314, 3050, 741, 5388, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 340, 1077, 63, 1065, 26, 288, 291, 14, 23550, 7965, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 587, 26, 288, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 327, 6061, 511, 295, 16222, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 8823, 12, 892, 63, 929, 12, 2199, 63, 929, 9, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 3181, 1133, 1172, 376, 1687, 262, 1636, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 401, 1077, 63, 1065, 29, 549, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 18, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 756, 334, 73, 14, 69, 14, 2790, 1685, 9296, 1133, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 18, 401, 1077, 63, 1065, 29, 797, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 19, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 715, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 19, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 511, 63, 981, 63, 1238, 20, 8, 277, 304, 267, 408, 267, 1379, 3663, 24464, 14, 267, 408, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 1062, 437, 784, 941, 530, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 1062, 28195, 1866, 24527, 2127, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 797, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 1062, 28195, 1866, 19627, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 485, 396, 63, 1065, 63, 3009, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 12, 18069, 29, 403, 304, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 342, 4682, 288, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 8, 571, 63, 1302, 9, 398, 3875, 275, 408, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 17, 12, 650, 14, 1229, 2736, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 19, 12, 959, 14, 16, 2736, 267, 30512, 908, 8, 571, 63, 1302, 9, 398, 3439, 275, 6180, 14, 2540, 4657, 8, 3009 ]
[ 2882, 199, 199, 504, 1639, 14, 697, 492, 1950, 12, 6180, 12, 1709, 199, 504, 1639, 14, 697, 14, 7685, 14, 929, 492, 7290, 2223, 199, 504, 1639, 14, 396, 492, 4278, 63, 1751, 199, 199, 504, 1275, 396, 63, 8170, 492, 17954, 14440, 199, 199, 893, 26, 272, 492, 3875, 1122, 199, 2590, 3545, 26, 272, 3875, 1122, 275, 488, 421, 199, 533, 437, 784, 941, 530, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 1172, 376, 1687, 262, 1636, 12602, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 488, 421, 199, 533, 28195, 1866, 19627, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3181, 1133, 2040, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 756, 421, 199, 533, 28195, 1866, 24527, 2127, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 3544, 6127, 3952, 10417, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 715, 421, 199, 533, 28195, 1866, 11423, 5686, 11691, 8, 785, 304, 272, 408, 272, 437, 6197, 626, 6127, 3952, 10417, 10298, 641, 282, 8328, 14, 272, 408, 272, 347, 2040, 63, 8462, 8, 277, 12, 1592, 12, 1145, 63, 1302, 12, 1011, 12354, 304, 267, 372, 18069, 14, 362, 360, 1421, 297, 756, 9, 421, 199, 533, 6879, 2846, 6044, 2925, 8, 6044, 14440, 304, 272, 3510, 63, 697, 275, 715, 339, 347, 485, 396, 63, 981, 63, 1238, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 304, 267, 408, 267, 6496, 626, 2790, 1685, 394, 265, 16363, 3510, 13, 697, 2202, 14, 267, 408, 267, 3439, 275, 6180, 14, 14907, 8, 288, 298, 24442, 401, 288, 10003, 344, 401, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 25106, 267, 776, 267, 327, 1379, 314, 1174, 741, 5388, 267, 2199, 63, 929, 275, 7290, 2223, 342, 267, 892, 63, 929, 275, 2199, 63, 929, 14, 6311, 342, 267, 3439, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 892, 63, 929, 9, 267, 327, 1379, 314, 3050, 741, 5388, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 8823, 12, 2199, 63, 929, 12, 892, 63, 929, 9, 267, 340, 1077, 63, 1065, 26, 288, 291, 14, 23550, 7965, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 587, 26, 288, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 267, 327, 6061, 511, 295, 16222, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 3439, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 8823, 12, 892, 63, 929, 12, 2199, 63, 929, 9, 267, 291, 14, 23550, 25095, 3647, 83, 63, 18881, 2, 450, 1145, 63, 1302, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 3181, 1133, 1172, 376, 1687, 262, 1636, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 401, 1077, 63, 1065, 29, 549, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 18, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 756, 334, 73, 14, 69, 14, 2790, 1685, 9296, 1133, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 18, 401, 1077, 63, 1065, 29, 797, 9, 339, 768, 4415, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 9383, 272, 347, 511, 63, 981, 63, 1238, 19, 8, 277, 304, 267, 408, 267, 1379, 1380, 6197, 2529, 715, 334, 73, 14, 69, 14, 2790, 1685, 1077, 1255, 680, 267, 408, 267, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 19, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 511, 63, 981, 63, 1238, 20, 8, 277, 304, 267, 408, 267, 1379, 3663, 24464, 14, 267, 408, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 33, 784, 941, 530, 11691, 1062, 437, 784, 941, 530, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 19627, 11691, 1062, 28195, 1866, 24527, 2127, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 797, 9, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 1062, 28195, 1866, 19627, 11691, 342, 4682, 288, 291, 423, 396, 63, 981, 63, 1238, 480, 396, 63, 757, 84, 697, 63, 1556, 573, 20, 401, 1077, 63, 1065, 29, 549, 9, 339, 347, 485, 396, 63, 1065, 63, 3009, 8, 277, 12, 1145, 63, 1302, 12, 1077, 63, 1065, 12, 18069, 29, 403, 304, 267, 543, 4278, 63, 1751, 8, 17873, 63, 14999, 3960, 1524, 26641, 24527, 2127, 11691, 342, 4682, 288, 2199, 63, 929, 275, 291, 14, 409, 63, 384, 63, 396, 63, 1238, 8, 571, 63, 1302, 9, 398, 3875, 275, 408, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 17, 12, 650, 14, 1229, 2736, 267, 22542, 12872, 469, 16, 12585, 18881, 334, 26591, 12, 5401, 9, 13992, 334, 19, 12, 959, 14, 16, 2736, 267, 30512, 908, 8, 571, 63, 1302, 9, 398, 3439, 275, 6180, 14, 2540, 4657, 8, 3009, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
pumanzor/iot-redlibre
linkit/stepmotor.py
6
2151
#!/usr/bin/python # Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com> # Copyright (c) 2015 Intel Corporation. # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import time, sys, signal, atexit import pyupm_stepmotor as mylib # Instantiate a StepMotor object on pins 2 (dir) and 3 (step) stepper = mylib.StepMotor(2, 3) ## Exit handlers ## # This stops python from printing a stacktrace when you hit control-C def SIGINTHandler(signum, frame): raise SystemExit # This lets you run code on exit def exitHandler(): print "Exiting" sys.exit(0) # Register exit handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler) print "Rotating 1 revolution forward and back at 60 rpm." stepper.setSpeed(60) stepper.stepForward(200) time.sleep(1) stepper.stepBackward(200) time.sleep(1) print "Rotating 1 revolution forward and back at 150 rpm." stepper.setSpeed(150) stepper.stepForward(200) time.sleep(1) stepper.stepBackward(200) time.sleep(1) print "Rotating 1 revolution forward and back at 300 rpm." stepper.setSpeed(300) stepper.stepForward(200) time.sleep(1) stepper.stepBackward(200) time.sleep(1)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 6529, 26, 221, 603, 73, 17945, 377, 1181, 269, 510, 290, 85, 665, 2664, 17945, 14, 84, 1181, 269, 14, 10384, 85, 32, 22264, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 6900, 20619, 11098, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 421, 199, 646, 900, 12, 984, 12, 4673, 12, 19840, 199, 646, 1134, 384, 77, 63, 2926, 27840, 465, 3002, 773, 199, 199, 3, 32092, 282, 13382, 31642, 909, 641, 30541, 499, 334, 694, 9, 436, 650, 334, 2926, 9, 199, 2926, 529, 275, 3002, 773, 14, 7801, 31642, 8, 18, 12, 650, 9, 199, 199, 309, 18704, 8297, 925, 199, 3, 961, 20922, 2366, 687, 16116, 282, 3464, 3446, 1380, 1265, 9793, 3304, 13, 35, 199, 318, 15522, 568, 2080, 1221, 8, 1037, 453, 12, 2787, 304, 272, 746, 14838, 199, 199, 3, 961, 19083, 1265, 1255, 1233, 641, 4458, 199, 318, 4458, 2461, 837, 272, 870, 298, 6699, 316, 2, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 11828, 4458, 8297, 199, 24026, 390, 14, 2683, 8, 2224, 2461, 9, 199, 4653, 14, 4653, 8, 4653, 14, 21223, 12, 15522, 568, 2080, 1221, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 5212, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 2259, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 14711, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 8251, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 9601, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 5863, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 6529, 26, 221, 603, 73, 17945, 377, 1181, 269, 510, 290, 85, 665, 2664, 17945, 14, 84, 1181, 269, 14, 10384, 85, 32, 22264, 14, 957, 30, 199, 3, 1898, 334, 67, 9, 6900, 20619, 11098, 14, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 199, 3, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 199, 3, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 199, 3, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 421, 199, 646, 900, 12, 984, 12, 4673, 12, 19840, 199, 646, 1134, 384, 77, 63, 2926, 27840, 465, 3002, 773, 199, 199, 3, 32092, 282, 13382, 31642, 909, 641, 30541, 499, 334, 694, 9, 436, 650, 334, 2926, 9, 199, 2926, 529, 275, 3002, 773, 14, 7801, 31642, 8, 18, 12, 650, 9, 199, 199, 309, 18704, 8297, 925, 199, 3, 961, 20922, 2366, 687, 16116, 282, 3464, 3446, 1380, 1265, 9793, 3304, 13, 35, 199, 318, 15522, 568, 2080, 1221, 8, 1037, 453, 12, 2787, 304, 272, 746, 14838, 199, 199, 3, 961, 19083, 1265, 1255, 1233, 641, 4458, 199, 318, 4458, 2461, 837, 272, 870, 298, 6699, 316, 2, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 3, 11828, 4458, 8297, 199, 24026, 390, 14, 2683, 8, 2224, 2461, 9, 199, 4653, 14, 4653, 8, 4653, 14, 21223, 12, 15522, 568, 2080, 1221, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 5212, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 2259, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 14711, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 8251, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 199, 1361, 298, 14728, 1958, 413, 6822, 3347, 7568, 436, 1771, 737, 9601, 21980, 2122, 199, 2926, 529, 14, 409, 15146, 8, 5863, 9, 199, 2926, 529, 14, 2926, 12984, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 2926, 529, 14, 2926, 4540, 3079, 8, 1840, 9, 199, 521, 14, 4532, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zulip/zulip
zerver/lib/markdown/api_return_values_table_generator.py
2
9063
import copy import json import re from typing import Any, Dict, List, Mapping, Optional import markdown from markdown.extensions import Extension from markdown.preprocessors import Preprocessor from zerver.openapi.openapi import check_deprecated_consistency, get_openapi_return_values from .api_arguments_table_generator import generate_data_type REGEXP = re.compile(r"\{generate_return_values_table\|\s*(.+?)\s*\|\s*(.+)\s*\}") class MarkdownReturnValuesTableGenerator(Extension): def __init__(self, configs: Mapping[str, Any] = {}) -> None: self.config: Dict[str, Any] = {} def extendMarkdown(self, md: markdown.Markdown) -> None: md.preprocessors.register( APIReturnValuesTablePreprocessor(md, self.getConfigs()), "generate_return_values", 510 ) class APIReturnValuesTablePreprocessor(Preprocessor): def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None: super().__init__(md) def run(self, lines: List[str]) -> List[str]: done = False while not done: for line in lines: loc = lines.index(line) match = REGEXP.search(line) if not match: continue doc_name = match.group(2) endpoint, method = doc_name.rsplit(":", 1) return_values = get_openapi_return_values(endpoint, method) if doc_name == "/events:get": return_values = copy.deepcopy(return_values) events = return_values["events"].pop("items", None) text = self.render_table(return_values, 0) # Another heading for the events documentation text.append("\n\n## Events\n\n") text += self.render_events(events) else: text = self.render_table(return_values, 0) if len(text) > 0: text = ["#### Return values"] + text line_split = REGEXP.split(line, maxsplit=0) preceding = line_split[0] following = line_split[-1] text = [preceding, *text, following] lines = lines[:loc] + text + lines[loc + 1 :] break else: done = True return lines def render_desc( self, description: str, spacing: int, data_type: str, return_value: Optional[str] = None ) -> str: description = description.replace("\n", "\n" + ((spacing + 4) * " ")) if return_value is None: # HACK: It's not clear how to use OpenAPI data to identify # the `key` fields for objects where e.g. the keys are # user/stream IDs being mapped to data associated with # those IDs. We hackily describe those fields by # requiring that the descriptions be written as `key_name: # key_description` and parsing for that pattern; we need # to be careful to skip cases where we'd have `Note: ...` # on a later line. # # More correctly, we should be doing something that looks at the types; # print statements and test_api_doc_endpoint is useful for testing. arr = description.split(": ", 1) if len(arr) == 1 or "\n" in arr[0]: return (spacing * " ") + "* " + description (key_name, key_description) = arr return ( (spacing * " ") + "* " + key_name + ": " + '<span class="api-field-type">' + data_type + "</span> " + key_description ) return ( (spacing * " ") + "* `" + return_value + "`: " + '<span class="api-field-type">' + data_type + "</span> " + description ) def render_table(self, return_values: Dict[str, Any], spacing: int) -> List[str]: IGNORE = ["result", "msg"] ans = [] for return_value in return_values: if return_value in IGNORE: continue if "oneOf" in return_values[return_value]: # For elements using oneOf there are two descriptions. The first description # should be at level with the oneOf and should contain the basic non-specific # description of the endpoint. Then for each element of oneOf there is a # specialized description for that particular case. The description used # right below is the main description. data_type = generate_data_type(return_values[return_value]) ans.append( self.render_desc( return_values[return_value]["description"], spacing, data_type, return_value ) ) for element in return_values[return_value]["oneOf"]: if "description" not in element: continue # Add the specialized description of the oneOf element. data_type = generate_data_type(element) ans.append(self.render_desc(element["description"], spacing + 4, data_type)) # If the oneOf element is an object schema then render the documentation # of its keys. if "properties" in element: ans += self.render_table(element["properties"], spacing + 8) continue description = return_values[return_value]["description"] data_type = generate_data_type(return_values[return_value]) check_deprecated_consistency(return_values[return_value], description) ans.append(self.render_desc(description, spacing, data_type, return_value)) if "properties" in return_values[return_value]: ans += self.render_table(return_values[return_value]["properties"], spacing + 4) if return_values[return_value].get("additionalProperties", False): data_type = generate_data_type(return_values[return_value]["additionalProperties"]) ans.append( self.render_desc( return_values[return_value]["additionalProperties"]["description"], spacing + 4, data_type, ) ) if "properties" in return_values[return_value]["additionalProperties"]: ans += self.render_table( return_values[return_value]["additionalProperties"]["properties"], spacing + 8, ) if ( "items" in return_values[return_value] and "properties" in return_values[return_value]["items"] ): ans += self.render_table( return_values[return_value]["items"]["properties"], spacing + 4 ) return ans def render_events(self, events_dict: Dict[str, Any]) -> List[str]: text: List[str] = [] # Use argument section design for better visuals # Directly using `###` for subheading causes errors so use h3 with made up id. argument_template = ( '<div class="api-argument"><p class="api-argument-name"><h3 id="{h3_id}">' + " {event_type} {op}</h3></p></div> \n{description}\n\n\n" ) for events in events_dict["oneOf"]: event_type: Dict[str, Any] = events["properties"]["type"] event_type_str: str = event_type["enum"][0] # Internal hyperlink name h3_id: str = event_type_str event_type_str = f'<span class="api-argument-required"> {event_type_str}</span>' op: Optional[Dict[str, Any]] = events["properties"].pop("op", None) op_str: str = "" if op is not None: op_str = op["enum"][0] h3_id += "-" + op_str op_str = f'<span class="api-argument-deprecated">op: {op_str}</span>' description = events["description"] text.append( argument_template.format( event_type=event_type_str, op=op_str, description=description, h3_id=h3_id ) ) text += self.render_table(events["properties"], 0) # This part is for adding examples of individual events text.append("**Example**") text.append("\n```json\n") example = json.dumps(events["example"], indent=4, sort_keys=True) text.append(example) text.append("```\n\n") return text def makeExtension(*args: Any, **kwargs: str) -> MarkdownReturnValuesTableGenerator: return MarkdownReturnValuesTableGenerator(kwargs)
apache-2.0
[ 646, 1331, 199, 646, 2022, 199, 646, 295, 199, 504, 14090, 492, 6184, 12, 7448, 12, 3820, 12, 12340, 12, 4879, 199, 199, 646, 18502, 199, 504, 18502, 14, 5359, 492, 13282, 199, 504, 18502, 14, 657, 10547, 492, 5543, 6459, 199, 199, 504, 19959, 14, 1490, 1246, 14, 1490, 1246, 492, 1104, 63, 6667, 63, 20249, 12, 664, 63, 1490, 1246, 63, 1107, 63, 1459, 199, 199, 504, 1275, 1246, 63, 4958, 63, 1224, 63, 4679, 492, 3550, 63, 576, 63, 466, 199, 199, 10710, 48, 275, 295, 14, 2014, 8, 82, 3212, 91, 4208, 63, 1107, 63, 1459, 63, 1224, 60, 6113, 83, 5830, 11198, 2862, 83, 7590, 6113, 83, 5830, 6977, 2862, 83, 7590, 15412, 421, 199, 533, 24537, 1767, 6550, 3186, 7599, 8, 6382, 304, 272, 347, 636, 826, 721, 277, 12, 11585, 26, 12340, 59, 495, 12, 6184, 61, 275, 5009, 1035, 488, 26, 267, 291, 14, 888, 26, 7448, 59, 495, 12, 6184, 61, 275, 1052, 339, 347, 12247, 30916, 8, 277, 12, 6128, 26, 18502, 14, 30916, 9, 1035, 488, 26, 267, 6128, 14, 657, 10547, 14, 2683, 8, 288, 3261, 1767, 6550, 3186, 16482, 8, 1064, 12, 291, 14, 362, 29123, 4000, 298, 4208, 63, 1107, 63, 1459, 401, 959, 709, 267, 776, 421, 199, 533, 3261, 1767, 6550, 3186, 16482, 8, 16482, 304, 272, 347, 636, 826, 721, 277, 12, 6128, 26, 18502, 14, 30916, 12, 1101, 26, 12340, 59, 495, 12, 6184, 566, 1035, 488, 26, 267, 1613, 11027, 826, 721, 1064, 9, 339, 347, 1255, 8, 277, 12, 2385, 26, 3820, 59, 495, 566, 1035, 3820, 59, 495, 2189, 267, 4224, 275, 756, 267, 1830, 440, 4224, 26, 288, 367, 1004, 315, 2385, 26, 355, 4355, 275, 2385, 14, 1080, 8, 604, 9, 355, 1336, 275, 14142, 11992, 14, 1733, 8, 604, 9, 2234, 340, 440, 1336, 26, 490, 1980, 2234, 1382, 63, 354, 275, 1336, 14, 923, 8, 18, 9, 355, 6037, 12, 1083, 275, 1382, 63, 354, 14, 13490, 480, 6783, 413, 9, 355, 372, 63, 1459, 275, 664, 63, 1490, 1246, 63, 1107, 63, 1459, 8, 6520, 12, 1083, 9, 355, 340, 1382, 63, 354, 508, 3286, 4368, 26, 362, 582, 490, 372, 63, 1459, 275, 1331, 14, 8293, 8, 1107, 63, 1459, 9, 490, 4474, 275, 372, 63, 1459, 905, 4368, 4140, 1935, 480, 1744, 401, 488, 9, 490, 1318, 275, 291, 14, 3352, 63, 1224, 8, 1107, 63, 1459, 12, 378, 9, 490, 327, 22604, 16631, 367, 314, 4474, 3794, 490, 1318, 14, 740, 4582, 78, 60, 78, 309, 27982, 60, 78, 60, 78, 531, 490, 1318, 847, 291, 14, 3352, 63, 4368, 8, 4368, 9, 355, 587, 26, 490, 1318, 275, 291, 14, 3352, 63, 1224, 8, 1107, 63, 1459, 12, 378, 9, 355, 340, 822, 8, 505, 9, 690, 378, 26, 490, 1318, 275, 2097, 381, 1432, 1338, 937, 435, 1318, 355, 1004, 63, 1294, 275, 14142, 11992, 14, 1294, 8, 604, 12, 1390, 1294, 29, 16, 9, 355, 22627, 275, 1004, 63, 1294, 59, 16, 61, 355, 2569, 275, 1004, 63, 1294, 1988, 17, 61, 355, 1318, 275, 359, 657, 301, 1098, 12, 627, 505, 12, 2569, 61, 355, 2385, 275, 2385, 1491, 2102, 61, 435, 1318, 435, 2385, 59, 2102, 435, 413, 12228, 355, 2059, 288, 587, 26, 355, 4224, 275, 715, 267, 372, 2385, 339, 347, 3795, 63, 3257, 8, 267, 291, 12, 1369, 26, 620, 12, 19621, 26, 1109, 12, 666, 63, 466, 26, 620, 12, 372, 63, 585, 26, 4879, 59, 495, 61, 275, 488, 272, 776, 1035, 620, 26, 267, 1369, 275, 1369, 14, 1814, 4582, 78, 401, 1867, 78, 2, 435, 3666, 15880, 435, 841, 9, 627, 298, 26725, 267, 340, 372, 63, 585, 365, 488, 26, 288, 327, 31697, 26, 2779, 1159, 440, 5436, 4212, 370, 675, 3232, 3735, 666, 370, 10405, 288, 327, 314, 658, 498, 64, 1504, 367, 2251, 2382, 325, 14, 71, 14, 314, 2883, 787, 288, 327, 922, 15, 1745, 11449, 3769, 9994, 370, 666, 4568, 543, 288, 327, 5204, 11449, 14, 221, 2136, 11176, 3444, 13743, 5204, 1504, 701, 288, 327, 29963, 626, 314, 18714, 506, 5313, 465, 658, 498, 63, 354, 26, 288, 327, 790, 63, 1802, 64, 436, 6057, 367, 626, 3851, 27, 781, 1929, 288, 327, 370, 506, 25082, 370, 3372, 5560, 2382, 781, 5121, 1172, 658, 7443, 26, 2263, 64, 288, 327, 641, 282, 2945, 1004, 14, 288, 327, 288, 327, 16917, 6657, 12, 781, 1077, 506, 9689, 6020, 626, 10734, 737, 314, 2943, 27, 288, 327, 870, 9834, 436, 511, 63, 1246, 63, 1301, 63, 6520, 365, 2997, 367, 5343, 14, 288, 7953, 275, 1369, 14, 1294, 20308, 3872, 413, 9, 288, 340, 822, 8, 5250, 9, 508, 413, 503, 1867, 78, 2, 315, 7953, 59, 16, 2189, 355, 372, 334, 15880, 627, 298, 6099, 435, 8969, 298, 435, 1369, 288, 334, 498, 63, 354, 12, 790, 63, 1802, 9, 275, 7953, 288, 372, 334, 355, 334, 15880, 627, 298, 6099, 355, 435, 8969, 298, 355, 435, 790, 63, 354, 355, 435, 7244, 298, 355, 435, 2650, 3751, 1021, 628, 1246, 13, 698, 13, 466, 15603, 355, 435, 666, 63, 466, 355, 435, 15683, 3751, 30, 298, 355, 435, 790, 63, 1802, 288, 776, 267, 372, 334, 288, 334, 15880, 627, 298, 6099, 288, 435, 8969, 28531, 288, 435, 372, 63, 585, 288, 435, 298, 8340, 298, 288, 435, 2650, 3751, 1021, 628, 1246, 13, 698, 13, 466, 15603, 288, 435, 666, 63, 466, 288, 435, 15683, 3751, 30, 298, 288, 435, 1369, 267, 776, 339, 347, 3795, 63, 1224, 8, 277, 12, 372, 63, 1459, 26, 7448, 59, 495, 12, 6184, 467, 19621, 26, 1109, 9, 1035, 3820, 59, 495, 2189, 267, 27499, 5788, 275, 2097, 1099, 401, 298, 1328, 937, 267, 4987, 275, 942, 267, 367, 372, 63, 585, 315, 372, 63, 1459, 26, 288, 340, 372, 63, 585, 315, 27499, 5788, 26, 355, 1980, 288, 340, 298, 368, 3466, 2, 315, 372, 63, 1459, 59, 1107, 63, 585, 2189, 355, 327, 2104, 4008, 1808, 1373, 3466, 2337, 787, 2877, 18714, 14, 710, 1642, 1369, 355, 327, 1077, 506, 737, 2166, 543, 314, 1373, 3466, 436 ]
[ 1331, 199, 646, 2022, 199, 646, 295, 199, 504, 14090, 492, 6184, 12, 7448, 12, 3820, 12, 12340, 12, 4879, 199, 199, 646, 18502, 199, 504, 18502, 14, 5359, 492, 13282, 199, 504, 18502, 14, 657, 10547, 492, 5543, 6459, 199, 199, 504, 19959, 14, 1490, 1246, 14, 1490, 1246, 492, 1104, 63, 6667, 63, 20249, 12, 664, 63, 1490, 1246, 63, 1107, 63, 1459, 199, 199, 504, 1275, 1246, 63, 4958, 63, 1224, 63, 4679, 492, 3550, 63, 576, 63, 466, 199, 199, 10710, 48, 275, 295, 14, 2014, 8, 82, 3212, 91, 4208, 63, 1107, 63, 1459, 63, 1224, 60, 6113, 83, 5830, 11198, 2862, 83, 7590, 6113, 83, 5830, 6977, 2862, 83, 7590, 15412, 421, 199, 533, 24537, 1767, 6550, 3186, 7599, 8, 6382, 304, 272, 347, 636, 826, 721, 277, 12, 11585, 26, 12340, 59, 495, 12, 6184, 61, 275, 5009, 1035, 488, 26, 267, 291, 14, 888, 26, 7448, 59, 495, 12, 6184, 61, 275, 1052, 339, 347, 12247, 30916, 8, 277, 12, 6128, 26, 18502, 14, 30916, 9, 1035, 488, 26, 267, 6128, 14, 657, 10547, 14, 2683, 8, 288, 3261, 1767, 6550, 3186, 16482, 8, 1064, 12, 291, 14, 362, 29123, 4000, 298, 4208, 63, 1107, 63, 1459, 401, 959, 709, 267, 776, 421, 199, 533, 3261, 1767, 6550, 3186, 16482, 8, 16482, 304, 272, 347, 636, 826, 721, 277, 12, 6128, 26, 18502, 14, 30916, 12, 1101, 26, 12340, 59, 495, 12, 6184, 566, 1035, 488, 26, 267, 1613, 11027, 826, 721, 1064, 9, 339, 347, 1255, 8, 277, 12, 2385, 26, 3820, 59, 495, 566, 1035, 3820, 59, 495, 2189, 267, 4224, 275, 756, 267, 1830, 440, 4224, 26, 288, 367, 1004, 315, 2385, 26, 355, 4355, 275, 2385, 14, 1080, 8, 604, 9, 355, 1336, 275, 14142, 11992, 14, 1733, 8, 604, 9, 2234, 340, 440, 1336, 26, 490, 1980, 2234, 1382, 63, 354, 275, 1336, 14, 923, 8, 18, 9, 355, 6037, 12, 1083, 275, 1382, 63, 354, 14, 13490, 480, 6783, 413, 9, 355, 372, 63, 1459, 275, 664, 63, 1490, 1246, 63, 1107, 63, 1459, 8, 6520, 12, 1083, 9, 355, 340, 1382, 63, 354, 508, 3286, 4368, 26, 362, 582, 490, 372, 63, 1459, 275, 1331, 14, 8293, 8, 1107, 63, 1459, 9, 490, 4474, 275, 372, 63, 1459, 905, 4368, 4140, 1935, 480, 1744, 401, 488, 9, 490, 1318, 275, 291, 14, 3352, 63, 1224, 8, 1107, 63, 1459, 12, 378, 9, 490, 327, 22604, 16631, 367, 314, 4474, 3794, 490, 1318, 14, 740, 4582, 78, 60, 78, 309, 27982, 60, 78, 60, 78, 531, 490, 1318, 847, 291, 14, 3352, 63, 4368, 8, 4368, 9, 355, 587, 26, 490, 1318, 275, 291, 14, 3352, 63, 1224, 8, 1107, 63, 1459, 12, 378, 9, 355, 340, 822, 8, 505, 9, 690, 378, 26, 490, 1318, 275, 2097, 381, 1432, 1338, 937, 435, 1318, 355, 1004, 63, 1294, 275, 14142, 11992, 14, 1294, 8, 604, 12, 1390, 1294, 29, 16, 9, 355, 22627, 275, 1004, 63, 1294, 59, 16, 61, 355, 2569, 275, 1004, 63, 1294, 1988, 17, 61, 355, 1318, 275, 359, 657, 301, 1098, 12, 627, 505, 12, 2569, 61, 355, 2385, 275, 2385, 1491, 2102, 61, 435, 1318, 435, 2385, 59, 2102, 435, 413, 12228, 355, 2059, 288, 587, 26, 355, 4224, 275, 715, 267, 372, 2385, 339, 347, 3795, 63, 3257, 8, 267, 291, 12, 1369, 26, 620, 12, 19621, 26, 1109, 12, 666, 63, 466, 26, 620, 12, 372, 63, 585, 26, 4879, 59, 495, 61, 275, 488, 272, 776, 1035, 620, 26, 267, 1369, 275, 1369, 14, 1814, 4582, 78, 401, 1867, 78, 2, 435, 3666, 15880, 435, 841, 9, 627, 298, 26725, 267, 340, 372, 63, 585, 365, 488, 26, 288, 327, 31697, 26, 2779, 1159, 440, 5436, 4212, 370, 675, 3232, 3735, 666, 370, 10405, 288, 327, 314, 658, 498, 64, 1504, 367, 2251, 2382, 325, 14, 71, 14, 314, 2883, 787, 288, 327, 922, 15, 1745, 11449, 3769, 9994, 370, 666, 4568, 543, 288, 327, 5204, 11449, 14, 221, 2136, 11176, 3444, 13743, 5204, 1504, 701, 288, 327, 29963, 626, 314, 18714, 506, 5313, 465, 658, 498, 63, 354, 26, 288, 327, 790, 63, 1802, 64, 436, 6057, 367, 626, 3851, 27, 781, 1929, 288, 327, 370, 506, 25082, 370, 3372, 5560, 2382, 781, 5121, 1172, 658, 7443, 26, 2263, 64, 288, 327, 641, 282, 2945, 1004, 14, 288, 327, 288, 327, 16917, 6657, 12, 781, 1077, 506, 9689, 6020, 626, 10734, 737, 314, 2943, 27, 288, 327, 870, 9834, 436, 511, 63, 1246, 63, 1301, 63, 6520, 365, 2997, 367, 5343, 14, 288, 7953, 275, 1369, 14, 1294, 20308, 3872, 413, 9, 288, 340, 822, 8, 5250, 9, 508, 413, 503, 1867, 78, 2, 315, 7953, 59, 16, 2189, 355, 372, 334, 15880, 627, 298, 6099, 435, 8969, 298, 435, 1369, 288, 334, 498, 63, 354, 12, 790, 63, 1802, 9, 275, 7953, 288, 372, 334, 355, 334, 15880, 627, 298, 6099, 355, 435, 8969, 298, 355, 435, 790, 63, 354, 355, 435, 7244, 298, 355, 435, 2650, 3751, 1021, 628, 1246, 13, 698, 13, 466, 15603, 355, 435, 666, 63, 466, 355, 435, 15683, 3751, 30, 298, 355, 435, 790, 63, 1802, 288, 776, 267, 372, 334, 288, 334, 15880, 627, 298, 6099, 288, 435, 8969, 28531, 288, 435, 372, 63, 585, 288, 435, 298, 8340, 298, 288, 435, 2650, 3751, 1021, 628, 1246, 13, 698, 13, 466, 15603, 288, 435, 666, 63, 466, 288, 435, 15683, 3751, 30, 298, 288, 435, 1369, 267, 776, 339, 347, 3795, 63, 1224, 8, 277, 12, 372, 63, 1459, 26, 7448, 59, 495, 12, 6184, 467, 19621, 26, 1109, 9, 1035, 3820, 59, 495, 2189, 267, 27499, 5788, 275, 2097, 1099, 401, 298, 1328, 937, 267, 4987, 275, 942, 267, 367, 372, 63, 585, 315, 372, 63, 1459, 26, 288, 340, 372, 63, 585, 315, 27499, 5788, 26, 355, 1980, 288, 340, 298, 368, 3466, 2, 315, 372, 63, 1459, 59, 1107, 63, 585, 2189, 355, 327, 2104, 4008, 1808, 1373, 3466, 2337, 787, 2877, 18714, 14, 710, 1642, 1369, 355, 327, 1077, 506, 737, 2166, 543, 314, 1373, 3466, 436, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
antepsis/anteplahmacun
sympy/ntheory/tests/test_egyptian_fraction.py
51
1886
from sympy.core.numbers import Rational from sympy.ntheory.egyptian_fraction import egyptian_fraction from sympy.core.add import Add from sympy.utilities.pytest import raises from sympy.utilities.randtest import random_complex_number def test_egyptian_fraction(): def test_equality(r, alg="Greedy"): return r == Add(*[Rational(1, i) for i in egyptian_fraction(r, alg)]) r = random_complex_number(a=0, c=1, b=0, d=0, rational=True) assert test_equality(r) assert egyptian_fraction(Rational(4, 17)) == [5, 29, 1233, 3039345] assert egyptian_fraction(Rational(7, 13), "Greedy") == [2, 26] assert egyptian_fraction(Rational(23, 101), "Greedy") == \ [5, 37, 1438, 2985448, 40108045937720] assert egyptian_fraction(Rational(18, 23), "Takenouchi") == \ [2, 6, 12, 35, 276, 2415] assert egyptian_fraction(Rational(5, 6), "Graham Jewett") == \ [6, 7, 8, 9, 10, 42, 43, 44, 45, 56, 57, 58, 72, 73, 90, 1806, 1807, 1808, 1892, 1893, 1980, 3192, 3193, 3306, 5256, 3263442, 3263443, 3267056, 3581556, 10192056, 10650056950806] assert egyptian_fraction(Rational(5, 6), "Golomb") == [2, 6, 12, 20, 30] assert egyptian_fraction(Rational(5, 121), "Golomb") == [25, 1225, 3577, 7081, 11737] raises(ValueError, lambda: egyptian_fraction(Rational(-4, 9))) assert egyptian_fraction(Rational(8, 3), "Golomb") == [1, 2, 3, 4, 5, 6, 7, 14, 574, 2788, 6460, 11590, 33062, 113820] assert egyptian_fraction(Rational(355, 113)) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 27, 744, 893588, 1251493536607, 20361068938197002344405230]
bsd-3-clause
[ 504, 5840, 14, 1018, 14, 10548, 492, 20164, 199, 504, 5840, 14, 19323, 1089, 14, 5902, 2279, 23035, 63, 13054, 492, 325, 6179, 23035, 63, 13054, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 504, 5840, 14, 16355, 14, 3759, 396, 492, 2196, 63, 5254, 63, 1955, 421, 199, 318, 511, 63, 5902, 2279, 23035, 63, 13054, 837, 272, 347, 511, 63, 20982, 8, 82, 12, 15760, 628, 39, 24737, 2349, 267, 372, 519, 508, 2654, 23151, 20248, 8, 17, 12, 284, 9, 367, 284, 315, 325, 6179, 23035, 63, 13054, 8, 82, 12, 15760, 3948, 339, 519, 275, 2196, 63, 5254, 63, 1955, 8, 65, 29, 16, 12, 286, 29, 17, 12, 330, 29, 16, 12, 366, 29, 16, 12, 30239, 29, 549, 9, 272, 702, 511, 63, 20982, 8, 82, 9, 339, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 20, 12, 5557, 430, 508, 359, 21, 12, 7349, 12, 3144, 1153, 12, 4233, 1355, 9908, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 23, 12, 4944, 395, 298, 39, 24737, 531, 508, 359, 18, 12, 7875, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 1789, 12, 14313, 395, 298, 39, 24737, 531, 508, 971, 267, 359, 21, 12, 6877, 12, 4329, 1703, 12, 499, 2905, 1477, 2006, 12, 13952, 2036, 966, 1427, 7332, 1165, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 1085, 12, 6546, 395, 298, 22620, 917, 13087, 73, 531, 508, 971, 267, 359, 18, 12, 1227, 12, 3144, 12, 8685, 12, 499, 2114, 12, 5504, 1046, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 1227, 395, 298, 5761, 10670, 1603, 546, 386, 84, 531, 508, 971, 267, 359, 22, 12, 1520, 12, 1695, 12, 1749, 12, 1616, 12, 5685, 12, 11851, 12, 10868, 12, 10416, 12, 12001, 12, 12699, 12, 13713, 12, 15323, 12, 18525, 12, 9137, 12, 413, 11901, 12, 413, 11369, 12, 268, 413, 11292, 12, 413, 15765, 12, 413, 14590, 12, 5851, 1257, 12, 650, 5756, 12, 650, 13015, 12, 650, 11363, 12, 959, 3912, 12, 650, 1479, 1082, 2260, 12, 650, 1479, 1082, 2824, 12, 268, 650, 1479, 2760, 1367, 12, 650, 2010, 1046, 1367, 12, 413, 12512, 1165, 1367, 12, 1616, 2182, 383, 15143, 1400, 11901, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 1227, 395, 298, 7250, 320, 887, 531, 508, 359, 18, 12, 1227, 12, 3144, 12, 3388, 12, 4233, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 26228, 395, 298, 7250, 320, 887, 531, 508, 359, 821, 12, 3144, 821, 12, 8685, 1138, 12, 1520, 19896, 12, 26189, 1401, 61, 272, 6534, 8, 3393, 12, 2400, 26, 325, 6179, 23035, 63, 13054, 8, 20248, 2801, 20, 12, 1749, 1724, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 24, 12, 650, 395, 298, 7250, 320, 887, 531, 508, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 15491, 4329, 12, 959, 1342, 12, 8087, 1299, 12, 5049, 2259, 12, 15491, 22560, 2710, 12, 13540, 2789, 12, 413, 8527, 1165, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 10156, 12, 24073, 430, 508, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 12, 9349, 1616, 12, 4119, 12, 3144, 12, 8087, 12, 9720, 20, 12, 17838, 1276, 1299, 12, 9349, 19163, 10721, 1276, 11065, 1780, 12, 9349, 3388, 1344, 7357, 1407, 1703, 11165, 383, 5533, 1602, 1717, 9687, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5840, 14, 1018, 14, 10548, 492, 20164, 199, 504, 5840, 14, 19323, 1089, 14, 5902, 2279, 23035, 63, 13054, 492, 325, 6179, 23035, 63, 13054, 199, 504, 5840, 14, 1018, 14, 525, 492, 2654, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 504, 5840, 14, 16355, 14, 3759, 396, 492, 2196, 63, 5254, 63, 1955, 421, 199, 318, 511, 63, 5902, 2279, 23035, 63, 13054, 837, 272, 347, 511, 63, 20982, 8, 82, 12, 15760, 628, 39, 24737, 2349, 267, 372, 519, 508, 2654, 23151, 20248, 8, 17, 12, 284, 9, 367, 284, 315, 325, 6179, 23035, 63, 13054, 8, 82, 12, 15760, 3948, 339, 519, 275, 2196, 63, 5254, 63, 1955, 8, 65, 29, 16, 12, 286, 29, 17, 12, 330, 29, 16, 12, 366, 29, 16, 12, 30239, 29, 549, 9, 272, 702, 511, 63, 20982, 8, 82, 9, 339, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 20, 12, 5557, 430, 508, 359, 21, 12, 7349, 12, 3144, 1153, 12, 4233, 1355, 9908, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 23, 12, 4944, 395, 298, 39, 24737, 531, 508, 359, 18, 12, 7875, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 1789, 12, 14313, 395, 298, 39, 24737, 531, 508, 971, 267, 359, 21, 12, 6877, 12, 4329, 1703, 12, 499, 2905, 1477, 2006, 12, 13952, 2036, 966, 1427, 7332, 1165, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 1085, 12, 6546, 395, 298, 22620, 917, 13087, 73, 531, 508, 971, 267, 359, 18, 12, 1227, 12, 3144, 12, 8685, 12, 499, 2114, 12, 5504, 1046, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 1227, 395, 298, 5761, 10670, 1603, 546, 386, 84, 531, 508, 971, 267, 359, 22, 12, 1520, 12, 1695, 12, 1749, 12, 1616, 12, 5685, 12, 11851, 12, 10868, 12, 10416, 12, 12001, 12, 12699, 12, 13713, 12, 15323, 12, 18525, 12, 9137, 12, 413, 11901, 12, 413, 11369, 12, 268, 413, 11292, 12, 413, 15765, 12, 413, 14590, 12, 5851, 1257, 12, 650, 5756, 12, 650, 13015, 12, 650, 11363, 12, 959, 3912, 12, 650, 1479, 1082, 2260, 12, 650, 1479, 1082, 2824, 12, 268, 650, 1479, 2760, 1367, 12, 650, 2010, 1046, 1367, 12, 413, 12512, 1165, 1367, 12, 1616, 2182, 383, 15143, 1400, 11901, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 1227, 395, 298, 7250, 320, 887, 531, 508, 359, 18, 12, 1227, 12, 3144, 12, 3388, 12, 4233, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 21, 12, 26228, 395, 298, 7250, 320, 887, 531, 508, 359, 821, 12, 3144, 821, 12, 8685, 1138, 12, 1520, 19896, 12, 26189, 1401, 61, 272, 6534, 8, 3393, 12, 2400, 26, 325, 6179, 23035, 63, 13054, 8, 20248, 2801, 20, 12, 1749, 1724, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 24, 12, 650, 395, 298, 7250, 320, 887, 531, 508, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 15491, 4329, 12, 959, 1342, 12, 8087, 1299, 12, 5049, 2259, 12, 15491, 22560, 2710, 12, 13540, 2789, 12, 413, 8527, 1165, 61, 272, 702, 325, 6179, 23035, 63, 13054, 8, 20248, 8, 10156, 12, 24073, 430, 508, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 12, 9349, 1616, 12, 4119, 12, 3144, 12, 8087, 12, 9720, 20, 12, 17838, 1276, 1299, 12, 9349, 19163, 10721, 1276, 11065, 1780, 12, 9349, 3388, 1344, 7357, 1407, 1703, 11165, 383, 5533, 1602, 1717, 9687, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
thp44/delphin_6_automation
data_process/2d_1d/archieve/moisture_content_comparison.py
1
18274
__author__ = "Christian Kongsgaard" __license__ = 'MIT' # -------------------------------------------------------------------------------------------------------------------- # # IMPORTS # Modules import pandas as pd import matplotlib.pyplot as plt # RiBuild Modules # -------------------------------------------------------------------------------------------------------------------- # # RIBuild out_folder = r'C:\Users\ocni\PycharmProjects\delphin_6_automation\data_process\2d_1d\processed_data' graphic_folder = r'U:\RIBuild\2D_1D\Processed Results\4A' hdf_file = out_folder + '/relative_moisture_content.h5' # Open HDF # Uninsulated dresdenzp_highratio_uninsulated_4a = pd.read_hdf(hdf_file, 'dresden_zp_high_ratio_uninsulated_4a') dresdenzd_highratio_uninsulated_4a = pd.read_hdf(hdf_file, 'dresden_zd_high_ratio_uninsulated_4a') postdam_highratio_uninsulated_4a = pd.read_hdf(hdf_file, 'potsdam_high_ratio_uninsulated_4a') dresdenzp_lowratio_uninsulated_4a = pd.read_hdf(hdf_file, 'dresden_zp_low_ratio_uninsulated_4a') dresdenzd_lowratio_uninsulated_4a = pd.read_hdf(hdf_file, 'dresden_zd_low_ratio_uninsulated_4a') postdam_lowratio_uninsulated_4a = pd.read_hdf(hdf_file, 'potsdam_low_ratio_uninsulated_4a') total_uninsulated_4a = pd.concat([dresdenzp_highratio_uninsulated_4a, dresdenzd_highratio_uninsulated_4a, postdam_highratio_uninsulated_4a, dresdenzp_lowratio_uninsulated_4a, dresdenzd_lowratio_uninsulated_4a, postdam_lowratio_uninsulated_4a]) # Insulated dresdenzp_highratio_insulated_4a = pd.read_hdf(hdf_file, 'dresden_zp_high_ratio_insulated_4a') dresdenzd_highratio_insulated_4a = pd.read_hdf(hdf_file, 'dresden_zd_high_ratio_insulated_4a') postdam_highratio_insulated_4a = pd.read_hdf(hdf_file, 'potsdam_high_ratio_insulated_4a') dresdenzp_lowratio_insulated_4a = pd.read_hdf(hdf_file, 'dresden_zp_low_ratio_insulated_4a') dresdenzd_lowratio_insulated_4a = pd.read_hdf(hdf_file, 'dresden_zd_low_ratio_insulated_4a') postdam_lowratio_insulated_4a = pd.read_hdf(hdf_file, 'potsdam_low_ratio_insulated_4a') total_insulated_4a = pd.concat([dresdenzp_highratio_insulated_4a, dresdenzd_highratio_insulated_4a, postdam_highratio_insulated_4a, dresdenzp_lowratio_insulated_4a, dresdenzd_lowratio_insulated_4a, postdam_lowratio_insulated_4a]) def plots(plot, save=False): """ Creates box plots from all the wall scenarios """ if plot == 'uninsulated' or plot == 'all': plt.figure('dresdenzp_highratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzp_highratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZP - Mortar: High Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/dresdenzp_highratio_uninsulated_4a_moisture") plt.figure('dresdenzd_highratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzd_highratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZD - Mortar: High Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/dresdenzd_highratio_uninsulated_4a_moisture") plt.figure('postdam_highratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) postdam_highratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Potsdam - Mortar: High Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/postdam_highratio_uninsulated_4a_moisture") plt.figure('dresdenzp_lowratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzp_lowratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZP - Mortar: Low Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/dresdenzp_lowratio_uninsulated_4a_moisture") plt.figure('dresdenzd_lowratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzd_lowratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZD - Mortar: Low Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/dresdenzd_lowratio_uninsulated_4a_moisture") plt.figure('postdam_lowratio_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) postdam_lowratio_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Potsdam - Mortar: Low Cement Ratio - Insulation: None') if save: plt.savefig(f"{graphic_folder}/postdam_lowratio_uninsulated_4a_moisture") plt.figure('total_uninsulated_4a_moisture', figsize=(16, 8), tight_layout=True) total_uninsulated_4a.boxplot(showfliers=False) plt.ylim(-5, 1100) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: All - Mortar: All - Insulation: None') if save: plt.savefig(f"{graphic_folder}/total_uninsulated_4a_moisture") if plot == 'insulated' or plot == 'all': plt.figure('dresdenzp_highratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzp_highratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZP - Mortar: High Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/dresdenzp_highratio_insulated_4a_moisture") plt.figure('dresdenzd_highratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzd_highratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZD - Mortar: High Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/dresdenzd_highratio_insulated_4a_moisture") plt.figure('postdam_highratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) postdam_highratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Potsdam - Mortar: High Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/postdam_highratio_insulated_4a_moisture") plt.figure('dresdenzp_lowratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzp_lowratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZP - Mortar: Low Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/dresdenzp_lowratio_insulated_4a_moisture") plt.figure('dresdenzd_lowratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) dresdenzd_lowratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Dresden ZD - Mortar: Low Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/dresdenzd_lowratio_insulated_4a_moisture") plt.figure('postdam_lowratio_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) postdam_lowratio_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: Potsdam - Mortar: Low Cement Ratio - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/postdam_lowratio_insulated_4a_moisture") plt.figure('total_insulated_4a_moisture', figsize=(16, 8), tight_layout=True) total_insulated_4a.boxplot(showfliers=False) plt.ylim(-5, 2000) plt.ylabel('Relative Difference in %') plt.title('Weighted Relative Difference between 1D and 2D\n' 'Moisture Content\n' 'Brick: All - Mortar: All - Insulation: Calcium Silicate') if save: plt.savefig(f"{graphic_folder}/total_insulated_4a_moisture") plt.show() plots('all', False) def std3_ratio(print_=False, excel=False): """Computes ratio of outliers in the data sets. Outliers is here defined as data points deviating with more the 3 standard deviations from the mean.""" std3_uninsulated_ratio_ = uninsulated() std3_insulated_ratio_ = insulated() if print_: print('Uninsulated') print(std3_uninsulated_ratio_) print('') print('Insulated') print(std3_insulated_ratio_) if excel: writer = pd.ExcelWriter(f'{out_folder}/moisture_std_ratios.xlsx') std3_uninsulated_ratio_.to_excel(writer, 'Uninsulated') std3_insulated_ratio_.to_excel(writer, 'Insulated') writer.save() def uninsulated(): """Computes the outliers for the uninsulated cases""" outliers_total_uninsulated = (total_uninsulated_4a.shape[0] - total_uninsulated_4a.sub(total_uninsulated_4a.mean()) .div(total_uninsulated_4a.std()).abs().lt(3).sum()) / total_uninsulated_4a.shape[0] outliers_zd_high_uninsulated = (dresdenzd_highratio_uninsulated_4a.shape[0] - dresdenzd_highratio_uninsulated_4a.sub(dresdenzd_highratio_uninsulated_4a.mean()) .div(dresdenzd_highratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / dresdenzd_highratio_uninsulated_4a.shape[0] outliers_zp_high_uninsulated = (dresdenzp_highratio_uninsulated_4a.shape[0] - dresdenzp_highratio_uninsulated_4a.sub(dresdenzp_highratio_uninsulated_4a.mean()) .div(dresdenzp_highratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / dresdenzp_highratio_uninsulated_4a.shape[0] outliers_pd_high_uninsulated = (postdam_highratio_uninsulated_4a.shape[0] - postdam_highratio_uninsulated_4a.sub(postdam_highratio_uninsulated_4a.mean()) .div(postdam_highratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / postdam_highratio_uninsulated_4a.shape[0] outliers_zd_low_uninsulated = (dresdenzd_lowratio_uninsulated_4a.shape[0] - dresdenzd_lowratio_uninsulated_4a.sub(dresdenzd_lowratio_uninsulated_4a.mean()) .div(dresdenzd_lowratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / dresdenzd_lowratio_uninsulated_4a.shape[0] outliers_zp_low_uninsulated = (dresdenzp_lowratio_uninsulated_4a.shape[0] - dresdenzp_lowratio_uninsulated_4a.sub(dresdenzp_lowratio_uninsulated_4a.mean()) .div(dresdenzp_lowratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / dresdenzp_lowratio_uninsulated_4a.shape[0] outliers_pd_low_uninsulated = (postdam_lowratio_uninsulated_4a.shape[0] - postdam_lowratio_uninsulated_4a.sub(postdam_lowratio_uninsulated_4a.mean()) .div(postdam_lowratio_uninsulated_4a.std()).abs().lt(3).sum()) \ / postdam_lowratio_uninsulated_4a.shape[0] outliers_uninsulated_ratio_ = pd.concat([outliers_total_uninsulated, outliers_zd_high_uninsulated, outliers_zp_high_uninsulated, outliers_pd_high_uninsulated, outliers_zd_low_uninsulated, outliers_zp_low_uninsulated, outliers_pd_low_uninsulated], axis=1) outliers_uninsulated_ratio_.columns = ["Brick: All - Mortar: All - Insulation: None", "Brick: Dresden ZD - Mortar: High Cement Ratio - Insulation: None", "Brick: Dresden ZP - Mortar: High Cement Ratio - Insulation: None", "Brick: Potsdam - Mortar: High Cement Ratio - Insulation: None", "Brick: Dresden ZD - Mortar: Low Cement Ratio - Insulation: None", "Brick: Dresden ZP - Mortar: Low Cement Ratio - Insulation: None", "Brick: Potsdam - Mortar: Low Cement Ratio - Insulation: None"] return outliers_uninsulated_ratio_ def insulated(): """Computes the outliers for the insulated cases""" outliers_total_insulated = (total_insulated_4a.shape[0] - total_insulated_4a.sub(total_insulated_4a.mean()) .div(total_insulated_4a.std()).abs().lt(3).sum()) / total_insulated_4a.shape[0] outliers_zd_high_insulated = (dresdenzd_highratio_insulated_4a.shape[0] - dresdenzd_highratio_insulated_4a.sub(dresdenzd_highratio_insulated_4a.mean()) .div(dresdenzd_highratio_insulated_4a.std()).abs().lt(3).sum()) \ / dresdenzd_highratio_insulated_4a.shape[0] outliers_zp_high_insulated = (dresdenzp_highratio_insulated_4a.shape[0] - dresdenzp_highratio_insulated_4a.sub(dresdenzp_highratio_insulated_4a.mean()) .div(dresdenzp_highratio_insulated_4a.std()).abs().lt(3).sum()) \ / dresdenzp_highratio_insulated_4a.shape[0] outliers_pd_high_insulated = (postdam_highratio_insulated_4a.shape[0] - postdam_highratio_insulated_4a.sub(postdam_highratio_insulated_4a.mean()) .div(postdam_highratio_insulated_4a.std()).abs().lt(3).sum()) \ / postdam_highratio_insulated_4a.shape[0] outliers_zd_low_insulated = (dresdenzd_lowratio_insulated_4a.shape[0] - dresdenzd_lowratio_insulated_4a.sub(dresdenzd_lowratio_insulated_4a.mean()) .div(dresdenzd_lowratio_insulated_4a.std()).abs().lt(3).sum()) \ / dresdenzd_lowratio_insulated_4a.shape[0] outliers_zp_low_insulated = (dresdenzp_lowratio_insulated_4a.shape[0] - dresdenzp_lowratio_insulated_4a.sub(dresdenzp_lowratio_insulated_4a.mean()) .div(dresdenzp_lowratio_insulated_4a.std()).abs().lt(3).sum()) \ / dresdenzp_lowratio_insulated_4a.shape[0] outliers_pd_low_insulated = (postdam_lowratio_insulated_4a.shape[0] - postdam_lowratio_insulated_4a.sub(postdam_lowratio_insulated_4a.mean()) .div(postdam_lowratio_insulated_4a.std()).abs().lt(3).sum()) \ / postdam_lowratio_insulated_4a.shape[0] std2_insulated_ratio_ = pd.concat([outliers_total_insulated, outliers_zd_high_insulated, outliers_zp_high_insulated, outliers_pd_high_insulated, outliers_zd_low_insulated, outliers_zp_low_insulated, outliers_pd_low_insulated], axis=1) std2_insulated_ratio_.columns = ["Brick: All - Mortar: All - Insulation: None", "Brick: Dresden ZD - Mortar: High Cement Ratio - Insulation: Calcium Silicate", "Brick: Dresden ZP - Mortar: High Cement Ratio - Insulation: Calcium Silicate", "Brick: Potsdam - Mortar: High Cement Ratio - Insulation: Calcium Silicate", "Brick: Dresden ZD - Mortar: Low Cement Ratio - Insulation: Calcium Silicate", "Brick: Dresden ZP - Mortar: Low Cement Ratio - Insulation: Calcium Silicate", "Brick: Potsdam - Mortar: Low Cement Ratio - Insulation: Calcium Silicate"] return std2_insulated_ratio_ #std3_ratio(False, True)
mit
[ 363, 2502, 363, 275, 298, 1049, 18824, 5653, 1804, 12358, 5294, 1005, 2, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 5025, 2596, 51, 199, 199, 3, 18167, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 3, 820, 73, 3425, 18167, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 820, 41, 3425, 199, 199, 548, 63, 3741, 275, 519, 7, 35, 3427, 12117, 60, 679, 8445, 60, 2713, 1560, 77, 24286, 60, 2264, 838, 262, 63, 22, 63, 23867, 60, 576, 63, 1412, 60, 18, 68, 63, 17, 68, 60, 7292, 63, 576, 7, 199, 9770, 63, 3741, 275, 519, 7, 53, 3427, 6129, 3425, 60, 18, 36, 63, 17, 36, 60, 919, 4234, 24288, 60, 20, 33, 7, 199, 19912, 63, 493, 275, 734, 63, 3741, 435, 1994, 6188, 63, 573, 631, 608, 63, 1317, 14, 72, 21, 7, 199, 199, 3, 3232, 24521, 199, 3, 1910, 3617, 8097, 199, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 90, 80, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 199, 2923, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 9419, 779, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 23670, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 3303, 2963, 68, 455, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 90, 80, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 3303, 366, 470, 848, 23670, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 2963, 68, 455, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 566, 199, 199, 3, 12062, 8097, 199, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 90, 80, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 199, 2923, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 9419, 779, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 23670, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 1816, 2963, 68, 455, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 90, 80, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 12, 1816, 366, 470, 848, 23670, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 12, 2963, 68, 455, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 566, 421, 199, 318, 19695, 8, 2798, 12, 3354, 29, 797, 304, 272, 408, 272, 10560, 5689, 19695, 687, 1006, 314, 19882, 28444, 272, 408, 339, 340, 5137, 508, 283, 324, 3617, 8097, 7, 503, 5137, 508, 283, 452, 356, 267, 4488, 14, 8941, 360, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 63, 573, 631, 608, 297, 6085, 890, 2687, 975, 12, 1695, 395, 3367, 913, 63, 4209, 29, 549, 9, 267, 366, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 14, 1977, 2798, 8, 2384, 70, 14035, 29, 797, 9, 267, 4488, 14, 18123, 2801, 21, 12, 413, 1960, 9, 267, 4488, 14, 13849, 360, 15277, 18029, 4646, 315, 450, 358, 267, 4488, 14, 1213, 360, 6004, 8364, 22419, 18029 ]
[ 2502, 363, 275, 298, 1049, 18824, 5653, 1804, 12358, 5294, 1005, 2, 199, 363, 1682, 363, 275, 283, 13965, 7, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 5025, 2596, 51, 199, 199, 3, 18167, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 3, 820, 73, 3425, 18167, 199, 199, 3, 5620, 6489, 375, 327, 199, 3, 820, 41, 3425, 199, 199, 548, 63, 3741, 275, 519, 7, 35, 3427, 12117, 60, 679, 8445, 60, 2713, 1560, 77, 24286, 60, 2264, 838, 262, 63, 22, 63, 23867, 60, 576, 63, 1412, 60, 18, 68, 63, 17, 68, 60, 7292, 63, 576, 7, 199, 9770, 63, 3741, 275, 519, 7, 53, 3427, 6129, 3425, 60, 18, 36, 63, 17, 36, 60, 919, 4234, 24288, 60, 20, 33, 7, 199, 19912, 63, 493, 275, 734, 63, 3741, 435, 1994, 6188, 63, 573, 631, 608, 63, 1317, 14, 72, 21, 7, 199, 199, 3, 3232, 24521, 199, 3, 1910, 3617, 8097, 199, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 90, 80, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 324, 3617, 8097, 63, 20, 65, 358, 199, 199, 2923, 63, 324, 3617, 8097, 63, 20, 65, 275, 6454, 14, 9419, 779, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 23670, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 3303, 2963, 68, 455, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 90, 80, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 3303, 366, 470, 848, 23670, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 12, 2963, 68, 455, 63, 674, 6884, 63, 324, 3617, 8097, 63, 20, 65, 566, 199, 199, 3, 12062, 8097, 199, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 6260, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 90, 80, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 90, 80, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 68, 470, 848, 23670, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 68, 470, 848, 63, 23670, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 555, 1516, 455, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 739, 63, 19912, 8, 19912, 63, 493, 12, 283, 14173, 3893, 455, 63, 674, 63, 6884, 63, 3617, 8097, 63, 20, 65, 358, 199, 199, 2923, 63, 3617, 8097, 63, 20, 65, 275, 6454, 14, 9419, 779, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 23670, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 1816, 2963, 68, 455, 63, 6260, 6884, 63, 3617, 8097, 63, 20, 65, 12, 366, 470, 848, 90, 80, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 12, 1816, 366, 470, 848, 23670, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 12, 2963, 68, 455, 63, 674, 6884, 63, 3617, 8097, 63, 20, 65, 566, 421, 199, 318, 19695, 8, 2798, 12, 3354, 29, 797, 304, 272, 408, 272, 10560, 5689, 19695, 687, 1006, 314, 19882, 28444, 272, 408, 339, 340, 5137, 508, 283, 324, 3617, 8097, 7, 503, 5137, 508, 283, 452, 356, 267, 4488, 14, 8941, 360, 68, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 63, 573, 631, 608, 297, 6085, 890, 2687, 975, 12, 1695, 395, 3367, 913, 63, 4209, 29, 549, 9, 267, 366, 470, 848, 90, 80, 63, 6260, 6884, 63, 324, 3617, 8097, 63, 20, 65, 14, 1977, 2798, 8, 2384, 70, 14035, 29, 797, 9, 267, 4488, 14, 18123, 2801, 21, 12, 413, 1960, 9, 267, 4488, 14, 13849, 360, 15277, 18029, 4646, 315, 450, 358, 267, 4488, 14, 1213, 360, 6004, 8364, 22419, 18029, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kingvuplus/Gui3
lib/python/Plugins/newplugin.py
90
3448
#!/usr/bin/python import os os.system("clear") internalname = raw_input("Internal plugin name (no whitespaces, plugin directory): ") name = raw_input("Visible plugin name: ") print os.system("clear") dirlist = [] count = 0 print "Plugin categories:" for dir in os.listdir("."): if os.path.isdir(dir): count += 1 dirlist.append(dir) print count, dir category = raw_input("Select plugin category: ") category = dirlist[int(category) - 1] def add_where_extensionsmenu(name, fnc): description = raw_input("Plugin description: ") return 'PluginDescriptor(name = "%s", description = _("%s"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = %s)' % (name, description, fnc) def add_where_pluginmenu(name, fnc): description = raw_input("Plugin description: ") icon = raw_input("Icon (default: 'plugin.png': ") if icon == "": icon = "plugin.png" return 'PluginDescriptor(name = "%s", description = _("%s"), icon = "%s", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = %s)' % (name, description, icon, fnc) wherelist = [("WHERE_EXTENSIONSMENU", add_where_extensionsmenu), ("WHERE_PLUGINMENU", add_where_pluginmenu)] targetlist = [] stop = False while not stop: os.system("clear") print "selected targets:" for where in targetlist: print where[0] print print "available targets:" count = 0 for where in wherelist: count += 1 print count, where[0] print "x break" target = raw_input("Select WHERE-target: ") if target == "x": stop = True else: if wherelist[int(target) - 1] not in targetlist: targetlist.append(wherelist[int(target) - 1]) else: targetlist.remove(wherelist[int(target) - 1]) pluginpath = category + "/" + internalname os.mkdir(pluginpath) makefile = open(category + "/Makefile.am", "r") lines = makefile.readlines() lines = ''.join(lines) lines = lines.strip() lines += " " + internalname makefile.close() makefile = open(category + "/Makefile.am", "w") makefile.write(lines) makefile.close() lines = [] print "open" configure = open("../../../configure.ac", "r") while True: line = configure.readline() if not line: break lines.append(line) if line.strip() == "lib/python/Plugins/" + category + "/Makefile": lines.append("lib/python/Plugins/" + pluginpath + "/Makefile\n") configure.close() print "close" configure = open("../../../configure.ac", "w") configure.writelines(lines) configure.close() file = open(pluginpath + "/plugin.py", "w") importlist = [] for where in targetlist: importlist.append(where[0]) file.write("""from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor """) mainlist = [] for count in range(len(targetlist)): if count == 0: mainlist.append("main") else: mainlist.append("main" + str(count)) for main in mainlist: file.write(""" def %s(session, **kwargs): pass """ % main) descriptorlist = [] for count in range(len(targetlist)): os.system("clear") where = targetlist[count] print "Options for target %s" % where[0] descriptorlist.append(where[1](name, mainlist[count])) if len(descriptorlist) == 1: descriptorlist = descriptorlist[0] else: descriptorlist = "[" + ', '.join(descriptorlist) + "]" file.write(""" def Plugins(**kwargs): return %s """ % descriptorlist) file.close() makefile = open(pluginpath + "/Makefile.am", "w") makefile.write("""installdir = $(pkglibdir)/python/Plugins/%s/%s install_PYTHON = \\ __init__.py \\ plugin.py """ % (category, internalname)) makefile.close()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 747, 199, 199, 736, 14, 2253, 480, 3584, 531, 199, 4672, 354, 275, 3066, 63, 1210, 480, 8405, 3589, 536, 334, 889, 704, 31926, 12, 3589, 2082, 304, 6099, 199, 354, 275, 3066, 63, 1210, 480, 14917, 3589, 536, 26, 6099, 199, 1361, 199, 199, 736, 14, 2253, 480, 3584, 531, 199, 694, 513, 275, 942, 199, 835, 275, 378, 199, 1361, 298, 5061, 9695, 5424, 199, 509, 2935, 315, 747, 14, 7374, 480, 30946, 199, 198, 692, 747, 14, 515, 14, 6027, 8, 694, 304, 507, 198, 835, 847, 413, 507, 198, 694, 513, 14, 740, 8, 694, 9, 507, 198, 1361, 2338, 12, 2935, 199, 199, 3710, 275, 3066, 63, 1210, 480, 5446, 3589, 4637, 26, 6099, 199, 3710, 275, 2935, 513, 59, 442, 8, 3710, 9, 446, 413, 61, 199, 199, 318, 1050, 63, 4509, 63, 5359, 4470, 8, 354, 12, 4325, 67, 304, 199, 198, 1802, 275, 3066, 63, 1210, 480, 5061, 1369, 26, 6099, 199, 198, 1107, 283, 5061, 4311, 8, 354, 275, 2071, 83, 401, 1369, 275, 485, 3647, 83, 1288, 2382, 275, 11349, 4311, 14, 17688, 63, 18451, 18223, 12, 4325, 67, 275, 450, 83, 3171, 450, 334, 354, 12, 1369, 12, 4325, 67, 9, 199, 199, 318, 1050, 63, 4509, 63, 2718, 4470, 8, 354, 12, 4325, 67, 304, 199, 198, 1802, 275, 3066, 63, 1210, 480, 5061, 1369, 26, 6099, 199, 198, 4677, 275, 3066, 63, 1210, 480, 8954, 334, 885, 26, 283, 2718, 14, 4524, 356, 6099, 199, 198, 692, 7016, 508, 10812, 507, 198, 4677, 275, 298, 2718, 14, 4524, 2, 199, 198, 1107, 283, 5061, 4311, 8, 354, 275, 2071, 83, 401, 1369, 275, 485, 3647, 83, 1288, 7016, 275, 2071, 83, 401, 2382, 275, 11349, 4311, 14, 17688, 63, 19108, 18223, 12, 4325, 67, 275, 450, 83, 3171, 450, 334, 354, 12, 1369, 12, 7016, 12, 4325, 67, 9, 199, 199, 4509, 513, 275, 10003, 17688, 63, 18451, 18223, 401, 1050, 63, 4509, 63, 5359, 4470, 395, 1689, 17688, 63, 19108, 18223, 401, 1050, 63, 4509, 63, 2718, 4470, 1874, 199, 199, 1375, 513, 275, 942, 199, 199, 2379, 275, 756, 199, 199, 6710, 440, 3631, 26, 199, 198, 736, 14, 2253, 480, 3584, 531, 199, 198, 1361, 298, 5511, 4545, 5424, 199, 198, 509, 2382, 315, 1347, 513, 26, 507, 198, 1361, 2382, 59, 16, 61, 421, 198, 1361, 199, 198, 1361, 298, 4561, 4545, 5424, 199, 198, 835, 275, 378, 199, 198, 509, 2382, 315, 2382, 513, 26, 507, 198, 835, 847, 413, 507, 198, 1361, 2338, 12, 2382, 59, 16, 61, 199, 198, 1361, 298, 88, 2059, 2, 421, 198, 1375, 275, 3066, 63, 1210, 480, 5446, 6038, 13, 1375, 26, 6099, 199, 198, 692, 1347, 508, 298, 88, 582, 507, 198, 2379, 275, 715, 199, 198, 2836, 26, 507, 198, 692, 2382, 513, 59, 442, 8, 1375, 9, 446, 413, 61, 440, 315, 1347, 513, 26, 686, 198, 1375, 513, 14, 740, 8, 4509, 513, 59, 442, 8, 1375, 9, 446, 413, 566, 507, 198, 2836, 26, 686, 198, 1375, 513, 14, 2168, 8, 4509, 513, 59, 442, 8, 1375, 9, 446, 413, 566, 421, 199, 2718, 515, 275, 4637, 435, 10609, 435, 221, 5007, 354, 199, 736, 14, 8215, 8, 2718, 515, 9, 199, 199, 13941, 275, 1551, 8, 3710, 435, 3286, 19878, 14, 455, 401, 298, 82, 531, 199, 1278, 275, 16818, 14, 9684, 342, 199, 1278, 275, 6522, 904, 8, 1278, 9, 199, 1278, 275, 2385, 14, 1913, 342, 199, 1278, 847, 298, 298, 435, 5007, 354, 199, 13941, 14, 1600, 342, 199, 199, 13941, 275, 1551, 8, 3710, 435, 3286, 19878, 14, 455, 401, 298, 87, 531, 199, 13941, 14, 952, 8, 1278, 9, 199, 13941, 14, 1600, 342, 199, 199, 1278, 275, 942, 199, 1361, 298, 1490, 2, 199, 6472, 275, 1551, 480, 29866, 6472, 14, 645, 401, 298, 82, 531, 199, 6710, 715, 26, 199, 198, 604, 275, 7908, 14, 6407, 342, 199, 198, 692, 440, 1004, 26, 507, 198, 4785, 199, 198, 1278, 14, 740, 8, 604, 9, 199, 198, 692, 1004, 14, 1913, 342, 508, 298, 773, 15, 1548, 15, 19330, 6687, 435, 4637, 435, 3286, 19878, 582, 507, 198, 1278, 14, 740, 480, 773, 15, 1548, 15, 19330, 6687, 435, 3589, 515, 435, 3286, 19878, 60, 78, 531, 199, 6472, 14, 1600, 342, 199, 1361, 298, 1600, 2, 199, 199, 6472, 275, 1551, 480, 29866, 6472, 14, 645, 401, 298, 87, 531, 199, 6472, 14, 23277, 8, 1278, 9, 199, 6472, 14, 1600, 342, 199, 199, 493, 275, 1551, 8, 2718, 515, 435, 3286, 2718, 14, 647, 401, 298, 87, 531, 199, 199, 646, 513, 275, 942, 199, 509, 2382, 315, 1347, 513, 26, 199, 198, 646, 513, 14, 740, 8, 4509, 59, 16, 566, 199, 199, 493, 14, 952, 4852, 504, 29372, 14, 9616, 492, 17804, 199, 504, 30317, 14, 5061, 492, 11349, 4311, 199, 6141, 199, 199, 973, 513, 275, 942, 199, 509, 2338, 315, 1425, 8, 552, 8, 1375, 513, 2298, 199, 198, 692, 2338, 508, 378, 26, 507, 198, 973, 513, 14, 740, 480, 973, 531, 199, 198, 2836, 26, 507, 198, 973, 513, 14, 740, 480, 973, 2, 435, 620, 8, 835, 430, 199, 199, 509, 2446, 315, 2446, 513, 26, 199, 198, 493, 14, 952, 4852, 199, 318, 450, 83, 8, 1730, 12, 1011, 958, 304, 199, 198, 1529, 199, 624, 450, 2446, 9, 199, 199, 4120, 513, 275, 942, 199, 509, 2338, 315, 1425, 8, 552, 8, 1375, 513, 2298, 199, 198, 736, 14, 2253, 480, 3584, 531, 199, 198, 4509, 275, 1347, 513, 59, 835, 61, 199, 198, 1361, 298, 4558, 367, 1347, 450, 83, 2, 450, 2382, 59, 16, 61, 199, 198, 4120, 513, 14, 740, 8, 4509, 59, 17, 8738, 354, 12, 2446, 513, 59, 835, 2459, 199, 199, 692, 822, 8, 4120, 513, 9, 508, 413, 26, 199, 198, 4120, 513, 275, 5872, 513, 59, 16, 61, 199, 2836, 26, 199, 198, 4120, 513, 275, 32607, 435, 1656, 1987, 904, 8, 4120, 513, 9, 435, 298, 8480, 199, 199, 493, 14, 952, 4852, 199, 318, 30317, 3682, 958 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 747, 199, 199, 736, 14, 2253, 480, 3584, 531, 199, 4672, 354, 275, 3066, 63, 1210, 480, 8405, 3589, 536, 334, 889, 704, 31926, 12, 3589, 2082, 304, 6099, 199, 354, 275, 3066, 63, 1210, 480, 14917, 3589, 536, 26, 6099, 199, 1361, 199, 199, 736, 14, 2253, 480, 3584, 531, 199, 694, 513, 275, 942, 199, 835, 275, 378, 199, 1361, 298, 5061, 9695, 5424, 199, 509, 2935, 315, 747, 14, 7374, 480, 30946, 199, 198, 692, 747, 14, 515, 14, 6027, 8, 694, 304, 507, 198, 835, 847, 413, 507, 198, 694, 513, 14, 740, 8, 694, 9, 507, 198, 1361, 2338, 12, 2935, 199, 199, 3710, 275, 3066, 63, 1210, 480, 5446, 3589, 4637, 26, 6099, 199, 3710, 275, 2935, 513, 59, 442, 8, 3710, 9, 446, 413, 61, 199, 199, 318, 1050, 63, 4509, 63, 5359, 4470, 8, 354, 12, 4325, 67, 304, 199, 198, 1802, 275, 3066, 63, 1210, 480, 5061, 1369, 26, 6099, 199, 198, 1107, 283, 5061, 4311, 8, 354, 275, 2071, 83, 401, 1369, 275, 485, 3647, 83, 1288, 2382, 275, 11349, 4311, 14, 17688, 63, 18451, 18223, 12, 4325, 67, 275, 450, 83, 3171, 450, 334, 354, 12, 1369, 12, 4325, 67, 9, 199, 199, 318, 1050, 63, 4509, 63, 2718, 4470, 8, 354, 12, 4325, 67, 304, 199, 198, 1802, 275, 3066, 63, 1210, 480, 5061, 1369, 26, 6099, 199, 198, 4677, 275, 3066, 63, 1210, 480, 8954, 334, 885, 26, 283, 2718, 14, 4524, 356, 6099, 199, 198, 692, 7016, 508, 10812, 507, 198, 4677, 275, 298, 2718, 14, 4524, 2, 199, 198, 1107, 283, 5061, 4311, 8, 354, 275, 2071, 83, 401, 1369, 275, 485, 3647, 83, 1288, 7016, 275, 2071, 83, 401, 2382, 275, 11349, 4311, 14, 17688, 63, 19108, 18223, 12, 4325, 67, 275, 450, 83, 3171, 450, 334, 354, 12, 1369, 12, 7016, 12, 4325, 67, 9, 199, 199, 4509, 513, 275, 10003, 17688, 63, 18451, 18223, 401, 1050, 63, 4509, 63, 5359, 4470, 395, 1689, 17688, 63, 19108, 18223, 401, 1050, 63, 4509, 63, 2718, 4470, 1874, 199, 199, 1375, 513, 275, 942, 199, 199, 2379, 275, 756, 199, 199, 6710, 440, 3631, 26, 199, 198, 736, 14, 2253, 480, 3584, 531, 199, 198, 1361, 298, 5511, 4545, 5424, 199, 198, 509, 2382, 315, 1347, 513, 26, 507, 198, 1361, 2382, 59, 16, 61, 421, 198, 1361, 199, 198, 1361, 298, 4561, 4545, 5424, 199, 198, 835, 275, 378, 199, 198, 509, 2382, 315, 2382, 513, 26, 507, 198, 835, 847, 413, 507, 198, 1361, 2338, 12, 2382, 59, 16, 61, 199, 198, 1361, 298, 88, 2059, 2, 421, 198, 1375, 275, 3066, 63, 1210, 480, 5446, 6038, 13, 1375, 26, 6099, 199, 198, 692, 1347, 508, 298, 88, 582, 507, 198, 2379, 275, 715, 199, 198, 2836, 26, 507, 198, 692, 2382, 513, 59, 442, 8, 1375, 9, 446, 413, 61, 440, 315, 1347, 513, 26, 686, 198, 1375, 513, 14, 740, 8, 4509, 513, 59, 442, 8, 1375, 9, 446, 413, 566, 507, 198, 2836, 26, 686, 198, 1375, 513, 14, 2168, 8, 4509, 513, 59, 442, 8, 1375, 9, 446, 413, 566, 421, 199, 2718, 515, 275, 4637, 435, 10609, 435, 221, 5007, 354, 199, 736, 14, 8215, 8, 2718, 515, 9, 199, 199, 13941, 275, 1551, 8, 3710, 435, 3286, 19878, 14, 455, 401, 298, 82, 531, 199, 1278, 275, 16818, 14, 9684, 342, 199, 1278, 275, 6522, 904, 8, 1278, 9, 199, 1278, 275, 2385, 14, 1913, 342, 199, 1278, 847, 298, 298, 435, 5007, 354, 199, 13941, 14, 1600, 342, 199, 199, 13941, 275, 1551, 8, 3710, 435, 3286, 19878, 14, 455, 401, 298, 87, 531, 199, 13941, 14, 952, 8, 1278, 9, 199, 13941, 14, 1600, 342, 199, 199, 1278, 275, 942, 199, 1361, 298, 1490, 2, 199, 6472, 275, 1551, 480, 29866, 6472, 14, 645, 401, 298, 82, 531, 199, 6710, 715, 26, 199, 198, 604, 275, 7908, 14, 6407, 342, 199, 198, 692, 440, 1004, 26, 507, 198, 4785, 199, 198, 1278, 14, 740, 8, 604, 9, 199, 198, 692, 1004, 14, 1913, 342, 508, 298, 773, 15, 1548, 15, 19330, 6687, 435, 4637, 435, 3286, 19878, 582, 507, 198, 1278, 14, 740, 480, 773, 15, 1548, 15, 19330, 6687, 435, 3589, 515, 435, 3286, 19878, 60, 78, 531, 199, 6472, 14, 1600, 342, 199, 1361, 298, 1600, 2, 199, 199, 6472, 275, 1551, 480, 29866, 6472, 14, 645, 401, 298, 87, 531, 199, 6472, 14, 23277, 8, 1278, 9, 199, 6472, 14, 1600, 342, 199, 199, 493, 275, 1551, 8, 2718, 515, 435, 3286, 2718, 14, 647, 401, 298, 87, 531, 199, 199, 646, 513, 275, 942, 199, 509, 2382, 315, 1347, 513, 26, 199, 198, 646, 513, 14, 740, 8, 4509, 59, 16, 566, 199, 199, 493, 14, 952, 4852, 504, 29372, 14, 9616, 492, 17804, 199, 504, 30317, 14, 5061, 492, 11349, 4311, 199, 6141, 199, 199, 973, 513, 275, 942, 199, 509, 2338, 315, 1425, 8, 552, 8, 1375, 513, 2298, 199, 198, 692, 2338, 508, 378, 26, 507, 198, 973, 513, 14, 740, 480, 973, 531, 199, 198, 2836, 26, 507, 198, 973, 513, 14, 740, 480, 973, 2, 435, 620, 8, 835, 430, 199, 199, 509, 2446, 315, 2446, 513, 26, 199, 198, 493, 14, 952, 4852, 199, 318, 450, 83, 8, 1730, 12, 1011, 958, 304, 199, 198, 1529, 199, 624, 450, 2446, 9, 199, 199, 4120, 513, 275, 942, 199, 509, 2338, 315, 1425, 8, 552, 8, 1375, 513, 2298, 199, 198, 736, 14, 2253, 480, 3584, 531, 199, 198, 4509, 275, 1347, 513, 59, 835, 61, 199, 198, 1361, 298, 4558, 367, 1347, 450, 83, 2, 450, 2382, 59, 16, 61, 199, 198, 4120, 513, 14, 740, 8, 4509, 59, 17, 8738, 354, 12, 2446, 513, 59, 835, 2459, 199, 199, 692, 822, 8, 4120, 513, 9, 508, 413, 26, 199, 198, 4120, 513, 275, 5872, 513, 59, 16, 61, 199, 2836, 26, 199, 198, 4120, 513, 275, 32607, 435, 1656, 1987, 904, 8, 4120, 513, 9, 435, 298, 8480, 199, 199, 493, 14, 952, 4852, 199, 318, 30317, 3682, 958, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ernesto-g/micropython
tests/wipy/wlan/wlan.py
66
4116
''' WLAN test for the CC3200 based boards. ''' from network import WLAN import os import time import testconfig mch = os.uname().machine if not 'LaunchPad' in mch and not 'WiPy' in mch: raise Exception('Board not supported!') def wait_for_connection(wifi, timeout=10): while not wifi.isconnected() and timeout > 0: time.sleep(1) timeout -= 1 if wifi.isconnected(): print('Connected') else: print('Connection failed!') wifi = WLAN(0, WLAN.STA) print(wifi.mode() == WLAN.STA) print(wifi.antenna() == WLAN.INT_ANT) wifi = WLAN(mode=WLAN.AP) print(wifi.mode() == WLAN.AP) print(wifi.channel() == 1) print(wifi.auth() == None) print(wifi.antenna() == WLAN.INT_ANT) wifi = WLAN(0, mode=WLAN.AP, ssid='test-wlan', auth=(WLAN.WPA, '123456abc'), channel=7) print(wifi.mode() == WLAN.AP) print(wifi.channel() == 7) print(wifi.ssid() == 'test-wlan') print(wifi.auth() == (WLAN.WPA, '123456abc')) print(wifi.antenna() == WLAN.INT_ANT) wifi = WLAN(mode=WLAN.STA) print(wifi.mode() == WLAN.STA) time.sleep(5) # this ensures a full network scan scan_r = wifi.scan() print(len(scan_r) > 3) for net in scan_r: if net.ssid == testconfig.wlan_ssid: # test that the scan results contains the desired params print(len(net.bssid) == 6) print(net.channel == None) print(net.sec == testconfig.wlan_auth[0]) print(net.rssi < 0) print('Network found') break wifi.mode(WLAN.STA) print(wifi.mode() == WLAN.STA) wifi.channel(7) print(wifi.channel() == 7) wifi.ssid('t-wlan') print(wifi.ssid() == 't-wlan') wifi.auth(None) print(wifi.auth() == None) wifi.auth((WLAN.WEP, '11223344556677889900')) print(wifi.auth() == (WLAN.WEP, '11223344556677889900')) wifi.antenna(WLAN.INT_ANT) print(wifi.antenna() == WLAN.INT_ANT) wifi.antenna(WLAN.EXT_ANT) print(wifi.antenna() == WLAN.EXT_ANT) time.sleep(2) # this ensures a full network scan scan_r = wifi.scan() print(len(scan_r) > 3) for net in scan_r: if net.ssid == testconfig.wlan_ssid: print('Network found') break wifi.antenna(WLAN.INT_ANT) wifi.mode(WLAN.STA) print(wifi.mode() == WLAN.STA) wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=10000) wait_for_connection(wifi) wifi.ifconfig(config='dhcp') wait_for_connection(wifi) print('0.0.0.0' not in wifi.ifconfig()) wifi.ifconfig(0, ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) wait_for_connection(wifi) print(wifi.ifconfig(0) == ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8')) wait_for_connection(wifi) print(wifi.isconnected() == True) wifi.disconnect() print(wifi.isconnected() == False) t0 = time.ticks_ms() wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=0) print(time.ticks_ms() - t0 < 500) wifi.disconnect() print(wifi.isconnected() == False) # test init again wifi.init(WLAN.AP, ssid='www.wipy.io', auth=None, channel=5, antenna=WLAN.INT_ANT) print(wifi.mode() == WLAN.AP) # get the current instance without re-init wifi = WLAN() print(wifi.mode() == WLAN.AP) wifi = WLAN(0) print(wifi.mode() == WLAN.AP) # test the MAC address length print(len(wifi.mac()) == 6) # next ones MUST raise try: wifi.init(mode=12345) except: print('Exception') try: wifi.init(1, mode=WLAN.AP) except: print('Exception') try: wifi.init(mode=WLAN.AP, ssid=None) except: print('Exception') try: wifi = WLAN(mode=WLAN.AP, channel=12) except: print('Exception') try: wifi.antenna(2) except: print('Exception') try: wifi.mode(10) except: print('Exception') try: wifi.ssid('11111sdfasdfasdfasdf564sdf654asdfasdf123451245ssdgfsdf1111111111111111111111111234123412341234asdfasdf') except: print('Exception') try: wifi.auth((0)) except: print('Exception') try: wifi.auth((0, None)) except: print('Exception') try: wifi.auth((10, 10)) except: print('Exception') try: wifi.channel(0) except: print('Exception') try: wifi.ifconfig(1, 'dhcp') except: print('Exception') try: wifi.ifconfig(config=()) except: print('Exception')
mit
[ 2344, 199, 55, 10825, 511, 367, 314, 17586, 32079, 4079, 1234, 5596, 14, 199, 2344, 199, 199, 504, 2784, 492, 644, 10825, 199, 646, 747, 199, 646, 900, 199, 646, 511, 888, 199, 199, 77, 335, 275, 747, 14, 16040, 1252, 6744, 199, 692, 440, 283, 18543, 18584, 7, 315, 333, 335, 436, 440, 283, 55, 73, 2713, 7, 315, 333, 335, 26, 272, 746, 2186, 360, 18995, 440, 3748, 10916, 421, 199, 318, 3618, 63, 509, 63, 2105, 8, 4326, 12, 2653, 29, 709, 304, 272, 1830, 440, 7912, 14, 374, 7113, 342, 436, 2653, 690, 378, 26, 267, 900, 14, 4532, 8, 17, 9, 267, 2653, 4862, 413, 272, 340, 7912, 14, 374, 7113, 837, 267, 870, 360, 16382, 358, 272, 587, 26, 267, 870, 360, 3225, 3405, 10916, 421, 199, 4326, 275, 644, 10825, 8, 16, 12, 644, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 275, 644, 10825, 8, 632, 29, 55, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 413, 9, 199, 1361, 8, 4326, 14, 1178, 342, 508, 488, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 4326, 275, 644, 10825, 8, 16, 12, 818, 29, 55, 10825, 14, 1282, 12, 25891, 534, 396, 13, 87, 1502, 297, 1790, 2687, 55, 10825, 14, 55, 8470, 12, 283, 19060, 3175, 659, 3623, 29, 23, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 1520, 9, 199, 1361, 8, 4326, 14, 23283, 342, 508, 283, 396, 13, 87, 1502, 358, 199, 1361, 8, 4326, 14, 1178, 342, 508, 334, 55, 10825, 14, 55, 8470, 12, 283, 19060, 3175, 1333, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 275, 644, 10825, 8, 632, 29, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 521, 14, 4532, 8, 21, 9, 327, 642, 15620, 282, 2615, 2784, 8000, 199, 6282, 63, 82, 275, 7912, 14, 6282, 342, 199, 1361, 8, 552, 8, 6282, 63, 82, 9, 690, 650, 9, 199, 509, 1851, 315, 8000, 63, 82, 26, 272, 340, 1851, 14, 23283, 508, 511, 888, 14, 87, 1502, 63, 23283, 26, 267, 327, 511, 626, 314, 8000, 2058, 3509, 314, 6387, 1862, 267, 870, 8, 552, 8, 846, 14, 1533, 4148, 9, 508, 1227, 9, 267, 870, 8, 846, 14, 2775, 508, 488, 9, 267, 870, 8, 846, 14, 3321, 508, 511, 888, 14, 87, 1502, 63, 1178, 59, 16, 566, 267, 870, 8, 846, 14, 2393, 338, 665, 378, 9, 267, 870, 360, 4491, 1911, 358, 267, 2059, 199, 199, 4326, 14, 632, 8, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 4326, 14, 2775, 8, 23, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 1520, 9, 199, 4326, 14, 23283, 360, 84, 13, 87, 1502, 358, 199, 1361, 8, 4326, 14, 23283, 342, 508, 283, 84, 13, 87, 1502, 358, 199, 4326, 14, 1178, 8, 403, 9, 199, 1361, 8, 4326, 14, 1178, 342, 508, 488, 9, 199, 4326, 14, 1178, 1332, 55, 10825, 14, 5408, 48, 12, 283, 6094, 1789, 10875, 1229, 1272, 1138, 1299, 1020, 383, 1333, 199, 1361, 8, 4326, 14, 1178, 342, 508, 334, 55, 10825, 14, 5408, 48, 12, 283, 6094, 1789, 10875, 1229, 1272, 1138, 1299, 1020, 383, 1333, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2919, 63, 1441, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2472, 63, 1441, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2472, 63, 1441, 9, 199, 521, 14, 4532, 8, 18, 9, 327, 642, 15620, 282, 2615, 2784, 8000, 199, 6282, 63, 82, 275, 7912, 14, 6282, 342, 199, 1361, 8, 552, 8, 6282, 63, 82, 9, 690, 650, 9, 199, 509, 1851, 315, 8000, 63, 82, 26, 272, 340, 1851, 14, 23283, 508, 511, 888, 14, 87, 1502, 63, 23283, 26, 267, 870, 360, 4491, 1911, 358, 267, 2059, 199, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2919, 63, 1441, 9, 199, 4326, 14, 632, 8, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 4326, 14, 2242, 8, 396, 888, 14, 87, 1502, 63, 23283, 12, 1790, 29, 396, 888, 14, 87, 1502, 63, 1178, 12, 2653, 29, 9943, 9, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 199, 4326, 14, 692, 888, 8, 888, 534, 10801, 358, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 1361, 360, 16, 14, 16, 14, 16, 14, 16, 7, 440, 315, 7912, 14, 692, 888, 1012, 199, 4326, 14, 692, 888, 8, 16, 12, 661, 5756, 14, 6568, 14, 11175, 14, 6996, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 297, 283, 5756, 14, 6568, 14, 11175, 14, 17, 297, 283, 24, 14, 24, 14, 24, 14, 24, 1333, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 1361, 8, 4326, 14, 692, 888, 8, 16, 9, 508, 661, 5756, 14, 6568, 14, 11175, 14, 6996, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 297, 283, 5756, 14, 6568, 14, 11175, 14, 17, 297, 283, 24, 14, 24, 14, 24, 14, 24, 1333, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 199, 1361, 8, 4326, 14, 374, 7113, 342, 508, 715, 9, 199, 4326, 14, 10673, 342, 199, 1361, 8, 4326, 14, 374, 7113, 342, 508, 756, 9, 199, 199, 84, 16, 275, 900, 14, 10406, 63, 706, 342, 199, 4326, 14, 2242 ]
[ 199, 55, 10825, 511, 367, 314, 17586, 32079, 4079, 1234, 5596, 14, 199, 2344, 199, 199, 504, 2784, 492, 644, 10825, 199, 646, 747, 199, 646, 900, 199, 646, 511, 888, 199, 199, 77, 335, 275, 747, 14, 16040, 1252, 6744, 199, 692, 440, 283, 18543, 18584, 7, 315, 333, 335, 436, 440, 283, 55, 73, 2713, 7, 315, 333, 335, 26, 272, 746, 2186, 360, 18995, 440, 3748, 10916, 421, 199, 318, 3618, 63, 509, 63, 2105, 8, 4326, 12, 2653, 29, 709, 304, 272, 1830, 440, 7912, 14, 374, 7113, 342, 436, 2653, 690, 378, 26, 267, 900, 14, 4532, 8, 17, 9, 267, 2653, 4862, 413, 272, 340, 7912, 14, 374, 7113, 837, 267, 870, 360, 16382, 358, 272, 587, 26, 267, 870, 360, 3225, 3405, 10916, 421, 199, 4326, 275, 644, 10825, 8, 16, 12, 644, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 275, 644, 10825, 8, 632, 29, 55, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 413, 9, 199, 1361, 8, 4326, 14, 1178, 342, 508, 488, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 4326, 275, 644, 10825, 8, 16, 12, 818, 29, 55, 10825, 14, 1282, 12, 25891, 534, 396, 13, 87, 1502, 297, 1790, 2687, 55, 10825, 14, 55, 8470, 12, 283, 19060, 3175, 659, 3623, 29, 23, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 1282, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 1520, 9, 199, 1361, 8, 4326, 14, 23283, 342, 508, 283, 396, 13, 87, 1502, 358, 199, 1361, 8, 4326, 14, 1178, 342, 508, 334, 55, 10825, 14, 55, 8470, 12, 283, 19060, 3175, 1333, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 275, 644, 10825, 8, 632, 29, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 521, 14, 4532, 8, 21, 9, 327, 642, 15620, 282, 2615, 2784, 8000, 199, 6282, 63, 82, 275, 7912, 14, 6282, 342, 199, 1361, 8, 552, 8, 6282, 63, 82, 9, 690, 650, 9, 199, 509, 1851, 315, 8000, 63, 82, 26, 272, 340, 1851, 14, 23283, 508, 511, 888, 14, 87, 1502, 63, 23283, 26, 267, 327, 511, 626, 314, 8000, 2058, 3509, 314, 6387, 1862, 267, 870, 8, 552, 8, 846, 14, 1533, 4148, 9, 508, 1227, 9, 267, 870, 8, 846, 14, 2775, 508, 488, 9, 267, 870, 8, 846, 14, 3321, 508, 511, 888, 14, 87, 1502, 63, 1178, 59, 16, 566, 267, 870, 8, 846, 14, 2393, 338, 665, 378, 9, 267, 870, 360, 4491, 1911, 358, 267, 2059, 199, 199, 4326, 14, 632, 8, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 4326, 14, 2775, 8, 23, 9, 199, 1361, 8, 4326, 14, 2775, 342, 508, 1520, 9, 199, 4326, 14, 23283, 360, 84, 13, 87, 1502, 358, 199, 1361, 8, 4326, 14, 23283, 342, 508, 283, 84, 13, 87, 1502, 358, 199, 4326, 14, 1178, 8, 403, 9, 199, 1361, 8, 4326, 14, 1178, 342, 508, 488, 9, 199, 4326, 14, 1178, 1332, 55, 10825, 14, 5408, 48, 12, 283, 6094, 1789, 10875, 1229, 1272, 1138, 1299, 1020, 383, 1333, 199, 1361, 8, 4326, 14, 1178, 342, 508, 334, 55, 10825, 14, 5408, 48, 12, 283, 6094, 1789, 10875, 1229, 1272, 1138, 1299, 1020, 383, 1333, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2919, 63, 1441, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2919, 63, 1441, 9, 199, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2472, 63, 1441, 9, 199, 1361, 8, 4326, 14, 290, 21634, 342, 508, 644, 10825, 14, 2472, 63, 1441, 9, 199, 521, 14, 4532, 8, 18, 9, 327, 642, 15620, 282, 2615, 2784, 8000, 199, 6282, 63, 82, 275, 7912, 14, 6282, 342, 199, 1361, 8, 552, 8, 6282, 63, 82, 9, 690, 650, 9, 199, 509, 1851, 315, 8000, 63, 82, 26, 272, 340, 1851, 14, 23283, 508, 511, 888, 14, 87, 1502, 63, 23283, 26, 267, 870, 360, 4491, 1911, 358, 267, 2059, 199, 199, 4326, 14, 290, 21634, 8, 55, 10825, 14, 2919, 63, 1441, 9, 199, 4326, 14, 632, 8, 55, 10825, 14, 840, 33, 9, 199, 1361, 8, 4326, 14, 632, 342, 508, 644, 10825, 14, 840, 33, 9, 199, 4326, 14, 2242, 8, 396, 888, 14, 87, 1502, 63, 23283, 12, 1790, 29, 396, 888, 14, 87, 1502, 63, 1178, 12, 2653, 29, 9943, 9, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 199, 4326, 14, 692, 888, 8, 888, 534, 10801, 358, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 1361, 360, 16, 14, 16, 14, 16, 14, 16, 7, 440, 315, 7912, 14, 692, 888, 1012, 199, 4326, 14, 692, 888, 8, 16, 12, 661, 5756, 14, 6568, 14, 11175, 14, 6996, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 297, 283, 5756, 14, 6568, 14, 11175, 14, 17, 297, 283, 24, 14, 24, 14, 24, 14, 24, 1333, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 1361, 8, 4326, 14, 692, 888, 8, 16, 9, 508, 661, 5756, 14, 6568, 14, 11175, 14, 6996, 297, 283, 2299, 14, 2299, 14, 2299, 14, 16, 297, 283, 5756, 14, 6568, 14, 11175, 14, 17, 297, 283, 24, 14, 24, 14, 24, 14, 24, 1333, 199, 2573, 63, 509, 63, 2105, 8, 4326, 9, 199, 199, 1361, 8, 4326, 14, 374, 7113, 342, 508, 715, 9, 199, 4326, 14, 10673, 342, 199, 1361, 8, 4326, 14, 374, 7113, 342, 508, 756, 9, 199, 199, 84, 16, 275, 900, 14, 10406, 63, 706, 342, 199, 4326, 14, 2242, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Lafunamor/ns3
.waf-1.7.13-5a064c2686fe54de4e11018d22148cfc/waflib/Tools/waf_unit_test.py
267
3438
#! /usr/bin/env python # encoding: utf-8 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file import os,sys from waflib.TaskGen import feature,after_method from waflib import Utils,Task,Logs,Options testlock=Utils.threading.Lock() @feature('test') @after_method('apply_link') def make_test(self): if getattr(self,'link_task',None): self.create_task('utest',self.link_task.outputs) class utest(Task.Task): color='PINK' after=['vnum','inst'] vars=[] def runnable_status(self): if getattr(Options.options,'no_tests',False): return Task.SKIP_ME ret=super(utest,self).runnable_status() if ret==Task.SKIP_ME: if getattr(Options.options,'all_tests',False): return Task.RUN_ME return ret def run(self): filename=self.inputs[0].abspath() self.ut_exec=getattr(self.generator,'ut_exec',[filename]) if getattr(self.generator,'ut_fun',None): self.generator.ut_fun(self) try: fu=getattr(self.generator.bld,'all_test_paths') except AttributeError: fu=os.environ.copy() lst=[] for g in self.generator.bld.groups: for tg in g: if getattr(tg,'link_task',None): s=tg.link_task.outputs[0].parent.abspath() if s not in lst: lst.append(s) def add_path(dct,path,var): dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')]) if Utils.is_win32: add_path(fu,lst,'PATH') elif Utils.unversioned_sys_platform()=='darwin': add_path(fu,lst,'DYLD_LIBRARY_PATH') add_path(fu,lst,'LD_LIBRARY_PATH') else: add_path(fu,lst,'LD_LIBRARY_PATH') self.generator.bld.all_test_paths=fu cwd=getattr(self.generator,'ut_cwd','')or self.inputs[0].parent.abspath() testcmd=getattr(Options.options,'testcmd',False) if testcmd: self.ut_exec=(testcmd%self.ut_exec[0]).split(' ') proc=Utils.subprocess.Popen(self.ut_exec,cwd=cwd,env=fu,stderr=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE) (stdout,stderr)=proc.communicate() tup=(filename,proc.returncode,stdout,stderr) self.generator.utest_result=tup testlock.acquire() try: bld=self.generator.bld Logs.debug("ut: %r",tup) try: bld.utest_results.append(tup) except AttributeError: bld.utest_results=[tup] finally: testlock.release() def summary(bld): lst=getattr(bld,'utest_results',[]) if lst: Logs.pprint('CYAN','execution summary') total=len(lst) tfail=len([x for x in lst if x[1]]) Logs.pprint('CYAN',' tests that pass %d/%d'%(total-tfail,total)) for(f,code,out,err)in lst: if not code: Logs.pprint('CYAN',' %s'%f) Logs.pprint('CYAN',' tests that fail %d/%d'%(tfail,total)) for(f,code,out,err)in lst: if code: Logs.pprint('CYAN',' %s'%f) def set_exit_code(bld): lst=getattr(bld,'utest_results',[]) for(f,code,out,err)in lst: if code: msg=[] if out: msg.append('stdout:%s%s'%(os.linesep,out.decode('utf-8'))) if err: msg.append('stderr:%s%s'%(os.linesep,err.decode('utf-8'))) bld.fatal(os.linesep.join(msg)) def options(opt): opt.add_option('--notests',action='store_true',default=False,help='Exec no unit tests',dest='no_tests') opt.add_option('--alltests',action='store_true',default=False,help='Exec all unit tests',dest='all_tests') opt.add_option('--testcmd',action='store',default=False,help='Run the unit tests using the test-cmd string'' example "--test-cmd="valgrind --error-exitcode=1'' %s" to run under valgrind',dest='testcmd')
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 199, 504, 31380, 14, 4476, 8168, 492, 3878, 12, 4399, 63, 765, 199, 504, 31380, 492, 17397, 12, 4476, 12, 16333, 12, 4558, 199, 396, 831, 29, 7535, 14, 12562, 14, 6432, 342, 199, 32, 4445, 360, 396, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1852, 63, 396, 8, 277, 304, 199, 198, 692, 2519, 8, 277, 2584, 1073, 63, 1765, 297, 403, 304, 507, 198, 277, 14, 981, 63, 1765, 360, 85, 396, 297, 277, 14, 1073, 63, 1765, 14, 4467, 9, 199, 533, 399, 396, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 4399, 2968, 86, 1507, 1673, 3615, 418, 199, 198, 2936, 9811, 199, 198, 318, 1255, 25757, 63, 1205, 8, 277, 304, 507, 198, 692, 2519, 8, 4558, 14, 1419, 2584, 889, 63, 2219, 297, 797, 304, 686, 198, 1107, 8495, 14, 13525, 63, 3635, 507, 198, 3292, 29, 4792, 8, 85, 396, 12, 277, 680, 1065, 25757, 63, 1205, 342, 507, 198, 692, 2203, 389, 4476, 14, 13525, 63, 3635, 26, 686, 198, 692, 2519, 8, 4558, 14, 1419, 2584, 452, 63, 2219, 297, 797, 304, 1585, 198, 1107, 8495, 14, 9390, 63, 3635, 507, 198, 1107, 2203, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1501, 29, 277, 14, 3711, 59, 16, 1055, 4832, 342, 507, 198, 277, 14, 337, 63, 1628, 29, 5675, 8, 277, 14, 4679, 2584, 337, 63, 1628, 23993, 1501, 566, 507, 198, 692, 2519, 8, 277, 14, 4679, 2584, 337, 63, 7036, 297, 403, 304, 686, 198, 277, 14, 4679, 14, 337, 63, 7036, 8, 277, 9, 507, 198, 893, 26, 686, 198, 13499, 29, 5675, 8, 277, 14, 4679, 14, 14341, 2584, 452, 63, 396, 63, 3771, 358, 507, 198, 2590, 4281, 26, 686, 198, 13499, 29, 736, 14, 2314, 14, 1574, 342, 686, 198, 6916, 9811, 686, 198, 509, 486, 315, 291, 14, 4679, 14, 14341, 14, 2634, 26, 1585, 198, 509, 22387, 315, 486, 26, 1871, 198, 692, 2519, 8, 17699, 2584, 1073, 63, 1765, 297, 403, 304, 4671, 198, 83, 29, 17699, 14, 1073, 63, 1765, 14, 4467, 59, 16, 1055, 1708, 14, 4832, 342, 4671, 198, 692, 308, 440, 315, 9877, 26, 5264, 198, 6916, 14, 740, 8, 83, 9, 686, 198, 318, 1050, 63, 515, 8, 20660, 12, 515, 12, 1391, 304, 1585, 198, 20660, 59, 1391, 10404, 736, 14, 17843, 14, 904, 8, 7535, 14, 475, 63, 513, 8, 515, 6393, 59, 736, 14, 2314, 14, 362, 8, 1391, 2584, 2023, 686, 198, 692, 17397, 14, 374, 63, 2676, 708, 26, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 3243, 358, 686, 198, 4164, 17397, 14, 324, 24155, 63, 1274, 63, 3246, 342, 6803, 13245, 356, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 11446, 6533, 63, 16983, 63, 3243, 358, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 6533, 63, 16983, 63, 3243, 358, 686, 198, 2836, 26, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 6533, 63, 16983, 63, 3243, 358, 686, 198, 277, 14, 4679, 14, 14341, 14, 452, 63, 396, 63, 3771, 29, 13499, 507, 198, 6525, 29, 5675, 8, 277, 14, 4679, 2584, 337, 63, 6525, 20944, 269, 291, 14, 3711, 59, 16, 1055, 1708, 14, 4832, 342, 507, 198, 396, 1760, 29, 5675, 8, 4558, 14, 1419, 2584, 396, 1760, 297, 797, 9, 507, 198, 692, 511, 1760, 26, 686, 198, 277, 14, 337, 63, 1628, 2687, 396, 1760, 5, 277, 14, 337, 63, 1628, 59, 16, 6575, 1294, 360, 5320, 507, 198, 4687, 29, 7535, 14, 5781, 14, 7942, 8, 277, 14, 337, 63, 1628, 12, 6525, 29, 6525, 12, 1813, 29, 13499, 12, 3083, 29, 7535, 14, 5781, 14, 6089, 12, 2703, 29, 7535, 14, 5781, 14, 6089, 9, 507, 198, 8, 2703, 12, 3083, 23397, 4687, 14, 10664, 342, 507, 198, 17034, 2687, 1501, 12, 4687, 14, 9913, 12, 2703, 12, 3083, 9, 507, 198, 277, 14, 4679, 14, 85, 396, 63, 1099, 29, 17034, 507, 198, 396, 831, 14, 8174, 342, 507, 198, 893, 26, 686, 198, 14341, 29, 277, 14, 4679, 14, 14341, 686, 198, 16333, 14, 1757, 480, 337, 26, 450, 82, 401, 17034, 9, 686, 198, 893, 26, 1585, 198, 14341, 14, 85, 396, 63, 2604, 14, 740, 8, 17034, 9, 686, 198, 2590, 4281, 26, 1585, 198, 14341, 14, 85, 396, 63, 2604, 1524, 17034, 61, 507, 198, 15172, 26, 686, 198, 396, 831, 14, 3221, 342, 199, 318, 6212, 8, 14341, 304, 199, 198, 6916, 29, 5675, 8, 14341, 2584, 85, 396, 63, 2604, 23993, 566, 199, 198, 692, 9877, 26, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 9416, 6212, 358, 507, 198, 2923, 29, 552, 8, 6916, 9, 507, 198, 84, 1633, 29, 552, 779, 88, 367, 671, 315, 9877, 340, 671, 59, 17, 3934, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 221, 2295, 626, 986, 450, 68, 3149, 68, 13328, 2923, 13, 84, 1633, 12, 2923, 430, 507, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262, 9877, 26, 686, 198, 692, 440, 1233, 26, 1585, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 259, 450, 83, 5956, 70, 9, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 221, 2295, 626, 2449, 450, 68, 3149, 68, 13328, 84, 1633, 12, 2923, 430, 507, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262, 9877, 26, 686, 198, 692, 1233, 26, 1585, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 259, 450, 83, 5956, 70, 9, 199, 318, 663, 63, 2224, 63, 600, 8, 14341, 304, 199, 198, 6916, 29, 5675, 8, 14341, 2584, 85, 396, 63, 2604, 23993, 566, 199, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2644, 26, 2774, 13, 24, 199, 3, 14750, 1, 4226, 440, 5283, 1, 1455, 921, 21500, 14, 31864, 14, 957, 15, 3187, 15, 4757, 15, 21500, 2706, 15, 4780, 14, 1360, 20930, 2873, 24522, 63, 1589, 63, 21500, 63, 493, 199, 199, 646, 747, 12, 1274, 199, 504, 31380, 14, 4476, 8168, 492, 3878, 12, 4399, 63, 765, 199, 504, 31380, 492, 17397, 12, 4476, 12, 16333, 12, 4558, 199, 396, 831, 29, 7535, 14, 12562, 14, 6432, 342, 199, 32, 4445, 360, 396, 358, 199, 32, 4399, 63, 765, 360, 4998, 63, 1073, 358, 199, 318, 1852, 63, 396, 8, 277, 304, 199, 198, 692, 2519, 8, 277, 2584, 1073, 63, 1765, 297, 403, 304, 507, 198, 277, 14, 981, 63, 1765, 360, 85, 396, 297, 277, 14, 1073, 63, 1765, 14, 4467, 9, 199, 533, 399, 396, 8, 4476, 14, 4476, 304, 199, 198, 2326, 534, 48, 12394, 7, 199, 198, 4399, 2968, 86, 1507, 1673, 3615, 418, 199, 198, 2936, 9811, 199, 198, 318, 1255, 25757, 63, 1205, 8, 277, 304, 507, 198, 692, 2519, 8, 4558, 14, 1419, 2584, 889, 63, 2219, 297, 797, 304, 686, 198, 1107, 8495, 14, 13525, 63, 3635, 507, 198, 3292, 29, 4792, 8, 85, 396, 12, 277, 680, 1065, 25757, 63, 1205, 342, 507, 198, 692, 2203, 389, 4476, 14, 13525, 63, 3635, 26, 686, 198, 692, 2519, 8, 4558, 14, 1419, 2584, 452, 63, 2219, 297, 797, 304, 1585, 198, 1107, 8495, 14, 9390, 63, 3635, 507, 198, 1107, 2203, 199, 198, 318, 1255, 8, 277, 304, 507, 198, 1501, 29, 277, 14, 3711, 59, 16, 1055, 4832, 342, 507, 198, 277, 14, 337, 63, 1628, 29, 5675, 8, 277, 14, 4679, 2584, 337, 63, 1628, 23993, 1501, 566, 507, 198, 692, 2519, 8, 277, 14, 4679, 2584, 337, 63, 7036, 297, 403, 304, 686, 198, 277, 14, 4679, 14, 337, 63, 7036, 8, 277, 9, 507, 198, 893, 26, 686, 198, 13499, 29, 5675, 8, 277, 14, 4679, 14, 14341, 2584, 452, 63, 396, 63, 3771, 358, 507, 198, 2590, 4281, 26, 686, 198, 13499, 29, 736, 14, 2314, 14, 1574, 342, 686, 198, 6916, 9811, 686, 198, 509, 486, 315, 291, 14, 4679, 14, 14341, 14, 2634, 26, 1585, 198, 509, 22387, 315, 486, 26, 1871, 198, 692, 2519, 8, 17699, 2584, 1073, 63, 1765, 297, 403, 304, 4671, 198, 83, 29, 17699, 14, 1073, 63, 1765, 14, 4467, 59, 16, 1055, 1708, 14, 4832, 342, 4671, 198, 692, 308, 440, 315, 9877, 26, 5264, 198, 6916, 14, 740, 8, 83, 9, 686, 198, 318, 1050, 63, 515, 8, 20660, 12, 515, 12, 1391, 304, 1585, 198, 20660, 59, 1391, 10404, 736, 14, 17843, 14, 904, 8, 7535, 14, 475, 63, 513, 8, 515, 6393, 59, 736, 14, 2314, 14, 362, 8, 1391, 2584, 2023, 686, 198, 692, 17397, 14, 374, 63, 2676, 708, 26, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 3243, 358, 686, 198, 4164, 17397, 14, 324, 24155, 63, 1274, 63, 3246, 342, 6803, 13245, 356, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 11446, 6533, 63, 16983, 63, 3243, 358, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 6533, 63, 16983, 63, 3243, 358, 686, 198, 2836, 26, 1585, 198, 525, 63, 515, 8, 13499, 12, 6916, 2584, 6533, 63, 16983, 63, 3243, 358, 686, 198, 277, 14, 4679, 14, 14341, 14, 452, 63, 396, 63, 3771, 29, 13499, 507, 198, 6525, 29, 5675, 8, 277, 14, 4679, 2584, 337, 63, 6525, 20944, 269, 291, 14, 3711, 59, 16, 1055, 1708, 14, 4832, 342, 507, 198, 396, 1760, 29, 5675, 8, 4558, 14, 1419, 2584, 396, 1760, 297, 797, 9, 507, 198, 692, 511, 1760, 26, 686, 198, 277, 14, 337, 63, 1628, 2687, 396, 1760, 5, 277, 14, 337, 63, 1628, 59, 16, 6575, 1294, 360, 5320, 507, 198, 4687, 29, 7535, 14, 5781, 14, 7942, 8, 277, 14, 337, 63, 1628, 12, 6525, 29, 6525, 12, 1813, 29, 13499, 12, 3083, 29, 7535, 14, 5781, 14, 6089, 12, 2703, 29, 7535, 14, 5781, 14, 6089, 9, 507, 198, 8, 2703, 12, 3083, 23397, 4687, 14, 10664, 342, 507, 198, 17034, 2687, 1501, 12, 4687, 14, 9913, 12, 2703, 12, 3083, 9, 507, 198, 277, 14, 4679, 14, 85, 396, 63, 1099, 29, 17034, 507, 198, 396, 831, 14, 8174, 342, 507, 198, 893, 26, 686, 198, 14341, 29, 277, 14, 4679, 14, 14341, 686, 198, 16333, 14, 1757, 480, 337, 26, 450, 82, 401, 17034, 9, 686, 198, 893, 26, 1585, 198, 14341, 14, 85, 396, 63, 2604, 14, 740, 8, 17034, 9, 686, 198, 2590, 4281, 26, 1585, 198, 14341, 14, 85, 396, 63, 2604, 1524, 17034, 61, 507, 198, 15172, 26, 686, 198, 396, 831, 14, 3221, 342, 199, 318, 6212, 8, 14341, 304, 199, 198, 6916, 29, 5675, 8, 14341, 2584, 85, 396, 63, 2604, 23993, 566, 199, 198, 692, 9877, 26, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 9416, 6212, 358, 507, 198, 2923, 29, 552, 8, 6916, 9, 507, 198, 84, 1633, 29, 552, 779, 88, 367, 671, 315, 9877, 340, 671, 59, 17, 3934, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 221, 2295, 626, 986, 450, 68, 3149, 68, 13328, 2923, 13, 84, 1633, 12, 2923, 430, 507, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262, 9877, 26, 686, 198, 692, 440, 1233, 26, 1585, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 259, 450, 83, 5956, 70, 9, 507, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 221, 2295, 626, 2449, 450, 68, 3149, 68, 13328, 84, 1633, 12, 2923, 430, 507, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262, 9877, 26, 686, 198, 692, 1233, 26, 1585, 198, 16333, 14, 15380, 360, 15068, 879, 1673, 259, 450, 83, 5956, 70, 9, 199, 318, 663, 63, 2224, 63, 600, 8, 14341, 304, 199, 198, 6916, 29, 5675, 8, 14341, 2584, 85, 396, 63, 2604, 23993, 566, 199, 198, 509, 8, 70, 12, 600, 12, 548, 12, 1508, 9, 262, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
janezhango/BigDataMachineLearning
py/testdir_single_jvm/test_parse_header_rows_mismatch_fvec.py
2
3846
import unittest, time, sys, random sys.path.extend(['.','..','py']) import h2o, h2o_cmd, h2o_hosts, h2o_import as h2i import h2o_browse as h2b def write_syn_dataset(csvPathname, rowCount, headerData, rList): dsf = open(csvPathname, "w+") dsf.write(headerData + "\n") for i in range(rowCount): # two choices on the input. Make output choices random r = rList[random.randint(0,1)] + "," + str(random.randint(0,7)) dsf.write(r + "\n") dsf.close() def rand_rowData(totalCols): rowData1 = str(random.randint(0,7)) for i in range(totalCols): rowData1 = rowData1 + "," + str(random.randint(0,7)) rowData2 = str(random.randint(0,7)) for i in range(totalCols): rowData2 = rowData2 + "," + str(random.randint(0,7)) # RF will complain if all inputs are the same r = [rowData1, rowData2] return r class Basic(unittest.TestCase): def tearDown(self): h2o.check_sandbox_for_errors() @classmethod def setUpClass(cls): global SEED, localhost SEED = h2o.setup_random_seed() localhost = h2o.decide_if_localhost() if (localhost): h2o.build_cloud(2,java_heap_MB=1300,use_flatfile=True) else: h2o_hosts.build_cloud_with_hosts() h2o.beta_features = True @classmethod def tearDownClass(cls): h2o.tear_down_cloud(h2o.nodes) def test_parse_header_rows_mismatch_fvec(self): SYNDATASETS_DIR = h2o.make_syn_dir() csvFilename = "syn_ints.csv" csvPathname = SYNDATASETS_DIR + '/' + csvFilename # headerData = "ID,CAPSULE,AGE,RACE,DPROS,DCAPS,PSA,VOL,GLEASON" headerData = "ID,CAPSULE,AGE,RACE,DPROS,DCAPS,PSA,VOL" totalCols = 8 totalRows = 10000 rList = rand_rowData(totalCols) write_syn_dataset(csvPathname, totalRows, headerData, rList) for trial in range (2): # make sure all key names are unique, when we re-put and re-parse (h2o caching issues) src_key = csvFilename + "_" + str(trial) hex_key = csvFilename + "_" + str(trial) + ".hex" start = time.time() timeoutSecs = 30 print "Force it to think there's a header. using comma forced as separator" parseResult = h2i.import_parse(path=csvPathname, src_key=src_key, schema='put', hex_key=hex_key, timeoutSecs=timeoutSecs, pollTimeoutSecs=30, header=1, separator=44) print "parseResult['destination_key']: " + parseResult['destination_key'] inspect = h2o_cmd.runInspect(None, parseResult['destination_key']) h2o_cmd.infoFromInspect(inspect, csvPathname) print "\n" + csvPathname, \ " numRows:", "{:,}".format(inspect['numRows']), \ " numCols:", "{:,}".format(inspect['numCols']) # should match # of cols in header or ?? self.assertEqual(inspect['numCols'], totalCols, "parse created result with the wrong number of cols %s %s" % (inspect['numCols'], totalCols)) self.assertEqual(inspect['numRows'], totalRows, "parse created result with the wrong number of rows (header shouldn't count) %s %s" % (inspect['numRows'], totalRows)) kwargs = {'sample_rate': 0.75, 'max_depth': 25, 'ntrees': 1} start = time.time() rfv = h2o_cmd.runRF(parseResult=parseResult, timeoutSecs=30, **kwargs) elapsed = time.time() - start print "%d pct. of timeout" % ((elapsed/timeoutSecs) * 100) print "trial #", trial, "totalRows:", totalRows, "parse end on ", csvFilename, \ 'took', time.time() - start, 'seconds' h2o.check_sandbox_for_errors() if __name__ == '__main__': h2o.unit_main()
apache-2.0
[ 646, 2882, 12, 900, 12, 984, 12, 2196, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 647, 1105, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 5146, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 199, 646, 394, 18, 79, 63, 4570, 465, 394, 18, 66, 199, 199, 318, 2218, 63, 9466, 63, 5214, 8, 4737, 2042, 354, 12, 1962, 2353, 12, 1406, 1451, 12, 519, 1296, 304, 272, 6364, 70, 275, 1551, 8, 4737, 2042, 354, 12, 298, 87, 21425, 2286, 6364, 70, 14, 952, 8, 1291, 1451, 435, 1867, 78, 531, 272, 367, 284, 315, 1425, 8, 1143, 2353, 304, 267, 327, 2877, 3415, 641, 314, 1324, 14, 4155, 1072, 3415, 2196, 267, 519, 275, 519, 1296, 59, 2355, 14, 8393, 8, 16, 12, 17, 1874, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 267, 6364, 70, 14, 952, 8, 82, 435, 1867, 78, 531, 272, 6364, 70, 14, 1600, 342, 199, 199, 318, 10261, 63, 1143, 1451, 8, 2923, 17203, 304, 272, 1962, 1451, 17, 275, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 367, 284, 315, 1425, 8, 2923, 17203, 304, 267, 1962, 1451, 17, 275, 1962, 1451, 17, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 339, 1962, 1451, 18, 275, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 367, 284, 315, 1425, 8, 2923, 17203, 304, 267, 1962, 1451, 18, 275, 1962, 1451, 18, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 327, 820, 38, 911, 24105, 340, 1006, 4153, 787, 314, 2011, 272, 519, 275, 359, 1143, 1451, 17, 12, 1962, 1451, 18, 61, 272, 372, 519, 199, 199, 533, 10082, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 394, 18, 79, 14, 1074, 63, 16647, 63, 509, 63, 2550, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 2288, 5795, 1149, 12, 11667, 267, 5795, 1149, 275, 394, 18, 79, 14, 2758, 63, 2355, 63, 5176, 342, 267, 11667, 275, 394, 18, 79, 14, 22612, 271, 63, 692, 63, 5967, 342, 267, 340, 334, 5967, 304, 288, 394, 18, 79, 14, 1506, 63, 4091, 8, 18, 12, 6138, 63, 12492, 63, 4567, 29, 969, 383, 12, 1180, 63, 7088, 493, 29, 549, 9, 267, 587, 26, 288, 394, 18, 79, 63, 5146, 14, 1506, 63, 4091, 63, 1045, 63, 5146, 342, 267, 394, 18, 79, 14, 5683, 63, 3179, 275, 715, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 394, 18, 79, 14, 266, 285, 63, 2110, 63, 4091, 8, 72, 18, 79, 14, 2415, 9, 2286, 347, 511, 63, 1122, 63, 1291, 63, 3838, 63, 20759, 63, 70, 6046, 8, 277, 304, 267, 10046, 46, 28231, 30416, 63, 3022, 275, 394, 18, 79, 14, 1875, 63, 9466, 63, 694, 342, 267, 7392, 8117, 275, 298, 9466, 63, 13141, 14, 4737, 2, 267, 7392, 2042, 354, 275, 10046, 46, 28231, 30416, 63, 3022, 435, 7324, 435, 7392, 8117, 398, 327, 1406, 1451, 275, 298, 998, 12, 8549, 6195, 906, 12, 2962, 12, 50, 4121, 12, 36, 2514, 51, 12, 5196, 1282, 51, 12, 48, 4251, 12, 12209, 12, 12827, 28883, 2, 267, 1406, 1451, 275, 298, 998, 12, 8549, 6195, 906, 12, 2962, 12, 50, 4121, 12, 36, 2514, 51, 12, 5196, 1282, 51, 12, 48, 4251, 12, 12209, 2, 398, 3141, 17203, 275, 1695, 267, 3141, 13405, 275, 11630, 267, 519, 1296, 275, 10261, 63, 1143, 1451, 8, 2923, 17203, 9, 267, 2218, 63, 9466, 63, 5214, 8, 4737, 2042, 354, 12, 3141, 13405, 12, 1406, 1451, 12, 519, 1296, 9, 398, 367, 16324, 315, 1425, 334, 18, 304, 288, 327, 1852, 3238, 1006, 790, 1561, 787, 3747, 12, 1380, 781, 295, 13, 524, 436, 295, 13, 1122, 334, 72, 18, 79, 13627, 10876, 9, 288, 2928, 63, 498, 275, 7392, 8117, 435, 14220, 435, 620, 8, 14443, 9, 288, 6318, 63, 498, 275, 7392, 8117, 435, 14220, 435, 620, 8, 14443, 9, 435, 3680, 4097, 2, 953, 1343, 275, 900, 14, 521, 342, 288, 2653, 29224, 275, 4233, 288, 870, 298, 13606, 652, 370, 13516, 2337, 1159, 282, 1406, 14, 1808, 10029, 19565, 465, 9432, 2, 288, 2198, 2889, 275, 394, 18, 73, 14, 646, 63, 1122, 8, 515, 29, 4737, 2042, 354, 12, 2928, 63, 498, 29, 2164, 63, 498, 12, 4177, 534, 524, 297, 6318, 63, 498, 29, 4097, 63, 498, 12, 355, 2653, 29224, 29, 2593, 29224, 12, 11271, 6372, 29224, 29, 1216, 12, 1406, 29, 17, 12, 9432, 29, 1602, 9, 288, 870, 298, 1122, 2889, 459, 6881, 63, 498, 2565, 298, 435, 2198, 2889, 459, 6881, 63, 498, 418, 953, 6485, 275, 394, 18, 79, 63, 1760, 14, 1065, 13962, 1764, 8, 403, 12, 2198, 2889, 459, 6881, 63, 498, 1105, 288, 394, 18, 79, 63, 1760, 14, 815, 2532, 13962, 1764, 8, 10955, 12, 7392, 2042, 354, 9, 288, 870, 1867, 78, 2, 435, 7392, 2042, 354, 12, 971, 355, 298, 259, 1967, 13405, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 13405, 3815, 971, 355, 298, 259, 1967, 17203, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 17203, 1105, 288, 327, 1077, 1336, 327, 402, 8850, 315, 1406, 503, 5805, 31, 288, 291, 14, 629, 8, 10955, 459, 1507, 17203, 995, 3141, 17203, 12, 8892, 298, 1122, 2737, 754, 543, 314, 6835, 1329, 402, 8850, 450, 83, 450, 83, 2, 450, 334, 10955, 459, 1507, 17203, 995, 3141, 17203, 430, 288, 291, 14, 629, 8, 10955, 459, 1507, 13405, 995, 3141, 13405, 12, 355, 298, 1122, 2737, 754, 543, 314, 6835, 1329, 402, 4730, 334, 1291, 9296, 1133, 2338, 9, 450, 83, 450, 83, 2, 450, 334, 10955, 459, 1507, 13405, 995, 3141, 13405, 430, 22919, 2074, 275, 791, 3271, 63, 1866, 356, 378, 14, 2194, 12, 283, 988, 63, 4631, 356, 5661, 12, 283, 343, 5710, 356, 413, 93, 288, 1343, 275, 900, 14, 521, 342, 288, 519, 13692, 275, 394, 18, 79, 63, 1760, 14, 1065, 11778, 8, 1122, 2889 ]
[ 2882, 12, 900, 12, 984, 12, 2196, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 647, 1105, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 5146, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 199, 646, 394, 18, 79, 63, 4570, 465, 394, 18, 66, 199, 199, 318, 2218, 63, 9466, 63, 5214, 8, 4737, 2042, 354, 12, 1962, 2353, 12, 1406, 1451, 12, 519, 1296, 304, 272, 6364, 70, 275, 1551, 8, 4737, 2042, 354, 12, 298, 87, 21425, 2286, 6364, 70, 14, 952, 8, 1291, 1451, 435, 1867, 78, 531, 272, 367, 284, 315, 1425, 8, 1143, 2353, 304, 267, 327, 2877, 3415, 641, 314, 1324, 14, 4155, 1072, 3415, 2196, 267, 519, 275, 519, 1296, 59, 2355, 14, 8393, 8, 16, 12, 17, 1874, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 267, 6364, 70, 14, 952, 8, 82, 435, 1867, 78, 531, 272, 6364, 70, 14, 1600, 342, 199, 199, 318, 10261, 63, 1143, 1451, 8, 2923, 17203, 304, 272, 1962, 1451, 17, 275, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 367, 284, 315, 1425, 8, 2923, 17203, 304, 267, 1962, 1451, 17, 275, 1962, 1451, 17, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 339, 1962, 1451, 18, 275, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 367, 284, 315, 1425, 8, 2923, 17203, 304, 267, 1962, 1451, 18, 275, 1962, 1451, 18, 435, 21147, 435, 620, 8, 2355, 14, 8393, 8, 16, 12, 23, 430, 272, 327, 820, 38, 911, 24105, 340, 1006, 4153, 787, 314, 2011, 272, 519, 275, 359, 1143, 1451, 17, 12, 1962, 1451, 18, 61, 272, 372, 519, 199, 199, 533, 10082, 8, 2796, 14, 1746, 304, 272, 347, 6766, 8, 277, 304, 267, 394, 18, 79, 14, 1074, 63, 16647, 63, 509, 63, 2550, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 2288, 5795, 1149, 12, 11667, 267, 5795, 1149, 275, 394, 18, 79, 14, 2758, 63, 2355, 63, 5176, 342, 267, 11667, 275, 394, 18, 79, 14, 22612, 271, 63, 692, 63, 5967, 342, 267, 340, 334, 5967, 304, 288, 394, 18, 79, 14, 1506, 63, 4091, 8, 18, 12, 6138, 63, 12492, 63, 4567, 29, 969, 383, 12, 1180, 63, 7088, 493, 29, 549, 9, 267, 587, 26, 288, 394, 18, 79, 63, 5146, 14, 1506, 63, 4091, 63, 1045, 63, 5146, 342, 267, 394, 18, 79, 14, 5683, 63, 3179, 275, 715, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 394, 18, 79, 14, 266, 285, 63, 2110, 63, 4091, 8, 72, 18, 79, 14, 2415, 9, 2286, 347, 511, 63, 1122, 63, 1291, 63, 3838, 63, 20759, 63, 70, 6046, 8, 277, 304, 267, 10046, 46, 28231, 30416, 63, 3022, 275, 394, 18, 79, 14, 1875, 63, 9466, 63, 694, 342, 267, 7392, 8117, 275, 298, 9466, 63, 13141, 14, 4737, 2, 267, 7392, 2042, 354, 275, 10046, 46, 28231, 30416, 63, 3022, 435, 7324, 435, 7392, 8117, 398, 327, 1406, 1451, 275, 298, 998, 12, 8549, 6195, 906, 12, 2962, 12, 50, 4121, 12, 36, 2514, 51, 12, 5196, 1282, 51, 12, 48, 4251, 12, 12209, 12, 12827, 28883, 2, 267, 1406, 1451, 275, 298, 998, 12, 8549, 6195, 906, 12, 2962, 12, 50, 4121, 12, 36, 2514, 51, 12, 5196, 1282, 51, 12, 48, 4251, 12, 12209, 2, 398, 3141, 17203, 275, 1695, 267, 3141, 13405, 275, 11630, 267, 519, 1296, 275, 10261, 63, 1143, 1451, 8, 2923, 17203, 9, 267, 2218, 63, 9466, 63, 5214, 8, 4737, 2042, 354, 12, 3141, 13405, 12, 1406, 1451, 12, 519, 1296, 9, 398, 367, 16324, 315, 1425, 334, 18, 304, 288, 327, 1852, 3238, 1006, 790, 1561, 787, 3747, 12, 1380, 781, 295, 13, 524, 436, 295, 13, 1122, 334, 72, 18, 79, 13627, 10876, 9, 288, 2928, 63, 498, 275, 7392, 8117, 435, 14220, 435, 620, 8, 14443, 9, 288, 6318, 63, 498, 275, 7392, 8117, 435, 14220, 435, 620, 8, 14443, 9, 435, 3680, 4097, 2, 953, 1343, 275, 900, 14, 521, 342, 288, 2653, 29224, 275, 4233, 288, 870, 298, 13606, 652, 370, 13516, 2337, 1159, 282, 1406, 14, 1808, 10029, 19565, 465, 9432, 2, 288, 2198, 2889, 275, 394, 18, 73, 14, 646, 63, 1122, 8, 515, 29, 4737, 2042, 354, 12, 2928, 63, 498, 29, 2164, 63, 498, 12, 4177, 534, 524, 297, 6318, 63, 498, 29, 4097, 63, 498, 12, 355, 2653, 29224, 29, 2593, 29224, 12, 11271, 6372, 29224, 29, 1216, 12, 1406, 29, 17, 12, 9432, 29, 1602, 9, 288, 870, 298, 1122, 2889, 459, 6881, 63, 498, 2565, 298, 435, 2198, 2889, 459, 6881, 63, 498, 418, 953, 6485, 275, 394, 18, 79, 63, 1760, 14, 1065, 13962, 1764, 8, 403, 12, 2198, 2889, 459, 6881, 63, 498, 1105, 288, 394, 18, 79, 63, 1760, 14, 815, 2532, 13962, 1764, 8, 10955, 12, 7392, 2042, 354, 9, 288, 870, 1867, 78, 2, 435, 7392, 2042, 354, 12, 971, 355, 298, 259, 1967, 13405, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 13405, 3815, 971, 355, 298, 259, 1967, 17203, 6783, 5310, 11941, 5469, 908, 8, 10955, 459, 1507, 17203, 1105, 288, 327, 1077, 1336, 327, 402, 8850, 315, 1406, 503, 5805, 31, 288, 291, 14, 629, 8, 10955, 459, 1507, 17203, 995, 3141, 17203, 12, 8892, 298, 1122, 2737, 754, 543, 314, 6835, 1329, 402, 8850, 450, 83, 450, 83, 2, 450, 334, 10955, 459, 1507, 17203, 995, 3141, 17203, 430, 288, 291, 14, 629, 8, 10955, 459, 1507, 13405, 995, 3141, 13405, 12, 355, 298, 1122, 2737, 754, 543, 314, 6835, 1329, 402, 4730, 334, 1291, 9296, 1133, 2338, 9, 450, 83, 450, 83, 2, 450, 334, 10955, 459, 1507, 13405, 995, 3141, 13405, 430, 22919, 2074, 275, 791, 3271, 63, 1866, 356, 378, 14, 2194, 12, 283, 988, 63, 4631, 356, 5661, 12, 283, 343, 5710, 356, 413, 93, 288, 1343, 275, 900, 14, 521, 342, 288, 519, 13692, 275, 394, 18, 79, 63, 1760, 14, 1065, 11778, 8, 1122, 2889, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
smartforceplus/SmartForceplus
addons/portal/__openerp__.py
250
2271
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2012 OpenERP S.A (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name' : 'Portal', 'version': '1.0', 'depends': [ 'base', 'share', 'auth_signup', ], 'author': 'OpenERP SA', 'category': 'Portal', 'description': """ Customize access to your OpenERP database to external users by creating portals. ================================================================================ A portal defines a specific user menu and access rights for its members. This menu can be seen by portal members, public users and any other user that have the access to technical features (e.g. the administrator). Also, each portal member is linked to a specific partner. The module also associates user groups to the portal users (adding a group in the portal automatically adds it to the portal users, etc). That feature is very handy when used in combination with the module 'share'. """, 'website': 'https://www.odoo.com', 'data': [ 'portal_data.xml', 'portal_view.xml', 'wizard/portal_wizard_view.xml', 'wizard/share_wizard_view.xml', 'security/ir.model.access.csv', 'views/portal.xml', ], 'demo': ['portal_demo.xml'], 'auto_install': True, 'installable': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 428, 14, 33, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 7, 520, 283, 26708, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 8912, 356, 359, 267, 283, 1095, 297, 267, 283, 6251, 297, 267, 283, 1178, 63, 19799, 297, 272, 2156, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 26708, 297, 272, 283, 1802, 356, 408, 199, 7223, 794, 2879, 370, 2195, 7653, 3050, 370, 5957, 4390, 701, 6425, 1844, 2551, 14, 199, 5695, 1280, 199, 33, 18428, 7890, 282, 2488, 922, 6269, 436, 2879, 4481, 367, 2399, 7556, 14, 221, 961, 199, 4470, 883, 506, 6775, 701, 18428, 7556, 12, 4575, 4390, 436, 1263, 1163, 922, 626, 199, 7804, 314, 2879, 370, 32742, 4534, 334, 69, 14, 71, 14, 314, 31056, 680, 199, 31892, 12, 1924, 18428, 3653, 365, 10632, 370, 282, 2488, 5854, 14, 199, 199, 1918, 859, 2597, 4035, 2335, 922, 4652, 370, 314, 18428, 4390, 334, 4095, 282, 1572, 315, 199, 1589, 18428, 5847, 9584, 652, 370, 314, 18428, 4390, 12, 5423, 680, 221, 10314, 3878, 365, 199, 2588, 4926, 89, 1380, 1202, 315, 14665, 543, 314, 859, 283, 6251, 1370, 272, 10327, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 576, 356, 359, 267, 283, 8707, 63, 576, 14, 1652, 297, 267, 283, 8707, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 8707, 63, 9819, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6251, 63, 9819, 63, 1345, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 8707, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 8707, 63, 8768, 14, 1652, 995, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 21762, 356, 715, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 428, 14, 33, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 7, 520, 283, 26708, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 8912, 356, 359, 267, 283, 1095, 297, 267, 283, 6251, 297, 267, 283, 1178, 63, 19799, 297, 272, 2156, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 26708, 297, 272, 283, 1802, 356, 408, 199, 7223, 794, 2879, 370, 2195, 7653, 3050, 370, 5957, 4390, 701, 6425, 1844, 2551, 14, 199, 5695, 1280, 199, 33, 18428, 7890, 282, 2488, 922, 6269, 436, 2879, 4481, 367, 2399, 7556, 14, 221, 961, 199, 4470, 883, 506, 6775, 701, 18428, 7556, 12, 4575, 4390, 436, 1263, 1163, 922, 626, 199, 7804, 314, 2879, 370, 32742, 4534, 334, 69, 14, 71, 14, 314, 31056, 680, 199, 31892, 12, 1924, 18428, 3653, 365, 10632, 370, 282, 2488, 5854, 14, 199, 199, 1918, 859, 2597, 4035, 2335, 922, 4652, 370, 314, 18428, 4390, 334, 4095, 282, 1572, 315, 199, 1589, 18428, 5847, 9584, 652, 370, 314, 18428, 4390, 12, 5423, 680, 221, 10314, 3878, 365, 199, 2588, 4926, 89, 1380, 1202, 315, 14665, 543, 314, 859, 283, 6251, 1370, 272, 10327, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 297, 272, 283, 576, 356, 359, 267, 283, 8707, 63, 576, 14, 1652, 297, 267, 283, 8707, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 8707, 63, 9819, 63, 1345, 14, 1652, 297, 267, 283, 9819, 15, 6251, 63, 9819, 63, 1345, 14, 1652, 297, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 4196, 15, 8707, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 788, 8707, 63, 8768, 14, 1652, 995, 272, 283, 2495, 63, 3174, 356, 715, 12, 272, 283, 21762, 356, 715, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]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 0 ]
bloff/ZeroNet
src/Config.py
1
11857
import argparse import sys import os import ConfigParser class Config(object): def __init__(self, argv): self.version = "0.3.1" self.rev = 307 self.argv = argv self.action = None self.createParser() self.createArguments() def createParser(self): # Create parser self.parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) self.parser.register('type', 'bool', self.strToBool) self.subparsers = self.parser.add_subparsers(title="Action to perform", dest="action") def __str__(self): return str(self.arguments).replace("Namespace", "Config") # Using argparse str output # Convert string to bool def strToBool(self, v): return v.lower() in ("yes", "true", "t", "1") # Create command line arguments def createArguments(self): # Platform specific if sys.platform.startswith("win"): coffeescript = "type %s | tools\\coffee\\coffee.cmd" else: coffeescript = None use_openssl = True # Main action = self.subparsers.add_parser("main", help='Start UiServer and FileServer (default)') # SiteCreate action = self.subparsers.add_parser("siteCreate", help='Create a new site') # SiteSign action = self.subparsers.add_parser("siteSign", help='Update and sign content.json: address [privatekey]') action.add_argument('address', help='Site to sign') action.add_argument('privatekey', help='Private key (default: ask on execute)', nargs='?') action.add_argument('--inner_path', help='File you want to sign (default: content.json)', default="content.json", metavar="inner_path") action.add_argument('--publish', help='Publish site after the signing', action='store_true') # SitePublish action = self.subparsers.add_parser("sitePublish", help='Publish site to other peers: address') action.add_argument('address', help='Site to publish') action.add_argument('peer_ip', help='Peer ip to publish (default: random peers ip from tracker)', default=None, nargs='?') action.add_argument('peer_port', help='Peer port to publish (default: random peer port from tracker)', default=15441, nargs='?') action.add_argument('--inner_path', help='Content.json you want to publish (default: content.json)', default="content.json", metavar="inner_path") # SiteVerify action = self.subparsers.add_parser("siteVerify", help='Verify site files using sha512: address') action.add_argument('address', help='Site to verify') # dbRebuild action = self.subparsers.add_parser("dbRebuild", help='Rebuild site database cache') action.add_argument('address', help='Site to rebuild') # dbQuery action = self.subparsers.add_parser("dbQuery", help='Query site sql cache') action.add_argument('address', help='Site to query') action.add_argument('query', help='Sql query') # PeerPing action = self.subparsers.add_parser("peerPing", help='Send Ping command to peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port', nargs='?') # PeerGetFile action = self.subparsers.add_parser("peerGetFile", help='Request and print a file content from peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port') action.add_argument('site', help='Site address') action.add_argument('filename', help='File name to request') # PeerGetFile action = self.subparsers.add_parser("peerCmd", help='Request and print a file content from peer') action.add_argument('peer_ip', help='Peer ip') action.add_argument('peer_port', help='Peer port') action.add_argument('cmd', help='Command to execute') action.add_argument('parameters', help='Parameters to command', nargs='?') # CryptSign action = self.subparsers.add_parser("cryptSign", help='Sign message using Bitcoin private key') action.add_argument('message', help='Message to sign') action.add_argument('privatekey', help='Private key') # Config parameters self.parser.add_argument('--debug', help='Debug mode', action='store_true') self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true') self.parser.add_argument('--config_file', help='Path of config file', default="zeronet.conf", metavar="path") self.parser.add_argument('--data_dir', help='Path of data directory', default="data", metavar="path") self.parser.add_argument('--log_dir', help='Path of logging directory', default="log", metavar="path") self.parser.add_argument('--ui_ip', help='Web interface bind address', default="127.0.0.1", metavar='ip') self.parser.add_argument('--ui_port', help='Web interface bind port', default=43110, type=int, metavar='port') self.parser.add_argument('--ui_restrict', help='Restrict web access', default=False, metavar='ip', nargs='*') self.parser.add_argument('--open_browser', help='Open homepage in web browser automatically', nargs='?', const="default_browser", metavar='browser_name') self.parser.add_argument('--homepage', help='Web interface Homepage', default='1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr', metavar='address') self.parser.add_argument('--size_limit', help='Default site size limit in MB', default=10, metavar='size') self.parser.add_argument('--fileserver_ip', help='FileServer bind address', default="*", metavar='ip') self.parser.add_argument('--fileserver_port', help='FileServer bind port', default=15441, type=int, metavar='port') self.parser.add_argument('--disable_udp', help='Disable UDP connections', action='store_true') self.parser.add_argument('--proxy', help='Socks proxy address', metavar='ip:port') self.parser.add_argument('--ip_external', help='External ip (tested on start if None)', metavar='ip') self.parser.add_argument('--use_openssl', help='Use OpenSSL liblary for speedup', type='bool', choices=[True, False], default=use_openssl) self.parser.add_argument('--disable_encryption', help='Disable connection encryption', action='store_true') self.parser.add_argument('--disable_sslcompression', help='Disable SSL compression to save memory', type='bool', choices=[True, False], default=True) self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript, metavar='executable_path') self.parser.add_argument('--version', action='version', version='ZeroNet %s r%s' % (self.version, self.rev)) return self.parser # Find arguments specificed for current action def getActionArguments(self): back = {} arguments = self.parser._subparsers._group_actions[0].choices[self.action]._actions[1:] # First is --version for argument in arguments: back[argument.dest] = getattr(self, argument.dest) return back # Try to find action from argv def getAction(self, argv): actions = [action.choices.keys() for action in self.parser._actions if action.dest == "action"][0] # Valid actions found_action = False for action in actions: # See if any in argv if action in argv: found_action = action break return found_action # Move plugin parameters to end of argument list def moveUnknownToEnd(self, argv, default_action): valid_actions = sum([action.option_strings for action in self.parser._actions], []) valid_parameters = [] plugin_parameters = [] plugin = False for arg in argv: if arg.startswith("--"): if arg not in valid_actions: plugin = True else: plugin = False elif arg == default_action: plugin = False if plugin: plugin_parameters.append(arg) else: valid_parameters.append(arg) return valid_parameters + plugin_parameters # Parse arguments from config file and command line def parse(self, silent=False, parse_config=True): if silent: # Don't display messages or quit on unknown parameter original_print_message = self.parser._print_message original_exit = self.parser.exit def silent(parser, function_name): parser.exited = True return None self.parser.exited = False self.parser._print_message = lambda *args, **kwargs: silent(self.parser, "_print_message") self.parser.exit = lambda *args, **kwargs: silent(self.parser, "exit") argv = self.argv[:] # Copy command line arguments if parse_config: argv = self.parseConfig(argv) # Add arguments from config file self.parseCommandline(argv, silent) # Parse argv self.setAttributes() if silent: # Restore original functions if self.parser.exited and self.action == "main": # Argument parsing halted, don't start ZeroNet with main action self.action = None self.parser._print_message = original_print_message self.parser.exit = original_exit # Parse command line arguments def parseCommandline(self, argv, silent=False): # Find out if action is specificed on start action = self.getAction(argv) if not action: argv.append("main") action = "main" argv = self.moveUnknownToEnd(argv, action) if silent: res = self.parser.parse_known_args(argv[1:]) if res: self.arguments = res[0] else: self.arguments = {} else: self.arguments = self.parser.parse_args(argv[1:]) # Parse config file def parseConfig(self, argv): # Find config file path from parameters config_file = "zeronet.conf" if "--config_file" in argv: config_file = argv[argv.index("--config_file") + 1] # Load config file if os.path.isfile(config_file): config = ConfigParser.ConfigParser(allow_no_value=True) config.read(config_file) for section in config.sections(): for key, val in config.items(section): if section != "global": # If not global prefix key with section key = section + "_" + key if val: argv.insert(1, val) argv.insert(1, "--%s" % key) return argv # Expose arguments as class attributes def setAttributes(self): # Set attributes from arguments if self.arguments: args = vars(self.arguments) for key, val in args.items(): setattr(self, key, val) def loadPlugins(self): from Plugin import PluginManager @PluginManager.acceptPlugins class ConfigPlugin(object): def __init__(self, config): self.parser = config.parser self.createArguments() def createArguments(self): pass ConfigPlugin(self) config = Config(sys.argv)
gpl-2.0
[ 646, 7534, 199, 646, 984, 199, 646, 747, 199, 646, 14196, 421, 199, 533, 4094, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 9238, 304, 267, 291, 14, 1023, 275, 298, 16, 14, 19, 14, 17, 2, 267, 291, 14, 4964, 275, 26959, 267, 291, 14, 3020, 275, 9238, 267, 291, 14, 1287, 275, 488, 267, 291, 14, 981, 2842, 342, 267, 291, 14, 981, 14517, 342, 339, 347, 1218, 2842, 8, 277, 304, 267, 327, 2790, 1798, 267, 291, 14, 2087, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 267, 291, 14, 2087, 14, 2683, 360, 466, 297, 283, 2245, 297, 291, 14, 495, 1378, 10349, 9, 267, 291, 14, 954, 11531, 275, 291, 14, 2087, 14, 525, 63, 954, 11531, 8, 1213, 628, 3310, 370, 5147, 401, 2053, 628, 1287, 531, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 4958, 680, 1814, 480, 8814, 401, 298, 2028, 531, 221, 327, 11719, 7534, 620, 1072, 339, 327, 7905, 1059, 370, 2155, 272, 347, 620, 1378, 10349, 8, 277, 12, 373, 304, 267, 372, 373, 14, 2325, 342, 315, 1689, 5066, 401, 298, 2052, 401, 298, 84, 401, 298, 17, 531, 339, 327, 2790, 1414, 1004, 2368, 272, 347, 1218, 14517, 8, 277, 304, 267, 327, 16078, 2488, 267, 340, 984, 14, 3246, 14, 2460, 480, 2676, 2349, 288, 512, 2026, 397, 1669, 275, 298, 466, 450, 83, 1204, 7249, 1103, 331, 24715, 1103, 331, 24715, 14, 1760, 2, 267, 587, 26, 288, 512, 2026, 397, 1669, 275, 488, 398, 675, 63, 14837, 275, 715, 398, 327, 11298, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 973, 401, 1720, 534, 3162, 32471, 3120, 436, 3814, 3120, 334, 885, 5942, 398, 327, 11666, 2499, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 2499, 401, 1720, 534, 2499, 282, 892, 4770, 358, 398, 327, 11666, 4940, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 4940, 401, 1720, 534, 4152, 436, 2070, 1564, 14, 1001, 26, 2287, 359, 4239, 498, 10374, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 2070, 358, 267, 1595, 14, 525, 63, 2094, 360, 4239, 498, 297, 1720, 534, 12185, 790, 334, 885, 26, 7198, 641, 5341, 3196, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 4517, 5216, 63, 515, 297, 1720, 534, 1173, 1265, 2934, 370, 2070, 334, 885, 26, 1564, 14, 1001, 3196, 1169, 849, 628, 1317, 14, 1001, 401, 8214, 628, 5216, 63, 515, 531, 267, 1595, 14, 525, 63, 2094, 4517, 4763, 297, 1720, 534, 13956, 4770, 2410, 314, 18057, 297, 1595, 534, 1617, 63, 2052, 358, 398, 327, 11666, 13956, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 13956, 401, 1720, 534, 13956, 4770, 370, 1163, 28166, 26, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 2780, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 370, 2780, 334, 885, 26, 2196, 28166, 3384, 687, 15271, 3196, 1169, 849, 29, 403, 12, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 370, 2780, 334, 885, 26, 2196, 9104, 1844, 687, 15271, 3196, 1169, 849, 29, 1046, 24284, 12, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 4517, 5216, 63, 515, 297, 1720, 534, 2714, 14, 1001, 1265, 2934, 370, 2780, 334, 885, 26, 1564, 14, 1001, 3196, 1169, 849, 628, 1317, 14, 1001, 401, 8214, 628, 5216, 63, 515, 531, 398, 327, 11666, 7496, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 7496, 401, 1720, 534, 7496, 4770, 1584, 1808, 7793, 7736, 26, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 4911, 358, 398, 327, 1592, 497, 1506, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 697, 497, 1506, 401, 1720, 534, 497, 1506, 4770, 3050, 2581, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 22110, 358, 398, 327, 1592, 3227, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 697, 3227, 401, 1720, 534, 3227, 4770, 3875, 2581, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 1827, 358, 267, 1595, 14, 525, 63, 2094, 360, 1131, 297, 1720, 534, 16790, 1827, 358, 398, 327, 11379, 281, 22638, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 22638, 401, 1720, 534, 6795, 510, 316, 1414, 370, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 297, 9237, 534, 18478, 398, 327, 11379, 281, 26535, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 26535, 401, 1720, 534, 2017, 436, 870, 282, 570, 1564, 687, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 358, 267, 1595, 14, 525, 63, 2094, 360, 2124, 297, 1720, 534, 8972, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1501, 297, 1720, 534, 1173, 536, 370, 1056, 358, 398, 327, 11379, 281, 26535, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 7874, 401, 1720, 534, 2017, 436, 870, 282, 570, 1564, 687, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 358, 267, 1595, 14, 525, 63, 2094, 360, 1760, 297, 1720, 534, 3110, 370, 5341, 358, 267, 1595, 14, 525, 63, 2094, 360, 3214, 297, 1720, 534, 5976, 370, 1414, 297, 9237, 534, 18478, 398, 327, 445, 13656, 4940, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 4997 ]
[ 7534, 199, 646, 984, 199, 646, 747, 199, 646, 14196, 421, 199, 533, 4094, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 9238, 304, 267, 291, 14, 1023, 275, 298, 16, 14, 19, 14, 17, 2, 267, 291, 14, 4964, 275, 26959, 267, 291, 14, 3020, 275, 9238, 267, 291, 14, 1287, 275, 488, 267, 291, 14, 981, 2842, 342, 267, 291, 14, 981, 14517, 342, 339, 347, 1218, 2842, 8, 277, 304, 267, 327, 2790, 1798, 267, 291, 14, 2087, 275, 7534, 14, 10730, 8, 8911, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 267, 291, 14, 2087, 14, 2683, 360, 466, 297, 283, 2245, 297, 291, 14, 495, 1378, 10349, 9, 267, 291, 14, 954, 11531, 275, 291, 14, 2087, 14, 525, 63, 954, 11531, 8, 1213, 628, 3310, 370, 5147, 401, 2053, 628, 1287, 531, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 4958, 680, 1814, 480, 8814, 401, 298, 2028, 531, 221, 327, 11719, 7534, 620, 1072, 339, 327, 7905, 1059, 370, 2155, 272, 347, 620, 1378, 10349, 8, 277, 12, 373, 304, 267, 372, 373, 14, 2325, 342, 315, 1689, 5066, 401, 298, 2052, 401, 298, 84, 401, 298, 17, 531, 339, 327, 2790, 1414, 1004, 2368, 272, 347, 1218, 14517, 8, 277, 304, 267, 327, 16078, 2488, 267, 340, 984, 14, 3246, 14, 2460, 480, 2676, 2349, 288, 512, 2026, 397, 1669, 275, 298, 466, 450, 83, 1204, 7249, 1103, 331, 24715, 1103, 331, 24715, 14, 1760, 2, 267, 587, 26, 288, 512, 2026, 397, 1669, 275, 488, 398, 675, 63, 14837, 275, 715, 398, 327, 11298, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 973, 401, 1720, 534, 3162, 32471, 3120, 436, 3814, 3120, 334, 885, 5942, 398, 327, 11666, 2499, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 2499, 401, 1720, 534, 2499, 282, 892, 4770, 358, 398, 327, 11666, 4940, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 4940, 401, 1720, 534, 4152, 436, 2070, 1564, 14, 1001, 26, 2287, 359, 4239, 498, 10374, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 2070, 358, 267, 1595, 14, 525, 63, 2094, 360, 4239, 498, 297, 1720, 534, 12185, 790, 334, 885, 26, 7198, 641, 5341, 3196, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 4517, 5216, 63, 515, 297, 1720, 534, 1173, 1265, 2934, 370, 2070, 334, 885, 26, 1564, 14, 1001, 3196, 1169, 849, 628, 1317, 14, 1001, 401, 8214, 628, 5216, 63, 515, 531, 267, 1595, 14, 525, 63, 2094, 4517, 4763, 297, 1720, 534, 13956, 4770, 2410, 314, 18057, 297, 1595, 534, 1617, 63, 2052, 358, 398, 327, 11666, 13956, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 13956, 401, 1720, 534, 13956, 4770, 370, 1163, 28166, 26, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 2780, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 370, 2780, 334, 885, 26, 2196, 28166, 3384, 687, 15271, 3196, 1169, 849, 29, 403, 12, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 370, 2780, 334, 885, 26, 2196, 9104, 1844, 687, 15271, 3196, 1169, 849, 29, 1046, 24284, 12, 9237, 534, 18478, 267, 1595, 14, 525, 63, 2094, 4517, 5216, 63, 515, 297, 1720, 534, 2714, 14, 1001, 1265, 2934, 370, 2780, 334, 885, 26, 1564, 14, 1001, 3196, 1169, 849, 628, 1317, 14, 1001, 401, 8214, 628, 5216, 63, 515, 531, 398, 327, 11666, 7496, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 2124, 7496, 401, 1720, 534, 7496, 4770, 1584, 1808, 7793, 7736, 26, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 4911, 358, 398, 327, 1592, 497, 1506, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 697, 497, 1506, 401, 1720, 534, 497, 1506, 4770, 3050, 2581, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 22110, 358, 398, 327, 1592, 3227, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 697, 3227, 401, 1720, 534, 3227, 4770, 3875, 2581, 358, 267, 1595, 14, 525, 63, 2094, 360, 1562, 297, 1720, 534, 8972, 370, 1827, 358, 267, 1595, 14, 525, 63, 2094, 360, 1131, 297, 1720, 534, 16790, 1827, 358, 398, 327, 11379, 281, 22638, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 22638, 401, 1720, 534, 6795, 510, 316, 1414, 370, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 297, 9237, 534, 18478, 398, 327, 11379, 281, 26535, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 26535, 401, 1720, 534, 2017, 436, 870, 282, 570, 1564, 687, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 358, 267, 1595, 14, 525, 63, 2094, 360, 2124, 297, 1720, 534, 8972, 2287, 358, 267, 1595, 14, 525, 63, 2094, 360, 1501, 297, 1720, 534, 1173, 536, 370, 1056, 358, 398, 327, 11379, 281, 26535, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 7866, 7874, 401, 1720, 534, 2017, 436, 870, 282, 570, 1564, 687, 9104, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 711, 297, 1720, 534, 12566, 3384, 358, 267, 1595, 14, 525, 63, 2094, 360, 7866, 63, 719, 297, 1720, 534, 12566, 1844, 358, 267, 1595, 14, 525, 63, 2094, 360, 1760, 297, 1720, 534, 3110, 370, 5341, 358, 267, 1595, 14, 525, 63, 2094, 360, 3214, 297, 1720, 534, 5976, 370, 1414, 297, 9237, 534, 18478, 398, 327, 445, 13656, 4940, 267, 1595, 275, 291, 14, 954, 11531, 14, 525, 63, 2087, 480, 4997, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
md5555/S6-UniKernel
tools/perf/scripts/python/futex-contention.py
11261
1486
# futex contention # (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com> # Licensed under the terms of the GNU GPL License version 2 # # Translation of: # # http://sourceware.org/systemtap/wiki/WSFutexContention # # to perf python scripting. # # Measures futex contention import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Util import * process_names = {} thread_thislock = {} thread_blocktime = {} lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time process_names = {} # long-lived pid-to-execname mapping def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, nr, uaddr, op, val, utime, uaddr2, val3): cmd = op & FUTEX_CMD_MASK if cmd != FUTEX_WAIT: return # we don't care about originators of WAKE events process_names[tid] = comm thread_thislock[tid] = uaddr thread_blocktime[tid] = nsecs(s, ns) def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, nr, ret): if thread_blocktime.has_key(tid): elapsed = nsecs(s, ns) - thread_blocktime[tid] add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) del thread_blocktime[tid] del thread_thislock[tid] def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): for (tid, lock) in lock_waits: min, max, avg, count = lock_waits[tid, lock] print "%s[%d] lock %x contended %d times, %d avg ns" % \ (process_names[tid], tid, lock, count, avg)
gpl-2.0
[ 3, 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
morissette/devopsdays-hackathon-2016
venv/lib/python2.7/site-packages/pip/_vendor/cachecontrol/heuristics.py
490
4141
import calendar import time from email.utils import formatdate, parsedate, parsedate_tz from datetime import datetime, timedelta TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT" def expire_after(delta, date=None): date = date or datetime.now() return date + delta def datetime_to_header(dt): return formatdate(calendar.timegm(dt.timetuple())) class BaseHeuristic(object): def warning(self, response): """ Return a valid 1xx warning header value describing the cache adjustments. The response is provided too allow warnings like 113 http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need to explicitly say response is over 24 hours old. """ return '110 - "Response is Stale"' def update_headers(self, response): """Update the response headers with any new headers. NOTE: This SHOULD always include some Warning header to signify that the response was cached by the client, not by way of the provided headers. """ return {} def apply(self, response): updated_headers = self.update_headers(response) if updated_headers: response.headers.update(updated_headers) warning_header_value = self.warning(response) if warning_header_value is not None: response.headers.update({'Warning': warning_header_value}) return response class OneDayCache(BaseHeuristic): """ Cache the response by providing an expires 1 day in the future. """ def update_headers(self, response): headers = {} if 'expires' not in response.headers: date = parsedate(response.headers['date']) expires = expire_after(timedelta(days=1), date=datetime(*date[:6])) headers['expires'] = datetime_to_header(expires) headers['cache-control'] = 'public' return headers class ExpiresAfter(BaseHeuristic): """ Cache **all** requests for a defined time period. """ def __init__(self, **kw): self.delta = timedelta(**kw) def update_headers(self, response): expires = expire_after(self.delta) return { 'expires': datetime_to_header(expires), 'cache-control': 'public', } def warning(self, response): tmpl = '110 - Automatically cached for %s. Response might be stale' return tmpl % self.delta class LastModified(BaseHeuristic): """ If there is no Expires header already, fall back on Last-Modified using the heuristic from http://tools.ietf.org/html/rfc7234#section-4.2.2 to calculate a reasonable value. Firefox also does something like this per https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397 Unlike mozilla we limit this to 24-hr. """ cacheable_by_default_statuses = set([ 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501 ]) def update_headers(self, resp): headers = resp.headers if 'expires' in headers: return {} if 'cache-control' in headers and headers['cache-control'] != 'public': return {} if resp.status not in self.cacheable_by_default_statuses: return {} if 'date' not in headers or 'last-modified' not in headers: return {} date = calendar.timegm(parsedate_tz(headers['date'])) last_modified = parsedate(headers['last-modified']) if date is None or last_modified is None: return {} now = time.time() current_age = max(0, now - date) delta = date - calendar.timegm(last_modified) freshness_lifetime = max(0, min(delta / 10, 24 * 3600)) if freshness_lifetime <= current_age: return {} expires = date + freshness_lifetime return {'expires': time.strftime(TIME_FMT, time.gmtime(expires))} def warning(self, resp): return None
gpl-3.0
[ 646, 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 4588, 63, 2139, 275, 291, 14, 873, 63, 2139, 8, 1310, 9, 398, 340, 4588, 63, 2139, 26, 288, 1177, 14, 2139, 14, 873, 8, 5334, 63, 2139, 9, 288, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 288, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 355, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 398, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721, 8, 277, 12, 3085, 304, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 4588, 63, 2139, 275, 291, 14, 873, 63, 2139, 8, 1310, 9, 398, 340, 4588, 63, 2139, 26, 288, 1177, 14, 2139, 14, 873, 8, 5334, 63, 2139, 9, 288, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 288, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 355, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 398, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721, 8, 277, 12, 3085, 304, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kalahbrown/HueBigSQL
desktop/core/ext-py/Django-1.6.10/tests/custom_managers_regress/tests.py
150
2212
from __future__ import absolute_import from django.test import TestCase from .models import RelatedModel, RestrictedModel, OneToOneRestrictedModel class CustomManagersRegressTestCase(TestCase): def test_filtered_default_manager(self): """Even though the default manager filters out some records, we must still be able to save (particularly, save by updating existing records) those filtered instances. This is a regression test for #8990, #9527""" related = RelatedModel.objects.create(name="xyzzy") obj = RestrictedModel.objects.create(name="hidden", related=related) obj.name = "still hidden" obj.save() # If the hidden object wasn't seen during the save process, # there would now be two objects in the database. self.assertEqual(RestrictedModel.plain_manager.count(), 1) def test_delete_related_on_filtered_manager(self): """Deleting related objects should also not be distracted by a restricted manager on the related object. This is a regression test for #2698.""" related = RelatedModel.objects.create(name="xyzzy") for name, public in (('one', True), ('two', False), ('three', False)): RestrictedModel.objects.create(name=name, is_public=public, related=related) obj = RelatedModel.objects.get(name="xyzzy") obj.delete() # All of the RestrictedModel instances should have been # deleted, since they *all* pointed to the RelatedModel. If # the default manager is used, only the public one will be # deleted. self.assertEqual(len(RestrictedModel.plain_manager.all()), 0) def test_delete_one_to_one_manager(self): # The same test case as the last one, but for one-to-one # models, which are implemented slightly different internally, # so it's a different code path. obj = RelatedModel.objects.create(name="xyzzy") OneToOneRestrictedModel.objects.create(name="foo", is_public=False, related=obj) obj = RelatedModel.objects.get(name="xyzzy") obj.delete() self.assertEqual(len(OneToOneRestrictedModel.plain_manager.all()), 0)
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 20116, 1685, 12, 32491, 1522, 1685, 12, 7309, 10939, 28850, 1685, 421, 199, 533, 8388, 2395, 10246, 2872, 753, 1746, 8, 1746, 304, 272, 347, 511, 63, 11142, 63, 885, 63, 2609, 8, 277, 304, 267, 408, 29704, 10617, 314, 849, 5256, 4766, 734, 2005, 5767, 12, 267, 781, 1471, 5139, 506, 7688, 370, 3354, 334, 462, 6628, 590, 12, 3354, 701, 12928, 267, 3411, 5767, 9, 5204, 9806, 4454, 14, 961, 365, 282, 267, 10864, 511, 367, 327, 24, 16166, 12, 327, 2720, 1465, 624, 267, 4048, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 267, 1559, 275, 32491, 1522, 1685, 14, 1462, 14, 981, 8, 354, 628, 5642, 401, 4048, 29, 2407, 9, 267, 1559, 14, 354, 275, 298, 32310, 8752, 2, 267, 1559, 14, 2117, 342, 398, 327, 982, 314, 8752, 909, 17373, 1133, 6775, 5309, 314, 3354, 2112, 12, 267, 327, 2337, 3955, 3063, 506, 2877, 2251, 315, 314, 3050, 14, 267, 291, 14, 629, 8, 28850, 1685, 14, 6104, 63, 2609, 14, 835, 1062, 413, 9, 339, 347, 511, 63, 1807, 63, 2407, 63, 265, 63, 11142, 63, 2609, 8, 277, 304, 267, 408, 22001, 4048, 2251, 1077, 2597, 440, 506, 2917, 345, 1522, 701, 282, 267, 15297, 5256, 641, 314, 4048, 909, 14, 961, 365, 282, 10864, 267, 511, 367, 327, 1479, 2905, 1041, 267, 4048, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 398, 367, 536, 12, 4575, 315, 13636, 368, 297, 715, 395, 661, 5601, 297, 756, 395, 661, 10480, 297, 756, 2298, 288, 32491, 1522, 1685, 14, 1462, 14, 981, 8, 354, 29, 354, 12, 365, 63, 3455, 29, 3455, 12, 4048, 29, 2407, 9, 398, 1559, 275, 20116, 1685, 14, 1462, 14, 362, 8, 354, 628, 8568, 3605, 531, 267, 1559, 14, 1807, 342, 398, 327, 2900, 402, 314, 32491, 1522, 1685, 4454, 1077, 1172, 2757, 267, 327, 5463, 12, 3967, 2985, 627, 452, 10, 32031, 370, 314, 20116, 1685, 14, 982, 267, 327, 314, 849, 5256, 365, 1202, 12, 1454, 314, 4575, 1373, 911, 506, 267, 327, 5463, 14, 267, 291, 14, 629, 8, 552, 8, 28850, 1685, 14, 6104, 63, 2609, 14, 452, 4000, 378, 9, 339, 347, 511, 63, 1807, 63, 368, 63, 475, 63, 368, 63, 2609, 8, 277, 304, 267, 327, 710, 2011, 511, 1930, 465, 314, 2061, 1373, 12, 1325, 367, 1373, 13, 475, 13, 368, 267, 327, 1709, 12, 1314, 787, 6366, 18023, 3365, 14448, 12, 267, 327, 880, 652, 1159, 282, 3365, 1233, 931, 14, 267, 1559, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 267, 7309, 10939, 28850, 1685, 14, 1462, 14, 981, 8, 354, 628, 1421, 401, 365, 63, 3455, 29, 797, 12, 4048, 29, 1113, 9, 267, 1559, 275, 20116, 1685, 14, 1462, 14, 362, 8, 354, 628, 8568, 3605, 531, 267, 1559, 14, 1807, 342, 267, 291, 14, 629, 8, 552, 8, 4395, 10939, 28850, 1685, 14, 6104, 63, 2609, 14, 452, 4000, 378, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 20116, 1685, 12, 32491, 1522, 1685, 12, 7309, 10939, 28850, 1685, 421, 199, 533, 8388, 2395, 10246, 2872, 753, 1746, 8, 1746, 304, 272, 347, 511, 63, 11142, 63, 885, 63, 2609, 8, 277, 304, 267, 408, 29704, 10617, 314, 849, 5256, 4766, 734, 2005, 5767, 12, 267, 781, 1471, 5139, 506, 7688, 370, 3354, 334, 462, 6628, 590, 12, 3354, 701, 12928, 267, 3411, 5767, 9, 5204, 9806, 4454, 14, 961, 365, 282, 267, 10864, 511, 367, 327, 24, 16166, 12, 327, 2720, 1465, 624, 267, 4048, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 267, 1559, 275, 32491, 1522, 1685, 14, 1462, 14, 981, 8, 354, 628, 5642, 401, 4048, 29, 2407, 9, 267, 1559, 14, 354, 275, 298, 32310, 8752, 2, 267, 1559, 14, 2117, 342, 398, 327, 982, 314, 8752, 909, 17373, 1133, 6775, 5309, 314, 3354, 2112, 12, 267, 327, 2337, 3955, 3063, 506, 2877, 2251, 315, 314, 3050, 14, 267, 291, 14, 629, 8, 28850, 1685, 14, 6104, 63, 2609, 14, 835, 1062, 413, 9, 339, 347, 511, 63, 1807, 63, 2407, 63, 265, 63, 11142, 63, 2609, 8, 277, 304, 267, 408, 22001, 4048, 2251, 1077, 2597, 440, 506, 2917, 345, 1522, 701, 282, 267, 15297, 5256, 641, 314, 4048, 909, 14, 961, 365, 282, 10864, 267, 511, 367, 327, 1479, 2905, 1041, 267, 4048, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 398, 367, 536, 12, 4575, 315, 13636, 368, 297, 715, 395, 661, 5601, 297, 756, 395, 661, 10480, 297, 756, 2298, 288, 32491, 1522, 1685, 14, 1462, 14, 981, 8, 354, 29, 354, 12, 365, 63, 3455, 29, 3455, 12, 4048, 29, 2407, 9, 398, 1559, 275, 20116, 1685, 14, 1462, 14, 362, 8, 354, 628, 8568, 3605, 531, 267, 1559, 14, 1807, 342, 398, 327, 2900, 402, 314, 32491, 1522, 1685, 4454, 1077, 1172, 2757, 267, 327, 5463, 12, 3967, 2985, 627, 452, 10, 32031, 370, 314, 20116, 1685, 14, 982, 267, 327, 314, 849, 5256, 365, 1202, 12, 1454, 314, 4575, 1373, 911, 506, 267, 327, 5463, 14, 267, 291, 14, 629, 8, 552, 8, 28850, 1685, 14, 6104, 63, 2609, 14, 452, 4000, 378, 9, 339, 347, 511, 63, 1807, 63, 368, 63, 475, 63, 368, 63, 2609, 8, 277, 304, 267, 327, 710, 2011, 511, 1930, 465, 314, 2061, 1373, 12, 1325, 367, 1373, 13, 475, 13, 368, 267, 327, 1709, 12, 1314, 787, 6366, 18023, 3365, 14448, 12, 267, 327, 880, 652, 1159, 282, 3365, 1233, 931, 14, 267, 1559, 275, 20116, 1685, 14, 1462, 14, 981, 8, 354, 628, 8568, 3605, 531, 267, 7309, 10939, 28850, 1685, 14, 1462, 14, 981, 8, 354, 628, 1421, 401, 365, 63, 3455, 29, 797, 12, 4048, 29, 1113, 9, 267, 1559, 275, 20116, 1685, 14, 1462, 14, 362, 8, 354, 628, 8568, 3605, 531, 267, 1559, 14, 1807, 342, 267, 291, 14, 629, 8, 552, 8, 4395, 10939, 28850, 1685, 14, 6104, 63, 2609, 14, 452, 4000, 378, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
elelianghh/gunicorn
examples/frameworks/django/testing/testing/apps/someapp/views.py
22
1628
# Create your views here. import csv import io import os from django import forms from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext import tempfile class MsgForm(forms.Form): subject = forms.CharField(max_length=100) message = forms.CharField() f = forms.FileField() def home(request): from django.conf import settings print(settings.SOME_VALUE) subject = None message = None size = 0 print(request.META) if request.POST: form = MsgForm(request.POST, request.FILES) print(request.FILES) if form.is_valid(): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] f = request.FILES['f'] if not hasattr(f, "fileno"): size = len(f.read()) else: try: size = int(os.fstat(f.fileno())[6]) except io.UnsupportedOperation: size = len(f.read()) else: form = MsgForm() return render_to_response('home.html', { 'form': form, 'subject': subject, 'message': message, 'size': size }, RequestContext(request)) def acsv(request): rows = [ {'a': 1, 'b': 2}, {'a': 3, 'b': 3} ] response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=report.csv' writer = csv.writer(response) writer.writerow(['a', 'b']) for r in rows: writer.writerow([r['a'], r['b']]) return response
mit
[ 3, 2790, 2195, 6858, 2348, 14, 199, 199, 646, 7392, 199, 646, 5890, 199, 646, 747, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1160, 492, 22538, 199, 646, 5549, 199, 199, 533, 603, 1226, 2821, 8, 3351, 14, 2821, 304, 272, 5420, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1245, 275, 4513, 14, 2183, 342, 272, 289, 275, 4513, 14, 23252, 342, 421, 199, 318, 5629, 8, 1069, 304, 272, 687, 1639, 14, 2190, 492, 2202, 272, 870, 8, 1751, 14, 4118, 3635, 63, 7041, 9, 272, 5420, 275, 488, 272, 1245, 275, 488, 272, 1568, 275, 378, 272, 870, 8, 1069, 14, 10614, 9, 272, 340, 1056, 14, 4030, 26, 267, 1824, 275, 603, 1226, 2821, 8, 1069, 14, 4030, 12, 1056, 14, 9472, 9, 267, 870, 8, 1069, 14, 9472, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 288, 5420, 275, 1824, 14, 8275, 63, 576, 459, 5875, 418, 288, 1245, 275, 1824, 14, 8275, 63, 576, 459, 1188, 418, 288, 289, 275, 1056, 14, 9472, 459, 70, 418, 953, 340, 440, 2688, 8, 70, 12, 298, 9843, 2349, 355, 1568, 275, 822, 8, 70, 14, 739, 1012, 288, 587, 26, 355, 862, 26, 490, 1568, 275, 1109, 8, 736, 14, 32127, 8, 70, 14, 9843, 18756, 22, 566, 355, 871, 5890, 14, 12647, 6044, 26, 490, 1568, 275, 822, 8, 70, 14, 739, 1012, 272, 587, 26, 267, 1824, 275, 603, 1226, 2821, 342, 339, 372, 3795, 63, 475, 63, 1310, 360, 4219, 14, 1360, 297, 469, 267, 283, 964, 356, 1824, 12, 267, 283, 5875, 356, 5420, 12, 267, 283, 1188, 356, 1245, 12, 267, 283, 890, 356, 1568, 272, 1660, 22538, 8, 1069, 430, 421, 199, 318, 1066, 2772, 8, 1069, 304, 272, 4730, 275, 359, 267, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1386, 267, 791, 65, 356, 650, 12, 283, 66, 356, 650, 93, 272, 1622, 339, 1177, 275, 6183, 8, 17450, 534, 505, 15, 4737, 358, 272, 1177, 459, 2714, 13, 15954, 418, 275, 283, 8905, 27, 1788, 29, 3070, 14, 4737, 7, 339, 7060, 275, 7392, 14, 5491, 8, 1310, 9, 272, 7060, 14, 22686, 2941, 65, 297, 283, 66, 1105, 339, 367, 519, 315, 4730, 26, 267, 7060, 14, 22686, 779, 82, 459, 65, 995, 519, 459, 66, 12121, 339, 372, 1177, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2790, 2195, 6858, 2348, 14, 199, 199, 646, 7392, 199, 646, 5890, 199, 646, 747, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1160, 492, 22538, 199, 646, 5549, 199, 199, 533, 603, 1226, 2821, 8, 3351, 14, 2821, 304, 272, 5420, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1245, 275, 4513, 14, 2183, 342, 272, 289, 275, 4513, 14, 23252, 342, 421, 199, 318, 5629, 8, 1069, 304, 272, 687, 1639, 14, 2190, 492, 2202, 272, 870, 8, 1751, 14, 4118, 3635, 63, 7041, 9, 272, 5420, 275, 488, 272, 1245, 275, 488, 272, 1568, 275, 378, 272, 870, 8, 1069, 14, 10614, 9, 272, 340, 1056, 14, 4030, 26, 267, 1824, 275, 603, 1226, 2821, 8, 1069, 14, 4030, 12, 1056, 14, 9472, 9, 267, 870, 8, 1069, 14, 9472, 9, 267, 340, 1824, 14, 374, 63, 1078, 837, 288, 5420, 275, 1824, 14, 8275, 63, 576, 459, 5875, 418, 288, 1245, 275, 1824, 14, 8275, 63, 576, 459, 1188, 418, 288, 289, 275, 1056, 14, 9472, 459, 70, 418, 953, 340, 440, 2688, 8, 70, 12, 298, 9843, 2349, 355, 1568, 275, 822, 8, 70, 14, 739, 1012, 288, 587, 26, 355, 862, 26, 490, 1568, 275, 1109, 8, 736, 14, 32127, 8, 70, 14, 9843, 18756, 22, 566, 355, 871, 5890, 14, 12647, 6044, 26, 490, 1568, 275, 822, 8, 70, 14, 739, 1012, 272, 587, 26, 267, 1824, 275, 603, 1226, 2821, 342, 339, 372, 3795, 63, 475, 63, 1310, 360, 4219, 14, 1360, 297, 469, 267, 283, 964, 356, 1824, 12, 267, 283, 5875, 356, 5420, 12, 267, 283, 1188, 356, 1245, 12, 267, 283, 890, 356, 1568, 272, 1660, 22538, 8, 1069, 430, 421, 199, 318, 1066, 2772, 8, 1069, 304, 272, 4730, 275, 359, 267, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1386, 267, 791, 65, 356, 650, 12, 283, 66, 356, 650, 93, 272, 1622, 339, 1177, 275, 6183, 8, 17450, 534, 505, 15, 4737, 358, 272, 1177, 459, 2714, 13, 15954, 418, 275, 283, 8905, 27, 1788, 29, 3070, 14, 4737, 7, 339, 7060, 275, 7392, 14, 5491, 8, 1310, 9, 272, 7060, 14, 22686, 2941, 65, 297, 283, 66, 1105, 339, 367, 519, 315, 4730, 26, 267, 7060, 14, 22686, 779, 82, 459, 65, 995, 519, 459, 66, 12121, 339, 372, 1177, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
edx/edx-platform
openedx/core/djangoapps/user_api/partition_schemes.py
4
4663
""" Provides partition support to the user service. """ import logging import random from eventtracking import tracker import openedx.core.djangoapps.user_api.course_tag.api as course_tag_api from xmodule.partitions.partitions import NoSuchUserPartitionGroupError, UserPartitionError log = logging.getLogger(__name__) class NotImplementedPartitionScheme: """ This "scheme" allows previously-defined schemes to be purged, while giving existing course data definitions a safe entry point to load. """ @classmethod def get_group_for_user(cls, course_key, user, user_partition, assign=True): # pylint: disable=unused-argument """ Returning None is equivalent to saying "This user is not in any groups using this partition scheme", be sure the scheme you're removing is compatible with that assumption. """ return None class ReturnGroup1PartitionScheme: """ This scheme is needed to allow verification partitions to be killed, see EDUCATOR-199 """ @classmethod def get_group_for_user(cls, course_key, user, user_partition, assign=True): # pylint: disable=unused-argument """ The previous "allow" definition for verification was defined as 1, so return that. Details at https://github.com/edx/edx-platform/pull/14913/files#diff-feff1466ec4d1b8c38894310d8342a80 """ return user_partition.get_group(1) class RandomUserPartitionScheme: """ This scheme randomly assigns users into the partition's groups. """ RANDOM = random.Random() @classmethod def get_group_for_user(cls, course_key, user, user_partition, assign=True): """ Returns the group from the specified user position to which the user is assigned. If the user has not yet been assigned, a group will be randomly chosen for them if assign flag is True. """ partition_key = cls.key_for_partition(user_partition) group_id = course_tag_api.get_course_tag(user, course_key, partition_key) group = None if group_id is not None: # attempt to look up the presently assigned group try: group = user_partition.get_group(int(group_id)) except NoSuchUserPartitionGroupError: # jsa: we can turn off warnings here if this is an expected case. log.warning( "group not found in RandomUserPartitionScheme: %r", { "requested_partition_id": user_partition.id, "requested_group_id": group_id, }, exc_info=True ) except ValueError: log.error("Bad group_id %r for user: %r", group_id, user) if group is None and assign and not course_tag_api.BulkCourseTags.is_prefetched(course_key): if not user_partition.groups: raise UserPartitionError('Cannot assign user to an empty user partition') # pylint: disable=fixme # TODO: had a discussion in arch council about making randomization more # deterministic (e.g. some hash). Could do that, but need to be careful not # to introduce correlation between users or bias in generation. group = cls.RANDOM.choice(user_partition.groups) # persist the value as a course tag course_tag_api.set_course_tag(user, course_key, partition_key, group.id) # emit event for analytics # FYI - context is always user ID that is logged in, NOT the user id that is # being operated on. If instructor can move user explicitly, then we should # put in event_info the user id that is being operated on. event_name = 'xmodule.partitions.assigned_user_to_partition' event_info = { 'group_id': group.id, 'group_name': group.name, 'partition_id': user_partition.id, 'partition_name': user_partition.name } # pylint: disable=fixme # TODO: Use the XBlock publish api instead with tracker.get_tracker().context(event_name, {}): tracker.emit( event_name, event_info, ) return group @classmethod def key_for_partition(cls, user_partition): """ Returns the key to use to look up and save the user's group for a given user partition. """ return f'xblock.partition_service.partition_{user_partition.id}'
agpl-3.0
[ 624, 199, 17473, 6484, 2291, 370, 314, 922, 2435, 14, 199, 624, 421, 199, 646, 2050, 199, 646, 2196, 199, 199, 504, 1566, 14428, 492, 15271, 199, 199, 646, 22709, 14, 1018, 14, 16432, 14, 751, 63, 1246, 14, 1972, 63, 1450, 14, 1246, 465, 2518, 63, 1450, 63, 1246, 199, 504, 9872, 14, 12553, 14, 12553, 492, 23798, 1899, 13068, 2448, 547, 12, 2876, 13068, 547, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3784, 13068, 19530, 26, 272, 408, 272, 961, 298, 5512, 2, 6127, 10889, 13, 4037, 21149, 370, 506, 5861, 3046, 12, 1830, 15131, 3411, 272, 2518, 666, 10269, 282, 5048, 2397, 2376, 370, 2248, 14, 272, 408, 339, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 267, 1432, 316, 488, 365, 7353, 370, 14722, 316, 298, 2765, 922, 365, 440, 315, 1263, 4652, 267, 1808, 642, 6484, 5687, 401, 506, 3238, 314, 5687, 1265, 3984, 12881, 365, 267, 9025, 543, 626, 30075, 14, 267, 408, 267, 372, 488, 421, 199, 533, 1432, 2448, 17, 13068, 19530, 26, 272, 408, 272, 961, 5687, 365, 4346, 370, 2040, 14786, 16394, 370, 506, 26659, 12, 1937, 662, 4980, 35, 6467, 13, 7155, 272, 408, 272, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 267, 710, 4136, 298, 3306, 2, 5492, 367, 14786, 1990, 3247, 465, 413, 12, 880, 372, 626, 14, 267, 15621, 737, 4178, 921, 5031, 14, 957, 15, 8268, 15, 8268, 13, 3246, 15, 9302, 15, 10721, 969, 15, 1725, 3, 3028, 13, 771, 556, 1079, 1272, 825, 20, 68, 17, 66, 24, 67, 11403, 2635, 18035, 68, 24, 14519, 65, 1257, 267, 408, 267, 372, 922, 63, 5312, 14, 362, 63, 923, 8, 17, 9, 421, 199, 533, 9571, 1899, 13068, 19530, 26, 272, 408, 272, 961, 5687, 19311, 465, 20440, 4390, 1901, 314, 6484, 1159, 4652, 14, 272, 408, 272, 820, 879, 10462, 275, 2196, 14, 3883, 342, 339, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 267, 408, 267, 1803, 314, 1572, 687, 314, 2013, 922, 3421, 370, 1314, 314, 922, 365, 7943, 14, 267, 982, 314, 922, 965, 440, 5966, 2757, 7943, 12, 282, 1572, 911, 506, 19311, 12414, 367, 3062, 340, 5090, 3305, 365, 715, 14, 267, 408, 267, 6484, 63, 498, 275, 843, 14, 498, 63, 509, 63, 5312, 8, 751, 63, 5312, 9, 267, 1572, 63, 344, 275, 2518, 63, 1450, 63, 1246, 14, 362, 63, 1972, 63, 1450, 8, 751, 12, 2518, 63, 498, 12, 6484, 63, 498, 9, 398, 1572, 275, 488, 267, 340, 1572, 63, 344, 365, 440, 488, 26, 288, 327, 7427, 370, 3648, 1536, 314, 3451, 590, 7943, 1572, 288, 862, 26, 355, 1572, 275, 922, 63, 5312, 14, 362, 63, 923, 8, 442, 8, 923, 63, 344, 430, 288, 871, 23798, 1899, 13068, 2448, 547, 26, 355, 327, 1335, 2231, 26, 781, 883, 7485, 2331, 3598, 2348, 340, 642, 365, 376, 1420, 1930, 14, 355, 943, 14, 3764, 8, 490, 298, 923, 440, 1911, 315, 9571, 1899, 13068, 19530, 26, 450, 82, 401, 490, 469, 717, 298, 11151, 63, 5312, 63, 344, 582, 922, 63, 5312, 14, 344, 12, 717, 298, 11151, 63, 923, 63, 344, 582, 1572, 63, 344, 12, 490, 1660, 490, 3178, 63, 815, 29, 549, 355, 776, 288, 871, 1722, 26, 355, 943, 14, 705, 480, 5725, 1572, 63, 344, 450, 82, 367, 922, 26, 450, 82, 401, 1572, 63, 344, 12, 922, 9, 398, 340, 1572, 365, 488, 436, 5090, 436, 440, 2518, 63, 1450, 63, 1246, 14, 26033, 6979, 9440, 14, 374, 63, 13829, 13534, 8, 1972, 63, 498, 304, 288, 340, 440, 922, 63, 5312, 14, 2634, 26, 355, 746, 2876, 13068, 547, 360, 6612, 5090, 922, 370, 376, 2701, 922, 6484, 358, 953, 327, 4287, 26, 3507, 29, 970, 278, 288, 327, 3254, 26, 10530, 282, 16582, 315, 3819, 512, 1097, 382, 3595, 10663, 2196, 2072, 1655, 288, 327, 25286, 334, 69, 14, 71, 14, 2005, 2631, 680, 221, 18615, 886, 626, 12, 1325, 1929, 370, 506, 25082, 440, 288, 327, 370, 13318, 3402, 21280, 3382, 4390, 503, 10671, 315, 10152, 14, 288, 1572, 275, 843, 14, 27644, 10462, 14, 5095, 8, 751, 63, 5312, 14, 2634, 9, 953, 327, 22400, 314, 574, 465, 282, 2518, 1947, 288, 2518, 63, 1450, 63, 1246, 14, 409, 63, 1972, 63, 1450, 8, 751, 12, 2518, 63, 498, 12, 6484, 63, 498, 12, 1572, 14, 344, 9, 953, 327, 8689, 1566, 367, 30159, 288, 327, 481, 57, 41, 446, 1067, 365, 3544, 922, 2870, 626, 365, 10367, 315, 12, 2845, 314, 922, 1305, 626, 365, 288, 327, 3769, 1758, 972, 641, 14, 982, 17724, 883, 4057, 922, 7662, 12, 2066, 781, 1077, 288, 327, 5324, 315, 1566, 63, 815, 314, 922, 1305, 626, 365, 3769, 1758, 972, 641, 14, 288, 1566, 63, 354, 275, 283, 14293, 14, 12553, 14, 12941, 63, 751, 63, 475, 63, 5312, 7, 288, 1566, 63, 815, 275, 469, 355, 283, 923, 63, 344, 356, 1572, 14, 344, 12, 355, 283, 923, 63, 354, 356, 1572, 14, 354, 12, 355, 283, 5312, 63, 344, 356, 922, 63, 5312, 14, 344, 12, 355, 283, 5312, 63, 354, 356, 922, 63, 5312, 14, 354, 288, 789, 288, 327, 4287, 26, 3507, 29, 970, 278, 288, 327, 3254, 26, 3645, 314, 15398, 2780, 2986, 3140, 288, 543, 15271, 14, 362, 63, 8877, 1252, 1100, 8, 1430, 63, 354, 12, 1052, 304, 355, 15271, 14, 8159, 8, 490, 1566, 63, 354, 12, 490, 1566, 63, 815, 12, 355, 776, 398, 372, 1572, 339, 768, 3744, 272, 347, 790, 63, 509, 63, 5312, 8, 1886, 12, 922, 63, 5312, 304, 267, 408, 267, 1803, 314, 790 ]
[ 199, 17473, 6484, 2291, 370, 314, 922, 2435, 14, 199, 624, 421, 199, 646, 2050, 199, 646, 2196, 199, 199, 504, 1566, 14428, 492, 15271, 199, 199, 646, 22709, 14, 1018, 14, 16432, 14, 751, 63, 1246, 14, 1972, 63, 1450, 14, 1246, 465, 2518, 63, 1450, 63, 1246, 199, 504, 9872, 14, 12553, 14, 12553, 492, 23798, 1899, 13068, 2448, 547, 12, 2876, 13068, 547, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3784, 13068, 19530, 26, 272, 408, 272, 961, 298, 5512, 2, 6127, 10889, 13, 4037, 21149, 370, 506, 5861, 3046, 12, 1830, 15131, 3411, 272, 2518, 666, 10269, 282, 5048, 2397, 2376, 370, 2248, 14, 272, 408, 339, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 267, 1432, 316, 488, 365, 7353, 370, 14722, 316, 298, 2765, 922, 365, 440, 315, 1263, 4652, 267, 1808, 642, 6484, 5687, 401, 506, 3238, 314, 5687, 1265, 3984, 12881, 365, 267, 9025, 543, 626, 30075, 14, 267, 408, 267, 372, 488, 421, 199, 533, 1432, 2448, 17, 13068, 19530, 26, 272, 408, 272, 961, 5687, 365, 4346, 370, 2040, 14786, 16394, 370, 506, 26659, 12, 1937, 662, 4980, 35, 6467, 13, 7155, 272, 408, 272, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 267, 710, 4136, 298, 3306, 2, 5492, 367, 14786, 1990, 3247, 465, 413, 12, 880, 372, 626, 14, 267, 15621, 737, 4178, 921, 5031, 14, 957, 15, 8268, 15, 8268, 13, 3246, 15, 9302, 15, 10721, 969, 15, 1725, 3, 3028, 13, 771, 556, 1079, 1272, 825, 20, 68, 17, 66, 24, 67, 11403, 2635, 18035, 68, 24, 14519, 65, 1257, 267, 408, 267, 372, 922, 63, 5312, 14, 362, 63, 923, 8, 17, 9, 421, 199, 533, 9571, 1899, 13068, 19530, 26, 272, 408, 272, 961, 5687, 19311, 465, 20440, 4390, 1901, 314, 6484, 1159, 4652, 14, 272, 408, 272, 820, 879, 10462, 275, 2196, 14, 3883, 342, 339, 768, 3744, 272, 347, 664, 63, 923, 63, 509, 63, 751, 8, 1886, 12, 2518, 63, 498, 12, 922, 12, 922, 63, 5312, 12, 5090, 29, 549, 304, 267, 408, 267, 1803, 314, 1572, 687, 314, 2013, 922, 3421, 370, 1314, 314, 922, 365, 7943, 14, 267, 982, 314, 922, 965, 440, 5966, 2757, 7943, 12, 282, 1572, 911, 506, 19311, 12414, 367, 3062, 340, 5090, 3305, 365, 715, 14, 267, 408, 267, 6484, 63, 498, 275, 843, 14, 498, 63, 509, 63, 5312, 8, 751, 63, 5312, 9, 267, 1572, 63, 344, 275, 2518, 63, 1450, 63, 1246, 14, 362, 63, 1972, 63, 1450, 8, 751, 12, 2518, 63, 498, 12, 6484, 63, 498, 9, 398, 1572, 275, 488, 267, 340, 1572, 63, 344, 365, 440, 488, 26, 288, 327, 7427, 370, 3648, 1536, 314, 3451, 590, 7943, 1572, 288, 862, 26, 355, 1572, 275, 922, 63, 5312, 14, 362, 63, 923, 8, 442, 8, 923, 63, 344, 430, 288, 871, 23798, 1899, 13068, 2448, 547, 26, 355, 327, 1335, 2231, 26, 781, 883, 7485, 2331, 3598, 2348, 340, 642, 365, 376, 1420, 1930, 14, 355, 943, 14, 3764, 8, 490, 298, 923, 440, 1911, 315, 9571, 1899, 13068, 19530, 26, 450, 82, 401, 490, 469, 717, 298, 11151, 63, 5312, 63, 344, 582, 922, 63, 5312, 14, 344, 12, 717, 298, 11151, 63, 923, 63, 344, 582, 1572, 63, 344, 12, 490, 1660, 490, 3178, 63, 815, 29, 549, 355, 776, 288, 871, 1722, 26, 355, 943, 14, 705, 480, 5725, 1572, 63, 344, 450, 82, 367, 922, 26, 450, 82, 401, 1572, 63, 344, 12, 922, 9, 398, 340, 1572, 365, 488, 436, 5090, 436, 440, 2518, 63, 1450, 63, 1246, 14, 26033, 6979, 9440, 14, 374, 63, 13829, 13534, 8, 1972, 63, 498, 304, 288, 340, 440, 922, 63, 5312, 14, 2634, 26, 355, 746, 2876, 13068, 547, 360, 6612, 5090, 922, 370, 376, 2701, 922, 6484, 358, 953, 327, 4287, 26, 3507, 29, 970, 278, 288, 327, 3254, 26, 10530, 282, 16582, 315, 3819, 512, 1097, 382, 3595, 10663, 2196, 2072, 1655, 288, 327, 25286, 334, 69, 14, 71, 14, 2005, 2631, 680, 221, 18615, 886, 626, 12, 1325, 1929, 370, 506, 25082, 440, 288, 327, 370, 13318, 3402, 21280, 3382, 4390, 503, 10671, 315, 10152, 14, 288, 1572, 275, 843, 14, 27644, 10462, 14, 5095, 8, 751, 63, 5312, 14, 2634, 9, 953, 327, 22400, 314, 574, 465, 282, 2518, 1947, 288, 2518, 63, 1450, 63, 1246, 14, 409, 63, 1972, 63, 1450, 8, 751, 12, 2518, 63, 498, 12, 6484, 63, 498, 12, 1572, 14, 344, 9, 953, 327, 8689, 1566, 367, 30159, 288, 327, 481, 57, 41, 446, 1067, 365, 3544, 922, 2870, 626, 365, 10367, 315, 12, 2845, 314, 922, 1305, 626, 365, 288, 327, 3769, 1758, 972, 641, 14, 982, 17724, 883, 4057, 922, 7662, 12, 2066, 781, 1077, 288, 327, 5324, 315, 1566, 63, 815, 314, 922, 1305, 626, 365, 3769, 1758, 972, 641, 14, 288, 1566, 63, 354, 275, 283, 14293, 14, 12553, 14, 12941, 63, 751, 63, 475, 63, 5312, 7, 288, 1566, 63, 815, 275, 469, 355, 283, 923, 63, 344, 356, 1572, 14, 344, 12, 355, 283, 923, 63, 354, 356, 1572, 14, 354, 12, 355, 283, 5312, 63, 344, 356, 922, 63, 5312, 14, 344, 12, 355, 283, 5312, 63, 354, 356, 922, 63, 5312, 14, 354, 288, 789, 288, 327, 4287, 26, 3507, 29, 970, 278, 288, 327, 3254, 26, 3645, 314, 15398, 2780, 2986, 3140, 288, 543, 15271, 14, 362, 63, 8877, 1252, 1100, 8, 1430, 63, 354, 12, 1052, 304, 355, 15271, 14, 8159, 8, 490, 1566, 63, 354, 12, 490, 1566, 63, 815, 12, 355, 776, 398, 372, 1572, 339, 768, 3744, 272, 347, 790, 63, 509, 63, 5312, 8, 1886, 12, 922, 63, 5312, 304, 267, 408, 267, 1803, 314, 790, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MaT1g3R/YasenBaka
cogs/moderation.py
1
3215
from discord import DiscordException, Forbidden, HTTPException from discord.ext import commands from discord.ext.commands import Context from bot import Yasen from scripts.checks import has_manage_message, is_admin, no_pm from scripts.discord_utils import leading_members from scripts.helpers import parse_number class Moderation: """ Moderation commands. """ __slots__ = ('bot',) def __init__(self, bot: Yasen): self.bot = bot def __local_check(self, ctx: Context): return no_pm(ctx) @commands.command() @commands.check(is_admin) async def masspm(self, ctx: Context, *, args: str = None): """ Description: Send pm to all mentioned members. Restriction: Cannot be used in private message. Permission Required: Administrator Usage: "`{prefix}masspm @mention0 @mention1 my message`" """ if not args: await ctx.send( 'Please mention at least one member and include ' 'a message to send.' ) return members, msg = leading_members(ctx, args) if not members: await ctx.send('Please mention at least one member.') return if not msg: await ctx.send('Please enter a message for me to send.') return sent = [] failed = [] for m in members: try: await m.send(msg) sent.append(m.display_name) except DiscordException as e: self.bot.logger.warn(str(e)) failed.append(m.display_name) success_msg = (f'PM sent to the following members:' f'\n```\n{", ".join(sent)}\n```') if sent else '' failed_msg = (f'Failed to send PMs to the following members:' f'\n```\n{", ".join(failed)}\n```') if failed else '' if success_msg or failed_msg: await ctx.send(f'{success_msg}{failed_msg}') @commands.command() @commands.check(has_manage_message) async def purge(self, ctx: Context, num=None): """ Description: Purge up to 99 messages in the current channel. Restriction: | Cannot be used in private message. Can only purge from 1 to 99 (inclusive) messages at once. Permission Required: Manage Messages Usage: "`{prefix}purge num` where num is a number between 1 and 99." """ num = parse_number(num, int) or 0 if not 1 <= num <= 99: await ctx.send( 'Please enter a number between 1 and 99.', delete_after=3 ) return try: deleted = await ctx.channel.purge(limit=num + 1) except Forbidden: await ctx.send('I do not have the permissions to purge messages.') except HTTPException: await ctx.send(':no_entry_sign: Purging messages failed.') else: deleted_num = len(deleted) - 1 msg_str = (f'{deleted_num} message' if num == 1 else f'{deleted_num} messages') await ctx.send(f':recycle: Purged {msg_str}.', delete_after=3)
apache-2.0
[ 504, 4339, 2181, 492, 5289, 1577, 1726, 12, 2104, 10912, 12, 28185, 199, 504, 4339, 2181, 14, 832, 492, 3718, 199, 504, 4339, 2181, 14, 832, 14, 4405, 492, 9470, 199, 199, 504, 5888, 492, 1488, 482, 78, 199, 504, 10554, 14, 8625, 492, 965, 63, 9053, 63, 1188, 12, 365, 63, 2113, 12, 949, 63, 7073, 199, 504, 10554, 14, 6409, 2181, 63, 1208, 492, 9186, 63, 6334, 199, 504, 10554, 14, 7546, 492, 2198, 63, 1955, 421, 199, 533, 4900, 1754, 26, 272, 408, 272, 4900, 1754, 3718, 14, 272, 408, 272, 636, 7257, 363, 275, 661, 3018, 9538, 339, 347, 636, 826, 721, 277, 12, 5888, 26, 1488, 482, 78, 304, 267, 291, 14, 3018, 275, 5888, 339, 347, 636, 1832, 63, 1074, 8, 277, 12, 4027, 26, 9470, 304, 267, 372, 949, 63, 7073, 8, 3799, 9, 339, 768, 4405, 14, 1531, 342, 272, 768, 4405, 14, 1074, 8, 374, 63, 2113, 9, 272, 5316, 347, 12250, 7073, 8, 277, 12, 4027, 26, 9470, 12, 9889, 1249, 26, 620, 275, 488, 304, 267, 408, 267, 11994, 26, 10217, 14207, 370, 1006, 26239, 7556, 14, 267, 32491, 414, 26, 18435, 506, 1202, 315, 5726, 1245, 14, 267, 8779, 11105, 26, 30660, 267, 11028, 26, 24505, 91, 1861, 93, 11535, 7073, 768, 32016, 16, 768, 32016, 17, 3002, 1245, 64, 2, 267, 408, 267, 340, 440, 1249, 26, 288, 5517, 4027, 14, 2254, 8, 355, 283, 8254, 20811, 737, 5210, 1373, 3653, 436, 2387, 283, 355, 283, 65, 1245, 370, 3222, 3530, 288, 776, 288, 372, 267, 7556, 12, 1499, 275, 9186, 63, 6334, 8, 3799, 12, 1249, 9, 267, 340, 440, 7556, 26, 288, 5517, 4027, 14, 2254, 360, 8254, 20811, 737, 5210, 1373, 3653, 2659, 288, 372, 267, 340, 440, 1499, 26, 288, 5517, 4027, 14, 2254, 360, 8254, 9509, 282, 1245, 367, 562, 370, 3222, 2659, 288, 372, 267, 4847, 275, 942, 267, 3405, 275, 942, 267, 367, 333, 315, 7556, 26, 288, 862, 26, 355, 5517, 333, 14, 2254, 8, 1328, 9, 355, 4847, 14, 740, 8, 77, 14, 2918, 63, 354, 9, 288, 871, 5289, 1577, 1726, 465, 325, 26, 355, 291, 14, 3018, 14, 2921, 14, 4050, 8, 495, 8, 69, 430, 355, 3405, 14, 740, 8, 77, 14, 2918, 63, 354, 9, 267, 3182, 63, 1328, 275, 334, 70, 7, 10793, 4847, 370, 314, 2569, 7556, 4881, 2432, 289, 1154, 78, 1040, 25502, 78, 91, 401, 3680, 904, 8, 1150, 9, 4988, 78, 32323, 358, 340, 4847, 587, 2125, 267, 3405, 63, 1328, 275, 334, 70, 7, 4276, 370, 3222, 510, 13586, 370, 314, 2569, 7556, 4881, 1993, 289, 1154, 78, 1040, 25502, 78, 91, 401, 3680, 904, 8, 4892, 9, 4988, 78, 32323, 358, 340, 3405, 587, 2125, 267, 340, 3182, 63, 1328, 503, 3405, 63, 1328, 26, 288, 5517, 4027, 14, 2254, 8, 70, 16019, 3742, 63, 1328, 8847, 4892, 63, 1328, 12216, 339, 768, 4405, 14, 1531, 342, 272, 768, 4405, 14, 1074, 8, 1989, 63, 9053, 63, 1188, 9, 272, 5316, 347, 18503, 8, 277, 12, 4027, 26, 9470, 12, 1967, 29, 403, 304, 267, 408, 267, 11994, 26, 23177, 303, 1536, 370, 8806, 3788, 315, 314, 1453, 3623, 14, 267, 32491, 414, 26, 1204, 288, 18435, 506, 1202, 315, 5726, 1245, 14, 288, 6855, 1454, 18503, 687, 413, 370, 8806, 334, 26062, 9, 3788, 737, 5403, 14, 267, 8779, 11105, 26, 14944, 27377, 267, 11028, 26, 24505, 91, 1861, 93, 18254, 1967, 64, 2382, 1967, 365, 282, 1329, 3382, 413, 436, 8806, 2122, 267, 408, 267, 1967, 275, 2198, 63, 1955, 8, 1507, 12, 1109, 9, 503, 378, 267, 340, 440, 413, 2695, 1967, 2695, 8806, 26, 288, 5517, 4027, 14, 2254, 8, 355, 283, 8254, 9509, 282, 1329, 3382, 413, 436, 8806, 3130, 3145, 63, 4399, 29, 19, 288, 776, 288, 372, 267, 862, 26, 288, 5463, 275, 5517, 4027, 14, 2775, 14, 18254, 8, 3097, 29, 1507, 435, 413, 9, 267, 871, 2104, 10912, 26, 288, 5517, 4027, 14, 2254, 360, 41, 886, 440, 1172, 314, 3443, 370, 18503, 3788, 2659, 267, 871, 28185, 26, 288, 5517, 4027, 14, 2254, 6176, 889, 63, 2373, 63, 1037, 26, 23177, 1540, 3788, 3405, 2659, 267, 587, 26, 288, 5463, 63, 1507, 275, 822, 8, 6062, 9, 446, 413, 288, 1499, 63, 495, 275, 334, 70, 16019, 6062, 63, 1507, 93, 1245, 7, 340, 1967, 508, 413, 2432, 587, 289, 16019, 6062, 63, 1507, 93, 3788, 358, 288, 5517, 4027, 14, 2254, 8, 70, 356, 264, 7612, 26, 23177, 3046, 469, 1328, 63, 495, 93, 3130, 3145, 63, 4399, 29, 19, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4339, 2181, 492, 5289, 1577, 1726, 12, 2104, 10912, 12, 28185, 199, 504, 4339, 2181, 14, 832, 492, 3718, 199, 504, 4339, 2181, 14, 832, 14, 4405, 492, 9470, 199, 199, 504, 5888, 492, 1488, 482, 78, 199, 504, 10554, 14, 8625, 492, 965, 63, 9053, 63, 1188, 12, 365, 63, 2113, 12, 949, 63, 7073, 199, 504, 10554, 14, 6409, 2181, 63, 1208, 492, 9186, 63, 6334, 199, 504, 10554, 14, 7546, 492, 2198, 63, 1955, 421, 199, 533, 4900, 1754, 26, 272, 408, 272, 4900, 1754, 3718, 14, 272, 408, 272, 636, 7257, 363, 275, 661, 3018, 9538, 339, 347, 636, 826, 721, 277, 12, 5888, 26, 1488, 482, 78, 304, 267, 291, 14, 3018, 275, 5888, 339, 347, 636, 1832, 63, 1074, 8, 277, 12, 4027, 26, 9470, 304, 267, 372, 949, 63, 7073, 8, 3799, 9, 339, 768, 4405, 14, 1531, 342, 272, 768, 4405, 14, 1074, 8, 374, 63, 2113, 9, 272, 5316, 347, 12250, 7073, 8, 277, 12, 4027, 26, 9470, 12, 9889, 1249, 26, 620, 275, 488, 304, 267, 408, 267, 11994, 26, 10217, 14207, 370, 1006, 26239, 7556, 14, 267, 32491, 414, 26, 18435, 506, 1202, 315, 5726, 1245, 14, 267, 8779, 11105, 26, 30660, 267, 11028, 26, 24505, 91, 1861, 93, 11535, 7073, 768, 32016, 16, 768, 32016, 17, 3002, 1245, 64, 2, 267, 408, 267, 340, 440, 1249, 26, 288, 5517, 4027, 14, 2254, 8, 355, 283, 8254, 20811, 737, 5210, 1373, 3653, 436, 2387, 283, 355, 283, 65, 1245, 370, 3222, 3530, 288, 776, 288, 372, 267, 7556, 12, 1499, 275, 9186, 63, 6334, 8, 3799, 12, 1249, 9, 267, 340, 440, 7556, 26, 288, 5517, 4027, 14, 2254, 360, 8254, 20811, 737, 5210, 1373, 3653, 2659, 288, 372, 267, 340, 440, 1499, 26, 288, 5517, 4027, 14, 2254, 360, 8254, 9509, 282, 1245, 367, 562, 370, 3222, 2659, 288, 372, 267, 4847, 275, 942, 267, 3405, 275, 942, 267, 367, 333, 315, 7556, 26, 288, 862, 26, 355, 5517, 333, 14, 2254, 8, 1328, 9, 355, 4847, 14, 740, 8, 77, 14, 2918, 63, 354, 9, 288, 871, 5289, 1577, 1726, 465, 325, 26, 355, 291, 14, 3018, 14, 2921, 14, 4050, 8, 495, 8, 69, 430, 355, 3405, 14, 740, 8, 77, 14, 2918, 63, 354, 9, 267, 3182, 63, 1328, 275, 334, 70, 7, 10793, 4847, 370, 314, 2569, 7556, 4881, 2432, 289, 1154, 78, 1040, 25502, 78, 91, 401, 3680, 904, 8, 1150, 9, 4988, 78, 32323, 358, 340, 4847, 587, 2125, 267, 3405, 63, 1328, 275, 334, 70, 7, 4276, 370, 3222, 510, 13586, 370, 314, 2569, 7556, 4881, 1993, 289, 1154, 78, 1040, 25502, 78, 91, 401, 3680, 904, 8, 4892, 9, 4988, 78, 32323, 358, 340, 3405, 587, 2125, 267, 340, 3182, 63, 1328, 503, 3405, 63, 1328, 26, 288, 5517, 4027, 14, 2254, 8, 70, 16019, 3742, 63, 1328, 8847, 4892, 63, 1328, 12216, 339, 768, 4405, 14, 1531, 342, 272, 768, 4405, 14, 1074, 8, 1989, 63, 9053, 63, 1188, 9, 272, 5316, 347, 18503, 8, 277, 12, 4027, 26, 9470, 12, 1967, 29, 403, 304, 267, 408, 267, 11994, 26, 23177, 303, 1536, 370, 8806, 3788, 315, 314, 1453, 3623, 14, 267, 32491, 414, 26, 1204, 288, 18435, 506, 1202, 315, 5726, 1245, 14, 288, 6855, 1454, 18503, 687, 413, 370, 8806, 334, 26062, 9, 3788, 737, 5403, 14, 267, 8779, 11105, 26, 14944, 27377, 267, 11028, 26, 24505, 91, 1861, 93, 18254, 1967, 64, 2382, 1967, 365, 282, 1329, 3382, 413, 436, 8806, 2122, 267, 408, 267, 1967, 275, 2198, 63, 1955, 8, 1507, 12, 1109, 9, 503, 378, 267, 340, 440, 413, 2695, 1967, 2695, 8806, 26, 288, 5517, 4027, 14, 2254, 8, 355, 283, 8254, 9509, 282, 1329, 3382, 413, 436, 8806, 3130, 3145, 63, 4399, 29, 19, 288, 776, 288, 372, 267, 862, 26, 288, 5463, 275, 5517, 4027, 14, 2775, 14, 18254, 8, 3097, 29, 1507, 435, 413, 9, 267, 871, 2104, 10912, 26, 288, 5517, 4027, 14, 2254, 360, 41, 886, 440, 1172, 314, 3443, 370, 18503, 3788, 2659, 267, 871, 28185, 26, 288, 5517, 4027, 14, 2254, 6176, 889, 63, 2373, 63, 1037, 26, 23177, 1540, 3788, 3405, 2659, 267, 587, 26, 288, 5463, 63, 1507, 275, 822, 8, 6062, 9, 446, 413, 288, 1499, 63, 495, 275, 334, 70, 16019, 6062, 63, 1507, 93, 1245, 7, 340, 1967, 508, 413, 2432, 587, 289, 16019, 6062, 63, 1507, 93, 3788, 358, 288, 5517, 4027, 14, 2254, 8, 70, 356, 264, 7612, 26, 23177, 3046, 469, 1328, 63, 495, 93, 3130, 3145, 63, 4399, 29, 19, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chouseknecht/ansible
lib/ansible/plugins/doc_fragments/shell_common.py
79
1833
# Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) class ModuleDocFragment(object): # common shelldocumentation fragment DOCUMENTATION = """ options: remote_tmp: description: - Temporary directory to use on targets when executing tasks. default: '~/.ansible/tmp' env: [{name: ANSIBLE_REMOTE_TEMP}, {name: ANSIBLE_REMOTE_TMP}] ini: - section: defaults key: remote_tmp vars: - name: ansible_remote_tmp system_tmpdirs: description: - "List of valid system temporary directories for Ansible to choose when it cannot use ``remote_tmp``, normally due to permission issues. These must be world readable, writable, and executable." default: [ /var/tmp, /tmp ] type: list env: [{name: ANSIBLE_SYSTEM_TMPDIRS}] ini: - section: defaults key: system_tmpdirs vars: - name: ansible_system_tmpdirs async_dir: description: - Directory in which ansible will keep async job information default: '~/.ansible_async' env: [{name: ANSIBLE_ASYNC_DIR}] ini: - section: defaults key: async_dir vars: - name: ansible_async_dir environment: type: dict default: {} description: - dictionary of environment variables and their values to use when executing commands. admin_users: type: list default: ['root', 'toor'] description: - list of users to be expected to have admin privileges. This is used by the controller to determine how to share temporary files between the remote user and the become user. env: - name: ANSIBLE_ADMIN_USERS ini: - section: defaults key: admin_users vars: - name: ansible_admin_users """
gpl-3.0
[ 3, 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 2863, 5218, 9970, 7956, 272, 29970, 2594, 275, 408, 199, 1419, 26, 523, 3982, 63, 2791, 26, 272, 1369, 26, 489, 446, 21791, 2082, 370, 675, 641, 4545, 1380, 14043, 6527, 14, 272, 849, 26, 17352, 8083, 4853, 15, 2791, 7, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 16058, 63, 12510, 1386, 469, 354, 26, 32271, 7187, 63, 16058, 63, 17983, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 3982, 63, 2791, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 3846, 63, 2791, 523, 2656, 63, 2791, 3220, 26, 272, 1369, 26, 2126, 446, 298, 1296, 402, 1686, 2656, 7937, 6602, 367, 2622, 370, 11496, 1380, 652, 3913, 675, 268, 1124, 3846, 63, 2791, 4542, 12252, 7037, 370, 4983, 10876, 14, 221, 5723, 1471, 506, 6701, 12701, 12, 17267, 12, 268, 436, 7286, 2122, 272, 849, 26, 359, 1182, 1391, 15, 2791, 12, 1182, 2791, 1622, 272, 730, 26, 769, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 12711, 63, 17983, 14455, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 2656, 63, 2791, 3220, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 2253, 63, 2791, 3220, 523, 5316, 63, 694, 26, 272, 1369, 26, 2126, 446, 15191, 315, 1314, 3242, 911, 4215, 5316, 3906, 2556, 272, 849, 26, 17352, 8083, 4853, 63, 4146, 7, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 26222, 6389, 63, 3022, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 5316, 63, 694, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 4146, 63, 694, 523, 3734, 26, 272, 730, 26, 1211, 272, 849, 26, 1052, 272, 1369, 26, 489, 446, 2600, 402, 3734, 2860, 436, 3932, 1338, 370, 675, 1380, 14043, 3718, 14, 523, 4628, 63, 3707, 26, 272, 730, 26, 769, 272, 849, 26, 788, 1231, 297, 283, 475, 269, 418, 272, 1369, 26, 489, 446, 769, 402, 4390, 370, 506, 1420, 370, 1172, 4628, 20001, 14, 961, 365, 1202, 701, 314, 7614, 370, 267, 6705, 4212, 370, 8663, 7937, 1584, 3382, 314, 3982, 922, 436, 314, 8649, 922, 14, 272, 2589, 26, 489, 446, 536, 26, 32271, 7187, 63, 14288, 63, 28164, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 4628, 63, 3707, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 2113, 63, 3707, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 9708, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 2863, 5218, 9970, 7956, 272, 29970, 2594, 275, 408, 199, 1419, 26, 523, 3982, 63, 2791, 26, 272, 1369, 26, 489, 446, 21791, 2082, 370, 675, 641, 4545, 1380, 14043, 6527, 14, 272, 849, 26, 17352, 8083, 4853, 15, 2791, 7, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 16058, 63, 12510, 1386, 469, 354, 26, 32271, 7187, 63, 16058, 63, 17983, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 3982, 63, 2791, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 3846, 63, 2791, 523, 2656, 63, 2791, 3220, 26, 272, 1369, 26, 2126, 446, 298, 1296, 402, 1686, 2656, 7937, 6602, 367, 2622, 370, 11496, 1380, 652, 3913, 675, 268, 1124, 3846, 63, 2791, 4542, 12252, 7037, 370, 4983, 10876, 14, 221, 5723, 1471, 506, 6701, 12701, 12, 17267, 12, 268, 436, 7286, 2122, 272, 849, 26, 359, 1182, 1391, 15, 2791, 12, 1182, 2791, 1622, 272, 730, 26, 769, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 12711, 63, 17983, 14455, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 2656, 63, 2791, 3220, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 2253, 63, 2791, 3220, 523, 5316, 63, 694, 26, 272, 1369, 26, 2126, 446, 15191, 315, 1314, 3242, 911, 4215, 5316, 3906, 2556, 272, 849, 26, 17352, 8083, 4853, 63, 4146, 7, 272, 2589, 26, 8910, 354, 26, 32271, 7187, 63, 26222, 6389, 63, 3022, 11049, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 5316, 63, 694, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 4146, 63, 694, 523, 3734, 26, 272, 730, 26, 1211, 272, 849, 26, 1052, 272, 1369, 26, 489, 446, 2600, 402, 3734, 2860, 436, 3932, 1338, 370, 675, 1380, 14043, 3718, 14, 523, 4628, 63, 3707, 26, 272, 730, 26, 769, 272, 849, 26, 788, 1231, 297, 283, 475, 269, 418, 272, 1369, 26, 489, 446, 769, 402, 4390, 370, 506, 1420, 370, 1172, 4628, 20001, 14, 961, 365, 1202, 701, 314, 7614, 370, 267, 6705, 4212, 370, 8663, 7937, 1584, 3382, 314, 3982, 922, 436, 314, 8649, 922, 14, 272, 2589, 26, 489, 446, 536, 26, 32271, 7187, 63, 14288, 63, 28164, 272, 20364, 26, 489, 446, 3420, 26, 4243, 267, 790, 26, 4628, 63, 3707, 272, 6802, 26, 489, 446, 536, 26, 3242, 63, 2113, 63, 3707, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
t794104/ansible
test/sanity/validate-modules/main.py
11
69396
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2015 Matt Martz <matt@sivel.net> # Copyright (C) 2015 Rackspace US, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import abc import argparse import ast import json import errno import os import re import subprocess import sys import tempfile import traceback from collections import OrderedDict from contextlib import contextmanager from distutils.version import StrictVersion from fnmatch import fnmatch from ansible import __version__ as ansible_version from ansible.executor.module_common import REPLACER_WINDOWS from ansible.plugins.loader import fragment_loader from ansible.utils.plugin_docs import BLACKLIST, add_fragments, get_docstring from module_args import AnsibleModuleImportError, get_argument_spec from schema import ansible_module_kwargs_schema, doc_schema, metadata_1_1_schema, return_schema from utils import CaptureStd, NoArgsAnsibleModule, compare_unordered_lists, is_empty, parse_yaml from voluptuous.humanize import humanize_error from ansible.module_utils.six import PY3, with_metaclass from ansible.module_utils.basic import FILE_COMMON_ARGUMENTS if PY3: # Because there is no ast.TryExcept in Python 3 ast module TRY_EXCEPT = ast.Try # REPLACER_WINDOWS from ansible.executor.module_common is byte # string but we need unicode for Python 3 REPLACER_WINDOWS = REPLACER_WINDOWS.decode('utf-8') else: TRY_EXCEPT = ast.TryExcept BLACKLIST_DIRS = frozenset(('.git', 'test', '.github', '.idea')) INDENT_REGEX = re.compile(r'([\t]*)') TYPE_REGEX = re.compile(r'.*(if|or)(\s+[^"\']*|\s+)(?<!_)(?<!str\()type\([^)].*') SYS_EXIT_REGEX = re.compile(r'[^#]*sys.exit\s*\(.*') BLACKLIST_IMPORTS = { 'requests': { 'new_only': True, 'error': { 'code': 203, 'msg': ('requests import found, should use ' 'ansible.module_utils.urls instead') } }, r'boto(?:\.|$)': { 'new_only': True, 'error': { 'code': 204, 'msg': 'boto import found, new modules should use boto3' } }, } SUBPROCESS_REGEX = re.compile(r'subprocess\.Po.*') OS_CALL_REGEX = re.compile(r'os\.call.*') class ReporterEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, Exception): return str(o) return json.JSONEncoder.default(self, o) class Reporter(object): def __init__(self): self.files = OrderedDict() def _ensure_default_entry(self, path): try: self.files[path] except KeyError: self.files[path] = { 'errors': [], 'warnings': [], 'traces': [], 'warning_traces': [] } def _log(self, path, code, msg, level='error', line=0, column=0): self._ensure_default_entry(path) lvl_dct = self.files[path]['%ss' % level] lvl_dct.append({ 'code': code, 'msg': msg, 'line': line, 'column': column }) def error(self, *args, **kwargs): self._log(*args, level='error', **kwargs) def warning(self, *args, **kwargs): self._log(*args, level='warning', **kwargs) def trace(self, path, tracebk): self._ensure_default_entry(path) self.files[path]['traces'].append(tracebk) def warning_trace(self, path, tracebk): self._ensure_default_entry(path) self.files[path]['warning_traces'].append(tracebk) @staticmethod @contextmanager def _output_handle(output): if output != '-': handle = open(output, 'w+') else: handle = sys.stdout yield handle handle.flush() handle.close() @staticmethod def _filter_out_ok(reports): temp_reports = OrderedDict() for path, report in reports.items(): if report['errors'] or report['warnings']: temp_reports[path] = report return temp_reports def plain(self, warnings=False, output='-'): """Print out the test results in plain format output is ignored here for now """ ret = [] for path, report in Reporter._filter_out_ok(self.files).items(): traces = report['traces'][:] if warnings and report['warnings']: traces.extend(report['warning_traces']) for trace in traces: print('TRACE:') print('\n '.join((' %s' % trace).splitlines())) for error in report['errors']: error['path'] = path print('%(path)s:%(line)d:%(column)d: E%(code)d %(msg)s' % error) ret.append(1) if warnings: for warning in report['warnings']: warning['path'] = path print('%(path)s:%(line)d:%(column)d: W%(code)d %(msg)s' % warning) return 3 if ret else 0 def json(self, warnings=False, output='-'): """Print out the test results in json format warnings is not respected in this output """ ret = [len(r['errors']) for _, r in self.files.items()] with Reporter._output_handle(output) as handle: print(json.dumps(Reporter._filter_out_ok(self.files), indent=4, cls=ReporterEncoder), file=handle) return 3 if sum(ret) else 0 class Validator(with_metaclass(abc.ABCMeta, object)): """Validator instances are intended to be run on a single object. if you are scanning multiple objects for problems, you'll want to have a separate Validator for each one.""" def __init__(self, reporter=None): self.reporter = reporter @abc.abstractproperty def object_name(self): """Name of the object we validated""" pass @abc.abstractproperty def object_path(self): """Path of the object we validated""" pass @abc.abstractmethod def validate(self): """Run this method to generate the test results""" pass class ModuleValidator(Validator): BLACKLIST_PATTERNS = ('.git*', '*.pyc', '*.pyo', '.*', '*.md', '*.rst', '*.txt') BLACKLIST_FILES = frozenset(('.git', '.gitignore', '.travis.yml', 'shippable.yml', '.gitattributes', '.gitmodules', 'COPYING', '__init__.py', 'VERSION', 'test-docs.sh')) BLACKLIST = BLACKLIST_FILES.union(BLACKLIST['MODULE']) PS_DOC_BLACKLIST = frozenset(( 'async_status.ps1', 'slurp.ps1', 'setup.ps1' )) PS_ARG_VALIDATE_BLACKLIST = frozenset(( 'win_dsc.ps1', # win_dsc is a dynamic arg spec, the docs won't ever match )) WHITELIST_FUTURE_IMPORTS = frozenset(('absolute_import', 'division', 'print_function')) def __init__(self, path, analyze_arg_spec=False, base_branch=None, git_cache=None, reporter=None): super(ModuleValidator, self).__init__(reporter=reporter or Reporter()) self.path = path self.basename = os.path.basename(self.path) self.name, _ = os.path.splitext(self.basename) self.analyze_arg_spec = analyze_arg_spec self.base_branch = base_branch self.git_cache = git_cache or GitCache() self._python_module_override = False with open(path) as f: self.text = f.read() self.length = len(self.text.splitlines()) try: self.ast = ast.parse(self.text) except Exception: self.ast = None if base_branch: self.base_module = self._get_base_file() else: self.base_module = None def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): if not self.base_module: return try: os.remove(self.base_module) except Exception: pass @property def object_name(self): return self.basename @property def object_path(self): return self.path def _python_module(self): if self.path.endswith('.py') or self._python_module_override: return True return False def _powershell_module(self): if self.path.endswith('.ps1'): return True return False def _just_docs(self): """Module can contain just docs and from __future__ boilerplate """ try: for child in self.ast.body: if not isinstance(child, ast.Assign): # allowed from __future__ imports if isinstance(child, ast.ImportFrom) and child.module == '__future__': for future_import in child.names: if future_import.name not in self.WHITELIST_FUTURE_IMPORTS: break else: continue return False return True except AttributeError: return False def _get_base_branch_module_path(self): """List all paths within lib/ansible/modules to try and match a moved module""" return self.git_cache.base_module_paths.get(self.object_name) def _has_alias(self): """Return true if the module has any aliases.""" return self.object_name in self.git_cache.head_aliased_modules def _get_base_file(self): # In case of module moves, look for the original location base_path = self._get_base_branch_module_path() command = ['git', 'show', '%s:%s' % (self.base_branch, base_path or self.path)] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if int(p.returncode) != 0: return None t = tempfile.NamedTemporaryFile(delete=False) t.write(stdout) t.close() return t.name def _is_new_module(self): if self._has_alias(): return False return not self.object_name.startswith('_') and bool(self.base_branch) and not bool(self.base_module) def _check_interpreter(self, powershell=False): if powershell: if not self.text.startswith('#!powershell\n'): self.reporter.error( path=self.object_path, code=102, msg='Interpreter line is not "#!powershell"' ) return if not self.text.startswith('#!/usr/bin/python'): self.reporter.error( path=self.object_path, code=101, msg='Interpreter line is not "#!/usr/bin/python"' ) def _check_type_instead_of_isinstance(self, powershell=False): if powershell: return for line_no, line in enumerate(self.text.splitlines()): typekeyword = TYPE_REGEX.match(line) if typekeyword: # TODO: add column self.reporter.error( path=self.object_path, code=403, msg=('Type comparison using type() found. ' 'Use isinstance() instead'), line=line_no + 1 ) def _check_for_sys_exit(self): # Optimize out the happy path if 'sys.exit' not in self.text: return for line_no, line in enumerate(self.text.splitlines()): sys_exit_usage = SYS_EXIT_REGEX.match(line) if sys_exit_usage: # TODO: add column self.reporter.error( path=self.object_path, code=205, msg='sys.exit() call found. Should be exit_json/fail_json', line=line_no + 1 ) def _check_gpl3_header(self): header = '\n'.join(self.text.split('\n')[:20]) if ('GNU General Public License' not in header or ('version 3' not in header and 'v3.0' not in header)): self.reporter.error( path=self.object_path, code=105, msg='GPLv3 license header not found in the first 20 lines of the module' ) elif self._is_new_module(): if len([line for line in header if 'GNU General Public License' in line]) > 1: self.reporter.error( path=self.object_path, code=108, msg='Found old style GPLv3 license header: ' 'https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#copyright' ) def _check_for_subprocess(self): for child in self.ast.body: if isinstance(child, ast.Import): if child.names[0].name == 'subprocess': for line_no, line in enumerate(self.text.splitlines()): sp_match = SUBPROCESS_REGEX.search(line) if sp_match: self.reporter.error( path=self.object_path, code=210, msg=('subprocess.Popen call found. Should be module.run_command'), line=(line_no + 1), column=(sp_match.span()[0] + 1) ) def _check_for_os_call(self): if 'os.call' in self.text: for line_no, line in enumerate(self.text.splitlines()): os_call_match = OS_CALL_REGEX.search(line) if os_call_match: self.reporter.error( path=self.object_path, code=211, msg=('os.call() call found. Should be module.run_command'), line=(line_no + 1), column=(os_call_match.span()[0] + 1) ) def _find_blacklist_imports(self): for child in self.ast.body: names = [] if isinstance(child, ast.Import): names.extend(child.names) elif isinstance(child, TRY_EXCEPT): bodies = child.body for handler in child.handlers: bodies.extend(handler.body) for grandchild in bodies: if isinstance(grandchild, ast.Import): names.extend(grandchild.names) for name in names: # TODO: Add line/col for blacklist_import, options in BLACKLIST_IMPORTS.items(): if re.search(blacklist_import, name.name): new_only = options['new_only'] if self._is_new_module() and new_only: self.reporter.error( path=self.object_path, **options['error'] ) elif not new_only: self.reporter.error( path=self.object_path, **options['error'] ) def _find_module_utils(self, main): linenos = [] found_basic = False for child in self.ast.body: if isinstance(child, (ast.Import, ast.ImportFrom)): names = [] try: names.append(child.module) if child.module.endswith('.basic'): found_basic = True except AttributeError: pass names.extend([n.name for n in child.names]) if [n for n in names if n.startswith('ansible.module_utils')]: linenos.append(child.lineno) for name in child.names: if ('module_utils' in getattr(child, 'module', '') and isinstance(name, ast.alias) and name.name == '*'): msg = ( 208, ('module_utils imports should import specific ' 'components, not "*"') ) if self._is_new_module(): self.reporter.error( path=self.object_path, code=msg[0], msg=msg[1], line=child.lineno ) else: self.reporter.warning( path=self.object_path, code=msg[0], msg=msg[1], line=child.lineno ) if (isinstance(name, ast.alias) and name.name == 'basic'): found_basic = True if not linenos: self.reporter.error( path=self.object_path, code=201, msg='Did not find a module_utils import' ) elif not found_basic: self.reporter.warning( path=self.object_path, code=292, msg='Did not find "ansible.module_utils.basic" import' ) return linenos def _get_first_callable(self): linenos = [] for child in self.ast.body: if isinstance(child, (ast.FunctionDef, ast.ClassDef)): linenos.append(child.lineno) return min(linenos) def _find_main_call(self, look_for="main"): """ Ensure that the module ends with: if __name__ == '__main__': main() OR, in the case of modules that are in the docs-only deprecation phase if __name__ == '__main__': removed_module() """ lineno = False if_bodies = [] for child in self.ast.body: if isinstance(child, ast.If): try: if child.test.left.id == '__name__': if_bodies.extend(child.body) except AttributeError: pass bodies = self.ast.body bodies.extend(if_bodies) for child in bodies: # validate that the next to last line is 'if __name__ == "__main__"' if child.lineno == (self.length - 1): mainchecked = False try: if isinstance(child, ast.If) and \ child.test.left.id == '__name__' and \ len(child.test.ops) == 1 and \ isinstance(child.test.ops[0], ast.Eq) and \ child.test.comparators[0].s == '__main__': mainchecked = True except Exception: pass if not mainchecked: self.reporter.error( path=self.object_path, code=109, msg='Next to last line should be: if __name__ == "__main__":', line=child.lineno ) # validate that the final line is a call to main() if isinstance(child, ast.Expr): if isinstance(child.value, ast.Call): if (isinstance(child.value.func, ast.Name) and child.value.func.id == look_for): lineno = child.lineno if lineno < self.length - 1: self.reporter.error( path=self.object_path, code=104, msg=('Call to %s() not the last line' % look_for), line=lineno ) if not lineno: self.reporter.error( path=self.object_path, code=103, msg=('Did not find a call to %s()' % look_for) ) return lineno or 0 def _find_has_import(self): for child in self.ast.body: found_try_except_import = False found_has = False if isinstance(child, TRY_EXCEPT): bodies = child.body for handler in child.handlers: bodies.extend(handler.body) for grandchild in bodies: if isinstance(grandchild, ast.Import): found_try_except_import = True if isinstance(grandchild, ast.Assign): for target in grandchild.targets: if target.id.lower().startswith('has_'): found_has = True if found_try_except_import and not found_has: # TODO: Add line/col self.reporter.warning( path=self.object_path, code=291, msg='Found Try/Except block without HAS_ assignment' ) def _ensure_imports_below_docs(self, doc_info, first_callable): try: min_doc_line = min( [doc_info[key]['lineno'] for key in doc_info if doc_info[key]['lineno']] ) except ValueError: # We can't perform this validation, as there are no DOCs provided at all return max_doc_line = max( [doc_info[key]['end_lineno'] for key in doc_info if doc_info[key]['end_lineno']] ) import_lines = [] for child in self.ast.body: if isinstance(child, (ast.Import, ast.ImportFrom)): if isinstance(child, ast.ImportFrom) and child.module == '__future__': # allowed from __future__ imports for future_import in child.names: if future_import.name not in self.WHITELIST_FUTURE_IMPORTS: self.reporter.error( path=self.object_path, code=209, msg=('Only the following from __future__ imports are allowed: %s' % ', '.join(self.WHITELIST_FUTURE_IMPORTS)), line=child.lineno ) break else: # for-else. If we didn't find a problem nad break out of the loop, then this is a legal import continue import_lines.append(child.lineno) if child.lineno < min_doc_line: self.reporter.error( path=self.object_path, code=106, msg=('Import found before documentation variables. ' 'All imports must appear below ' 'DOCUMENTATION/EXAMPLES/RETURN/ANSIBLE_METADATA.'), line=child.lineno ) break elif isinstance(child, TRY_EXCEPT): bodies = child.body for handler in child.handlers: bodies.extend(handler.body) for grandchild in bodies: if isinstance(grandchild, (ast.Import, ast.ImportFrom)): import_lines.append(grandchild.lineno) if grandchild.lineno < min_doc_line: self.reporter.error( path=self.object_path, code=106, msg=('Import found before documentation ' 'variables. All imports must appear below ' 'DOCUMENTATION/EXAMPLES/RETURN/' 'ANSIBLE_METADATA.'), line=child.lineno ) break for import_line in import_lines: if not (max_doc_line < import_line < first_callable): msg = ( 107, ('Imports should be directly below DOCUMENTATION/EXAMPLES/' 'RETURN/ANSIBLE_METADATA.') ) if self._is_new_module(): self.reporter.error( path=self.object_path, code=msg[0], msg=msg[1], line=import_line ) else: self.reporter.warning( path=self.object_path, code=msg[0], msg=msg[1], line=import_line ) def _validate_ps_replacers(self): # loop all (for/else + error) # get module list for each # check "shape" of each module name module_requires = r'(?im)^#\s*requires\s+\-module(?:s?)\s*(Ansible\.ModuleUtils\..+)' csharp_requires = r'(?im)^#\s*ansiblerequires\s+\-csharputil\s*(Ansible\..+)' found_requires = False for req_stmt in re.finditer(module_requires, self.text): found_requires = True # this will bomb on dictionary format - "don't do that" module_list = [x.strip() for x in req_stmt.group(1).split(',')] if len(module_list) > 1: self.reporter.error( path=self.object_path, code=210, msg='Ansible.ModuleUtils requirements do not support multiple modules per statement: "%s"' % req_stmt.group(0) ) continue module_name = module_list[0] if module_name.lower().endswith('.psm1'): self.reporter.error( path=self.object_path, code=211, msg='Module #Requires should not end in .psm1: "%s"' % module_name ) for req_stmt in re.finditer(csharp_requires, self.text): found_requires = True # this will bomb on dictionary format - "don't do that" module_list = [x.strip() for x in req_stmt.group(1).split(',')] if len(module_list) > 1: self.reporter.error( path=self.object_path, code=210, msg='Ansible C# util requirements do not support multiple utils per statement: "%s"' % req_stmt.group(0) ) continue module_name = module_list[0] if module_name.lower().endswith('.cs'): self.reporter.error( path=self.object_path, code=211, msg='Module #AnsibleRequires -CSharpUtil should not end in .cs: "%s"' % module_name ) # also accept the legacy #POWERSHELL_COMMON replacer signal if not found_requires and REPLACER_WINDOWS not in self.text: self.reporter.error( path=self.object_path, code=207, msg='No Ansible.ModuleUtils or C# Ansible util requirements/imports found' ) def _find_ps_docs_py_file(self): if self.object_name in self.PS_DOC_BLACKLIST: return py_path = self.path.replace('.ps1', '.py') if not os.path.isfile(py_path): self.reporter.error( path=self.object_path, code=503, msg='Missing python documentation file' ) return py_path def _get_docs(self): docs = { 'DOCUMENTATION': { 'value': None, 'lineno': 0, 'end_lineno': 0, }, 'EXAMPLES': { 'value': None, 'lineno': 0, 'end_lineno': 0, }, 'RETURN': { 'value': None, 'lineno': 0, 'end_lineno': 0, }, 'ANSIBLE_METADATA': { 'value': None, 'lineno': 0, 'end_lineno': 0, } } for child in self.ast.body: if isinstance(child, ast.Assign): for grandchild in child.targets: if not isinstance(grandchild, ast.Name): continue if grandchild.id == 'DOCUMENTATION': docs['DOCUMENTATION']['value'] = child.value.s docs['DOCUMENTATION']['lineno'] = child.lineno docs['DOCUMENTATION']['end_lineno'] = ( child.lineno + len(child.value.s.splitlines()) ) elif grandchild.id == 'EXAMPLES': docs['EXAMPLES']['value'] = child.value.s docs['EXAMPLES']['lineno'] = child.lineno docs['EXAMPLES']['end_lineno'] = ( child.lineno + len(child.value.s.splitlines()) ) elif grandchild.id == 'RETURN': docs['RETURN']['value'] = child.value.s docs['RETURN']['lineno'] = child.lineno docs['RETURN']['end_lineno'] = ( child.lineno + len(child.value.s.splitlines()) ) elif grandchild.id == 'ANSIBLE_METADATA': docs['ANSIBLE_METADATA']['value'] = child.value docs['ANSIBLE_METADATA']['lineno'] = child.lineno try: docs['ANSIBLE_METADATA']['end_lineno'] = ( child.lineno + len(child.value.s.splitlines()) ) except AttributeError: docs['ANSIBLE_METADATA']['end_lineno'] = ( child.value.values[-1].lineno ) return docs def _validate_docs_schema(self, doc, schema, name, error_code): # TODO: Add line/col errors = [] try: schema(doc) except Exception as e: for error in e.errors: error.data = doc errors.extend(e.errors) for error in errors: path = [str(p) for p in error.path] if isinstance(error.data, dict): error_message = humanize_error(error.data, error) else: error_message = error if path: combined_path = '%s.%s' % (name, '.'.join(path)) else: combined_path = name self.reporter.error( path=self.object_path, code=error_code, msg='%s: %s' % (combined_path, error_message) ) def _validate_docs(self): doc_info = self._get_docs() doc = None documentation_exists = False examples_exist = False returns_exist = False # We have three ways of marking deprecated/removed files. Have to check each one # individually and then make sure they all agree filename_deprecated_or_removed = False deprecated = False removed = False doc_deprecated = None # doc legally might not exist if self.object_name.startswith('_') and not os.path.islink(self.object_path): filename_deprecated_or_removed = True # Have to check the metadata first so that we know if the module is removed or deprecated metadata = None if not bool(doc_info['ANSIBLE_METADATA']['value']): self.reporter.error( path=self.object_path, code=314, msg='No ANSIBLE_METADATA provided' ) else: if isinstance(doc_info['ANSIBLE_METADATA']['value'], ast.Dict): metadata = ast.literal_eval( doc_info['ANSIBLE_METADATA']['value'] ) else: # ANSIBLE_METADATA doesn't properly support YAML # we should consider removing it from the spec # Below code kept, incase we change our minds # metadata, errors, traces = parse_yaml( # doc_info['ANSIBLE_METADATA']['value'].s, # doc_info['ANSIBLE_METADATA']['lineno'], # self.name, 'ANSIBLE_METADATA' # ) # for error in errors: # self.reporter.error( # path=self.object_path, # code=315, # **error # ) # for trace in traces: # self.reporter.trace( # path=self.object_path, # tracebk=trace # ) self.reporter.error( path=self.object_path, code=315, msg='ANSIBLE_METADATA was not provided as a dict, YAML not supported' ) if metadata: self._validate_docs_schema(metadata, metadata_1_1_schema(), 'ANSIBLE_METADATA', 316) # We could validate these via the schema if we knew what the values are ahead of # time. We can figure that out for deprecated but we can't for removed. Only the # metadata has that information. if 'removed' in metadata['status']: removed = True if 'deprecated' in metadata['status']: deprecated = True if (deprecated or removed) and len(metadata['status']) > 1: self.reporter.error( path=self.object_path, code=333, msg='ANSIBLE_METADATA.status must be exactly one of "deprecated" or "removed"' ) if not removed: if not bool(doc_info['DOCUMENTATION']['value']): self.reporter.error( path=self.object_path, code=301, msg='No DOCUMENTATION provided' ) else: documentation_exists = True doc, errors, traces = parse_yaml( doc_info['DOCUMENTATION']['value'], doc_info['DOCUMENTATION']['lineno'], self.name, 'DOCUMENTATION' ) for error in errors: self.reporter.error( path=self.object_path, code=302, **error ) for trace in traces: self.reporter.trace( path=self.object_path, tracebk=trace ) if not errors and not traces: with CaptureStd(): try: get_docstring(self.path, fragment_loader, verbose=True) except AssertionError: fragment = doc['extends_documentation_fragment'] self.reporter.error( path=self.object_path, code=303, msg='DOCUMENTATION fragment missing: %s' % fragment ) except Exception as e: self.reporter.trace( path=self.object_path, tracebk=traceback.format_exc() ) self.reporter.error( path=self.object_path, code=304, msg='Unknown DOCUMENTATION error, see TRACE: %s' % e ) add_fragments(doc, self.object_path, fragment_loader=fragment_loader) if 'options' in doc and doc['options'] is None: self.reporter.error( path=self.object_path, code=320, msg='DOCUMENTATION.options must be a dictionary/hash when used', ) if 'deprecated' in doc and doc.get('deprecated'): doc_deprecated = True else: doc_deprecated = False if os.path.islink(self.object_path): # This module has an alias, which we can tell as it's a symlink # Rather than checking for `module: $filename` we need to check against the true filename self._validate_docs_schema(doc, doc_schema(os.readlink(self.object_path).split('.')[0]), 'DOCUMENTATION', 305) else: # This is the normal case self._validate_docs_schema(doc, doc_schema(self.object_name.split('.')[0]), 'DOCUMENTATION', 305) existing_doc = self._check_for_new_args(doc, metadata) self._check_version_added(doc, existing_doc) if not bool(doc_info['EXAMPLES']['value']): self.reporter.error( path=self.object_path, code=310, msg='No EXAMPLES provided' ) else: _, errors, traces = parse_yaml(doc_info['EXAMPLES']['value'], doc_info['EXAMPLES']['lineno'], self.name, 'EXAMPLES', load_all=True) for error in errors: self.reporter.error( path=self.object_path, code=311, **error ) for trace in traces: self.reporter.trace( path=self.object_path, tracebk=trace ) if not bool(doc_info['RETURN']['value']): if self._is_new_module(): self.reporter.error( path=self.object_path, code=312, msg='No RETURN provided' ) else: self.reporter.warning( path=self.object_path, code=312, msg='No RETURN provided' ) else: data, errors, traces = parse_yaml(doc_info['RETURN']['value'], doc_info['RETURN']['lineno'], self.name, 'RETURN') self._validate_docs_schema(data, return_schema, 'RETURN', 319) for error in errors: self.reporter.error( path=self.object_path, code=313, **error ) for trace in traces: self.reporter.trace( path=self.object_path, tracebk=trace ) # Check for mismatched deprecation mismatched_deprecation = True if not (filename_deprecated_or_removed or removed or deprecated or doc_deprecated): mismatched_deprecation = False else: if (filename_deprecated_or_removed and deprecated and doc_deprecated): mismatched_deprecation = False if (filename_deprecated_or_removed and removed and not (documentation_exists or examples_exist or returns_exist)): mismatched_deprecation = False if mismatched_deprecation: self.reporter.error( path=self.object_path, code=318, msg='Module deprecation/removed must agree in Metadata, by prepending filename with' ' "_", and setting DOCUMENTATION.deprecated for deprecation or by removing all' ' documentation for removed' ) return doc_info, doc def _check_version_added(self, doc, existing_doc): version_added_raw = doc.get('version_added') try: version_added = StrictVersion(str(doc.get('version_added', '0.0') or '0.0')) except ValueError: version_added = doc.get('version_added', '0.0') if self._is_new_module() or version_added != 'historical': self.reporter.error( path=self.object_path, code=306, msg='version_added is not a valid version number: %r' % version_added ) return if existing_doc and str(version_added_raw) != str(existing_doc.get('version_added')): self.reporter.error( path=self.object_path, code=307, msg='version_added should be %r. Currently %r' % (existing_doc.get('version_added'), version_added_raw) ) if not self._is_new_module(): return should_be = '.'.join(ansible_version.split('.')[:2]) strict_ansible_version = StrictVersion(should_be) if (version_added < strict_ansible_version or strict_ansible_version < version_added): self.reporter.error( path=self.object_path, code=307, msg='version_added should be %r. Currently %r' % (should_be, version_added_raw) ) def _validate_ansible_module_call(self, docs): try: spec, args, kwargs = get_argument_spec(self.path) except AnsibleModuleImportError as e: self.reporter.error( path=self.object_path, code=321, msg="Exception attempting to import module for argument_spec introspection, '%s'" % e ) self.reporter.trace( path=self.object_path, tracebk=traceback.format_exc() ) return self._validate_docs_schema(kwargs, ansible_module_kwargs_schema, 'AnsibleModule', 332) self._validate_argument_spec(docs, spec, kwargs) def _validate_argument_spec(self, docs, spec, kwargs): if not self.analyze_arg_spec: return if docs is None: docs = {} try: add_fragments(docs, self.object_path, fragment_loader=fragment_loader) except Exception: # Cannot merge fragments return # Use this to access type checkers later module = NoArgsAnsibleModule({}) provider_args = set() args_from_argspec = set() deprecated_args_from_argspec = set() for arg, data in spec.items(): if not isinstance(data, dict): self.reporter.error( path=self.object_path, code=331, msg="Argument '%s' in argument_spec must be a dictionary/hash when used" % arg, ) continue if not data.get('removed_in_version', None): args_from_argspec.add(arg) args_from_argspec.update(data.get('aliases', [])) else: deprecated_args_from_argspec.add(arg) deprecated_args_from_argspec.update(data.get('aliases', [])) if arg == 'provider' and self.object_path.startswith('lib/ansible/modules/network/'): # Record provider options from network modules, for later comparison for provider_arg, provider_data in data.get('options', {}).items(): provider_args.add(provider_arg) provider_args.update(provider_data.get('aliases', [])) if data.get('required') and data.get('default', object) != object: self.reporter.error( path=self.object_path, code=317, msg=("Argument '%s' in argument_spec is marked as required " "but specifies a default. Arguments with a default should not be marked as required" % arg) ) if arg in provider_args: # Provider args are being removed from network module top level # don't validate docs<->arg_spec checks below continue _type = data.get('type', 'str') if callable(_type): _type_checker = _type else: _type_checker = module._CHECK_ARGUMENT_TYPES_DISPATCHER.get(_type) # TODO: needs to recursively traverse suboptions arg_default = None if 'default' in data and not is_empty(data['default']): try: with CaptureStd(): arg_default = _type_checker(data['default']) except (Exception, SystemExit): self.reporter.error( path=self.object_path, code=329, msg=("Argument '%s' in argument_spec defines default as (%r) " "but this is incompatible with parameter type %r" % (arg, data['default'], _type)) ) continue elif data.get('default') is None and _type == 'bool' and 'options' not in data: arg_default = False try: doc_default = None doc_options_arg = docs.get('options', {}).get(arg, {}) if 'default' in doc_options_arg and not is_empty(doc_options_arg['default']): with CaptureStd(): doc_default = _type_checker(doc_options_arg['default']) elif doc_options_arg.get('default') is None and _type == 'bool' and 'suboptions' not in doc_options_arg: doc_default = False except (Exception, SystemExit): self.reporter.error( path=self.object_path, code=327, msg=("Argument '%s' in documentation defines default as (%r) " "but this is incompatible with parameter type %r" % (arg, doc_options_arg.get('default'), _type)) ) continue if arg_default != doc_default: self.reporter.error( path=self.object_path, code=324, msg=("Argument '%s' in argument_spec defines default as (%r) " "but documentation defines default as (%r)" % (arg, arg_default, doc_default)) ) # TODO: needs to recursively traverse suboptions doc_type = docs.get('options', {}).get(arg, {}).get('type') if 'type' in data: if data['type'] != doc_type and doc_type is not None: self.reporter.error( path=self.object_path, code=325, msg="Argument '%s' in argument_spec defines type as %r " "but documentation defines type as %r" % (arg, data['type'], doc_type) ) else: if doc_type != 'str' and doc_type is not None: self.reporter.error( path=self.object_path, code=335, msg="Argument '%s' in argument_spec implies type as 'str' " "but documentation defines as %r" % (arg, doc_type) ) # TODO: needs to recursively traverse suboptions doc_choices = [] try: for choice in docs.get('options', {}).get(arg, {}).get('choices', []): try: with CaptureStd(): doc_choices.append(_type_checker(choice)) except (Exception, SystemExit): self.reporter.error( path=self.object_path, code=328, msg=("Argument '%s' in documentation defines choices as (%r) " "but this is incompatible with argument type %r" % (arg, choice, _type)) ) raise StopIteration() except StopIteration: continue arg_choices = [] try: for choice in data.get('choices', []): try: with CaptureStd(): arg_choices.append(_type_checker(choice)) except (Exception, SystemExit): self.reporter.error( path=self.object_path, code=330, msg=("Argument '%s' in argument_spec defines choices as (%r) " "but this is incompatible with argument type %r" % (arg, choice, _type)) ) raise StopIteration() except StopIteration: continue if not compare_unordered_lists(arg_choices, doc_choices): self.reporter.error( path=self.object_path, code=326, msg=("Argument '%s' in argument_spec defines choices as (%r) " "but documentation defines choices as (%r)" % (arg, arg_choices, doc_choices)) ) for arg in args_from_argspec: if not str(arg).isidentifier(): self.reporter.error( path=self.object_path, code=336, msg="Argument '%s' is not a valid python identifier" % arg ) if docs: file_common_arguments = set() for arg, data in FILE_COMMON_ARGUMENTS.items(): file_common_arguments.add(arg) file_common_arguments.update(data.get('aliases', [])) args_from_docs = set() for arg, data in docs.get('options', {}).items(): args_from_docs.add(arg) args_from_docs.update(data.get('aliases', [])) args_missing_from_docs = args_from_argspec.difference(args_from_docs) docs_missing_from_args = args_from_docs.difference(args_from_argspec | deprecated_args_from_argspec) for arg in args_missing_from_docs: # args_from_argspec contains undocumented argument if kwargs.get('add_file_common_args', False) and arg in file_common_arguments: # add_file_common_args is handled in AnsibleModule, and not exposed earlier continue if arg in provider_args: # Provider args are being removed from network module top level # So they are likely not documented on purpose continue self.reporter.error( path=self.object_path, code=322, msg="Argument '%s' is listed in the argument_spec, " "but not documented in the module documentation" % arg ) for arg in docs_missing_from_args: # args_from_docs contains argument not in the argument_spec if kwargs.get('add_file_common_args', False) and arg in file_common_arguments: # add_file_common_args is handled in AnsibleModule, and not exposed earlier continue self.reporter.error( path=self.object_path, code=323, msg="Argument '%s' is listed in DOCUMENTATION.options, " "but not accepted by the module argument_spec" % arg ) def _check_for_new_args(self, doc, metadata): if not self.base_branch or self._is_new_module(): return with CaptureStd(): try: existing_doc, dummy_examples, dummy_return, existing_metadata = get_docstring(self.base_module, fragment_loader, verbose=True) existing_options = existing_doc.get('options', {}) or {} except AssertionError: fragment = doc['extends_documentation_fragment'] self.reporter.warning( path=self.object_path, code=392, msg='Pre-existing DOCUMENTATION fragment missing: %s' % fragment ) return except Exception as e: self.reporter.warning_trace( path=self.object_path, tracebk=e ) self.reporter.warning( path=self.object_path, code=391, msg=('Unknown pre-existing DOCUMENTATION error, see TRACE. Submodule refs may need updated') ) return try: mod_version_added = StrictVersion() mod_version_added.parse( str(existing_doc.get('version_added', '0.0')) ) except ValueError: mod_version_added = StrictVersion('0.0') if self.base_branch and 'stable-' in self.base_branch: metadata.pop('metadata_version', None) metadata.pop('version', None) if metadata != existing_metadata: self.reporter.error( path=self.object_path, code=334, msg=('ANSIBLE_METADATA cannot be changed in a point release for a stable branch') ) options = doc.get('options', {}) or {} should_be = '.'.join(ansible_version.split('.')[:2]) strict_ansible_version = StrictVersion(should_be) for option, details in options.items(): try: names = [option] + details.get('aliases', []) except (TypeError, AttributeError): # Reporting of this syntax error will be handled by schema validation. continue if any(name in existing_options for name in names): for name in names: existing_version = existing_options.get(name, {}).get('version_added') if existing_version: break current_version = details.get('version_added') if str(current_version) != str(existing_version): self.reporter.error( path=self.object_path, code=309, msg=('version_added for new option (%s) should ' 'be %r. Currently %r' % (option, existing_version, current_version)) ) continue try: version_added = StrictVersion() version_added.parse( str(details.get('version_added', '0.0')) ) except ValueError: version_added = details.get('version_added', '0.0') self.reporter.error( path=self.object_path, code=308, msg=('version_added for new option (%s) ' 'is not a valid version number: %r' % (option, version_added)) ) continue except Exception: # If there is any other exception it should have been caught # in schema validation, so we won't duplicate errors by # listing it again continue if (strict_ansible_version != mod_version_added and (version_added < strict_ansible_version or strict_ansible_version < version_added)): self.reporter.error( path=self.object_path, code=309, msg=('version_added for new option (%s) should ' 'be %r. Currently %r' % (option, should_be, version_added)) ) return existing_doc @staticmethod def is_blacklisted(path): base_name = os.path.basename(path) file_name, _ = os.path.splitext(base_name) if file_name.startswith('_') and os.path.islink(path): return True if not frozenset((base_name, file_name)).isdisjoint(ModuleValidator.BLACKLIST): return True for pat in ModuleValidator.BLACKLIST_PATTERNS: if fnmatch(base_name, pat): return True return False def validate(self): super(ModuleValidator, self).validate() if not self._python_module() and not self._powershell_module(): self.reporter.error( path=self.object_path, code=501, msg=('Official Ansible modules must have a .py ' 'extension for python modules or a .ps1 ' 'for powershell modules') ) self._python_module_override = True if self._python_module() and self.ast is None: self.reporter.error( path=self.object_path, code=401, msg='Python SyntaxError while parsing module' ) try: compile(self.text, self.path, 'exec') except Exception: self.reporter.trace( path=self.object_path, tracebk=traceback.format_exc() ) return end_of_deprecation_should_be_removed_only = False if self._python_module(): doc_info, docs = self._validate_docs() # See if current version => deprecated.removed_in, ie, should be docs only if isinstance(doc_info['ANSIBLE_METADATA']['value'], ast.Dict) and 'removed' in ast.literal_eval(doc_info['ANSIBLE_METADATA']['value'])['status']: end_of_deprecation_should_be_removed_only = True elif docs and 'deprecated' in docs and docs['deprecated'] is not None: try: removed_in = StrictVersion(str(docs.get('deprecated')['removed_in'])) except ValueError: end_of_deprecation_should_be_removed_only = False else: strict_ansible_version = StrictVersion('.'.join(ansible_version.split('.')[:2])) end_of_deprecation_should_be_removed_only = strict_ansible_version >= removed_in if self._python_module() and not self._just_docs() and not end_of_deprecation_should_be_removed_only: self._validate_ansible_module_call(docs) self._check_for_sys_exit() self._find_blacklist_imports() main = self._find_main_call() self._find_module_utils(main) self._find_has_import() first_callable = self._get_first_callable() self._ensure_imports_below_docs(doc_info, first_callable) self._check_for_subprocess() self._check_for_os_call() if self._powershell_module(): self._validate_ps_replacers() docs_path = self._find_ps_docs_py_file() # We can only validate PowerShell arg spec if it is using the new Ansible.Basic.AnsibleModule util pattern = r'(?im)^#\s*ansiblerequires\s+\-csharputil\s*Ansible\.Basic' if re.search(pattern, self.text) and self.object_name not in self.PS_ARG_VALIDATE_BLACKLIST: with ModuleValidator(docs_path, base_branch=self.base_branch, git_cache=self.git_cache) as docs_mv: docs = docs_mv._validate_docs()[1] self._validate_ansible_module_call(docs) self._check_gpl3_header() if not self._just_docs() and not end_of_deprecation_should_be_removed_only: self._check_interpreter(powershell=self._powershell_module()) self._check_type_instead_of_isinstance( powershell=self._powershell_module() ) if end_of_deprecation_should_be_removed_only: # Ensure that `if __name__ == '__main__':` calls `removed_module()` which ensure that the module has no code in main = self._find_main_call('removed_module') # FIXME: Ensure that the version in the call to removed_module is less than +2. # Otherwise it's time to remove the file (This may need to be done in another test to # avoid breaking whenever the Ansible version bumps) class PythonPackageValidator(Validator): BLACKLIST_FILES = frozenset(('__pycache__',)) def __init__(self, path, reporter=None): super(PythonPackageValidator, self).__init__(reporter=reporter or Reporter()) self.path = path self.basename = os.path.basename(path) @property def object_name(self): return self.basename @property def object_path(self): return self.path def validate(self): super(PythonPackageValidator, self).validate() if self.basename in self.BLACKLIST_FILES: return init_file = os.path.join(self.path, '__init__.py') if not os.path.exists(init_file): self.reporter.error( path=self.object_path, code=502, msg='Ansible module subdirectories must contain an __init__.py' ) def re_compile(value): """ Argparse expects things to raise TypeError, re.compile raises an re.error exception This function is a shorthand to convert the re.error exception to a TypeError """ try: return re.compile(value) except re.error as e: raise TypeError(e) def main(): parser = argparse.ArgumentParser(prog="validate-modules") parser.add_argument('modules', nargs='+', help='Path to module or module directory') parser.add_argument('-w', '--warnings', help='Show warnings', action='store_true') parser.add_argument('--exclude', help='RegEx exclusion pattern', type=re_compile) parser.add_argument('--arg-spec', help='Analyze module argument spec', action='store_true', default=False) parser.add_argument('--base-branch', default=None, help='Used in determining if new options were added') parser.add_argument('--format', choices=['json', 'plain'], default='plain', help='Output format. Default: "%(default)s"') parser.add_argument('--output', default='-', help='Output location, use "-" for stdout. ' 'Default "%(default)s"') args = parser.parse_args() args.modules[:] = [m.rstrip('/') for m in args.modules] reporter = Reporter() git_cache = GitCache(args.base_branch) check_dirs = set() for module in args.modules: if os.path.isfile(module): path = module if args.exclude and args.exclude.search(path): continue if ModuleValidator.is_blacklisted(path): continue with ModuleValidator(path, analyze_arg_spec=args.arg_spec, base_branch=args.base_branch, git_cache=git_cache, reporter=reporter) as mv: mv.validate() check_dirs.add(os.path.dirname(path)) for root, dirs, files in os.walk(module): basedir = root[len(module) + 1:].split('/', 1)[0] if basedir in BLACKLIST_DIRS: continue for dirname in dirs: if root == module and dirname in BLACKLIST_DIRS: continue path = os.path.join(root, dirname) if args.exclude and args.exclude.search(path): continue check_dirs.add(path) for filename in files: path = os.path.join(root, filename) if args.exclude and args.exclude.search(path): continue if ModuleValidator.is_blacklisted(path): continue with ModuleValidator(path, analyze_arg_spec=args.arg_spec, base_branch=args.base_branch, git_cache=git_cache, reporter=reporter) as mv: mv.validate() for path in sorted(check_dirs): pv = PythonPackageValidator(path, reporter=reporter) pv.validate() if args.format == 'plain': sys.exit(reporter.plain(warnings=args.warnings, output=args.output)) else: sys.exit(reporter.json(warnings=args.warnings, output=args.output)) class GitCache(object): def __init__(self, base_branch): self.base_branch = base_branch if self.base_branch: self.base_tree = self._git(['ls-tree', '-r', '--name-only', self.base_branch, 'lib/ansible/modules/']) else: self.base_tree = [] try: self.head_tree = self._git(['ls-tree', '-r', '--name-only', 'HEAD', 'lib/ansible/modules/']) except GitError as ex: if ex.status == 128: # fallback when there is no .git directory self.head_tree = self._get_module_files() else: raise except OSError as ex: if ex.errno == errno.ENOENT: # fallback when git is not installed self.head_tree = self._get_module_files() else: raise self.base_module_paths = dict((os.path.basename(p), p) for p in self.base_tree if os.path.splitext(p)[1] in ('.py', '.ps1')) self.base_module_paths.pop('__init__.py', None) self.head_aliased_modules = set() for path in self.head_tree: filename = os.path.basename(path) if filename.startswith('_') and filename != '__init__.py': if os.path.islink(path): self.head_aliased_modules.add(os.path.basename(os.path.realpath(path))) @staticmethod def _get_module_files(): module_files = [] for (dir_path, dir_names, file_names) in os.walk('lib/ansible/modules/'): for file_name in file_names: module_files.append(os.path.join(dir_path, file_name)) return module_files @staticmethod def _git(args): cmd = ['git'] + args p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode != 0: raise GitError(stderr, p.returncode) return stdout.decode('utf-8').splitlines() class GitError(Exception): def __init__(self, message, status): super(GitError, self).__init__(message) self.status = status if __name__ == '__main__': try: main() except KeyboardInterrupt: pass
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 31653, 603, 28124, 665, 569, 84, 32, 338, 1090, 14, 846, 30, 199, 3, 1898, 334, 35, 9, 6900, 32679, 19635, 12, 3277, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 7534, 199, 646, 6073, 199, 646, 2022, 199, 646, 7554, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 646, 5190, 199, 199, 504, 5055, 492, 8773, 199, 504, 15502, 492, 27608, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 504, 15951, 492, 15951, 199, 199, 504, 3242, 492, 636, 1023, 363, 465, 3242, 63, 1023, 199, 504, 3242, 14, 13471, 14, 578, 63, 2330, 492, 5363, 2749, 1348, 540, 63, 20509, 199, 504, 3242, 14, 5265, 14, 3422, 492, 7956, 63, 3422, 199, 504, 3242, 14, 1208, 14, 2718, 63, 4757, 492, 26774, 4924, 12, 1050, 63, 18047, 12, 664, 63, 12485, 199, 199, 504, 859, 63, 589, 492, 6953, 17825, 12, 664, 63, 2094, 63, 1650, 199, 199, 504, 4177, 492, 3242, 63, 578, 63, 958, 63, 3629, 12, 1382, 63, 3629, 12, 3341, 63, 17, 63, 17, 63, 3629, 12, 372, 63, 3629, 199, 199, 504, 3778, 492, 29828, 11976, 12, 3091, 6213, 10047, 2377, 12, 6540, 63, 24182, 63, 6717, 12, 365, 63, 1667, 12, 2198, 63, 5963, 199, 504, 30291, 14, 14864, 794, 492, 11779, 794, 63, 705, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 7843, 19, 12, 543, 63, 6577, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 13024, 63, 21637, 63, 24165, 51, 199, 199, 692, 7843, 19, 26, 272, 327, 13821, 2337, 365, 949, 6073, 14, 12357, 920, 716, 315, 2018, 650, 6073, 859, 272, 377, 5782, 63, 11764, 275, 6073, 14, 12357, 272, 327, 5363, 2749, 1348, 540, 63, 20509, 687, 3242, 14, 13471, 14, 578, 63, 2330, 365, 3696, 272, 327, 1059, 1325, 781, 1929, 2649, 367, 2018, 650, 272, 5363, 2749, 1348, 540, 63, 20509, 275, 5363, 2749, 1348, 540, 63, 20509, 14, 2708, 360, 1624, 13, 24, 358, 199, 2836, 26, 272, 377, 5782, 63, 11764, 275, 6073, 14, 12357, 920, 716, 199, 199, 23113, 4924, 63, 14455, 275, 9522, 4725, 14, 3187, 297, 283, 396, 297, 1987, 5031, 297, 1987, 2655, 65, 1333, 199, 29080, 63, 10710, 275, 295, 14, 2014, 8, 82, 7, 16510, 84, 3672, 5942, 199, 2711, 63, 10710, 275, 295, 14, 2014, 8, 82, 1370, 5830, 692, 92, 269, 10127, 83, 11, 4735, 3212, 20445, 6113, 83, 8771, 2229, 11230, 4602, 2229, 11230, 495, 60, 342, 466, 60, 7059, 22509, 13418, 199, 13326, 63, 17219, 63, 10710, 275, 295, 14, 2014, 8, 82, 16122, 3, 3672, 1274, 14, 2224, 60, 83, 7590, 19276, 358, 199, 23113, 4924, 63, 17576, 51, 275, 469, 272, 283, 6615, 356, 469, 267, 283, 1222, 63, 2118, 356, 715, 12, 267, 283, 705, 356, 469, 288, 283, 600, 356, 29202, 12, 288, 283, 1328, 356, 661, 6615, 492, 1911, 12, 1077, 675, 283, 490, 283, 4853, 14, 578, 63, 1208, 14, 3603, 3140, 358, 267, 789, 272, 1660, 272, 519, 7, 10914, 15840, 14, 92, 4, 11862, 469, 267, 283, 1222, 63, 2118, 356, 715, 12, 267, 283, 705, 356, 469, 288, 283, 600, 356, 14785, 12, 288, 283, 1328, 356, 283, 10914, 492, 1911, 12, 892, 4621, 1077, 675, 6055, 19, 7, 267, 789, 272, 1660, 199, 93, 199, 6348, 10494, 63, 10710, 275, 295, 14, 2014, 8, 82, 1159, 456, 1412, 4537, 1575, 24915, 199, 3100, 63, 11978, 63, 10710, 275, 295, 14, 2014, 8, 82, 7, 736, 4537, 1250, 24915, 421, 199, 533, 23786, 6679, 8, 1001, 14, 23069, 304, 272, 347, 849, 8, 277, 12, 312, 304, 267, 340, 1228, 8, 79, 12, 2186, 304, 288, 372, 620, 8, 79, 9, 398, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 312, 9, 421, 199, 533, 23786, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1725, 275, 8773, 342, 339, 347, 485, 7505, 63, 885, 63, 2373, 8, 277, 12, 931, 304, 267, 862, 26, 288, 291, 14, 1725, 59, 515, 61, 267, 871, 4067, 26, 288, 291, 14, 1725, 59, 515, 61, 275, 469, 355, 283, 2550, 356, 990, 355, 283, 5451, 356, 990, 355, 283, 28388, 356, 990, 355, 283, 3764, 63, 28388, 356, 942, 288, 789, 339, 347, 485, 793, 8, 277, 12, 931, 12, 1233, 12, 1499, 12, 2166, 534, 705, 297, 1004, 29, 16, 12, 2763, 29, 16, 304, 267, 291, 423, 7505, 63, 885, 63, 2373, 8, 515, 9, 267, 634, 7300, 63, 20660, 275, 291, 14, 1725, 59, 515, 2733, 5, 385, 7, 450, 2166, 61, 267, 634, 7300, 63, 20660, 14, 740, 2561, 288, 283, 600, 356, 1233, 12, 288, 283, 1328, 356, 1499, 12, 288, 283, 604, 356, 1004, 12, 288, 283, 2301, 356, 2763, 267, 3828, 339, 347, 1125, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 423, 793, 2031, 589, 12, 2166, 534, 705, 297, 1011, 958, 9, 339 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 31653, 603, 28124, 665, 569, 84, 32, 338, 1090, 14, 846, 30, 199, 3, 1898, 334, 35, 9, 6900, 32679, 19635, 12, 3277, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 7534, 199, 646, 6073, 199, 646, 2022, 199, 646, 7554, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 646, 5190, 199, 199, 504, 5055, 492, 8773, 199, 504, 15502, 492, 27608, 199, 504, 7065, 14, 1023, 492, 23052, 3353, 199, 504, 15951, 492, 15951, 199, 199, 504, 3242, 492, 636, 1023, 363, 465, 3242, 63, 1023, 199, 504, 3242, 14, 13471, 14, 578, 63, 2330, 492, 5363, 2749, 1348, 540, 63, 20509, 199, 504, 3242, 14, 5265, 14, 3422, 492, 7956, 63, 3422, 199, 504, 3242, 14, 1208, 14, 2718, 63, 4757, 492, 26774, 4924, 12, 1050, 63, 18047, 12, 664, 63, 12485, 199, 199, 504, 859, 63, 589, 492, 6953, 17825, 12, 664, 63, 2094, 63, 1650, 199, 199, 504, 4177, 492, 3242, 63, 578, 63, 958, 63, 3629, 12, 1382, 63, 3629, 12, 3341, 63, 17, 63, 17, 63, 3629, 12, 372, 63, 3629, 199, 199, 504, 3778, 492, 29828, 11976, 12, 3091, 6213, 10047, 2377, 12, 6540, 63, 24182, 63, 6717, 12, 365, 63, 1667, 12, 2198, 63, 5963, 199, 504, 30291, 14, 14864, 794, 492, 11779, 794, 63, 705, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 7843, 19, 12, 543, 63, 6577, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 13024, 63, 21637, 63, 24165, 51, 199, 199, 692, 7843, 19, 26, 272, 327, 13821, 2337, 365, 949, 6073, 14, 12357, 920, 716, 315, 2018, 650, 6073, 859, 272, 377, 5782, 63, 11764, 275, 6073, 14, 12357, 272, 327, 5363, 2749, 1348, 540, 63, 20509, 687, 3242, 14, 13471, 14, 578, 63, 2330, 365, 3696, 272, 327, 1059, 1325, 781, 1929, 2649, 367, 2018, 650, 272, 5363, 2749, 1348, 540, 63, 20509, 275, 5363, 2749, 1348, 540, 63, 20509, 14, 2708, 360, 1624, 13, 24, 358, 199, 2836, 26, 272, 377, 5782, 63, 11764, 275, 6073, 14, 12357, 920, 716, 199, 199, 23113, 4924, 63, 14455, 275, 9522, 4725, 14, 3187, 297, 283, 396, 297, 1987, 5031, 297, 1987, 2655, 65, 1333, 199, 29080, 63, 10710, 275, 295, 14, 2014, 8, 82, 7, 16510, 84, 3672, 5942, 199, 2711, 63, 10710, 275, 295, 14, 2014, 8, 82, 1370, 5830, 692, 92, 269, 10127, 83, 11, 4735, 3212, 20445, 6113, 83, 8771, 2229, 11230, 4602, 2229, 11230, 495, 60, 342, 466, 60, 7059, 22509, 13418, 199, 13326, 63, 17219, 63, 10710, 275, 295, 14, 2014, 8, 82, 16122, 3, 3672, 1274, 14, 2224, 60, 83, 7590, 19276, 358, 199, 23113, 4924, 63, 17576, 51, 275, 469, 272, 283, 6615, 356, 469, 267, 283, 1222, 63, 2118, 356, 715, 12, 267, 283, 705, 356, 469, 288, 283, 600, 356, 29202, 12, 288, 283, 1328, 356, 661, 6615, 492, 1911, 12, 1077, 675, 283, 490, 283, 4853, 14, 578, 63, 1208, 14, 3603, 3140, 358, 267, 789, 272, 1660, 272, 519, 7, 10914, 15840, 14, 92, 4, 11862, 469, 267, 283, 1222, 63, 2118, 356, 715, 12, 267, 283, 705, 356, 469, 288, 283, 600, 356, 14785, 12, 288, 283, 1328, 356, 283, 10914, 492, 1911, 12, 892, 4621, 1077, 675, 6055, 19, 7, 267, 789, 272, 1660, 199, 93, 199, 6348, 10494, 63, 10710, 275, 295, 14, 2014, 8, 82, 1159, 456, 1412, 4537, 1575, 24915, 199, 3100, 63, 11978, 63, 10710, 275, 295, 14, 2014, 8, 82, 7, 736, 4537, 1250, 24915, 421, 199, 533, 23786, 6679, 8, 1001, 14, 23069, 304, 272, 347, 849, 8, 277, 12, 312, 304, 267, 340, 1228, 8, 79, 12, 2186, 304, 288, 372, 620, 8, 79, 9, 398, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 312, 9, 421, 199, 533, 23786, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1725, 275, 8773, 342, 339, 347, 485, 7505, 63, 885, 63, 2373, 8, 277, 12, 931, 304, 267, 862, 26, 288, 291, 14, 1725, 59, 515, 61, 267, 871, 4067, 26, 288, 291, 14, 1725, 59, 515, 61, 275, 469, 355, 283, 2550, 356, 990, 355, 283, 5451, 356, 990, 355, 283, 28388, 356, 990, 355, 283, 3764, 63, 28388, 356, 942, 288, 789, 339, 347, 485, 793, 8, 277, 12, 931, 12, 1233, 12, 1499, 12, 2166, 534, 705, 297, 1004, 29, 16, 12, 2763, 29, 16, 304, 267, 291, 423, 7505, 63, 885, 63, 2373, 8, 515, 9, 267, 634, 7300, 63, 20660, 275, 291, 14, 1725, 59, 515, 2733, 5, 385, 7, 450, 2166, 61, 267, 634, 7300, 63, 20660, 14, 740, 2561, 288, 283, 600, 356, 1233, 12, 288, 283, 1328, 356, 1499, 12, 288, 283, 604, 356, 1004, 12, 288, 283, 2301, 356, 2763, 267, 3828, 339, 347, 1125, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 423, 793, 2031, 589, 12, 2166, 534, 705, 297, 1011, 958, 9, 339, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
schumi2004/NOT_UPDATED_Sick-Beard-Dutch
lib/trakt/__init__.py
49
1728
import urllib2 from hashlib import sha1 try: import json except ImportError: from lib import simplejson as json def TraktCall(method, api, username, password, data = {}): """ A generic method for communicating with trakt. Uses the method and data provided along with the auth info to send the command. method: The URL to use at trakt, relative, no leading slash. api: The API string to provide to trakt username: The username to use when logging in password: The unencrypted password to use when logging in Returns: A boolean representing success """ #logger.log("trakt: Call method " + method, logger.DEBUG) # if the API isn't given then it failed if not api: return None # if the username isn't given then it failed if not username: return None password = sha1(password).hexdigest() # replace the API string with what we found method = method.replace("%API%", api) data["username"] = username data["password"] = password # take the URL params and make a json object out of them encoded_data = json.dumps(data); # request the URL from trakt and parse the result as json try: #logger.log("trakt: Calling method http://api.trakt.tv/" + method + ", with data" + encoded_data, logger.DEBUG) stream = urllib2.urlopen("http://api.trakt.tv/" + method, encoded_data) resp = stream.read() resp = json.loads(resp) if ("error" in resp): raise Exception(resp["error"]) except (IOError): #logger.log("trakt: Failed calling method", logger.ERROR) return None #logger.log("trakt: Failed calling method", logger.ERROR) return resp
gpl-3.0
[ 646, 4011, 18, 199, 199, 504, 8337, 492, 7793, 17, 523, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 687, 1973, 492, 13804, 465, 2022, 199, 199, 318, 12643, 5973, 2176, 8, 765, 12, 2986, 12, 3434, 12, 2505, 12, 666, 275, 1052, 304, 272, 408, 272, 437, 7809, 1083, 367, 13882, 1958, 543, 30501, 14, 14911, 314, 1083, 436, 666, 2741, 3180, 272, 543, 314, 1790, 2256, 370, 3222, 314, 1414, 14, 339, 1083, 26, 710, 2851, 370, 675, 737, 30501, 12, 3847, 12, 949, 9186, 14457, 14, 272, 2986, 26, 710, 3261, 1059, 370, 5647, 370, 30501, 272, 3434, 26, 710, 3434, 370, 675, 1380, 2050, 315, 272, 2505, 26, 710, 625, 15078, 2505, 370, 675, 1380, 2050, 315, 339, 1803, 26, 437, 5046, 6144, 3182, 272, 408, 272, 327, 2921, 14, 793, 480, 28257, 26, 6523, 1083, 298, 435, 1083, 12, 2512, 14, 5287, 9, 339, 327, 340, 314, 3261, 5712, 1133, 1627, 2066, 652, 3405, 272, 340, 440, 2986, 26, 267, 372, 488, 339, 327, 340, 314, 3434, 5712, 1133, 1627, 2066, 652, 3405, 272, 340, 440, 3434, 26, 267, 372, 488, 339, 2505, 275, 7793, 17, 8, 2060, 680, 11453, 342, 339, 327, 3350, 314, 3261, 1059, 543, 4052, 781, 1911, 272, 1083, 275, 1083, 14, 1814, 3647, 3735, 31181, 2986, 9, 339, 666, 905, 2473, 937, 275, 3434, 272, 666, 905, 2060, 937, 275, 2505, 339, 327, 5452, 314, 2851, 1862, 436, 1852, 282, 2022, 909, 734, 402, 3062, 272, 5737, 63, 576, 275, 2022, 14, 4180, 8, 576, 2736, 339, 327, 1056, 314, 2851, 687, 30501, 436, 2198, 314, 754, 465, 2022, 272, 862, 26, 267, 327, 2921, 14, 793, 480, 28257, 26, 23892, 1083, 1455, 921, 1246, 14, 28257, 14, 6993, 6687, 435, 1083, 435, 3872, 543, 666, 2, 435, 5737, 63, 576, 12, 2512, 14, 5287, 9, 267, 2547, 275, 4011, 18, 14, 10890, 480, 1014, 921, 1246, 14, 28257, 14, 6993, 6687, 435, 1083, 12, 5737, 63, 576, 9, 267, 3085, 275, 2547, 14, 739, 342, 398, 3085, 275, 2022, 14, 3640, 8, 4518, 9, 398, 340, 1689, 705, 2, 315, 3085, 304, 288, 746, 2186, 8, 4518, 905, 705, 3135, 339, 871, 334, 13760, 304, 267, 327, 2921, 14, 793, 480, 28257, 26, 16277, 6358, 1083, 401, 2512, 14, 3170, 9, 267, 372, 488, 339, 327, 2921, 14, 793, 480, 28257, 26, 16277, 6358, 1083, 401, 2512, 14, 3170, 9, 272, 372, 3085, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4011, 18, 199, 199, 504, 8337, 492, 7793, 17, 523, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 687, 1973, 492, 13804, 465, 2022, 199, 199, 318, 12643, 5973, 2176, 8, 765, 12, 2986, 12, 3434, 12, 2505, 12, 666, 275, 1052, 304, 272, 408, 272, 437, 7809, 1083, 367, 13882, 1958, 543, 30501, 14, 14911, 314, 1083, 436, 666, 2741, 3180, 272, 543, 314, 1790, 2256, 370, 3222, 314, 1414, 14, 339, 1083, 26, 710, 2851, 370, 675, 737, 30501, 12, 3847, 12, 949, 9186, 14457, 14, 272, 2986, 26, 710, 3261, 1059, 370, 5647, 370, 30501, 272, 3434, 26, 710, 3434, 370, 675, 1380, 2050, 315, 272, 2505, 26, 710, 625, 15078, 2505, 370, 675, 1380, 2050, 315, 339, 1803, 26, 437, 5046, 6144, 3182, 272, 408, 272, 327, 2921, 14, 793, 480, 28257, 26, 6523, 1083, 298, 435, 1083, 12, 2512, 14, 5287, 9, 339, 327, 340, 314, 3261, 5712, 1133, 1627, 2066, 652, 3405, 272, 340, 440, 2986, 26, 267, 372, 488, 339, 327, 340, 314, 3434, 5712, 1133, 1627, 2066, 652, 3405, 272, 340, 440, 3434, 26, 267, 372, 488, 339, 2505, 275, 7793, 17, 8, 2060, 680, 11453, 342, 339, 327, 3350, 314, 3261, 1059, 543, 4052, 781, 1911, 272, 1083, 275, 1083, 14, 1814, 3647, 3735, 31181, 2986, 9, 339, 666, 905, 2473, 937, 275, 3434, 272, 666, 905, 2060, 937, 275, 2505, 339, 327, 5452, 314, 2851, 1862, 436, 1852, 282, 2022, 909, 734, 402, 3062, 272, 5737, 63, 576, 275, 2022, 14, 4180, 8, 576, 2736, 339, 327, 1056, 314, 2851, 687, 30501, 436, 2198, 314, 754, 465, 2022, 272, 862, 26, 267, 327, 2921, 14, 793, 480, 28257, 26, 23892, 1083, 1455, 921, 1246, 14, 28257, 14, 6993, 6687, 435, 1083, 435, 3872, 543, 666, 2, 435, 5737, 63, 576, 12, 2512, 14, 5287, 9, 267, 2547, 275, 4011, 18, 14, 10890, 480, 1014, 921, 1246, 14, 28257, 14, 6993, 6687, 435, 1083, 12, 5737, 63, 576, 9, 267, 3085, 275, 2547, 14, 739, 342, 398, 3085, 275, 2022, 14, 3640, 8, 4518, 9, 398, 340, 1689, 705, 2, 315, 3085, 304, 288, 746, 2186, 8, 4518, 905, 705, 3135, 339, 871, 334, 13760, 304, 267, 327, 2921, 14, 793, 480, 28257, 26, 16277, 6358, 1083, 401, 2512, 14, 3170, 9, 267, 372, 488, 339, 327, 2921, 14, 793, 480, 28257, 26, 16277, 6358, 1083, 401, 2512, 14, 3170, 9, 272, 372, 3085, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Universal-Model-Converter/UMC3.0a
data/Python/x86/Lib/distutils/tests/test_filelist.py
127
10078
"""Tests for distutils.filelist.""" import os import re import unittest from distutils import debug from distutils.log import WARN from distutils.errors import DistutilsTemplateError from distutils.filelist import glob_to_re, translate_pattern, FileList from test.test_support import captured_stdout, run_unittest from distutils.tests import support MANIFEST_IN = """\ include ok include xo exclude xo include foo.tmp include buildout.cfg global-include *.x global-include *.txt global-exclude *.tmp recursive-include f *.oo recursive-exclude global *.x graft dir prune dir3 """ def make_local_path(s): """Converts '/' in a string to os.sep""" return s.replace('/', os.sep) class FileListTestCase(support.LoggingSilencer, unittest.TestCase): def assertNoWarnings(self): self.assertEqual(self.get_logs(WARN), []) self.clear_logs() def assertWarnings(self): self.assertGreater(len(self.get_logs(WARN)), 0) self.clear_logs() def test_glob_to_re(self): sep = os.sep if os.sep == '\\': sep = re.escape(os.sep) for glob, regex in ( # simple cases ('foo*', r'foo[^%(sep)s]*\Z(?ms)'), ('foo?', r'foo[^%(sep)s]\Z(?ms)'), ('foo??', r'foo[^%(sep)s][^%(sep)s]\Z(?ms)'), # special cases (r'foo\\*', r'foo\\\\[^%(sep)s]*\Z(?ms)'), (r'foo\\\*', r'foo\\\\\\[^%(sep)s]*\Z(?ms)'), ('foo????', r'foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s]\Z(?ms)'), (r'foo\\??', r'foo\\\\[^%(sep)s][^%(sep)s]\Z(?ms)')): regex = regex % {'sep': sep} self.assertEqual(glob_to_re(glob), regex) def test_process_template_line(self): # testing all MANIFEST.in template patterns file_list = FileList() l = make_local_path # simulated file list file_list.allfiles = ['foo.tmp', 'ok', 'xo', 'four.txt', 'buildout.cfg', # filelist does not filter out VCS directories, # it's sdist that does l('.hg/last-message.txt'), l('global/one.txt'), l('global/two.txt'), l('global/files.x'), l('global/here.tmp'), l('f/o/f.oo'), l('dir/graft-one'), l('dir/dir2/graft2'), l('dir3/ok'), l('dir3/sub/ok.txt'), ] for line in MANIFEST_IN.split('\n'): if line.strip() == '': continue file_list.process_template_line(line) wanted = ['ok', 'buildout.cfg', 'four.txt', l('.hg/last-message.txt'), l('global/one.txt'), l('global/two.txt'), l('f/o/f.oo'), l('dir/graft-one'), l('dir/dir2/graft2'), ] self.assertEqual(file_list.files, wanted) def test_debug_print(self): file_list = FileList() with captured_stdout() as stdout: file_list.debug_print('xxx') self.assertEqual(stdout.getvalue(), '') debug.DEBUG = True try: with captured_stdout() as stdout: file_list.debug_print('xxx') self.assertEqual(stdout.getvalue(), 'xxx\n') finally: debug.DEBUG = False def test_set_allfiles(self): file_list = FileList() files = ['a', 'b', 'c'] file_list.set_allfiles(files) self.assertEqual(file_list.allfiles, files) def test_remove_duplicates(self): file_list = FileList() file_list.files = ['a', 'b', 'a', 'g', 'c', 'g'] # files must be sorted beforehand (sdist does it) file_list.sort() file_list.remove_duplicates() self.assertEqual(file_list.files, ['a', 'b', 'c', 'g']) def test_translate_pattern(self): # not regex self.assertTrue(hasattr( translate_pattern('a', anchor=True, is_regex=False), 'search')) # is a regex regex = re.compile('a') self.assertEqual( translate_pattern(regex, anchor=True, is_regex=True), regex) # plain string flagged as regex self.assertTrue(hasattr( translate_pattern('a', anchor=True, is_regex=True), 'search')) # glob support self.assertTrue(translate_pattern( '*.py', anchor=True, is_regex=False).search('filelist.py')) def test_exclude_pattern(self): # return False if no match file_list = FileList() self.assertFalse(file_list.exclude_pattern('*.py')) # return True if files match file_list = FileList() file_list.files = ['a.py', 'b.py'] self.assertTrue(file_list.exclude_pattern('*.py')) # test excludes file_list = FileList() file_list.files = ['a.py', 'a.txt'] file_list.exclude_pattern('*.py') self.assertEqual(file_list.files, ['a.txt']) def test_include_pattern(self): # return False if no match file_list = FileList() file_list.set_allfiles([]) self.assertFalse(file_list.include_pattern('*.py')) # return True if files match file_list = FileList() file_list.set_allfiles(['a.py', 'b.txt']) self.assertTrue(file_list.include_pattern('*.py')) # test * matches all files file_list = FileList() self.assertIsNone(file_list.allfiles) file_list.set_allfiles(['a.py', 'b.txt']) file_list.include_pattern('*') self.assertEqual(file_list.allfiles, ['a.py', 'b.txt']) def test_process_template(self): l = make_local_path # invalid lines file_list = FileList() for action in ('include', 'exclude', 'global-include', 'global-exclude', 'recursive-include', 'recursive-exclude', 'graft', 'prune', 'blarg'): self.assertRaises(DistutilsTemplateError, file_list.process_template_line, action) # include file_list = FileList() file_list.set_allfiles(['a.py', 'b.txt', l('d/c.py')]) file_list.process_template_line('include *.py') self.assertEqual(file_list.files, ['a.py']) self.assertNoWarnings() file_list.process_template_line('include *.rb') self.assertEqual(file_list.files, ['a.py']) self.assertWarnings() # exclude file_list = FileList() file_list.files = ['a.py', 'b.txt', l('d/c.py')] file_list.process_template_line('exclude *.py') self.assertEqual(file_list.files, ['b.txt', l('d/c.py')]) self.assertNoWarnings() file_list.process_template_line('exclude *.rb') self.assertEqual(file_list.files, ['b.txt', l('d/c.py')]) self.assertWarnings() # global-include file_list = FileList() file_list.set_allfiles(['a.py', 'b.txt', l('d/c.py')]) file_list.process_template_line('global-include *.py') self.assertEqual(file_list.files, ['a.py', l('d/c.py')]) self.assertNoWarnings() file_list.process_template_line('global-include *.rb') self.assertEqual(file_list.files, ['a.py', l('d/c.py')]) self.assertWarnings() # global-exclude file_list = FileList() file_list.files = ['a.py', 'b.txt', l('d/c.py')] file_list.process_template_line('global-exclude *.py') self.assertEqual(file_list.files, ['b.txt']) self.assertNoWarnings() file_list.process_template_line('global-exclude *.rb') self.assertEqual(file_list.files, ['b.txt']) self.assertWarnings() # recursive-include file_list = FileList() file_list.set_allfiles(['a.py', l('d/b.py'), l('d/c.txt'), l('d/d/e.py')]) file_list.process_template_line('recursive-include d *.py') self.assertEqual(file_list.files, [l('d/b.py'), l('d/d/e.py')]) self.assertNoWarnings() file_list.process_template_line('recursive-include e *.py') self.assertEqual(file_list.files, [l('d/b.py'), l('d/d/e.py')]) self.assertWarnings() # recursive-exclude file_list = FileList() file_list.files = ['a.py', l('d/b.py'), l('d/c.txt'), l('d/d/e.py')] file_list.process_template_line('recursive-exclude d *.py') self.assertEqual(file_list.files, ['a.py', l('d/c.txt')]) self.assertNoWarnings() file_list.process_template_line('recursive-exclude e *.py') self.assertEqual(file_list.files, ['a.py', l('d/c.txt')]) self.assertWarnings() # graft file_list = FileList() file_list.set_allfiles(['a.py', l('d/b.py'), l('d/d/e.py'), l('f/f.py')]) file_list.process_template_line('graft d') self.assertEqual(file_list.files, [l('d/b.py'), l('d/d/e.py')]) self.assertNoWarnings() file_list.process_template_line('graft e') self.assertEqual(file_list.files, [l('d/b.py'), l('d/d/e.py')]) self.assertWarnings() # prune file_list = FileList() file_list.files = ['a.py', l('d/b.py'), l('d/d/e.py'), l('f/f.py')] file_list.process_template_line('prune d') self.assertEqual(file_list.files, ['a.py', l('f/f.py')]) self.assertNoWarnings() file_list.process_template_line('prune e') self.assertEqual(file_list.files, ['a.py', l('f/f.py')]) self.assertWarnings() def test_suite(): return unittest.makeSuite(FileListTestCase) if __name__ == "__main__": run_unittest(test_suite())
mit
[ 624, 2925, 367, 7065, 14, 14964, 1041, 199, 646, 747, 199, 646, 295, 199, 646, 2882, 199, 504, 7065, 492, 3105, 199, 504, 7065, 14, 793, 492, 13253, 46, 199, 504, 7065, 14, 2550, 492, 12577, 4231, 547, 199, 504, 7065, 14, 14964, 492, 5739, 63, 475, 63, 264, 12, 9028, 63, 3401, 12, 3814, 1296, 199, 199, 504, 511, 14, 396, 63, 4058, 492, 17487, 63, 2703, 12, 1255, 63, 2796, 199, 504, 7065, 14, 2219, 492, 2291, 199, 199, 24067, 63, 568, 275, 9638, 199, 2613, 4112, 199, 2613, 671, 79, 199, 5473, 671, 79, 199, 2613, 3925, 14, 2791, 199, 2613, 1900, 548, 14, 4128, 199, 2966, 13, 2613, 23588, 88, 199, 2966, 13, 2613, 23588, 2424, 199, 2966, 13, 5473, 23588, 2791, 199, 9931, 13, 2613, 289, 23588, 1534, 199, 9931, 13, 5473, 2288, 23588, 88, 199, 926, 856, 2935, 199, 22268, 2935, 19, 199, 624, 421, 199, 318, 1852, 63, 1832, 63, 515, 8, 83, 304, 272, 408, 17729, 7324, 315, 282, 1059, 370, 747, 14, 4127, 624, 272, 372, 308, 14, 1814, 10998, 747, 14, 4127, 9, 421, 199, 533, 3814, 1296, 1746, 8, 4058, 14, 14054, 51, 441, 78, 2247, 12, 2432, 2882, 14, 1746, 304, 339, 347, 702, 1944, 15921, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 362, 63, 7270, 8, 17449, 395, 3073, 267, 291, 14, 3584, 63, 7270, 342, 339, 347, 702, 15921, 8, 277, 304, 267, 291, 14, 15070, 8, 552, 8, 277, 14, 362, 63, 7270, 8, 17449, 1826, 378, 9, 267, 291, 14, 3584, 63, 7270, 342, 339, 347, 511, 63, 6463, 63, 475, 63, 264, 8, 277, 304, 267, 7375, 275, 747, 14, 4127, 267, 340, 747, 14, 4127, 508, 29082, 288, 7375, 275, 295, 14, 3765, 8, 736, 14, 4127, 9, 398, 367, 5739, 12, 5163, 315, 334, 288, 327, 3486, 5560, 288, 661, 1421, 7693, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 661, 1421, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 661, 1421, 31, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 327, 4539, 5560, 288, 334, 82, 7, 1421, 1103, 7693, 519, 7, 1421, 8712, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 334, 82, 7, 1421, 9780, 7693, 519, 7, 1421, 8712, 1103, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 661, 1421, 10674, 31, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 334, 82, 7, 1421, 1103, 31, 7044, 519, 7, 1421, 8712, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 5942, 304, 288, 5163, 275, 5163, 450, 791, 4127, 356, 7375, 93, 288, 291, 14, 629, 8, 6463, 63, 475, 63, 264, 8, 6463, 395, 5163, 9, 339, 347, 511, 63, 1412, 63, 1160, 63, 604, 8, 277, 304, 267, 327, 5343, 221, 1006, 26688, 20649, 14, 262, 1978, 7970, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 634, 275, 1852, 63, 1832, 63, 515, 398, 327, 4389, 8097, 570, 769, 267, 570, 63, 513, 14, 279, 12059, 83, 275, 788, 1421, 14, 2791, 297, 283, 745, 297, 283, 15987, 297, 283, 13672, 14, 2424, 297, 2892, 283, 1506, 548, 14, 4128, 297, 2892, 327, 26148, 1630, 440, 2457, 734, 23563, 6602, 12, 2892, 327, 652, 1159, 26644, 626, 1630, 2892, 634, 5175, 9208, 15, 2019, 13, 1188, 14, 2424, 659, 2892, 634, 360, 2966, 15, 368, 14, 2424, 659, 2892, 634, 360, 2966, 15, 5601, 14, 2424, 659, 2892, 634, 360, 2966, 15, 1725, 14, 88, 659, 2892, 634, 360, 2966, 15, 1681, 14, 2791, 659, 2892, 634, 360, 70, 15, 79, 15, 70, 14, 1534, 659, 2892, 634, 360, 694, 15, 926, 856, 13, 368, 659, 2892, 634, 360, 694, 15, 694, 18, 15, 926, 856, 18, 659, 2892, 634, 360, 694, 19, 15, 745, 659, 2892, 634, 360, 694, 19, 15, 954, 15, 745, 14, 2424, 659, 2490, 1622, 398, 367, 1004, 315, 26688, 20649, 63, 568, 14, 1294, 2258, 78, 735, 288, 340, 1004, 14, 1913, 342, 508, 8061, 355, 1980, 288, 570, 63, 513, 14, 1412, 63, 1160, 63, 604, 8, 604, 9, 398, 13632, 275, 788, 745, 297, 2116, 283, 1506, 548, 14, 4128, 297, 2116, 283, 13672, 14, 2424, 297, 2116, 634, 5175, 9208, 15, 2019, 13, 1188, 14, 2424, 659, 2116, 634, 360, 2966, 15, 368, 14, 2424, 659, 2116, 634, 360, 2966, 15, 5601, 14, 2424, 659, 2116, 634, 360, 70, 15, 79, 15, 70, 14, 1534, 659, 2116, 634, 360, 694, 15, 926, 856, 13, 368, 659, 2116, 634, 360, 694, 15, 694, 18, 15, 926, 856, 18, 659, 326, 1622, 398, 291, 14, 629, 8, 493, 63, 513, 14, 1725, 12, 13632, 9, 339, 347, 511, 63, 1757, 63, 1361, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 543, 17487, 63, 2703, 342, 465, 3839, 26, 288, 570, 63, 513, 14, 1757, 63, 1361, 360, 10013, 358, 267, 291, 14, 629, 8, 2703, 14, 7150, 1062, 4074, 398, 3105, 14, 5287, 275, 715, 267, 862, 26, 288, 543, 17487, 63, 2703, 342, 465, 3839, 26, 355, 570, 63, 513, 14, 1757, 63, 1361, 360, 10013, 358, 288, 291, 14, 629, 8, 2703, 14, 7150, 1062, 283, 10013, 60, 78, 358, 267, 3753, 26, 288, 3105, 14, 5287, 275, 756, 339, 347, 511, 63, 409, 63, 279, 12059, 83, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 1584, 275, 788, 65, 297, 283, 66, 297, 283, 67, 418, 267, 570, 63, 513, 14, 409, 63, 279, 12059, 83, 8, 1725, 9, 267, 291, 14, 629, 8, 493, 63, 513, 14, 279, 12059, 83, 12, 1584, 9, 339, 347, 511, 63, 2168, 63, 18563, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 570, 63, 513, 14, 1725, 275, 788, 65, 297, 283, 66 ]
[ 2925, 367, 7065, 14, 14964, 1041, 199, 646, 747, 199, 646, 295, 199, 646, 2882, 199, 504, 7065, 492, 3105, 199, 504, 7065, 14, 793, 492, 13253, 46, 199, 504, 7065, 14, 2550, 492, 12577, 4231, 547, 199, 504, 7065, 14, 14964, 492, 5739, 63, 475, 63, 264, 12, 9028, 63, 3401, 12, 3814, 1296, 199, 199, 504, 511, 14, 396, 63, 4058, 492, 17487, 63, 2703, 12, 1255, 63, 2796, 199, 504, 7065, 14, 2219, 492, 2291, 199, 199, 24067, 63, 568, 275, 9638, 199, 2613, 4112, 199, 2613, 671, 79, 199, 5473, 671, 79, 199, 2613, 3925, 14, 2791, 199, 2613, 1900, 548, 14, 4128, 199, 2966, 13, 2613, 23588, 88, 199, 2966, 13, 2613, 23588, 2424, 199, 2966, 13, 5473, 23588, 2791, 199, 9931, 13, 2613, 289, 23588, 1534, 199, 9931, 13, 5473, 2288, 23588, 88, 199, 926, 856, 2935, 199, 22268, 2935, 19, 199, 624, 421, 199, 318, 1852, 63, 1832, 63, 515, 8, 83, 304, 272, 408, 17729, 7324, 315, 282, 1059, 370, 747, 14, 4127, 624, 272, 372, 308, 14, 1814, 10998, 747, 14, 4127, 9, 421, 199, 533, 3814, 1296, 1746, 8, 4058, 14, 14054, 51, 441, 78, 2247, 12, 2432, 2882, 14, 1746, 304, 339, 347, 702, 1944, 15921, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 362, 63, 7270, 8, 17449, 395, 3073, 267, 291, 14, 3584, 63, 7270, 342, 339, 347, 702, 15921, 8, 277, 304, 267, 291, 14, 15070, 8, 552, 8, 277, 14, 362, 63, 7270, 8, 17449, 1826, 378, 9, 267, 291, 14, 3584, 63, 7270, 342, 339, 347, 511, 63, 6463, 63, 475, 63, 264, 8, 277, 304, 267, 7375, 275, 747, 14, 4127, 267, 340, 747, 14, 4127, 508, 29082, 288, 7375, 275, 295, 14, 3765, 8, 736, 14, 4127, 9, 398, 367, 5739, 12, 5163, 315, 334, 288, 327, 3486, 5560, 288, 661, 1421, 7693, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 661, 1421, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 661, 1421, 31, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 327, 4539, 5560, 288, 334, 82, 7, 1421, 1103, 7693, 519, 7, 1421, 8712, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 334, 82, 7, 1421, 9780, 7693, 519, 7, 1421, 8712, 1103, 4735, 2840, 4127, 9, 83, 25739, 58, 2229, 706, 11218, 288, 661, 1421, 10674, 31, 7044, 519, 7, 1421, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 11218, 288, 334, 82, 7, 1421, 1103, 31, 7044, 519, 7, 1421, 8712, 4735, 2840, 4127, 9, 83, 1527, 62, 2840, 4127, 9, 83, 7272, 58, 2229, 706, 5942, 304, 288, 5163, 275, 5163, 450, 791, 4127, 356, 7375, 93, 288, 291, 14, 629, 8, 6463, 63, 475, 63, 264, 8, 6463, 395, 5163, 9, 339, 347, 511, 63, 1412, 63, 1160, 63, 604, 8, 277, 304, 267, 327, 5343, 221, 1006, 26688, 20649, 14, 262, 1978, 7970, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 634, 275, 1852, 63, 1832, 63, 515, 398, 327, 4389, 8097, 570, 769, 267, 570, 63, 513, 14, 279, 12059, 83, 275, 788, 1421, 14, 2791, 297, 283, 745, 297, 283, 15987, 297, 283, 13672, 14, 2424, 297, 2892, 283, 1506, 548, 14, 4128, 297, 2892, 327, 26148, 1630, 440, 2457, 734, 23563, 6602, 12, 2892, 327, 652, 1159, 26644, 626, 1630, 2892, 634, 5175, 9208, 15, 2019, 13, 1188, 14, 2424, 659, 2892, 634, 360, 2966, 15, 368, 14, 2424, 659, 2892, 634, 360, 2966, 15, 5601, 14, 2424, 659, 2892, 634, 360, 2966, 15, 1725, 14, 88, 659, 2892, 634, 360, 2966, 15, 1681, 14, 2791, 659, 2892, 634, 360, 70, 15, 79, 15, 70, 14, 1534, 659, 2892, 634, 360, 694, 15, 926, 856, 13, 368, 659, 2892, 634, 360, 694, 15, 694, 18, 15, 926, 856, 18, 659, 2892, 634, 360, 694, 19, 15, 745, 659, 2892, 634, 360, 694, 19, 15, 954, 15, 745, 14, 2424, 659, 2490, 1622, 398, 367, 1004, 315, 26688, 20649, 63, 568, 14, 1294, 2258, 78, 735, 288, 340, 1004, 14, 1913, 342, 508, 8061, 355, 1980, 288, 570, 63, 513, 14, 1412, 63, 1160, 63, 604, 8, 604, 9, 398, 13632, 275, 788, 745, 297, 2116, 283, 1506, 548, 14, 4128, 297, 2116, 283, 13672, 14, 2424, 297, 2116, 634, 5175, 9208, 15, 2019, 13, 1188, 14, 2424, 659, 2116, 634, 360, 2966, 15, 368, 14, 2424, 659, 2116, 634, 360, 2966, 15, 5601, 14, 2424, 659, 2116, 634, 360, 70, 15, 79, 15, 70, 14, 1534, 659, 2116, 634, 360, 694, 15, 926, 856, 13, 368, 659, 2116, 634, 360, 694, 15, 694, 18, 15, 926, 856, 18, 659, 326, 1622, 398, 291, 14, 629, 8, 493, 63, 513, 14, 1725, 12, 13632, 9, 339, 347, 511, 63, 1757, 63, 1361, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 543, 17487, 63, 2703, 342, 465, 3839, 26, 288, 570, 63, 513, 14, 1757, 63, 1361, 360, 10013, 358, 267, 291, 14, 629, 8, 2703, 14, 7150, 1062, 4074, 398, 3105, 14, 5287, 275, 715, 267, 862, 26, 288, 543, 17487, 63, 2703, 342, 465, 3839, 26, 355, 570, 63, 513, 14, 1757, 63, 1361, 360, 10013, 358, 288, 291, 14, 629, 8, 2703, 14, 7150, 1062, 283, 10013, 60, 78, 358, 267, 3753, 26, 288, 3105, 14, 5287, 275, 756, 339, 347, 511, 63, 409, 63, 279, 12059, 83, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 1584, 275, 788, 65, 297, 283, 66, 297, 283, 67, 418, 267, 570, 63, 513, 14, 409, 63, 279, 12059, 83, 8, 1725, 9, 267, 291, 14, 629, 8, 493, 63, 513, 14, 279, 12059, 83, 12, 1584, 9, 339, 347, 511, 63, 2168, 63, 18563, 8, 277, 304, 267, 570, 63, 513, 275, 3814, 1296, 342, 267, 570, 63, 513, 14, 1725, 275, 788, 65, 297, 283, 66, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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future__ import print_function from __future__ import division from __future__ import absolute_import import tensorflow as tf import csv def catClassification_loader(path): cat_names = ['Abyssinian','Bengal','Birman','Bombay','British_Shorthair', 'Egyptian_Mau','Maine_Coon','Persian','Ragdoll','Russian_Blue', 'Siamese','Sphynx'] cat_dict = dict(zip(cat_names,range(len(cat_names)))) labels_list, filename_list = [], [] with open(path,mode = 'r') as csvfile: reader = csv.reader(csvfile, delimiter = ',') for row in reader: labels_list.append(cat_dict[row[0]]) filename_list.append(row[1]) labels_list = tf.convert_to_tensor(labels_list) images_list = tf.convert_to_tensor(filename_list) filename_queue = tf.train.slice_input_producer([labels_list,images_list], shuffle=True) label = filename_queue[0] filename = filename_queue[1] raw_image = tf.read_file(filename) image = tf.image.decode_jpeg(raw_image, channels = 3) cat_dict = dict(zip(cat_dict.values(),cat_dict.keys())) return image, label, cat_dict # image = tf.image.resize_images(image,image_size, # method = tf.image.ResizeMethod.BILINEAR, # align_corners= True) # image = tf.cast(image, tf.uint8) # # batch_size = batch_size # # capacity = min_after_dequeue + 3 * batch_size # # image_batch, label_batch = tf.train.shuffle_batch([image,label], # batch_size = batch_size, # capacity = capacity, # min_after_dequeue = min_after_dequeue, # num_threads=num_threads) # return image_batch,label_batch
mit
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 202, 199, 504, 636, 2443, 363, 492, 4629, 202, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 8065, 199, 646, 3228, 465, 2833, 202, 199, 646, 7392, 10060, 8065, 199, 318, 6230, 28362, 63, 3422, 8, 515, 304, 1128, 6230, 63, 1247, 275, 788, 33, 991, 385, 2730, 290, 1673, 34, 7420, 279, 1673, 34, 723, 1237, 1673, 34, 676, 19558, 1673, 34, 322, 23184, 63, 2662, 11297, 8387, 297, 17554, 283, 37, 6179, 23035, 63, 45, 3844, 1673, 11903, 1132, 63, 967, 265, 1673, 2623, 6214, 1673, 50, 643, 68, 14385, 1673, 50, 8630, 63, 15617, 297, 17554, 283, 18934, 313, 261, 1673, 51, 838, 1236, 88, 418, 1128, 6230, 63, 807, 275, 1211, 8, 3065, 8, 3385, 63, 1247, 12, 1842, 8, 552, 8, 3385, 63, 1247, 7845, 11787, 3628, 63, 513, 12, 1788, 63, 513, 275, 990, 942, 11787, 543, 1551, 8, 515, 12, 632, 275, 283, 82, 358, 465, 7392, 493, 26, 1039, 7002, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 275, 1656, 358, 1039, 367, 1962, 315, 7002, 26, 1675, 3628, 63, 513, 14, 740, 8, 3385, 63, 807, 59, 1143, 59, 16, 3934, 1675, 1788, 63, 513, 14, 740, 8, 1143, 59, 17, 566, 11787, 3628, 63, 513, 275, 2833, 14, 3916, 63, 475, 63, 3128, 8, 3512, 63, 513, 9, 1128, 5935, 63, 513, 275, 2833, 14, 3916, 63, 475, 63, 3128, 8, 1501, 63, 513, 9, 8428, 1223, 11787, 1788, 63, 1825, 275, 2833, 14, 2834, 14, 5224, 63, 1210, 63, 16376, 779, 3512, 63, 513, 12, 4782, 63, 513, 467, 13031, 29, 549, 9, 11787, 1768, 275, 1788, 63, 1825, 59, 16, 61, 1128, 1788, 275, 1788, 63, 1825, 59, 17, 61, 11787, 3066, 63, 1569, 275, 2833, 14, 739, 63, 493, 8, 1501, 9, 1128, 1834, 275, 2833, 14, 1569, 14, 2708, 63, 14230, 8, 1773, 63, 1569, 12, 9245, 275, 650, 9, 8428, 11787, 6230, 63, 807, 275, 1211, 8, 3065, 8, 3385, 63, 807, 14, 1459, 1062, 3385, 63, 807, 14, 1612, 4059, 1128, 372, 1834, 12, 1768, 12, 6230, 63, 807, 2999, 199, 3, 259, 1834, 275, 2833, 14, 1569, 14, 8709, 63, 4782, 8, 1569, 12, 1569, 63, 890, 12, 202, 199, 3, 15530, 1083, 275, 2833, 14, 1569, 14, 24559, 3767, 14, 34, 1193, 3565, 689, 12, 202, 199, 3, 15530, 6998, 63, 30652, 29, 715, 9, 202, 199, 3, 259, 1834, 275, 2833, 14, 2931, 8, 1569, 12, 2833, 14, 1635, 24, 9, 202, 199, 3, 263, 202, 199, 3, 259, 3522, 63, 890, 275, 3522, 63, 890, 202, 199, 3, 202, 199, 3, 259, 14893, 275, 1748, 63, 4399, 63, 18522, 435, 650, 627, 3522, 63, 890, 202, 199, 3, 258, 202, 199, 3, 259, 1834, 63, 2912, 12, 1768, 63, 2912, 275, 2833, 14, 2834, 14, 11777, 63, 2912, 779, 1569, 12, 1302, 467, 20712, 199, 3, 2476, 4519, 3522, 63, 890, 275, 3522, 63, 890, 12, 202, 199, 3, 2476, 4519, 14893, 275, 14893, 12, 202, 199, 3, 2476, 4519, 1748, 63, 4399, 63, 18522, 275, 1748, 63, 4399, 63, 18522, 12, 202, 199, 3, 2476, 4519, 1967, 63, 6962, 29, 1507, 63, 6962, 9, 202, 199, 3, 259, 372, 1834, 63, 2912, 12, 1302, 63, 2912, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 202, 199, 504, 636, 2443, 363, 492, 4629, 202, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 8065, 199, 646, 3228, 465, 2833, 202, 199, 646, 7392, 10060, 8065, 199, 318, 6230, 28362, 63, 3422, 8, 515, 304, 1128, 6230, 63, 1247, 275, 788, 33, 991, 385, 2730, 290, 1673, 34, 7420, 279, 1673, 34, 723, 1237, 1673, 34, 676, 19558, 1673, 34, 322, 23184, 63, 2662, 11297, 8387, 297, 17554, 283, 37, 6179, 23035, 63, 45, 3844, 1673, 11903, 1132, 63, 967, 265, 1673, 2623, 6214, 1673, 50, 643, 68, 14385, 1673, 50, 8630, 63, 15617, 297, 17554, 283, 18934, 313, 261, 1673, 51, 838, 1236, 88, 418, 1128, 6230, 63, 807, 275, 1211, 8, 3065, 8, 3385, 63, 1247, 12, 1842, 8, 552, 8, 3385, 63, 1247, 7845, 11787, 3628, 63, 513, 12, 1788, 63, 513, 275, 990, 942, 11787, 543, 1551, 8, 515, 12, 632, 275, 283, 82, 358, 465, 7392, 493, 26, 1039, 7002, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 275, 1656, 358, 1039, 367, 1962, 315, 7002, 26, 1675, 3628, 63, 513, 14, 740, 8, 3385, 63, 807, 59, 1143, 59, 16, 3934, 1675, 1788, 63, 513, 14, 740, 8, 1143, 59, 17, 566, 11787, 3628, 63, 513, 275, 2833, 14, 3916, 63, 475, 63, 3128, 8, 3512, 63, 513, 9, 1128, 5935, 63, 513, 275, 2833, 14, 3916, 63, 475, 63, 3128, 8, 1501, 63, 513, 9, 8428, 1223, 11787, 1788, 63, 1825, 275, 2833, 14, 2834, 14, 5224, 63, 1210, 63, 16376, 779, 3512, 63, 513, 12, 4782, 63, 513, 467, 13031, 29, 549, 9, 11787, 1768, 275, 1788, 63, 1825, 59, 16, 61, 1128, 1788, 275, 1788, 63, 1825, 59, 17, 61, 11787, 3066, 63, 1569, 275, 2833, 14, 739, 63, 493, 8, 1501, 9, 1128, 1834, 275, 2833, 14, 1569, 14, 2708, 63, 14230, 8, 1773, 63, 1569, 12, 9245, 275, 650, 9, 8428, 11787, 6230, 63, 807, 275, 1211, 8, 3065, 8, 3385, 63, 807, 14, 1459, 1062, 3385, 63, 807, 14, 1612, 4059, 1128, 372, 1834, 12, 1768, 12, 6230, 63, 807, 2999, 199, 3, 259, 1834, 275, 2833, 14, 1569, 14, 8709, 63, 4782, 8, 1569, 12, 1569, 63, 890, 12, 202, 199, 3, 15530, 1083, 275, 2833, 14, 1569, 14, 24559, 3767, 14, 34, 1193, 3565, 689, 12, 202, 199, 3, 15530, 6998, 63, 30652, 29, 715, 9, 202, 199, 3, 259, 1834, 275, 2833, 14, 2931, 8, 1569, 12, 2833, 14, 1635, 24, 9, 202, 199, 3, 263, 202, 199, 3, 259, 3522, 63, 890, 275, 3522, 63, 890, 202, 199, 3, 202, 199, 3, 259, 14893, 275, 1748, 63, 4399, 63, 18522, 435, 650, 627, 3522, 63, 890, 202, 199, 3, 258, 202, 199, 3, 259, 1834, 63, 2912, 12, 1768, 63, 2912, 275, 2833, 14, 2834, 14, 11777, 63, 2912, 779, 1569, 12, 1302, 467, 20712, 199, 3, 2476, 4519, 3522, 63, 890, 275, 3522, 63, 890, 12, 202, 199, 3, 2476, 4519, 14893, 275, 14893, 12, 202, 199, 3, 2476, 4519, 1748, 63, 4399, 63, 18522, 275, 1748, 63, 4399, 63, 18522, 12, 202, 199, 3, 2476, 4519, 1967, 63, 6962, 29, 1507, 63, 6962, 9, 202, 199, 3, 259, 372, 1834, 63, 2912, 12, 1302, 63, 2912, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1,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/python2.7/site-packages/django/db/utils.py
15
11769
from importlib import import_module import os import pkgutil from threading import local import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning from django.utils.functional import cached_property from django.utils.module_loading import import_string from django.utils._os import upath from django.utils import six DEFAULT_DB_ALIAS = 'default' class Error(Exception if six.PY3 else StandardError): pass class InterfaceError(Error): pass class DatabaseError(Error): pass class DataError(DatabaseError): pass class OperationalError(DatabaseError): pass class IntegrityError(DatabaseError): pass class InternalError(DatabaseError): pass class ProgrammingError(DatabaseError): pass class NotSupportedError(DatabaseError): pass class DatabaseErrorWrapper(object): """ Context manager and decorator that re-throws backend-specific database exceptions using Django's common wrappers. """ def __init__(self, wrapper): """ wrapper is a database wrapper. It must have a Database attribute defining PEP-249 exceptions. """ self.wrapper = wrapper def __enter__(self): pass def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: return for dj_exc_type in ( DataError, OperationalError, IntegrityError, InternalError, ProgrammingError, NotSupportedError, DatabaseError, InterfaceError, Error, ): db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__) if issubclass(exc_type, db_exc_type): dj_exc_value = dj_exc_type(*exc_value.args) dj_exc_value.__cause__ = exc_value # Only set the 'errors_occurred' flag for errors that may make # the connection unusable. if dj_exc_type not in (DataError, IntegrityError): self.wrapper.errors_occurred = True six.reraise(dj_exc_type, dj_exc_value, traceback) def __call__(self, func): # Note that we are intentionally not using @wraps here for performance # reasons. Refs #21109. def inner(*args, **kwargs): with self: return func(*args, **kwargs) return inner def load_backend(backend_name): # Look for a fully qualified database backend name try: return import_module('%s.base' % backend_name) except ImportError as e_user: # The database backend wasn't found. Display a helpful error message # listing all possible (built-in) database backends. backend_dir = os.path.join(os.path.dirname(upath(__file__)), 'backends') try: builtin_backends = [ name for _, name, ispkg in pkgutil.iter_modules([backend_dir]) if ispkg and name != 'dummy'] except EnvironmentError: builtin_backends = [] if backend_name not in ['django.db.backends.%s' % b for b in builtin_backends]: backend_reprs = map(repr, sorted(builtin_backends)) error_msg = ("%r isn't an available database backend.\n" "Try using 'django.db.backends.XXX', where XXX " "is one of:\n %s\nError was: %s" % (backend_name, ", ".join(backend_reprs), e_user)) raise ImproperlyConfigured(error_msg) else: # If there's some other error, this must be an error in Django raise class ConnectionDoesNotExist(Exception): pass class ConnectionHandler(object): def __init__(self, databases=None): """ databases is an optional dictionary of database definitions (structured like settings.DATABASES). """ self._databases = databases self._connections = local() @cached_property def databases(self): if self._databases is None: self._databases = settings.DATABASES if self._databases == {}: self._databases = { DEFAULT_DB_ALIAS: { 'ENGINE': 'django.db.backends.dummy', }, } if DEFAULT_DB_ALIAS not in self._databases: raise ImproperlyConfigured("You must define a '%s' database" % DEFAULT_DB_ALIAS) return self._databases def ensure_defaults(self, alias): """ Puts the defaults into the settings dictionary for a given connection where no settings is provided. """ try: conn = self.databases[alias] except KeyError: raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias) conn.setdefault('ATOMIC_REQUESTS', False) if settings.TRANSACTIONS_MANAGED: warnings.warn( "TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.", RemovedInDjango18Warning, stacklevel=2) conn.setdefault('AUTOCOMMIT', False) conn.setdefault('AUTOCOMMIT', True) conn.setdefault('ENGINE', 'django.db.backends.dummy') if conn['ENGINE'] == 'django.db.backends.' or not conn['ENGINE']: conn['ENGINE'] = 'django.db.backends.dummy' conn.setdefault('CONN_MAX_AGE', 0) conn.setdefault('OPTIONS', {}) conn.setdefault('TIME_ZONE', 'UTC' if settings.USE_TZ else settings.TIME_ZONE) for setting in ['NAME', 'USER', 'PASSWORD', 'HOST', 'PORT']: conn.setdefault(setting, '') TEST_SETTING_RENAMES = { 'CREATE': 'CREATE_DB', 'USER_CREATE': 'CREATE_USER', 'PASSWD': 'PASSWORD', } TEST_SETTING_RENAMES_REVERSE = {v: k for k, v in TEST_SETTING_RENAMES.items()} def prepare_test_settings(self, alias): """ Makes sure the test settings are available in the 'TEST' sub-dictionary. """ try: conn = self.databases[alias] except KeyError: raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias) test_dict_set = 'TEST' in conn test_settings = conn.setdefault('TEST', {}) old_test_settings = {} for key, value in six.iteritems(conn): if key.startswith('TEST_'): new_key = key[5:] new_key = self.TEST_SETTING_RENAMES.get(new_key, new_key) old_test_settings[new_key] = value if old_test_settings: if test_dict_set: if test_settings != old_test_settings: raise ImproperlyConfigured( "Connection '%s' has mismatched TEST and TEST_* " "database settings." % alias) else: test_settings.update(old_test_settings) for key, _ in six.iteritems(old_test_settings): warnings.warn("In Django 1.9 the %s connection setting will be moved " "to a %s entry in the TEST setting" % (self.TEST_SETTING_RENAMES_REVERSE.get(key, key), key), RemovedInDjango19Warning, stacklevel=2) for key in list(conn.keys()): if key.startswith('TEST_'): del conn[key] # Check that they didn't just use the old name with 'TEST_' removed for key, new_key in six.iteritems(self.TEST_SETTING_RENAMES): if key in test_settings: warnings.warn("Test setting %s was renamed to %s; specified value (%s) ignored" % (key, new_key, test_settings[key]), stacklevel=2) for key in ['CHARSET', 'COLLATION', 'NAME', 'MIRROR']: test_settings.setdefault(key, None) def __getitem__(self, alias): if hasattr(self._connections, alias): return getattr(self._connections, alias) self.ensure_defaults(alias) self.prepare_test_settings(alias) db = self.databases[alias] backend = load_backend(db['ENGINE']) conn = backend.DatabaseWrapper(db, alias) setattr(self._connections, alias, conn) return conn def __setitem__(self, key, value): setattr(self._connections, key, value) def __delitem__(self, key): delattr(self._connections, key) def __iter__(self): return iter(self.databases) def all(self): return [self[alias] for alias in self] class ConnectionRouter(object): def __init__(self, routers=None): """ If routers is not specified, will default to settings.DATABASE_ROUTERS. """ self._routers = routers @cached_property def routers(self): if self._routers is None: self._routers = settings.DATABASE_ROUTERS routers = [] for r in self._routers: if isinstance(r, six.string_types): router = import_string(r)() else: router = r routers.append(router) return routers def _router_func(action): def _route_db(self, model, **hints): chosen_db = None for router in self.routers: try: method = getattr(router, action) except AttributeError: # If the router doesn't have a method, skip to the next one. pass else: chosen_db = method(model, **hints) if chosen_db: return chosen_db try: return hints['instance']._state.db or DEFAULT_DB_ALIAS except KeyError: return DEFAULT_DB_ALIAS return _route_db db_for_read = _router_func('db_for_read') db_for_write = _router_func('db_for_write') def allow_relation(self, obj1, obj2, **hints): for router in self.routers: try: method = router.allow_relation except AttributeError: # If the router doesn't have a method, skip to the next one. pass else: allow = method(obj1, obj2, **hints) if allow is not None: return allow return obj1._state.db == obj2._state.db def allow_migrate(self, db, model): for router in self.routers: try: try: method = router.allow_migrate except AttributeError: method = router.allow_syncdb warnings.warn( 'Router.allow_syncdb has been deprecated and will stop working in Django 1.9. ' 'Rename the method to allow_migrate.', RemovedInDjango19Warning, stacklevel=2) except AttributeError: # If the router doesn't have a method, skip to the next one. pass else: allow = method(db, model) if allow is not None: return allow return True def get_migratable_models(self, app_config, db, include_auto_created=False): """ Return app models allowed to be synchronized on provided db. """ models = app_config.get_models(include_auto_created=include_auto_created) return [model for model in models if self.allow_migrate(db, model)]
apache-2.0
[ 504, 14802, 492, 492, 63, 578, 199, 646, 747, 199, 646, 28728, 199, 504, 5796, 492, 2257, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 12, 23687, 1167, 3849, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 3472, 63, 2846, 63, 12644, 275, 283, 885, 7, 421, 199, 533, 4520, 8, 1726, 340, 3816, 14, 4521, 19, 587, 29912, 304, 272, 986, 421, 199, 533, 14816, 547, 8, 547, 304, 272, 986, 421, 199, 533, 27728, 8, 547, 304, 272, 986, 421, 199, 533, 3918, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 6654, 6279, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 26864, 8, 25198, 304, 272, 986, 421, 199, 533, 12624, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 2165, 9258, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 2832, 10682, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 27728, 4590, 8, 785, 304, 272, 408, 272, 9470, 5256, 436, 7531, 626, 295, 13, 32229, 4865, 13, 6100, 3050, 272, 4967, 1808, 5634, 1159, 2863, 17995, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4975, 304, 267, 408, 267, 4975, 365, 282, 3050, 4975, 14, 398, 2779, 1471, 1172, 282, 8692, 2225, 12669, 13663, 13, 11032, 4967, 14, 267, 408, 267, 291, 14, 5029, 275, 4975, 339, 347, 636, 4200, 721, 277, 304, 267, 986, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 267, 340, 3178, 63, 466, 365, 488, 26, 288, 372, 267, 367, 366, 74, 63, 2804, 63, 466, 315, 334, 355, 3918, 547, 12, 355, 6654, 6279, 547, 12, 355, 26864, 12, 355, 12624, 547, 12, 355, 2165, 9258, 547, 12, 355, 2832, 10682, 547, 12, 355, 27728, 12, 355, 14816, 547, 12, 355, 4520, 12, 267, 3461, 288, 1592, 63, 2804, 63, 466, 275, 2519, 8, 277, 14, 5029, 14, 7243, 12, 366, 74, 63, 2804, 63, 466, 855, 354, 3368, 288, 340, 11602, 8, 2804, 63, 466, 12, 1592, 63, 2804, 63, 466, 304, 355, 366, 74, 63, 2804, 63, 585, 275, 366, 74, 63, 2804, 63, 466, 2031, 2804, 63, 585, 14, 589, 9, 355, 366, 74, 63, 2804, 63, 585, 855, 2651, 363, 275, 3178, 63, 585, 355, 327, 5972, 663, 314, 283, 2550, 63, 20051, 581, 7, 3305, 367, 2552, 626, 1443, 1852, 355, 327, 314, 1950, 625, 14418, 14, 355, 340, 366, 74, 63, 2804, 63, 466, 440, 315, 334, 1451, 547, 12, 26864, 304, 490, 291, 14, 5029, 14, 2550, 63, 20051, 581, 275, 715, 355, 3816, 14, 20614, 8, 18256, 63, 2804, 63, 466, 12, 366, 74, 63, 2804, 63, 585, 12, 5190, 9, 339, 347, 636, 1250, 721, 277, 12, 2562, 304, 267, 327, 3390, 626, 781, 787, 32005, 440, 1808, 768, 13582, 2348, 367, 10238, 267, 327, 14872, 14, 22165, 327, 2025, 6996, 14, 267, 347, 6506, 2031, 589, 12, 1011, 958, 304, 288, 543, 291, 26, 355, 372, 2562, 2031, 589, 12, 1011, 958, 9, 267, 372, 6506, 421, 199, 318, 2248, 63, 4620, 8, 4620, 63, 354, 304, 272, 327, 12077, 367, 282, 9999, 12313, 3050, 4865, 536, 272, 862, 26, 267, 372, 492, 63, 578, 3508, 83, 14, 1095, 7, 450, 4865, 63, 354, 9, 272, 871, 3545, 465, 325, 63, 751, 26, 267, 327, 710, 3050, 4865, 17373, 1133, 1911, 14, 12175, 282, 24606, 1125, 1245, 267, 327, 13778, 1006, 3962, 334, 11730, 13, 262, 9, 3050, 14745, 14, 267, 4865, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 7765, 358, 267, 862, 26, 288, 6762, 63, 7765, 275, 359, 355, 536, 367, 5501, 536, 12, 365, 4600, 315, 28728, 14, 1661, 63, 3112, 779, 4620, 63, 694, 566, 355, 340, 365, 4600, 436, 536, 1137, 283, 5869, 418, 267, 871, 25139, 26, 288, 6762, 63, 7765, 275, 942, 267, 340, 4865, 63, 354, 440, 315, 788, 1176, 14, 697, 14, 7765, 4111, 83, 7, 450, 330, 367, 330, 315, 1816, 6762, 63, 7765, 2189, 288, 4865, 63, 1155, 2393, 275, 2341, 8, 2722, 12, 3355, 8, 5351, 63, 7765, 430, 288, 1125, 63, 1328, 275, 19426, 82, 5712, 1133, 376, 2808, 3050, 4865, 3134, 78, 2, 586, 298, 12357, 1808, 283, 1176, 14, 697, 14, 7765, 14, 13933, 297, 2382, 5787, 298, 586, 298, 374, 1373, 402, 3427, 78, 259, 450, 83, 60, 78, 547, 1990, 26, 450, 83, 2, 450, 586, 334, 4620, 63, 354, 12, 3872, 3680, 904, 8, 4620, 63, 1155, 2393, 395, 325, 63, 751, 430, 288, 746, 11897, 8, 705, 63, 1328, 9, 267, 587, 26, 288, 327, 982, 2337, 1159, 2005, 1163, 1125, 12, 642, 1471, 506, 376, 1125, 315, 5634, 288, 746, 421, 199, 533, 8113, 7400, 8, 1726, 304, 272, 986, 421, 199, 533, 8113, 2461, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 16219, 29, 403, 304, 267, 408, 267, 16219, 365, 376, 2716, 2600, 402, 3050, 10269, 334, 15774, 267, 2839, 2202, 14, 27260, 680, 267, 408, 267, 291, 423, 17439, 275, 16219, 267, 291, 423, 7995, 275, 2257, 342, 339, 768, 5245, 63, 1829, 272, 347, 16219, 8, 277, 304, 267, 340, 291, 423, 17439, 365, 488, 26, 288, 291, 423, 17439, 275, 2202, 14, 27260, 267, 340, 291, 423, 17439, 508, 24702, 288, 291, 423, 17439, 275, 469, 355, 6186, 63, 2846, 63, 12644, 26, 469, 490, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 5869, 297, 355, 1660, 288, 789, 267, 340, 6186, 63, 2846, 63, 12644, 440, 315, 291, 423, 17439, 26, 288, 746, 11897, 480, 5556, 1471, 5627, 282, 1543, 83, 7, 3050, 2, 450, 6186, 63, 2846, 63, 12644, 9, 267, 372, 291, 423, 17439, 339, 347, 4868, 63, 4322, 8, 277, 12, 5162, 304, 267, 408 ]
[ 14802, 492, 492, 63, 578, 199, 646, 747, 199, 646, 28728, 199, 504, 5796, 492, 2257, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1208, 14, 15383, 492, 23687, 1085, 3849, 12, 23687, 1167, 3849, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 3472, 63, 2846, 63, 12644, 275, 283, 885, 7, 421, 199, 533, 4520, 8, 1726, 340, 3816, 14, 4521, 19, 587, 29912, 304, 272, 986, 421, 199, 533, 14816, 547, 8, 547, 304, 272, 986, 421, 199, 533, 27728, 8, 547, 304, 272, 986, 421, 199, 533, 3918, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 6654, 6279, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 26864, 8, 25198, 304, 272, 986, 421, 199, 533, 12624, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 2165, 9258, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 2832, 10682, 547, 8, 25198, 304, 272, 986, 421, 199, 533, 27728, 4590, 8, 785, 304, 272, 408, 272, 9470, 5256, 436, 7531, 626, 295, 13, 32229, 4865, 13, 6100, 3050, 272, 4967, 1808, 5634, 1159, 2863, 17995, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4975, 304, 267, 408, 267, 4975, 365, 282, 3050, 4975, 14, 398, 2779, 1471, 1172, 282, 8692, 2225, 12669, 13663, 13, 11032, 4967, 14, 267, 408, 267, 291, 14, 5029, 275, 4975, 339, 347, 636, 4200, 721, 277, 304, 267, 986, 339, 347, 636, 2224, 721, 277, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 5190, 304, 267, 340, 3178, 63, 466, 365, 488, 26, 288, 372, 267, 367, 366, 74, 63, 2804, 63, 466, 315, 334, 355, 3918, 547, 12, 355, 6654, 6279, 547, 12, 355, 26864, 12, 355, 12624, 547, 12, 355, 2165, 9258, 547, 12, 355, 2832, 10682, 547, 12, 355, 27728, 12, 355, 14816, 547, 12, 355, 4520, 12, 267, 3461, 288, 1592, 63, 2804, 63, 466, 275, 2519, 8, 277, 14, 5029, 14, 7243, 12, 366, 74, 63, 2804, 63, 466, 855, 354, 3368, 288, 340, 11602, 8, 2804, 63, 466, 12, 1592, 63, 2804, 63, 466, 304, 355, 366, 74, 63, 2804, 63, 585, 275, 366, 74, 63, 2804, 63, 466, 2031, 2804, 63, 585, 14, 589, 9, 355, 366, 74, 63, 2804, 63, 585, 855, 2651, 363, 275, 3178, 63, 585, 355, 327, 5972, 663, 314, 283, 2550, 63, 20051, 581, 7, 3305, 367, 2552, 626, 1443, 1852, 355, 327, 314, 1950, 625, 14418, 14, 355, 340, 366, 74, 63, 2804, 63, 466, 440, 315, 334, 1451, 547, 12, 26864, 304, 490, 291, 14, 5029, 14, 2550, 63, 20051, 581, 275, 715, 355, 3816, 14, 20614, 8, 18256, 63, 2804, 63, 466, 12, 366, 74, 63, 2804, 63, 585, 12, 5190, 9, 339, 347, 636, 1250, 721, 277, 12, 2562, 304, 267, 327, 3390, 626, 781, 787, 32005, 440, 1808, 768, 13582, 2348, 367, 10238, 267, 327, 14872, 14, 22165, 327, 2025, 6996, 14, 267, 347, 6506, 2031, 589, 12, 1011, 958, 304, 288, 543, 291, 26, 355, 372, 2562, 2031, 589, 12, 1011, 958, 9, 267, 372, 6506, 421, 199, 318, 2248, 63, 4620, 8, 4620, 63, 354, 304, 272, 327, 12077, 367, 282, 9999, 12313, 3050, 4865, 536, 272, 862, 26, 267, 372, 492, 63, 578, 3508, 83, 14, 1095, 7, 450, 4865, 63, 354, 9, 272, 871, 3545, 465, 325, 63, 751, 26, 267, 327, 710, 3050, 4865, 17373, 1133, 1911, 14, 12175, 282, 24606, 1125, 1245, 267, 327, 13778, 1006, 3962, 334, 11730, 13, 262, 9, 3050, 14745, 14, 267, 4865, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 7765, 358, 267, 862, 26, 288, 6762, 63, 7765, 275, 359, 355, 536, 367, 5501, 536, 12, 365, 4600, 315, 28728, 14, 1661, 63, 3112, 779, 4620, 63, 694, 566, 355, 340, 365, 4600, 436, 536, 1137, 283, 5869, 418, 267, 871, 25139, 26, 288, 6762, 63, 7765, 275, 942, 267, 340, 4865, 63, 354, 440, 315, 788, 1176, 14, 697, 14, 7765, 4111, 83, 7, 450, 330, 367, 330, 315, 1816, 6762, 63, 7765, 2189, 288, 4865, 63, 1155, 2393, 275, 2341, 8, 2722, 12, 3355, 8, 5351, 63, 7765, 430, 288, 1125, 63, 1328, 275, 19426, 82, 5712, 1133, 376, 2808, 3050, 4865, 3134, 78, 2, 586, 298, 12357, 1808, 283, 1176, 14, 697, 14, 7765, 14, 13933, 297, 2382, 5787, 298, 586, 298, 374, 1373, 402, 3427, 78, 259, 450, 83, 60, 78, 547, 1990, 26, 450, 83, 2, 450, 586, 334, 4620, 63, 354, 12, 3872, 3680, 904, 8, 4620, 63, 1155, 2393, 395, 325, 63, 751, 430, 288, 746, 11897, 8, 705, 63, 1328, 9, 267, 587, 26, 288, 327, 982, 2337, 1159, 2005, 1163, 1125, 12, 642, 1471, 506, 376, 1125, 315, 5634, 288, 746, 421, 199, 533, 8113, 7400, 8, 1726, 304, 272, 986, 421, 199, 533, 8113, 2461, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 16219, 29, 403, 304, 267, 408, 267, 16219, 365, 376, 2716, 2600, 402, 3050, 10269, 334, 15774, 267, 2839, 2202, 14, 27260, 680, 267, 408, 267, 291, 423, 17439, 275, 16219, 267, 291, 423, 7995, 275, 2257, 342, 339, 768, 5245, 63, 1829, 272, 347, 16219, 8, 277, 304, 267, 340, 291, 423, 17439, 365, 488, 26, 288, 291, 423, 17439, 275, 2202, 14, 27260, 267, 340, 291, 423, 17439, 508, 24702, 288, 291, 423, 17439, 275, 469, 355, 6186, 63, 2846, 63, 12644, 26, 469, 490, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 5869, 297, 355, 1660, 288, 789, 267, 340, 6186, 63, 2846, 63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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
grpc/grpc
examples/python/data_transmission/demo_pb2.py
13
5424
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: demo.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor.FileDescriptor( name='demo.proto', package='demo', syntax='proto3', serialized_options=None, serialized_pb=_b('\n\ndemo.proto\x12\x04\x64\x65mo\"2\n\x07Request\x12\x11\n\tclient_id\x18\x01 \x01(\x03\x12\x14\n\x0crequest_data\x18\x02 \x01(\t\"4\n\x08Response\x12\x11\n\tserver_id\x18\x01 \x01(\x03\x12\x15\n\rresponse_data\x18\x02 \x01(\t2\xf0\x01\n\x08GRPCDemo\x12-\n\x0cSimpleMethod\x12\r.demo.Request\x1a\x0e.demo.Response\x12\x38\n\x15\x43lientStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x12\x38\n\x15ServerStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response0\x01\x12\x41\n\x1c\x42idirectionalStreamingMethod\x12\r.demo.Request\x1a\x0e.demo.Response(\x01\x30\x01\x62\x06proto3') ) _REQUEST = _descriptor.Descriptor( name='Request', full_name='demo.Request', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='client_id', full_name='demo.Request.client_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='request_data', full_name='demo.Request.request_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), ], extensions=[ ], nested_types=[], enum_types=[ ], serialized_options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=20, serialized_end=70, ) _RESPONSE = _descriptor.Descriptor( name='Response', full_name='demo.Response', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='server_id', full_name='demo.Response.server_id', index=0, number=1, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='response_data', full_name='demo.Response.response_data', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), ], extensions=[ ], nested_types=[], enum_types=[ ], serialized_options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=72, serialized_end=124, ) DESCRIPTOR.message_types_by_name['Request'] = _REQUEST DESCRIPTOR.message_types_by_name['Response'] = _RESPONSE _sym_db.RegisterFileDescriptor(DESCRIPTOR) Request = _reflection.GeneratedProtocolMessageType('Request', (_message.Message,), { 'DESCRIPTOR' : _REQUEST, '__module__' : 'demo_pb2' # @@protoc_insertion_point(class_scope:demo.Request) }) _sym_db.RegisterMessage(Request) Response = _reflection.GeneratedProtocolMessageType('Response', (_message.Message,), { 'DESCRIPTOR' : _RESPONSE, '__module__' : 'demo_pb2' # @@protoc_insertion_point(class_scope:demo.Response) }) _sym_db.RegisterMessage(Response) _GRPCDEMO = _descriptor.ServiceDescriptor( name='GRPCDemo', full_name='demo.GRPCDemo', file=DESCRIPTOR, index=0, serialized_options=None, serialized_start=127, serialized_end=367, methods=[ _descriptor.MethodDescriptor( name='SimpleMethod', full_name='demo.GRPCDemo.SimpleMethod', index=0, containing_service=None, input_type=_REQUEST, output_type=_RESPONSE, serialized_options=None, ), _descriptor.MethodDescriptor( name='ClientStreamingMethod', full_name='demo.GRPCDemo.ClientStreamingMethod', index=1, containing_service=None, input_type=_REQUEST, output_type=_RESPONSE, serialized_options=None, ), _descriptor.MethodDescriptor( name='ServerStreamingMethod', full_name='demo.GRPCDemo.ServerStreamingMethod', index=2, containing_service=None, input_type=_REQUEST, output_type=_RESPONSE, serialized_options=None, ), _descriptor.MethodDescriptor( name='BidirectionalStreamingMethod', full_name='demo.GRPCDemo.BidirectionalStreamingMethod', index=3, containing_service=None, input_type=_REQUEST, output_type=_RESPONSE, serialized_options=None, ), ]) _sym_db.RegisterServiceDescriptor(_GRPCDEMO) DESCRIPTOR.services_by_name['GRPCDemo'] = _GRPCDEMO # @@protoc_insertion_point(module_scope)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 14779, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 6905, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 8768, 14, 2625, 297, 523, 2559, 534, 8768, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 1419, 29, 403, 12, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 60, 78, 8768, 14, 2625, 60, 88, 713, 60, 88, 966, 60, 88, 772, 60, 88, 2182, 573, 4451, 18, 60, 78, 60, 88, 1780, 2017, 60, 88, 713, 60, 88, 845, 60, 78, 60, 84, 1258, 63, 344, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 1069, 63, 576, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 4451, 20, 60, 78, 60, 88, 2036, 2364, 60, 88, 713, 60, 88, 845, 60, 78, 60, 84, 1000, 63, 344, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 82, 1310, 63, 576, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 18, 60, 1949, 16, 60, 88, 614, 60, 78, 60, 88, 2036, 3975, 4222, 21493, 60, 88, 713, 2696, 78, 60, 88, 16, 67, 3184, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1046, 60, 88, 2824, 864, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 2961, 88, 614, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1046, 3120, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 16, 60, 88, 614, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 17, 67, 60, 88, 2260, 73, 21360, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 2961, 88, 614, 60, 88, 1216, 60, 88, 614, 60, 88, 2789, 60, 88, 1690, 2625, 19, 358, 199, 9, 6905, 199, 63, 6780, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 2017, 297, 523, 2615, 63, 354, 534, 8768, 14, 2017, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1258, 63, 344, 297, 2615, 63, 354, 534, 8768, 14, 2017, 14, 1258, 63, 344, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 19, 12, 7246, 63, 466, 29, 18, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 16, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1069, 63, 576, 297, 2615, 63, 354, 534, 8768, 14, 2017, 14, 1069, 63, 576, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 25, 12, 7246, 63, 466, 29, 25, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 3699, 66, 25639, 2708, 360, 1624, 13, 24, 659, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 523, 2156, 523, 5478, 1524, 523, 2156, 523, 6032, 63, 1313, 6034, 523, 4952, 63, 1313, 1524, 523, 2156, 523, 6380, 63, 1419, 29, 403, 12, 523, 365, 63, 18363, 29, 797, 12, 523, 6302, 534, 2625, 19, 297, 523, 3329, 63, 8404, 6034, 523, 20753, 1524, 523, 2156, 523, 6380, 63, 928, 29, 1165, 12, 523, 6380, 63, 500, 29, 2760, 12, 199, 9, 421, 199, 63, 12801, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 2364, 297, 523, 2615, 63, 354, 534, 8768, 14, 2364, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1000, 63, 344, 297, 2615, 63, 354, 534, 8768, 14, 2364, 14, 1000, 63, 344, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 19, 12, 7246, 63, 466, 29, 18, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 16, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1310, 63, 576, 297, 2615, 63, 354, 534, 8768, 14, 2364, 14, 1310, 63, 576, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 25, 12, 7246, 63, 466, 29, 25, 12, 1768, 29, 17, 12, 489 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 14779, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 6905, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 8768, 14, 2625, 297, 523, 2559, 534, 8768, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 1419, 29, 403, 12, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 60, 78, 8768, 14, 2625, 60, 88, 713, 60, 88, 966, 60, 88, 772, 60, 88, 2182, 573, 4451, 18, 60, 78, 60, 88, 1780, 2017, 60, 88, 713, 60, 88, 845, 60, 78, 60, 84, 1258, 63, 344, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 1069, 63, 576, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 4451, 20, 60, 78, 60, 88, 2036, 2364, 60, 88, 713, 60, 88, 845, 60, 78, 60, 84, 1000, 63, 344, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 1644, 60, 88, 713, 60, 88, 1046, 60, 78, 60, 82, 1310, 63, 576, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 18, 60, 1949, 16, 60, 88, 614, 60, 78, 60, 88, 2036, 3975, 4222, 21493, 60, 88, 713, 2696, 78, 60, 88, 16, 67, 3184, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1046, 60, 88, 2824, 864, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 2961, 88, 614, 60, 88, 713, 60, 88, 1703, 60, 78, 60, 88, 1046, 3120, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 16, 60, 88, 614, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 17, 67, 60, 88, 2260, 73, 21360, 22555, 3767, 60, 88, 713, 60, 82, 14, 8768, 14, 2017, 60, 88, 17, 65, 60, 88, 16, 69, 14, 8768, 14, 2364, 2961, 88, 614, 60, 88, 1216, 60, 88, 614, 60, 88, 2789, 60, 88, 1690, 2625, 19, 358, 199, 9, 6905, 199, 63, 6780, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 2017, 297, 523, 2615, 63, 354, 534, 8768, 14, 2017, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1258, 63, 344, 297, 2615, 63, 354, 534, 8768, 14, 2017, 14, 1258, 63, 344, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 19, 12, 7246, 63, 466, 29, 18, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 16, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1069, 63, 576, 297, 2615, 63, 354, 534, 8768, 14, 2017, 14, 1069, 63, 576, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 25, 12, 7246, 63, 466, 29, 25, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 3699, 66, 25639, 2708, 360, 1624, 13, 24, 659, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 523, 2156, 523, 5478, 1524, 523, 2156, 523, 6032, 63, 1313, 6034, 523, 4952, 63, 1313, 1524, 523, 2156, 523, 6380, 63, 1419, 29, 403, 12, 523, 365, 63, 18363, 29, 797, 12, 523, 6302, 534, 2625, 19, 297, 523, 3329, 63, 8404, 6034, 523, 20753, 1524, 523, 2156, 523, 6380, 63, 928, 29, 1165, 12, 523, 6380, 63, 500, 29, 2760, 12, 199, 9, 421, 199, 63, 12801, 275, 485, 4120, 14, 4311, 8, 523, 536, 534, 2364, 297, 523, 2615, 63, 354, 534, 8768, 14, 2364, 297, 523, 1788, 29, 403, 12, 523, 570, 29, 7580, 12, 523, 3035, 63, 466, 29, 403, 12, 523, 1504, 1524, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1000, 63, 344, 297, 2615, 63, 354, 534, 8768, 14, 2364, 14, 1000, 63, 344, 297, 1478, 29, 16, 12, 489, 1329, 29, 17, 12, 730, 29, 19, 12, 7246, 63, 466, 29, 18, 12, 1768, 29, 17, 12, 489, 965, 63, 885, 63, 585, 29, 797, 12, 849, 63, 585, 29, 16, 12, 489, 1245, 63, 466, 29, 403, 12, 4952, 63, 466, 29, 403, 12, 3035, 63, 466, 29, 403, 12, 489, 365, 63, 3435, 29, 797, 12, 3329, 63, 2645, 29, 403, 12, 489, 6380, 63, 1419, 29, 403, 12, 570, 29, 7580, 395, 272, 485, 4120, 14, 8510, 8, 489, 536, 534, 1310, 63, 576, 297, 2615, 63, 354, 534, 8768, 14, 2364, 14, 1310, 63, 576, 297, 1478, 29, 17, 12, 489, 1329, 29, 18, 12, 730, 29, 25, 12, 7246, 63, 466, 29, 25,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 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
unigent/OpenWrt-Firefly-SDK
staging_dir/host/lib/scons-2.3.1/SCons/Tool/MSCommon/common.py
6
9240
# # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "src/engine/SCons/Tool/MSCommon/common.py 2014/03/02 14:18:15 garyo" __doc__ = """ Common helper functions for working with the Microsoft tool chain. """ import copy import os import subprocess import re import SCons.Util logfile = os.environ.get('SCONS_MSCOMMON_DEBUG') if logfile == '-': def debug(x): print x elif logfile: try: import logging except ImportError: debug = lambda x: open(logfile, 'a').write(x + '\n') else: logging.basicConfig(filename=logfile, level=logging.DEBUG) debug = logging.debug else: debug = lambda x: None _is_win64 = None def is_win64(): """Return true if running on windows 64 bits. Works whether python itself runs in 64 bits or 32 bits.""" # Unfortunately, python does not provide a useful way to determine # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether # the Python itself is 32-bit or 64-bit affects what it returns, # so nothing in sys.* or os.* help. # Apparently the best solution is to use env vars that Windows # sets. If PROCESSOR_ARCHITECTURE is not x86, then the python # process is running in 64 bit mode (on a 64-bit OS, 64-bit # hardware, obviously). # If this python is 32-bit but the OS is 64, Windows will set # ProgramW6432 and PROCESSOR_ARCHITEW6432 to non-null. # (Checking for HKLM\Software\Wow6432Node in the registry doesn't # work, because some 32-bit installers create it.) global _is_win64 if _is_win64 is None: # I structured these tests to make it easy to add new ones or # add exceptions in the future, because this is a bit fragile. _is_win64 = False if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86': _is_win64 = True if os.environ.get('PROCESSOR_ARCHITEW6432'): _is_win64 = True if os.environ.get('ProgramW6432'): _is_win64 = True return _is_win64 def read_reg(value): return SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0] def has_reg(value): """Return True if the given key exists in HKEY_LOCAL_MACHINE, False otherwise.""" try: SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, value) ret = True except WindowsError: ret = False return ret # Functions for fetching environment variable settings from batch files. def normalize_env(env, keys, force=False): """Given a dictionary representing a shell environment, add the variables from os.environ needed for the processing of .bat files; the keys are controlled by the keys argument. It also makes sure the environment values are correctly encoded. If force=True, then all of the key values that exist are copied into the returned dictionary. If force=false, values are only copied if the key does not already exist in the copied dictionary. Note: the environment is copied.""" normenv = {} if env: for k in env.keys(): normenv[k] = copy.deepcopy(env[k]).encode('mbcs') for k in keys: if k in os.environ and (force or not k in normenv): normenv[k] = os.environ[k].encode('mbcs') # This shouldn't be necessary, since the default environment should include system32, # but keep this here to be safe, since it's needed to find reg.exe which the MSVC # bat scripts use. sys32_dir = os.path.join(os.environ.get("SystemRoot", os.environ.get("windir",r"C:\Windows\system32")),"System32") if sys32_dir not in normenv['PATH']: normenv['PATH'] = normenv['PATH'] + os.pathsep + sys32_dir debug("PATH: %s"%normenv['PATH']) return normenv def get_output(vcbat, args = None, env = None): """Parse the output of given bat file, with given args.""" if env is None: # Create a blank environment, for use in launching the tools env = SCons.Environment.Environment(tools=[]) # TODO: This is a hard-coded list of the variables that (may) need # to be imported from os.environ[] for v[sc]*vars*.bat file # execution to work. This list should really be either directly # controlled by vc.py, or else derived from the common_tools_var # settings in vs.py. vars = [ 'COMSPEC', # VS100 and VS110: Still set, but modern MSVC setup scripts will # discard these if registry has values. However Intel compiler setup # script still requires these as of 2013/2014. 'VS110COMNTOOLS', 'VS100COMNTOOLS', 'VS90COMNTOOLS', 'VS80COMNTOOLS', 'VS71COMNTOOLS', 'VS70COMNTOOLS', 'VS60COMNTOOLS', ] env['ENV'] = normalize_env(env['ENV'], vars, force=False) if args: debug("Calling '%s %s'" % (vcbat, args)) popen = SCons.Action._subproc(env, '"%s" %s & set' % (vcbat, args), stdin = 'devnull', stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: debug("Calling '%s'" % vcbat) popen = SCons.Action._subproc(env, '"%s" & set' % vcbat, stdin = 'devnull', stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Use the .stdout and .stderr attributes directly because the # .communicate() method uses the threading module on Windows # and won't work under Pythons not built with threading. stdout = popen.stdout.read() stderr = popen.stderr.read() # Extra debug logic, uncomment if necessar # debug('get_output():stdout:%s'%stdout) # debug('get_output():stderr:%s'%stderr) if stderr: # TODO: find something better to do with stderr; # this at least prevents errors from getting swallowed. import sys sys.stderr.write(stderr) if popen.wait() != 0: raise IOError(stderr.decode("mbcs")) output = stdout.decode("mbcs") return output def parse_output(output, keep = ("INCLUDE", "LIB", "LIBPATH", "PATH")): # dkeep is a dict associating key: path_list, where key is one item from # keep, and pat_list the associated list of paths dkeep = dict([(i, []) for i in keep]) # rdk will keep the regex to match the .bat file output line starts rdk = {} for i in keep: rdk[i] = re.compile('%s=(.*)' % i, re.I) def add_env(rmatch, key, dkeep=dkeep): plist = rmatch.group(1).split(os.pathsep) for p in plist: # Do not add empty paths (when a var ends with ;) if p: p = p.encode('mbcs') # XXX: For some reason, VC98 .bat file adds "" around the PATH # values, and it screws up the environment later, so we strip # it. p = p.strip('"') dkeep[key].append(p) for line in output.splitlines(): for k,v in rdk.items(): m = v.match(line) if m: add_env(m, k) return dkeep # TODO(sgk): unused def output_to_dict(output): """Given an output string, parse it to find env variables. Return a dict where keys are variables names, and values their content""" envlinem = re.compile(r'^([a-zA-z0-9]+)=([\S\s]*)$') parsedenv = {} for line in output.splitlines(): m = envlinem.match(line) if m: parsedenv[m.group(1)] = m.group(2) return parsedenv # TODO(sgk): unused def get_new(l1, l2): """Given two list l1 and l2, return the items in l2 which are not in l1. Order is maintained.""" # We don't try to be smart: lists are small, and this is not the bottleneck # is any case new = [] for i in l2: if i not in l1: new.append(i) return new # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
gpl-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 12, 6029, 12, 6171, 12, 6927, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 3053, 7844, 15, 2330, 14, 647, 221, 6927, 15, 1644, 15, 996, 4329, 26, 1085, 26, 1046, 486, 695, 79, 2, 199, 199, 363, 1301, 363, 275, 408, 199, 7844, 5922, 3423, 367, 6449, 543, 314, 15332, 4744, 6036, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 199, 199, 646, 8218, 14, 9562, 421, 199, 12804, 275, 747, 14, 2314, 14, 362, 360, 51, 1864, 51, 63, 3053, 21637, 63, 5287, 358, 199, 692, 17251, 508, 20905, 272, 347, 3105, 8, 88, 304, 267, 870, 671, 199, 4164, 17251, 26, 272, 862, 26, 267, 492, 2050, 272, 871, 3545, 26, 267, 3105, 275, 2400, 671, 26, 1551, 8, 12804, 12, 283, 65, 1959, 952, 8, 88, 435, 1557, 78, 358, 272, 587, 26, 267, 2050, 14, 19602, 8, 1501, 29, 12804, 12, 2166, 29, 4806, 14, 5287, 9, 267, 3105, 275, 2050, 14, 1757, 199, 2836, 26, 272, 3105, 275, 2400, 671, 26, 488, 421, 199, 63, 374, 63, 2676, 772, 275, 488, 199, 199, 318, 365, 63, 2676, 772, 837, 272, 408, 1767, 2549, 340, 3879, 641, 10061, 5049, 5821, 14, 339, 28099, 3775, 2366, 6337, 7858, 315, 5049, 5821, 503, 4337, 5821, 1041, 272, 327, 31076, 12, 2366, 1630, 440, 5647, 282, 2997, 4340, 370, 6705, 272, 327, 340, 314, 8793, 5417, 4403, 365, 4337, 13, 2075, 503, 5049, 13, 2075, 14, 221, 644, 9050, 12, 3775, 272, 327, 314, 2018, 6337, 365, 4337, 13, 2075, 503, 5049, 13, 2075, 29476, 4052, 652, 2529, 12, 272, 327, 880, 6548, 315, 984, 2795, 503, 747, 2795, 1720, 14, 339, 327, 13450, 1708, 590, 314, 5526, 8744, 365, 370, 675, 2589, 6802, 626, 5417, 272, 327, 5951, 14, 221, 982, 3611, 35, 1608, 726, 63, 7762, 649, 3582, 3942, 365, 440, 671, 1184, 12, 2066, 314, 2366, 272, 327, 2112, 365, 3879, 315, 5049, 4546, 818, 334, 265, 282, 5049, 13, 2075, 4403, 12, 5049, 13, 2075, 272, 327, 14991, 12, 25259, 590, 680, 272, 327, 982, 642, 2366, 365, 4337, 13, 2075, 1325, 314, 4403, 365, 5049, 12, 5417, 911, 663, 272, 327, 18841, 55, 23313, 436, 3611, 35, 1608, 726, 63, 7762, 4427, 55, 23313, 370, 2222, 13, 2307, 14, 272, 327, 334, 14740, 367, 869, 14307, 45, 60, 10337, 60, 55, 583, 23313, 1716, 315, 314, 7086, 3181, 1133, 272, 327, 1736, 12, 2952, 2005, 4337, 13, 2075, 18535, 83, 1218, 652, 4959, 272, 2288, 485, 374, 63, 2676, 772, 272, 340, 485, 374, 63, 2676, 772, 365, 488, 26, 267, 327, 473, 21781, 3520, 2295, 370, 1852, 652, 8837, 370, 1050, 892, 7869, 503, 267, 327, 1050, 4967, 315, 314, 6466, 12, 2952, 642, 365, 282, 4546, 11101, 441, 14, 267, 485, 374, 63, 2676, 772, 275, 756, 267, 340, 747, 14, 2314, 14, 362, 360, 24341, 63, 7762, 649, 3582, 3942, 1673, 88, 1184, 358, 1137, 283, 88, 1184, 356, 288, 485, 374, 63, 2676, 772, 275, 715, 267, 340, 747, 14, 2314, 14, 362, 360, 24341, 63, 7762, 4427, 55, 23313, 735, 288, 485, 374, 63, 2676, 772, 275, 715, 267, 340, 747, 14, 2314, 14, 362, 360, 9184, 55, 23313, 735, 288, 485, 374, 63, 2676, 772, 275, 715, 272, 372, 485, 374, 63, 2676, 772, 421, 199, 318, 1586, 63, 1135, 8, 585, 304, 272, 372, 8218, 14, 9562, 14, 2872, 9334, 8, 18521, 14, 9562, 14, 23802, 63, 7486, 63, 20890, 12, 574, 2788, 16, 61, 199, 199, 318, 965, 63, 1135, 8, 585, 304, 272, 408, 1767, 715, 340, 314, 1627, 790, 3495, 315, 869, 3078, 63, 7486, 63, 20890, 12, 756, 272, 4257, 1041, 272, 862, 26, 267, 8218, 14, 9562, 14, 2872, 28144, 920, 8, 18521, 14, 9562, 14, 23802, 63, 7486, 63, 20890, 12, 574, 9, 267, 2203, 275, 715, 272, 871, 23950, 26, 267, 2203, 275, 756, 272, 372, 2203, 199, 199, 3, 17471, 367, 21239, 3734, 1750, 2202, 687, 3522, 1584, 14, 199, 199, 318, 7666, 63, 1813, 8, 1813, 12, 2883, 12, 3542, 29, 797, 304, 272, 408, 13735, 282, 2600, 6144, 282, 5218, 3734, 12, 1050, 314, 2860, 272, 687, 747, 14, 2314, 4346, 367, 314, 6661, 402, 1275, 13475, 1584, 27, 314, 2883, 787, 272, 22284, 701, 314, 2883, 1423, 14, 339, 2779, 2597, 7704, 3238, 314, 3734, 1338, 787, 6657, 5737, 14, 339, 982, 3542, 29, 549, 12, 2066, 1006, 402, 314, 790, 1338, 626, 2187, 787, 8876, 272, 1901, 314, 2138 ]
[ 199, 3, 1898, 334, 67, 9, 12521, 12, 14790, 12, 13004, 12, 8353, 12, 11811, 12, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 12, 6029, 12, 6171, 12, 6927, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5157, 15, 3053, 7844, 15, 2330, 14, 647, 221, 6927, 15, 1644, 15, 996, 4329, 26, 1085, 26, 1046, 486, 695, 79, 2, 199, 199, 363, 1301, 363, 275, 408, 199, 7844, 5922, 3423, 367, 6449, 543, 314, 15332, 4744, 6036, 14, 199, 624, 199, 199, 646, 1331, 199, 646, 747, 199, 646, 3873, 199, 646, 295, 199, 199, 646, 8218, 14, 9562, 421, 199, 12804, 275, 747, 14, 2314, 14, 362, 360, 51, 1864, 51, 63, 3053, 21637, 63, 5287, 358, 199, 692, 17251, 508, 20905, 272, 347, 3105, 8, 88, 304, 267, 870, 671, 199, 4164, 17251, 26, 272, 862, 26, 267, 492, 2050, 272, 871, 3545, 26, 267, 3105, 275, 2400, 671, 26, 1551, 8, 12804, 12, 283, 65, 1959, 952, 8, 88, 435, 1557, 78, 358, 272, 587, 26, 267, 2050, 14, 19602, 8, 1501, 29, 12804, 12, 2166, 29, 4806, 14, 5287, 9, 267, 3105, 275, 2050, 14, 1757, 199, 2836, 26, 272, 3105, 275, 2400, 671, 26, 488, 421, 199, 63, 374, 63, 2676, 772, 275, 488, 199, 199, 318, 365, 63, 2676, 772, 837, 272, 408, 1767, 2549, 340, 3879, 641, 10061, 5049, 5821, 14, 339, 28099, 3775, 2366, 6337, 7858, 315, 5049, 5821, 503, 4337, 5821, 1041, 272, 327, 31076, 12, 2366, 1630, 440, 5647, 282, 2997, 4340, 370, 6705, 272, 327, 340, 314, 8793, 5417, 4403, 365, 4337, 13, 2075, 503, 5049, 13, 2075, 14, 221, 644, 9050, 12, 3775, 272, 327, 314, 2018, 6337, 365, 4337, 13, 2075, 503, 5049, 13, 2075, 29476, 4052, 652, 2529, 12, 272, 327, 880, 6548, 315, 984, 2795, 503, 747, 2795, 1720, 14, 339, 327, 13450, 1708, 590, 314, 5526, 8744, 365, 370, 675, 2589, 6802, 626, 5417, 272, 327, 5951, 14, 221, 982, 3611, 35, 1608, 726, 63, 7762, 649, 3582, 3942, 365, 440, 671, 1184, 12, 2066, 314, 2366, 272, 327, 2112, 365, 3879, 315, 5049, 4546, 818, 334, 265, 282, 5049, 13, 2075, 4403, 12, 5049, 13, 2075, 272, 327, 14991, 12, 25259, 590, 680, 272, 327, 982, 642, 2366, 365, 4337, 13, 2075, 1325, 314, 4403, 365, 5049, 12, 5417, 911, 663, 272, 327, 18841, 55, 23313, 436, 3611, 35, 1608, 726, 63, 7762, 4427, 55, 23313, 370, 2222, 13, 2307, 14, 272, 327, 334, 14740, 367, 869, 14307, 45, 60, 10337, 60, 55, 583, 23313, 1716, 315, 314, 7086, 3181, 1133, 272, 327, 1736, 12, 2952, 2005, 4337, 13, 2075, 18535, 83, 1218, 652, 4959, 272, 2288, 485, 374, 63, 2676, 772, 272, 340, 485, 374, 63, 2676, 772, 365, 488, 26, 267, 327, 473, 21781, 3520, 2295, 370, 1852, 652, 8837, 370, 1050, 892, 7869, 503, 267, 327, 1050, 4967, 315, 314, 6466, 12, 2952, 642, 365, 282, 4546, 11101, 441, 14, 267, 485, 374, 63, 2676, 772, 275, 756, 267, 340, 747, 14, 2314, 14, 362, 360, 24341, 63, 7762, 649, 3582, 3942, 1673, 88, 1184, 358, 1137, 283, 88, 1184, 356, 288, 485, 374, 63, 2676, 772, 275, 715, 267, 340, 747, 14, 2314, 14, 362, 360, 24341, 63, 7762, 4427, 55, 23313, 735, 288, 485, 374, 63, 2676, 772, 275, 715, 267, 340, 747, 14, 2314, 14, 362, 360, 9184, 55, 23313, 735, 288, 485, 374, 63, 2676, 772, 275, 715, 272, 372, 485, 374, 63, 2676, 772, 421, 199, 318, 1586, 63, 1135, 8, 585, 304, 272, 372, 8218, 14, 9562, 14, 2872, 9334, 8, 18521, 14, 9562, 14, 23802, 63, 7486, 63, 20890, 12, 574, 2788, 16, 61, 199, 199, 318, 965, 63, 1135, 8, 585, 304, 272, 408, 1767, 715, 340, 314, 1627, 790, 3495, 315, 869, 3078, 63, 7486, 63, 20890, 12, 756, 272, 4257, 1041, 272, 862, 26, 267, 8218, 14, 9562, 14, 2872, 28144, 920, 8, 18521, 14, 9562, 14, 23802, 63, 7486, 63, 20890, 12, 574, 9, 267, 2203, 275, 715, 272, 871, 23950, 26, 267, 2203, 275, 756, 272, 372, 2203, 199, 199, 3, 17471, 367, 21239, 3734, 1750, 2202, 687, 3522, 1584, 14, 199, 199, 318, 7666, 63, 1813, 8, 1813, 12, 2883, 12, 3542, 29, 797, 304, 272, 408, 13735, 282, 2600, 6144, 282, 5218, 3734, 12, 1050, 314, 2860, 272, 687, 747, 14, 2314, 4346, 367, 314, 6661, 402, 1275, 13475, 1584, 27, 314, 2883, 787, 272, 22284, 701, 314, 2883, 1423, 14, 339, 2779, 2597, 7704, 3238, 314, 3734, 1338, 787, 6657, 5737, 14, 339, 982, 3542, 29, 549, 12, 2066, 1006, 402, 314, 790, 1338, 626, 2187, 787, 8876, 272, 1901, 314, 2138, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
skrueger111/zazzie
src/sassie/calculate/old_sascalc/sascalc_library/setup_sascalc_library.py
2
3175
from __future__ import print_function # System imports from distutils.core import * import os, platform os_type = platform.system() #os.environ["CC"] = "g++" cpp_library_name = 'sascalc' cuda_library_name = 'cudaSascalc' if os_type == "Darwin": cuda_dir = os.path.join(os.path.sep,'usr','local','cuda') elif os_type == "Linux": cuda_dir = os.path.join(os.path.sep,'share','apps','local','cuda') # Third-party modules - we depend on numpy for everything import numpy from numpy.distutils.core import Extension, setup # Obtain the numpy include directory. This logic works across numpy versions. try: numpy_include = numpy.get_include() except AttributeError: numpy_include = numpy.get_numpy_include() if os.path.isdir(cuda_dir): cuda_driver = True else: cuda_driver = False if os.path.isfile(os.path.join('extensions','lib','libsascalc.a')): cpp_lib = True else: cpp_lib = False if os.path.isfile(os.path.join('extensions','lib','libcudaSascalc.a')): cuda_lib = True else: cuda_lib = False if not cpp_lib and not cuda_lib: print("Either cpp or cuda lib needs to be pre-built") exit(0) if cuda_lib and not cuda_driver: print("Cuda lib found but no cuda driver detected") exit(0) include_dir_names = [numpy_include] library_dir_names = [] library_names = [] macros = [] cuda_driver = False cuda_lib = False if cpp_lib: include_dir_names.append(os.path.join('extensions','src')) #include')) library_dir_names.append(os.path.join('extensions','lib')) library_names.append(cpp_library_name) macros.append(('CPP_LIB','1')) if cuda_driver: include_dir_names.append(os.path.join(cuda_dir,'include')) #library_dir_names.append(os.path.join(cuda_dir,'lib64')) library_dir_names.append(os.path.join(cuda_dir,'lib')) library_names.append('cuda') library_names.append('cudart') macros.append(('CUDA_DRIVER','1')) if cuda_lib: include_dir_names.append(os.path.join('extensions','src')) #include')) library_dir_names.append(os.path.join('extensions','lib')) library_names.append(cpp_library_name) #ZHL hack library_names.append(cuda_library_name) macros.append(('CUDA_LIB','1')) if cuda_driver and cuda_lib: macros.append(('USE_CUDA','1')) else: macros.append(('USE_CPU','1')) # extension module sascalc_api = Extension(name="sascalc_api",sources=['sascalc_library_extension.cpp'], include_dirs = include_dir_names, library_dirs = library_dir_names, libraries = library_names, define_macros = macros, ) # setup setup( name = "sascalc_api", description = "Module for sascalc_api", author = "Hailiang Zhang", ext_modules = [sascalc_api] ) ### post compilation file move try: lib_file = os.path.join('build', 'lib*', 'sascalc_api.*') os.system('mv ' + lib_file + ' .') except: print('sascalc_api.* not found') print('sascalc_api.* not found') print('sascalc_api.* not found') print('\nINSTALLATION FAILED\n') print('INSTALLATION FAILED\n') print('INSTALLATION FAILED\n')
gpl-3.0
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 3, 6187, 8925, 199, 504, 7065, 14, 1018, 492, 627, 199, 646, 747, 12, 4298, 199, 199, 736, 63, 466, 275, 4298, 14, 2253, 342, 199, 199, 3, 736, 14, 2314, 905, 2571, 937, 275, 298, 71, 4176, 2, 199, 199, 5910, 63, 4342, 63, 354, 275, 283, 22601, 8104, 7, 199, 16309, 63, 4342, 63, 354, 275, 283, 16309, 51, 305, 8104, 7, 199, 199, 692, 747, 63, 466, 508, 298, 31065, 582, 272, 23123, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 2584, 2647, 1673, 1832, 1673, 16309, 358, 199, 4164, 747, 63, 466, 508, 298, 14091, 582, 272, 23123, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 2584, 6251, 1673, 5181, 1673, 1832, 1673, 16309, 358, 199, 199, 3, 31079, 13, 7522, 4621, 446, 781, 11687, 641, 2680, 367, 8137, 199, 646, 2680, 199, 199, 504, 2680, 14, 13350, 14, 1018, 492, 13282, 12, 3272, 199, 199, 3, 17985, 877, 314, 2680, 2387, 2082, 14, 221, 961, 9661, 5419, 9371, 2680, 5459, 14, 199, 893, 26, 272, 2680, 63, 2613, 275, 2680, 14, 362, 63, 2613, 342, 199, 2590, 4281, 26, 272, 2680, 63, 2613, 275, 2680, 14, 362, 63, 4714, 63, 2613, 342, 199, 199, 692, 747, 14, 515, 14, 6027, 8, 16309, 63, 694, 304, 272, 23123, 63, 3090, 275, 715, 199, 2836, 26, 272, 23123, 63, 3090, 275, 756, 9948, 199, 692, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1673, 8450, 305, 8104, 14, 65, 8109, 272, 7246, 63, 773, 275, 715, 199, 2836, 26, 272, 7246, 63, 773, 275, 756, 199, 199, 692, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1673, 773, 16309, 51, 305, 8104, 14, 65, 8109, 272, 23123, 63, 773, 275, 715, 199, 2836, 26, 272, 23123, 63, 773, 275, 756, 199, 199, 692, 440, 7246, 63, 773, 436, 440, 23123, 63, 773, 26, 272, 870, 480, 37, 1711, 7246, 503, 23123, 1973, 4839, 370, 506, 876, 13, 11730, 531, 272, 4458, 8, 16, 9, 199, 692, 23123, 63, 773, 436, 440, 23123, 63, 3090, 26, 272, 870, 480, 35, 6727, 1973, 1911, 1325, 949, 23123, 5253, 10501, 531, 272, 4458, 8, 16, 9, 199, 199, 2613, 63, 694, 63, 1247, 275, 359, 4714, 63, 2613, 61, 199, 4342, 63, 694, 63, 1247, 275, 942, 199, 4342, 63, 1247, 275, 942, 199, 16358, 275, 942, 199, 199, 16309, 63, 3090, 275, 756, 199, 16309, 63, 773, 275, 756, 199, 199, 692, 7246, 63, 773, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 2164, 1333, 327, 2613, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1333, 272, 3555, 63, 1247, 14, 740, 8, 5910, 63, 4342, 63, 354, 9, 272, 16954, 14, 740, 4725, 14533, 63, 5617, 1673, 17, 1333, 199, 692, 23123, 63, 3090, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 2613, 1333, 272, 327, 4342, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 773, 772, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 773, 1333, 272, 3555, 63, 1247, 14, 740, 360, 16309, 358, 272, 3555, 63, 1247, 14, 740, 360, 67, 1181, 580, 358, 272, 16954, 14, 740, 4725, 30925, 33, 63, 23401, 1673, 17, 1333, 199, 692, 23123, 63, 773, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 2164, 1333, 327, 2613, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1333, 272, 3555, 63, 1247, 14, 740, 8, 5910, 63, 4342, 63, 354, 9, 327, 58, 29210, 11176, 272, 3555, 63, 1247, 14, 740, 8, 16309, 63, 4342, 63, 354, 9, 272, 16954, 14, 740, 4725, 30925, 33, 63, 5617, 1673, 17, 1333, 199, 199, 692, 23123, 63, 3090, 436, 23123, 63, 773, 26, 272, 16954, 14, 740, 4725, 4701, 63, 30925, 33, 1673, 17, 1333, 199, 2836, 26, 272, 16954, 14, 740, 4725, 4701, 63, 11011, 1673, 17, 1333, 199, 199, 3, 3329, 859, 199, 22601, 8104, 63, 1246, 275, 13282, 8, 354, 628, 22601, 8104, 63, 1246, 401, 4553, 2968, 22601, 8104, 63, 4342, 63, 3435, 14, 5910, 995, 490, 2387, 63, 3220, 275, 2387, 63, 694, 63, 1247, 12, 490, 3555, 63, 3220, 275, 3555, 63, 694, 63, 1247, 12, 490, 8363, 275, 3555, 63, 1247, 12, 490, 5627, 63, 16358, 275, 16954, 12, 673, 776, 199, 199, 3, 3272, 199, 2758, 8, 221, 536, 263, 275, 298, 22601, 8104, 63, 1246, 401, 267, 1369, 275, 298, 2377, 367, 26336, 8104, 63, 1246, 401, 267, 4132, 420, 275, 298, 15739, 1638, 621, 3107, 27304, 401, 267, 1599, 63, 3112, 275, 359, 22601, 8104, 63, 1246, 61, 267, 776, 4388, 199, 5680, 2963, 18653, 570, 4057, 199, 199, 893, 26, 272, 1973, 63, 493, 275, 747, 14, 515, 14, 904, 360, 1506, 297, 283, 773, 7693, 283, 22601, 8104, 63, 1246, 24915, 272, 747, 14, 2253, 360, 12393, 283, 435, 1973, 63, 493, 435, 283, 1275, 358, 199, 2590, 26, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 2258, 78, 16811, 2594, 26892, 60, 78, 358, 272, 870, 360, 16811, 2594, 26892, 60, 78, 358, 272, 870, 360, 16811, 2594, 26892, 60, 78, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 3, 6187, 8925, 199, 504, 7065, 14, 1018, 492, 627, 199, 646, 747, 12, 4298, 199, 199, 736, 63, 466, 275, 4298, 14, 2253, 342, 199, 199, 3, 736, 14, 2314, 905, 2571, 937, 275, 298, 71, 4176, 2, 199, 199, 5910, 63, 4342, 63, 354, 275, 283, 22601, 8104, 7, 199, 16309, 63, 4342, 63, 354, 275, 283, 16309, 51, 305, 8104, 7, 199, 199, 692, 747, 63, 466, 508, 298, 31065, 582, 272, 23123, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 2584, 2647, 1673, 1832, 1673, 16309, 358, 199, 4164, 747, 63, 466, 508, 298, 14091, 582, 272, 23123, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 2584, 6251, 1673, 5181, 1673, 1832, 1673, 16309, 358, 199, 199, 3, 31079, 13, 7522, 4621, 446, 781, 11687, 641, 2680, 367, 8137, 199, 646, 2680, 199, 199, 504, 2680, 14, 13350, 14, 1018, 492, 13282, 12, 3272, 199, 199, 3, 17985, 877, 314, 2680, 2387, 2082, 14, 221, 961, 9661, 5419, 9371, 2680, 5459, 14, 199, 893, 26, 272, 2680, 63, 2613, 275, 2680, 14, 362, 63, 2613, 342, 199, 2590, 4281, 26, 272, 2680, 63, 2613, 275, 2680, 14, 362, 63, 4714, 63, 2613, 342, 199, 199, 692, 747, 14, 515, 14, 6027, 8, 16309, 63, 694, 304, 272, 23123, 63, 3090, 275, 715, 199, 2836, 26, 272, 23123, 63, 3090, 275, 756, 9948, 199, 692, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1673, 8450, 305, 8104, 14, 65, 8109, 272, 7246, 63, 773, 275, 715, 199, 2836, 26, 272, 7246, 63, 773, 275, 756, 199, 199, 692, 747, 14, 515, 14, 6292, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1673, 773, 16309, 51, 305, 8104, 14, 65, 8109, 272, 23123, 63, 773, 275, 715, 199, 2836, 26, 272, 23123, 63, 773, 275, 756, 199, 199, 692, 440, 7246, 63, 773, 436, 440, 23123, 63, 773, 26, 272, 870, 480, 37, 1711, 7246, 503, 23123, 1973, 4839, 370, 506, 876, 13, 11730, 531, 272, 4458, 8, 16, 9, 199, 692, 23123, 63, 773, 436, 440, 23123, 63, 3090, 26, 272, 870, 480, 35, 6727, 1973, 1911, 1325, 949, 23123, 5253, 10501, 531, 272, 4458, 8, 16, 9, 199, 199, 2613, 63, 694, 63, 1247, 275, 359, 4714, 63, 2613, 61, 199, 4342, 63, 694, 63, 1247, 275, 942, 199, 4342, 63, 1247, 275, 942, 199, 16358, 275, 942, 199, 199, 16309, 63, 3090, 275, 756, 199, 16309, 63, 773, 275, 756, 199, 199, 692, 7246, 63, 773, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 2164, 1333, 327, 2613, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1333, 272, 3555, 63, 1247, 14, 740, 8, 5910, 63, 4342, 63, 354, 9, 272, 16954, 14, 740, 4725, 14533, 63, 5617, 1673, 17, 1333, 199, 692, 23123, 63, 3090, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 2613, 1333, 272, 327, 4342, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 773, 772, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 8, 16309, 63, 694, 2584, 773, 1333, 272, 3555, 63, 1247, 14, 740, 360, 16309, 358, 272, 3555, 63, 1247, 14, 740, 360, 67, 1181, 580, 358, 272, 16954, 14, 740, 4725, 30925, 33, 63, 23401, 1673, 17, 1333, 199, 692, 23123, 63, 773, 26, 272, 2387, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 2164, 1333, 327, 2613, 1333, 272, 3555, 63, 694, 63, 1247, 14, 740, 8, 736, 14, 515, 14, 904, 360, 5359, 1673, 773, 1333, 272, 3555, 63, 1247, 14, 740, 8, 5910, 63, 4342, 63, 354, 9, 327, 58, 29210, 11176, 272, 3555, 63, 1247, 14, 740, 8, 16309, 63, 4342, 63, 354, 9, 272, 16954, 14, 740, 4725, 30925, 33, 63, 5617, 1673, 17, 1333, 199, 199, 692, 23123, 63, 3090, 436, 23123, 63, 773, 26, 272, 16954, 14, 740, 4725, 4701, 63, 30925, 33, 1673, 17, 1333, 199, 2836, 26, 272, 16954, 14, 740, 4725, 4701, 63, 11011, 1673, 17, 1333, 199, 199, 3, 3329, 859, 199, 22601, 8104, 63, 1246, 275, 13282, 8, 354, 628, 22601, 8104, 63, 1246, 401, 4553, 2968, 22601, 8104, 63, 4342, 63, 3435, 14, 5910, 995, 490, 2387, 63, 3220, 275, 2387, 63, 694, 63, 1247, 12, 490, 3555, 63, 3220, 275, 3555, 63, 694, 63, 1247, 12, 490, 8363, 275, 3555, 63, 1247, 12, 490, 5627, 63, 16358, 275, 16954, 12, 673, 776, 199, 199, 3, 3272, 199, 2758, 8, 221, 536, 263, 275, 298, 22601, 8104, 63, 1246, 401, 267, 1369, 275, 298, 2377, 367, 26336, 8104, 63, 1246, 401, 267, 4132, 420, 275, 298, 15739, 1638, 621, 3107, 27304, 401, 267, 1599, 63, 3112, 275, 359, 22601, 8104, 63, 1246, 61, 267, 776, 4388, 199, 5680, 2963, 18653, 570, 4057, 199, 199, 893, 26, 272, 1973, 63, 493, 275, 747, 14, 515, 14, 904, 360, 1506, 297, 283, 773, 7693, 283, 22601, 8104, 63, 1246, 24915, 272, 747, 14, 2253, 360, 12393, 283, 435, 1973, 63, 493, 435, 283, 1275, 358, 199, 2590, 26, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 360, 22601, 8104, 63, 1246, 2795, 440, 1911, 358, 272, 870, 2258, 78, 16811, 2594, 26892, 60, 78, 358, 272, 870, 360, 16811, 2594, 26892, 60, 78, 358, 272, 870, 360, 16811, 2594, 26892, 60, 78, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tejal29/pants
src/python/pants/backend/jvm/tasks/specs_run.py
1
3288
# coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) from twitter.common.collections import OrderedSet from pants.backend.jvm.tasks.jvm_task import JvmTask from pants.backend.jvm.tasks.jvm_tool_task_mixin import JvmToolTaskMixin from pants.base.exceptions import TaskError from pants.base.workunit import WorkUnit from pants.binary_util import safe_args from pants.java.util import execute_java class SpecsRun(JvmTask, JvmToolTaskMixin): @classmethod def register_options(cls, register): super(SpecsRun, cls).register_options(register) register('--skip', action='store_true', help='Skip running specs.') register('--test', action='append', help='Force running of just these specs. Tests can be specified either by fully ' 'qualified classname or full file path.') # TODO: Get rid of this in favor of the inherited global color flag. register('--color', action='store_true', default=True, help='Emit test result with ANSI terminal color codes.') cls.register_jvm_tool(register, 'specs', default=['//:scala-specs']) @classmethod def prepare(cls, options, round_manager): super(SpecsRun, cls).prepare(options, round_manager) # TODO(John Sirois): these are fake requirements in order to force compile run before this # goal. Introduce a RuntimeClasspath product for JvmCompile and PrepareResources to populate # and depend on that. # See: https://github.com/pantsbuild/pants/issues/310 round_manager.require_data('resources_by_target') round_manager.require_data('classes_by_target') def __init__(self, *args, **kwargs): super(SpecsRun, self).__init__(*args, **kwargs) self.skip = self.get_options().skip self.color = self.get_options().color self.tests = self.get_options().test def execute(self): if not self.skip: targets = self.context.targets() def run_tests(tests): args = ['--color'] if self.color else [] args.append('--specs=%s' % ','.join(tests)) specs_runner_main = 'com.twitter.common.testing.ExplicitSpecsRunnerMain' bootstrapped_cp = self.tool_classpath('specs') classpath = self.classpath(bootstrapped_cp, confs=self.confs) result = execute_java( classpath=classpath, main=specs_runner_main, jvm_options=self.jvm_options, args=self.args + args, workunit_factory=self.context.new_workunit, workunit_name='specs', workunit_labels=[WorkUnit.TEST] ) if result != 0: raise TaskError('java %s ... exited non-zero (%i)' % (specs_runner_main, result)) if self.tests: run_tests(self.tests) else: with safe_args(self.calculate_tests(targets)) as tests: if tests: run_tests(tests) def calculate_tests(self, targets): tests = OrderedSet() for target in targets: if target.is_scala and target.is_test: tests.update(target.sources_relative_to_buildroot()) return tests
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 504, 15811, 14, 2330, 14, 7882, 492, 23617, 199, 199, 504, 18081, 14, 4620, 14, 15813, 14, 5054, 14, 15813, 63, 1765, 492, 1603, 2611, 4476, 199, 504, 18081, 14, 4620, 14, 15813, 14, 5054, 14, 15813, 63, 3557, 63, 1765, 63, 20406, 492, 1603, 2611, 5157, 4476, 4256, 199, 504, 18081, 14, 1095, 14, 3924, 492, 8495, 547, 199, 504, 18081, 14, 1095, 14, 800, 3248, 492, 9361, 5072, 199, 504, 18081, 14, 3008, 63, 1974, 492, 5048, 63, 589, 199, 504, 18081, 14, 6138, 14, 1974, 492, 5341, 63, 6138, 421, 199, 533, 31511, 83, 2540, 8, 42, 2611, 4476, 12, 1603, 2611, 5157, 4476, 4256, 304, 523, 768, 3744, 523, 347, 2274, 63, 1419, 8, 1886, 12, 2274, 304, 272, 1613, 8, 28834, 2540, 12, 843, 680, 2683, 63, 1419, 8, 2683, 9, 272, 2274, 4517, 2759, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 7738, 3879, 15941, 2659, 272, 2274, 4517, 396, 297, 1595, 534, 740, 297, 1467, 1720, 534, 13606, 3879, 402, 2951, 3520, 15941, 14, 221, 6496, 883, 506, 2013, 1902, 701, 9999, 283, 2116, 283, 11661, 15876, 503, 2615, 570, 931, 2659, 272, 327, 3254, 26, 2372, 16146, 402, 642, 315, 17914, 402, 314, 12623, 2288, 3164, 3305, 14, 272, 2274, 4517, 2326, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 549, 12, 1467, 1720, 534, 37, 1147, 511, 754, 543, 25600, 11167, 3164, 9479, 2659, 272, 843, 14, 2683, 63, 15813, 63, 3557, 8, 2683, 12, 283, 7273, 297, 849, 2968, 501, 26, 28708, 13, 7273, 1105, 819, 768, 3744, 523, 347, 9275, 8, 1886, 12, 1511, 12, 6168, 63, 2609, 304, 272, 1613, 8, 28834, 2540, 12, 843, 680, 6726, 8, 1419, 12, 6168, 63, 2609, 9, 339, 327, 3254, 8, 12923, 428, 14352, 374, 304, 3520, 787, 4026, 9760, 315, 1865, 370, 3542, 6555, 1255, 2544, 642, 272, 327, 14850, 14, 9805, 293, 3402, 282, 19103, 2543, 515, 3336, 367, 1603, 2611, 12626, 436, 17008, 13745, 370, 13904, 272, 327, 436, 11687, 641, 626, 14, 272, 327, 1666, 26, 4178, 921, 5031, 14, 957, 15, 21970, 1506, 15, 21970, 15, 10115, 15, 18035, 272, 6168, 63, 2609, 14, 4365, 63, 576, 360, 4435, 63, 991, 63, 1375, 358, 272, 6168, 63, 2609, 14, 4365, 63, 576, 360, 2888, 63, 991, 63, 1375, 358, 819, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 28834, 2540, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 272, 291, 14, 2759, 275, 291, 14, 362, 63, 1419, 1252, 2759, 272, 291, 14, 2326, 275, 291, 14, 362, 63, 1419, 1252, 2326, 272, 291, 14, 2219, 275, 291, 14, 362, 63, 1419, 1252, 396, 819, 347, 5341, 8, 277, 304, 272, 340, 440, 291, 14, 2759, 26, 489, 4545, 275, 291, 14, 1100, 14, 4684, 342, 2541, 347, 1255, 63, 2219, 8, 2219, 304, 267, 1249, 275, 14574, 2326, 418, 340, 291, 14, 2326, 587, 942, 267, 1249, 14, 740, 4517, 7273, 2458, 83, 7, 450, 12814, 904, 8, 2219, 430, 267, 15941, 63, 5933, 63, 973, 275, 283, 957, 14, 13746, 14, 2330, 14, 4776, 14, 26090, 28834, 7446, 6756, 7, 398, 15865, 1915, 63, 1850, 275, 291, 14, 3557, 63, 26977, 360, 7273, 358, 267, 1021, 515, 275, 291, 14, 26977, 8, 11146, 1915, 63, 1850, 12, 406, 2319, 29, 277, 14, 2190, 83, 9, 398, 754, 275, 5341, 63, 6138, 8, 881, 1021, 515, 29, 26977, 12, 881, 2446, 29, 7273, 63, 5933, 63, 973, 12, 881, 1335, 2611, 63, 1419, 29, 277, 14, 15813, 63, 1419, 12, 881, 1249, 29, 277, 14, 589, 435, 1249, 12, 881, 1736, 3248, 63, 3702, 29, 277, 14, 1100, 14, 1222, 63, 800, 3248, 12, 881, 1736, 3248, 63, 354, 534, 7273, 297, 881, 1736, 3248, 63, 3512, 1524, 6517, 5072, 14, 2864, 61, 267, 776, 267, 340, 754, 1137, 378, 26, 881, 746, 8495, 547, 360, 6138, 450, 83, 2263, 22987, 2222, 13, 4262, 4366, 73, 3171, 450, 334, 7273, 63, 5933, 63, 973, 12, 754, 430, 2541, 340, 291, 14, 2219, 26, 267, 1255, 63, 2219, 8, 277, 14, 2219, 9, 489, 587, 26, 267, 543, 5048, 63, 589, 8, 277, 14, 12063, 63, 2219, 8, 4684, 430, 465, 2295, 26, 881, 340, 2295, 26, 288, 1255, 63, 2219, 8, 2219, 9, 819, 347, 8671, 63, 2219, 8, 277, 12, 4545, 304, 272, 2295, 275, 23617, 342, 272, 367, 1347, 315, 4545, 26, 489, 340, 1347, 14, 374, 63, 28708, 436, 1347, 14, 374, 63, 396, 26, 267, 2295, 14, 873, 8, 1375, 14, 4553, 63, 6188, 63, 475, 63, 1506, 1231, 1012, 272, 372, 2295, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 1898, 6927, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 504, 15811, 14, 2330, 14, 7882, 492, 23617, 199, 199, 504, 18081, 14, 4620, 14, 15813, 14, 5054, 14, 15813, 63, 1765, 492, 1603, 2611, 4476, 199, 504, 18081, 14, 4620, 14, 15813, 14, 5054, 14, 15813, 63, 3557, 63, 1765, 63, 20406, 492, 1603, 2611, 5157, 4476, 4256, 199, 504, 18081, 14, 1095, 14, 3924, 492, 8495, 547, 199, 504, 18081, 14, 1095, 14, 800, 3248, 492, 9361, 5072, 199, 504, 18081, 14, 3008, 63, 1974, 492, 5048, 63, 589, 199, 504, 18081, 14, 6138, 14, 1974, 492, 5341, 63, 6138, 421, 199, 533, 31511, 83, 2540, 8, 42, 2611, 4476, 12, 1603, 2611, 5157, 4476, 4256, 304, 523, 768, 3744, 523, 347, 2274, 63, 1419, 8, 1886, 12, 2274, 304, 272, 1613, 8, 28834, 2540, 12, 843, 680, 2683, 63, 1419, 8, 2683, 9, 272, 2274, 4517, 2759, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 7738, 3879, 15941, 2659, 272, 2274, 4517, 396, 297, 1595, 534, 740, 297, 1467, 1720, 534, 13606, 3879, 402, 2951, 3520, 15941, 14, 221, 6496, 883, 506, 2013, 1902, 701, 9999, 283, 2116, 283, 11661, 15876, 503, 2615, 570, 931, 2659, 272, 327, 3254, 26, 2372, 16146, 402, 642, 315, 17914, 402, 314, 12623, 2288, 3164, 3305, 14, 272, 2274, 4517, 2326, 297, 1595, 534, 1617, 63, 2052, 297, 849, 29, 549, 12, 1467, 1720, 534, 37, 1147, 511, 754, 543, 25600, 11167, 3164, 9479, 2659, 272, 843, 14, 2683, 63, 15813, 63, 3557, 8, 2683, 12, 283, 7273, 297, 849, 2968, 501, 26, 28708, 13, 7273, 1105, 819, 768, 3744, 523, 347, 9275, 8, 1886, 12, 1511, 12, 6168, 63, 2609, 304, 272, 1613, 8, 28834, 2540, 12, 843, 680, 6726, 8, 1419, 12, 6168, 63, 2609, 9, 339, 327, 3254, 8, 12923, 428, 14352, 374, 304, 3520, 787, 4026, 9760, 315, 1865, 370, 3542, 6555, 1255, 2544, 642, 272, 327, 14850, 14, 9805, 293, 3402, 282, 19103, 2543, 515, 3336, 367, 1603, 2611, 12626, 436, 17008, 13745, 370, 13904, 272, 327, 436, 11687, 641, 626, 14, 272, 327, 1666, 26, 4178, 921, 5031, 14, 957, 15, 21970, 1506, 15, 21970, 15, 10115, 15, 18035, 272, 6168, 63, 2609, 14, 4365, 63, 576, 360, 4435, 63, 991, 63, 1375, 358, 272, 6168, 63, 2609, 14, 4365, 63, 576, 360, 2888, 63, 991, 63, 1375, 358, 819, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 28834, 2540, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 272, 291, 14, 2759, 275, 291, 14, 362, 63, 1419, 1252, 2759, 272, 291, 14, 2326, 275, 291, 14, 362, 63, 1419, 1252, 2326, 272, 291, 14, 2219, 275, 291, 14, 362, 63, 1419, 1252, 396, 819, 347, 5341, 8, 277, 304, 272, 340, 440, 291, 14, 2759, 26, 489, 4545, 275, 291, 14, 1100, 14, 4684, 342, 2541, 347, 1255, 63, 2219, 8, 2219, 304, 267, 1249, 275, 14574, 2326, 418, 340, 291, 14, 2326, 587, 942, 267, 1249, 14, 740, 4517, 7273, 2458, 83, 7, 450, 12814, 904, 8, 2219, 430, 267, 15941, 63, 5933, 63, 973, 275, 283, 957, 14, 13746, 14, 2330, 14, 4776, 14, 26090, 28834, 7446, 6756, 7, 398, 15865, 1915, 63, 1850, 275, 291, 14, 3557, 63, 26977, 360, 7273, 358, 267, 1021, 515, 275, 291, 14, 26977, 8, 11146, 1915, 63, 1850, 12, 406, 2319, 29, 277, 14, 2190, 83, 9, 398, 754, 275, 5341, 63, 6138, 8, 881, 1021, 515, 29, 26977, 12, 881, 2446, 29, 7273, 63, 5933, 63, 973, 12, 881, 1335, 2611, 63, 1419, 29, 277, 14, 15813, 63, 1419, 12, 881, 1249, 29, 277, 14, 589, 435, 1249, 12, 881, 1736, 3248, 63, 3702, 29, 277, 14, 1100, 14, 1222, 63, 800, 3248, 12, 881, 1736, 3248, 63, 354, 534, 7273, 297, 881, 1736, 3248, 63, 3512, 1524, 6517, 5072, 14, 2864, 61, 267, 776, 267, 340, 754, 1137, 378, 26, 881, 746, 8495, 547, 360, 6138, 450, 83, 2263, 22987, 2222, 13, 4262, 4366, 73, 3171, 450, 334, 7273, 63, 5933, 63, 973, 12, 754, 430, 2541, 340, 291, 14, 2219, 26, 267, 1255, 63, 2219, 8, 277, 14, 2219, 9, 489, 587, 26, 267, 543, 5048, 63, 589, 8, 277, 14, 12063, 63, 2219, 8, 4684, 430, 465, 2295, 26, 881, 340, 2295, 26, 288, 1255, 63, 2219, 8, 2219, 9, 819, 347, 8671, 63, 2219, 8, 277, 12, 4545, 304, 272, 2295, 275, 23617, 342, 272, 367, 1347, 315, 4545, 26, 489, 340, 1347, 14, 374, 63, 28708, 436, 1347, 14, 374, 63, 396, 26, 267, 2295, 14, 873, 8, 1375, 14, 4553, 63, 6188, 63, 475, 63, 1506, 1231, 1012, 272, 372, 2295, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tvalacarta/tvalacarta
python/main-classic/lib/youtube_dl/extractor/apa.py
20
3173
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( determine_ext, js_to_json, url_or_none, ) class APAIE(InfoExtractor): _VALID_URL = r'https?://[^/]+\.apa\.at/embed/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})' _TESTS = [{ 'url': 'http://uvp.apa.at/embed/293f6d17-692a-44e3-9fd5-7b178f3a1029', 'md5': '2b12292faeb0a7d930c778c7a5b4759b', 'info_dict': { 'id': 'jjv85FdZ', 'ext': 'mp4', 'title': '"Blau ist mysteriös": Die Blue Man Group im Interview', 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', 'thumbnail': r're:^https?://.*\.jpg$', 'duration': 254, 'timestamp': 1519211149, 'upload_date': '20180221', }, }, { 'url': 'https://uvp-apapublisher.sf.apa.at/embed/2f94e9e6-d945-4db2-9548-f9a41ebf7b78', 'only_matching': True, }, { 'url': 'http://uvp-rma.sf.apa.at/embed/70404cca-2f47-4855-bbb8-20b1fae58f76', 'only_matching': True, }, { 'url': 'http://uvp-kleinezeitung.sf.apa.at/embed/f1c44979-dba2-4ebf-b021-e4cf2cac3c81', 'only_matching': True, }] @staticmethod def _extract_urls(webpage): return [ mobj.group('url') for mobj in re.finditer( r'<iframe[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//[^/]+\.apa\.at/embed/[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}.*?)\1', webpage)] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) jwplatform_id = self._search_regex( r'media[iI]d\s*:\s*["\'](?P<id>[a-zA-Z0-9]{8})', webpage, 'jwplatform id', default=None) if jwplatform_id: return self.url_result( 'jwplatform:' + jwplatform_id, ie='JWPlatform', video_id=video_id) sources = self._parse_json( self._search_regex( r'sources\s*=\s*(\[.+?\])\s*;', webpage, 'sources'), video_id, transform_source=js_to_json) formats = [] for source in sources: if not isinstance(source, dict): continue source_url = url_or_none(source.get('file')) if not source_url: continue ext = determine_ext(source_url) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( source_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) else: formats.append({ 'url': source_url, }) self._sort_formats(formats) thumbnail = self._search_regex( r'image\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'thumbnail', fatal=False, group='url') return { 'id': video_id, 'title': video_id, 'thumbnail': thumbnail, 'formats': formats, }
gpl-3.0
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 8586, 63, 475, 63, 1001, 12, 272, 1166, 63, 269, 63, 3592, 12, 199, 9, 421, 199, 533, 437, 8470, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 26285, 4537, 65, 387, 4537, 292, 15, 6427, 9448, 48, 28, 344, 24693, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 29668, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 14, 65, 387, 14, 292, 15, 6427, 15, 16417, 70, 22, 68, 1196, 13, 27041, 65, 13, 1602, 69, 19, 13, 25, 2592, 21, 13, 23, 66, 11175, 70, 19, 65, 709, 1398, 297, 267, 283, 1064, 21, 356, 283, 18, 66, 713, 17027, 667, 2871, 16, 65, 23, 68, 25, 1216, 67, 16156, 67, 23, 65, 21, 66, 2417, 1427, 66, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 12098, 86, 2426, 20689, 58, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 5522, 34, 416, 85, 284, 270, 333, 588, 6236, 14614, 83, 582, 577, 1873, 22447, 4688, 5611, 3416, 6551, 1345, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 68, 2953, 68, 24, 2866, 2905, 70, 383, 66, 6686, 69, 2905, 383, 13830, 32430, 1349, 1465, 69, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 5553, 356, 22540, 12, 288, 283, 3954, 356, 4114, 5756, 845, 10721, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 11366, 2025, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 2859, 921, 9154, 80, 13, 65, 387, 12789, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 18, 70, 2635, 69, 25, 69, 22, 13, 68, 25, 2322, 13, 20, 697, 18, 13, 25, 17054, 13, 70, 25, 65, 2953, 2871, 70, 23, 66, 2277, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 13, 82, 391, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 32170, 966, 30031, 13, 18, 70, 2417, 13, 2006, 1229, 13, 19482, 24, 13, 1165, 66, 17, 667, 69, 2010, 70, 2114, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 13, 23572, 1132, 806, 390, 10335, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 70, 17, 67, 19738, 1965, 13, 27634, 18, 13, 20, 2871, 70, 13, 66, 15385, 13, 69, 20, 2177, 18, 11055, 19, 67, 2835, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 768, 4639, 272, 347, 485, 5005, 63, 3603, 8, 12022, 304, 267, 372, 359, 288, 14208, 14, 923, 360, 633, 358, 288, 367, 14208, 315, 295, 14, 19373, 8, 355, 519, 7601, 20052, 17478, 24621, 1533, 1195, 30982, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2859, 31, 26, 5547, 501, 26285, 4537, 65, 387, 4537, 292, 15, 6427, 15, 7023, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 93, 6697, 2862, 17, 297, 355, 9248, 1874, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 1335, 87, 3246, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 6704, 69, 2391, 59, 73, 41, 61, 68, 60, 83, 10, 3427, 83, 10, 905, 26889, 2229, 48, 28, 344, 9514, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 24, 25583, 9248, 12, 288, 283, 30561, 3246, 1305, 297, 849, 29, 403, 9, 398, 340, 1335, 87, 3246, 63, 344, 26, 288, 372, 291, 14, 633, 63, 1099, 8, 355, 283, 30561, 3246, 4881, 435, 1335, 87, 3246, 63, 344, 12, 13446, 534, 42, 55, 10397, 297, 355, 3991, 63, 344, 29, 3722, 63, 344, 9, 398, 5274, 275, 291, 423, 1122, 63, 1001, 8, 288, 291, 423, 1733, 63, 3821, 8, 355, 519, 1159, 616, 83, 60, 83, 23440, 83, 22588, 59, 6977, 8995, 27147, 83, 10, 10805, 9248, 12, 283, 4553, 659, 288, 3991, 63, 344, 12, 5793, 63, 1365, 29, 3596, 63, 475, 63, 1001, 9, 398, 6752, 275, 942, 267, 367, 1350, 315, 5274, 26, 288, 340, 440, 1228, 8, 1365, 12, 1211, 304, 355, 1980, 288, 1350, 63, 633, 275, 1166, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 493, 1333, 288, 340, 440, 1350, 63, 633, 26, 355, 1980, 288, 1599, 275, 6705, 63, 832, 8, 1365, 63, 633, 9, 288, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 490, 1350, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 490, 333, 19, 85, 24, 63, 344, 534, 30252, 297, 14294, 29, 797, 430, 288, 587, 26, 355, 6752, 14, 740, 2561, 490, 283, 633, 356, 1350, 63, 633, 12, 355, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 10062, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 1569, 60, 83, 10, 3427, 83, 10, 779, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2229, 12525, 17, 680, 6393, 2862, 17, 297, 9248, 12, 288, 283, 8311, 297, 14294, 29, 797, 12, 1572, 534, 633, 358, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 3991, 63, 344, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 6321, 356, 6752, 12, 267, 789 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 8586, 63, 475, 63, 1001, 12, 272, 1166, 63, 269, 63, 3592, 12, 199, 9, 421, 199, 533, 437, 8470, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 26285, 4537, 65, 387, 4537, 292, 15, 6427, 9448, 48, 28, 344, 24693, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 29668, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 14, 65, 387, 14, 292, 15, 6427, 15, 16417, 70, 22, 68, 1196, 13, 27041, 65, 13, 1602, 69, 19, 13, 25, 2592, 21, 13, 23, 66, 11175, 70, 19, 65, 709, 1398, 297, 267, 283, 1064, 21, 356, 283, 18, 66, 713, 17027, 667, 2871, 16, 65, 23, 68, 25, 1216, 67, 16156, 67, 23, 65, 21, 66, 2417, 1427, 66, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 12098, 86, 2426, 20689, 58, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 5522, 34, 416, 85, 284, 270, 333, 588, 6236, 14614, 83, 582, 577, 1873, 22447, 4688, 5611, 3416, 6551, 1345, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 68, 2953, 68, 24, 2866, 2905, 70, 383, 66, 6686, 69, 2905, 383, 13830, 32430, 1349, 1465, 69, 297, 288, 283, 8311, 356, 519, 3984, 23497, 2859, 32569, 8476, 4268, 288, 283, 5553, 356, 22540, 12, 288, 283, 3954, 356, 4114, 5756, 845, 10721, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 11366, 2025, 297, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 2859, 921, 9154, 80, 13, 65, 387, 12789, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 18, 70, 2635, 69, 25, 69, 22, 13, 68, 25, 2322, 13, 20, 697, 18, 13, 25, 17054, 13, 70, 25, 65, 2953, 2871, 70, 23, 66, 2277, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 13, 82, 391, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 32170, 966, 30031, 13, 18, 70, 2417, 13, 2006, 1229, 13, 19482, 24, 13, 1165, 66, 17, 667, 69, 2010, 70, 2114, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 9154, 80, 13, 23572, 1132, 806, 390, 10335, 14, 7646, 14, 65, 387, 14, 292, 15, 6427, 15, 70, 17, 67, 19738, 1965, 13, 27634, 18, 13, 20, 2871, 70, 13, 66, 15385, 13, 69, 20, 2177, 18, 11055, 19, 67, 2835, 297, 267, 283, 2118, 63, 9467, 356, 715, 12, 272, 14877, 339, 768, 4639, 272, 347, 485, 5005, 63, 3603, 8, 12022, 304, 267, 372, 359, 288, 14208, 14, 923, 360, 633, 358, 288, 367, 14208, 315, 295, 14, 19373, 8, 355, 519, 7601, 20052, 17478, 24621, 1533, 1195, 30982, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2859, 31, 26, 5547, 501, 26285, 4537, 65, 387, 4537, 292, 15, 6427, 15, 7023, 983, 13, 70, 8194, 24, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 20, 17063, 7023, 983, 13, 70, 8194, 713, 93, 6697, 2862, 17, 297, 355, 9248, 1874, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 1335, 87, 3246, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 6704, 69, 2391, 59, 73, 41, 61, 68, 60, 83, 10, 3427, 83, 10, 905, 26889, 2229, 48, 28, 344, 9514, 65, 13, 6353, 13, 58, 16, 13, 25, 8194, 24, 25583, 9248, 12, 288, 283, 30561, 3246, 1305, 297, 849, 29, 403, 9, 398, 340, 1335, 87, 3246, 63, 344, 26, 288, 372, 291, 14, 633, 63, 1099, 8, 355, 283, 30561, 3246, 4881, 435, 1335, 87, 3246, 63, 344, 12, 13446, 534, 42, 55, 10397, 297, 355, 3991, 63, 344, 29, 3722, 63, 344, 9, 398, 5274, 275, 291, 423, 1122, 63, 1001, 8, 288, 291, 423, 1733, 63, 3821, 8, 355, 519, 1159, 616, 83, 60, 83, 23440, 83, 22588, 59, 6977, 8995, 27147, 83, 10, 10805, 9248, 12, 283, 4553, 659, 288, 3991, 63, 344, 12, 5793, 63, 1365, 29, 3596, 63, 475, 63, 1001, 9, 398, 6752, 275, 942, 267, 367, 1350, 315, 5274, 26, 288, 340, 440, 1228, 8, 1365, 12, 1211, 304, 355, 1980, 288, 1350, 63, 633, 275, 1166, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 493, 1333, 288, 340, 440, 1350, 63, 633, 26, 355, 1980, 288, 1599, 275, 6705, 63, 832, 8, 1365, 63, 633, 9, 288, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 490, 1350, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 490, 333, 19, 85, 24, 63, 344, 534, 30252, 297, 14294, 29, 797, 430, 288, 587, 26, 355, 6752, 14, 740, 2561, 490, 283, 633, 356, 1350, 63, 633, 12, 355, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 10062, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 1569, 60, 83, 10, 3427, 83, 10, 779, 3212, 1105, 2229, 48, 28, 633, 30, 5169, 2229, 12525, 17, 680, 6393, 2862, 17, 297, 9248, 12, 288, 283, 8311, 297, 14294, 29, 797, 12, 1572, 534, 633, 358, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 3991, 63, 344, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
miaecle/deepchem
devtools/archive/jenkins/generate_graph.py
2
5220
import csv import os import numpy as np import matplotlib.pyplot as plt import time plt.switch_backend('agg') TODO = { ('tox21', 'random'): [ 'weave', 'graphconv', 'tf', 'tf_robust', 'irv', 'xgb', 'logreg', 'textcnn' ], ('clintox', 'random'): [ 'weave', 'graphconv', 'tf', 'tf_robust', 'irv', 'xgb', 'logreg', 'textcnn' ], ('sider', 'random'): [ 'weave', 'graphconv', 'tf', 'tf_robust', 'irv', 'xgb', 'logreg', 'textcnn' ], ('bbbp', 'scaffold'): ['weave', 'graphconv', 'tf', 'irv', 'xgb', 'logreg', 'textcnn'], ('bace_c', 'scaffold'): ['weave', 'graphconv', 'tf', 'irv', 'xgb', 'logreg', 'textcnn'], ('hiv', 'scaffold'): ['weave', 'graphconv', 'tf', 'irv', 'xgb', 'logreg', 'textcnn'], ('muv', 'random'): ['graphconv', 'tf', 'tf_robust', 'irv', 'xgb', 'logreg'], ('delaney', 'random'): [ 'weave_regression', 'graphconvreg', 'tf_regression', 'xgb_regression', 'krr', 'textcnn_regression', 'dag_regression', 'mpnn' ], ('sampl', 'random'): [ 'weave_regression', 'graphconvreg', 'tf_regression', 'xgb_regression', 'krr', 'textcnn_regression', 'dag_regression', 'mpnn' ], ('lipo', 'random'): [ 'weave_regression', 'graphconvreg', 'tf_regression', 'xgb_regression', 'krr', 'textcnn_regression', 'dag_regression', 'mpnn' ], ('qm7', 'stratified'): [ 'dtnn', 'graphconvreg', 'tf_regression_ft', 'krr_ft' ], ('qm8', 'random'): [ 'dtnn', 'graphconvreg', 'weave_regression', 'textcnn_regression', 'mpnn', 'tf_regression', 'tf_regression_ft' ], } ORDER = [ 'logreg', 'rf', 'rf_regression', 'xgb', 'xgb_regression', 'kernelsvm', 'krr', 'krr_ft', 'tf', 'tf_regression', 'tf_regression_ft', 'tf_robust', 'irv', 'textcnn', 'textcnn_regression', 'graphconv', 'graphconvreg', 'dag', 'dag_regression', 'ani', 'weave', 'weave_regression', 'dtnn', 'mpnn' ] COLOR = { 'logreg': '#3F3F3F', 'rf': '#67AD4F', 'rf_regression': '#67AD4F', 'xgb': '#0E766C', 'xgb_regression': '#0E766C', 'kernelsvm': '#FC926B', 'krr': '#FC926B', 'krr_ft': '#5A372A', 'tf': '#2B6596', 'tf_regression': '#2B6596', 'tf_regression_ft': '#162939', 'tf_robust': '#775183', 'irv': '#D9D9D9', 'graphconv': '#A4D192', 'graphconvreg': '#A4D192', 'dag': '#D06329', 'dag_regression': '#D06329', 'ani': '#D9D9D9', 'weave': '#8196AE', 'weave_regression': '#8196AE', 'textcnn': '#811B18', 'textcnn_regression': '#811B18', 'dtnn': '#D06329', 'mpnn': '#7B0A48' } TODO_list = set() for key in TODO.keys(): for val in TODO[key]: TODO_list.add((key[0], key[1], val)) def read_results(path): Results = set() with open(path, 'r') as f: reader = csv.reader(f) for line in reader: Results.add((line[0], line[1], line[3])) return Results def run_benchmark(path, deepchem_dir): finished = read_results(path) os.chdir(deepchem_dir) os.chdir('./examples') while len(TODO_list - finished) > 0: todo = TODO_list - finished for p in todo: os.system('python benchmark.py --seed 123 -d ' + p[0] + ' -s ' + p[1] + ' -m ' + p[2]) def plot(dataset, split, path, out_path): if dataset in [ 'bace_c', 'bbbp', 'clintox', 'hiv', 'muv', 'pcba', 'pcba_146', 'pcba_2475', 'sider', 'tox21', 'toxcast' ]: mode = 'classification' else: mode = 'regression' data = {} with open(path, 'r') as f: reader = csv.reader(f) for line in reader: if line[0] == dataset and line[1] == split: data[line[3]] = line[8] labels = [] values = [] colors = [] for model in ORDER: if model in data.keys(): labels.append(model) colors.append(COLOR[model]) values.append(float(data[model])) y_pos = np.arange(len(labels)) plt.rcdefaults() fig, ax = plt.subplots() ax.barh(y_pos, values, align='center', color='green') ax.set_yticks(y_pos) ax.set_yticklabels(labels) ax.invert_yaxis() if mode == 'regression': ax.set_xlabel('R square') ax.set_xlim(left=0., right=1.) else: ax.set_xlabel('ROC-AUC') ax.set_xlim(left=0.4, right=1.) t = time.localtime(time.time()) ax.set_title("Performance on %s (%s split), %i-%i-%i" % (dataset, split, t.tm_year, t.tm_mon, t.tm_mday)) plt.tight_layout() for i in range(len(colors)): ax.get_children()[i].set_color(colors[i]) ax.text( values[i] - 0.1, y_pos[i] + 0.1, str("%.3f" % values[i]), color='white') fig.savefig(os.path.join(out_path, dataset + '_' + split + '.png')) #plt.show() if __name__ == '__main__': current_dir = os.path.dirname(os.path.realpath(__file__)) DEEPCHEM_DIR = os.path.split(os.path.split(current_dir)[0])[0] FILE = os.path.join(os.path.join(DEEPCHEM_DIR, 'examples'), 'results.csv') #run_benchmark(FILE, DEEPCHEM_DIR) save_dir = os.path.join(DEEPCHEM_DIR, 'datasets/MolNet_pic') if not os.path.exists(save_dir): os.mkdir(save_dir) for pair in TODO.keys(): plot(pair[0], pair[1], FILE, save_dir) os.system('aws s3 sync ' + save_dir + ' s3://deepchem.io/trained_models/MolNet_pic')
mit
[ 646, 7392, 199, 646, 747, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 900, 199, 6003, 14, 5656, 63, 4620, 360, 13452, 358, 199, 199, 11768, 275, 469, 272, 661, 475, 88, 2025, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 429, 9924, 88, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 16994, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 2501, 10913, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 2470, 301, 63, 67, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 72, 1003, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 6553, 86, 297, 283, 2355, 735, 788, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 995, 272, 661, 271, 1502, 14655, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 2231, 2421, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 317, 555, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 17976, 23, 297, 283, 14183, 8981, 735, 359, 267, 283, 3583, 4411, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 63, 856, 297, 283, 75, 9734, 63, 856, 7, 272, 2156, 272, 661, 17976, 24, 297, 283, 2355, 735, 359, 267, 283, 3583, 4411, 297, 283, 2180, 5598, 1135, 297, 283, 1129, 811, 63, 12513, 297, 283, 505, 67, 4411, 63, 12513, 297, 267, 283, 311, 4411, 297, 283, 3249, 63, 12513, 297, 283, 3249, 63, 12513, 63, 856, 7, 272, 2156, 199, 93, 199, 199, 12125, 275, 359, 272, 283, 793, 1135, 297, 283, 3941, 297, 283, 3941, 63, 12513, 297, 283, 88, 4908, 297, 283, 88, 4908, 63, 12513, 297, 283, 4989, 16820, 297, 272, 283, 75, 9734, 297, 283, 75, 9734, 63, 856, 297, 283, 3249, 297, 283, 3249, 63, 12513, 297, 283, 3249, 63, 12513, 63, 856, 297, 283, 3249, 63, 293, 15549, 297, 272, 283, 723, 86, 297, 283, 505, 67, 4411, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 2180, 5598, 297, 283, 2180, 5598, 1135, 297, 283, 7406, 297, 272, 283, 7406, 63, 12513, 297, 283, 26455, 297, 283, 1129, 811, 297, 283, 1129, 811, 63, 12513, 297, 283, 3583, 4411, 297, 283, 311, 4411, 7, 199, 61, 199, 199, 7134, 275, 469, 272, 283, 793, 1135, 356, 3943, 19, 38, 19, 38, 19, 38, 297, 272, 283, 3941, 356, 3943, 1822, 1554, 20, 38, 297, 272, 283, 3941, 63, 12513, 356, 3943, 1822, 1554, 20, 38, 297, 272, 283, 88, 4908, 356, 3943, 16, 37, 31251, 35, 297, 272, 283, 88, 4908, 63, 12513, 356, 3943, 16, 37, 31251, 35, 297, 272, 283, 4989, 16820, 356, 3943, 4161, 27642, 34, 297, 272, 283, 75, 9734, 356, 3943, 4161, 27642, 34, 297, 272, 283, 75, 9734, 63, 856, 356, 3943, 21, 33, 15541, 33, 297, 272, 283, 3249, 356, 3943, 18, 34, 22, 15112, 297, 272, 283, 3249, 63, 12513, 356, 3943, 18, 34, 22, 15112, 297, 272, 283, 3249, 63, 12513, 63, 856, 356, 3943, 975, 1398, 1355, 297, 272, 283, 3249, 63, 293, 15549, 356, 3943, 12710, 12363, 297, 272, 283, 723, 86, 356, 3943, 36, 25, 36, 25, 36, 25, 297, 272, 283, 2180, 5598, 356, 3943, 33, 20, 36, 5756, 297, 272, 283, 2180, 5598, 1135, 356, 3943, 33, 20, 36, 5756, 297, 272, 283, 7406, 356, 3943, 36, 1690, 11685, 297, 272, 283, 7406, 63, 12513, 356, 3943, 36, 1690, 11685, 297, 272, 283, 26455, 356, 3943, 36, 25, 36, 25, 36, 25, 297, 272, 283, 1129, 811, 356, 3943, 24, 10800, 12500, 297, 272, 283, 1129, 811, 63, 12513, 356, 3943, 24, 10800, 12500, 297, 272, 283, 505, 67, 4411, 356, 3943, 26623, 34, 1085, 297, 272, 283, 505, 67, 4411, 63, 12513, 356, 3943, 26623, 34, 1085, 297, 272, 283, 3583, 4411, 356, 3943, 36, 1690, 11685, 297, 272, 283, 311, 4411, 356, 3943, 23, 34, 16, 33, 2006, 7, 199, 93, 199, 199, 11768, 63, 513, 275, 663, 342, 199, 509, 790, 315, 3254, 14, 1612, 837, 523, 367, 1139, 315, 3254, 59, 498, 2189, 272, 3254, 63, 513, 14, 525, 1332, 498, 59, 16, 467, 790, 59, 17, 467, 1139, 430, 421, 199, 318, 1586 ]
[ 7392, 199, 646, 747, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 900, 199, 6003, 14, 5656, 63, 4620, 360, 13452, 358, 199, 199, 11768, 275, 469, 272, 661, 475, 88, 2025, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 429, 9924, 88, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 16994, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 267, 283, 505, 67, 4411, 7, 272, 2156, 272, 661, 2501, 10913, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 2470, 301, 63, 67, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 72, 1003, 297, 283, 27927, 735, 272, 788, 1129, 811, 297, 283, 2180, 5598, 297, 283, 3249, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 297, 283, 505, 67, 4411, 995, 272, 661, 6553, 86, 297, 283, 2355, 735, 788, 2180, 5598, 297, 283, 3249, 297, 283, 3249, 63, 293, 15549, 297, 283, 723, 86, 297, 283, 88, 4908, 297, 283, 793, 1135, 995, 272, 661, 271, 1502, 14655, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 2231, 2421, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 317, 555, 297, 283, 2355, 735, 359, 267, 283, 1129, 811, 63, 12513, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 297, 283, 88, 4908, 63, 12513, 297, 267, 283, 75, 9734, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 7406, 63, 12513, 297, 283, 311, 4411, 7, 272, 2156, 272, 661, 17976, 23, 297, 283, 14183, 8981, 735, 359, 267, 283, 3583, 4411, 297, 283, 2180, 5598, 1135, 297, 283, 3249, 63, 12513, 63, 856, 297, 283, 75, 9734, 63, 856, 7, 272, 2156, 272, 661, 17976, 24, 297, 283, 2355, 735, 359, 267, 283, 3583, 4411, 297, 283, 2180, 5598, 1135, 297, 283, 1129, 811, 63, 12513, 297, 283, 505, 67, 4411, 63, 12513, 297, 267, 283, 311, 4411, 297, 283, 3249, 63, 12513, 297, 283, 3249, 63, 12513, 63, 856, 7, 272, 2156, 199, 93, 199, 199, 12125, 275, 359, 272, 283, 793, 1135, 297, 283, 3941, 297, 283, 3941, 63, 12513, 297, 283, 88, 4908, 297, 283, 88, 4908, 63, 12513, 297, 283, 4989, 16820, 297, 272, 283, 75, 9734, 297, 283, 75, 9734, 63, 856, 297, 283, 3249, 297, 283, 3249, 63, 12513, 297, 283, 3249, 63, 12513, 63, 856, 297, 283, 3249, 63, 293, 15549, 297, 272, 283, 723, 86, 297, 283, 505, 67, 4411, 297, 283, 505, 67, 4411, 63, 12513, 297, 283, 2180, 5598, 297, 283, 2180, 5598, 1135, 297, 283, 7406, 297, 272, 283, 7406, 63, 12513, 297, 283, 26455, 297, 283, 1129, 811, 297, 283, 1129, 811, 63, 12513, 297, 283, 3583, 4411, 297, 283, 311, 4411, 7, 199, 61, 199, 199, 7134, 275, 469, 272, 283, 793, 1135, 356, 3943, 19, 38, 19, 38, 19, 38, 297, 272, 283, 3941, 356, 3943, 1822, 1554, 20, 38, 297, 272, 283, 3941, 63, 12513, 356, 3943, 1822, 1554, 20, 38, 297, 272, 283, 88, 4908, 356, 3943, 16, 37, 31251, 35, 297, 272, 283, 88, 4908, 63, 12513, 356, 3943, 16, 37, 31251, 35, 297, 272, 283, 4989, 16820, 356, 3943, 4161, 27642, 34, 297, 272, 283, 75, 9734, 356, 3943, 4161, 27642, 34, 297, 272, 283, 75, 9734, 63, 856, 356, 3943, 21, 33, 15541, 33, 297, 272, 283, 3249, 356, 3943, 18, 34, 22, 15112, 297, 272, 283, 3249, 63, 12513, 356, 3943, 18, 34, 22, 15112, 297, 272, 283, 3249, 63, 12513, 63, 856, 356, 3943, 975, 1398, 1355, 297, 272, 283, 3249, 63, 293, 15549, 356, 3943, 12710, 12363, 297, 272, 283, 723, 86, 356, 3943, 36, 25, 36, 25, 36, 25, 297, 272, 283, 2180, 5598, 356, 3943, 33, 20, 36, 5756, 297, 272, 283, 2180, 5598, 1135, 356, 3943, 33, 20, 36, 5756, 297, 272, 283, 7406, 356, 3943, 36, 1690, 11685, 297, 272, 283, 7406, 63, 12513, 356, 3943, 36, 1690, 11685, 297, 272, 283, 26455, 356, 3943, 36, 25, 36, 25, 36, 25, 297, 272, 283, 1129, 811, 356, 3943, 24, 10800, 12500, 297, 272, 283, 1129, 811, 63, 12513, 356, 3943, 24, 10800, 12500, 297, 272, 283, 505, 67, 4411, 356, 3943, 26623, 34, 1085, 297, 272, 283, 505, 67, 4411, 63, 12513, 356, 3943, 26623, 34, 1085, 297, 272, 283, 3583, 4411, 356, 3943, 36, 1690, 11685, 297, 272, 283, 311, 4411, 356, 3943, 23, 34, 16, 33, 2006, 7, 199, 93, 199, 199, 11768, 63, 513, 275, 663, 342, 199, 509, 790, 315, 3254, 14, 1612, 837, 523, 367, 1139, 315, 3254, 59, 498, 2189, 272, 3254, 63, 513, 14, 525, 1332, 498, 59, 16, 467, 790, 59, 17, 467, 1139, 430, 421, 199, 318, 1586, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cyberark-bizdev/ansible
lib/ansible/modules/cloud/misc/rhevm.py
16
51635
#!/usr/bin/python # (c) 2016, Timothy Vandenbrande <timothy.vandenbrande@gmail.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: rhevm author: Timothy Vandenbrande short_description: RHEV/oVirt automation description: - This module only supports oVirt/RHEV version 3. A newer module M(ovirt_vms) supports oVirt/RHV version 4. - Allows you to create/remove/update or powermanage virtual machines on a RHEV/oVirt platform. version_added: "2.2" requirements: - ovirtsdk options: user: description: - The user to authenticate with. default: "admin@internal" required: false server: description: - The name/ip of your RHEV-m/oVirt instance. default: "127.0.0.1" required: false port: description: - The port on which the API is reacheable. default: "443" required: false insecure_api: description: - A boolean switch to make a secure or insecure connection to the server. default: false required: false name: description: - The name of the VM. cluster: description: - The rhev/ovirt cluster in which you want you VM to start. required: false datacenter: description: - The rhev/ovirt datacenter in which you want you VM to start. required: false default: "Default" state: description: - This serves to create/remove/update or powermanage your VM. default: "present" required: false choices: ['ping', 'present', 'absent', 'up', 'down', 'restarted', 'cd', 'info'] image: description: - The template to use for the VM. default: null required: false type: description: - To define if the VM is a server or desktop. default: server required: false choices: [ 'server', 'desktop', 'host' ] vmhost: description: - The host you wish your VM to run on. required: false vmcpu: description: - The number of CPUs you want in your VM. default: "2" required: false cpu_share: description: - This parameter is used to configure the cpu share. default: "0" required: false vmmem: description: - The amount of memory you want your VM to use (in GB). default: "1" required: false osver: description: - The operationsystem option in RHEV/oVirt. default: "rhel_6x64" required: false mempol: description: - The minimum amount of memory you wish to reserve for this system. default: "1" required: false vm_ha: description: - To make your VM High Available. default: true required: false disks: description: - This option uses complex arguments and is a list of disks with the options name, size and domain. required: false ifaces: description: - This option uses complex arguments and is a list of interfaces with the options name and vlan. aliases: ['nics', 'interfaces'] required: false boot_order: description: - This option uses complex arguments and is a list of items that specify the bootorder. default: ["network","hd"] required: false del_prot: description: - This option sets the delete protection checkbox. default: true required: false cd_drive: description: - The CD you wish to have mounted on the VM when I(state = 'CD'). default: null required: false timeout: description: - The timeout you wish to define for power actions. - When I(state = 'up') - When I(state = 'down') - When I(state = 'restarted') default: null required: false ''' RETURN = ''' vm: description: Returns all of the VMs variables and execution. returned: always type: dict sample: '{ "boot_order": [ "hd", "network" ], "changed": true, "changes": [ "Delete Protection" ], "cluster": "C1", "cpu_share": "0", "created": false, "datacenter": "Default", "del_prot": true, "disks": [ { "domain": "ssd-san", "name": "OS", "size": 40 } ], "eth0": "00:00:5E:00:53:00", "eth1": "00:00:5E:00:53:01", "eth2": "00:00:5E:00:53:02", "exists": true, "failed": false, "ifaces": [ { "name": "eth0", "vlan": "Management" }, { "name": "eth1", "vlan": "Internal" }, { "name": "eth2", "vlan": "External" } ], "image": false, "mempol": "0", "msg": [ "VM exists", "cpu_share was already set to 0", "VM high availability was already set to True", "The boot order has already been set", "VM delete protection has been set to True", "Disk web2_Disk0_OS already exists", "The VM starting host was already set to host416" ], "name": "web2", "type": "server", "uuid": "4ba5a1be-e60b-4368-9533-920f156c817b", "vm_ha": true, "vmcpu": "4", "vmhost": "host416", "vmmem": "16" }' ''' EXAMPLES = ''' # basic get info from VM - rhevm: name: "demo" user: "{{ rhev.admin.name }}" password: "{{ rhev.admin.pass }}" server: "rhevm01" state: "info" # basic create example from image - rhevm: name: "demo" user: "{{ rhev.admin.name }}" password: "{{ rhev.admin.pass }}" server: "rhevm01" state: "present" image: "centos7_x64" cluster: "centos" # power management - rhevm: name: "uptime_server" user: "{{ rhev.admin.name }}" password: "{{ rhev.admin.pass }}" server: "rhevm01" cluster: "RH" state: "down" image: "centos7_x64" # multi disk, multi nic create example - rhevm: name: "server007" user: "{{ rhev.admin.name }}" password: "{{ rhev.admin.pass }}" server: "rhevm01" cluster: "RH" state: "present" type: "server" vmcpu: 4 vmmem: 2 ifaces: - name: "eth0" vlan: "vlan2202" - name: "eth1" vlan: "vlan36" - name: "eth2" vlan: "vlan38" - name: "eth3" vlan: "vlan2202" disks: - name: "root" size: 10 domain: "ssd-san" - name: "swap" size: 10 domain: "15kiscsi-san" - name: "opt" size: 10 domain: "15kiscsi-san" - name: "var" size: 10 domain: "10kiscsi-san" - name: "home" size: 10 domain: "sata-san" boot_order: - "network" - "hd" # add a CD to the disk cd_drive - rhevm: name: 'server007' user: "{{ rhev.admin.name }}" password: "{{ rhev.admin.pass }}" state: 'cd' cd_drive: 'rhev-tools-setup.iso' # new host deployment + host network configuration - rhevm: name: "ovirt_node007" password: "{{ rhevm.admin.pass }}" type: "host" state: present cluster: "rhevm01" ifaces: - name: em1 - name: em2 - name: p3p1 ip: '172.31.224.200' netmask: '255.255.254.0' - name: p3p2 ip: '172.31.225.200' netmask: '255.255.254.0' - name: bond0 bond: - em1 - em2 network: 'rhevm' ip: '172.31.222.200' netmask: '255.255.255.0' management: True - name: bond0.36 network: 'vlan36' ip: '10.2.36.200' netmask: '255.255.254.0' gateway: '10.2.36.254' - name: bond0.2202 network: 'vlan2202' - name: bond0.38 network: 'vlan38' ''' import time try: from ovirtsdk.api import API from ovirtsdk.xml import params HAS_SDK = True except ImportError: HAS_SDK = False from ansible.module_utils.basic import AnsibleModule RHEV_FAILED = 1 RHEV_SUCCESS = 0 RHEV_UNAVAILABLE = 2 RHEV_TYPE_OPTS = ['server', 'desktop', 'host'] STATE_OPTS = ['ping', 'present', 'absent', 'up', 'down', 'restart', 'cd', 'info'] global msg, changed, failed msg = [] changed = False failed = False class RHEVConn(object): 'Connection to RHEV-M' def __init__(self, module): self.module = module user = module.params.get('user') password = module.params.get('password') server = module.params.get('server') port = module.params.get('port') insecure_api = module.params.get('insecure_api') url = "https://%s:%s" % (server, port) try: api = API(url=url, username=user, password=password, insecure=str(insecure_api)) api.test() self.conn = api except: raise Exception("Failed to connect to RHEV-M.") def __del__(self): self.conn.disconnect() def createVMimage(self, name, cluster, template): try: vmparams = params.VM( name=name, cluster=self.conn.clusters.get(name=cluster), template=self.conn.templates.get(name=template), disks=params.Disks(clone=True) ) self.conn.vms.add(vmparams) setMsg("VM is created") setChanged() return True except Exception as e: setMsg("Failed to create VM") setMsg(str(e)) setFailed() return False def createVM(self, name, cluster, os, actiontype): try: vmparams = params.VM( name=name, cluster=self.conn.clusters.get(name=cluster), os=params.OperatingSystem(type_=os), template=self.conn.templates.get(name="Blank"), type_=actiontype ) self.conn.vms.add(vmparams) setMsg("VM is created") setChanged() return True except Exception as e: setMsg("Failed to create VM") setMsg(str(e)) setFailed() return False def createDisk(self, vmname, diskname, disksize, diskdomain, diskinterface, diskformat, diskallocationtype, diskboot): VM = self.get_VM(vmname) newdisk = params.Disk( name=diskname, size=1024 * 1024 * 1024 * int(disksize), wipe_after_delete=True, sparse=diskallocationtype, interface=diskinterface, format=diskformat, bootable=diskboot, storage_domains=params.StorageDomains( storage_domain=[self.get_domain(diskdomain)] ) ) try: VM.disks.add(newdisk) VM.update() setMsg("Successfully added disk " + diskname) setChanged() except Exception as e: setFailed() setMsg("Error attaching " + diskname + "disk, please recheck and remove any leftover configuration.") setMsg(str(e)) return False try: currentdisk = VM.disks.get(name=diskname) attempt = 1 while currentdisk.status.state != 'ok': currentdisk = VM.disks.get(name=diskname) if attempt == 100: setMsg("Error, disk %s, state %s" % (diskname, str(currentdisk.status.state))) raise Exception() else: attempt += 1 time.sleep(2) setMsg("The disk " + diskname + " is ready.") except Exception as e: setFailed() setMsg("Error getting the state of " + diskname + ".") setMsg(str(e)) return False return True def createNIC(self, vmname, nicname, vlan, interface): VM = self.get_VM(vmname) CLUSTER = self.get_cluster_byid(VM.cluster.id) DC = self.get_DC_byid(CLUSTER.data_center.id) newnic = params.NIC( name=nicname, network=DC.networks.get(name=vlan), interface=interface ) try: VM.nics.add(newnic) VM.update() setMsg("Successfully added iface " + nicname) setChanged() except Exception as e: setFailed() setMsg("Error attaching " + nicname + " iface, please recheck and remove any leftover configuration.") setMsg(str(e)) return False try: currentnic = VM.nics.get(name=nicname) attempt = 1 while currentnic.active is not True: currentnic = VM.nics.get(name=nicname) if attempt == 100: setMsg("Error, iface %s, state %s" % (nicname, str(currentnic.active))) raise Exception() else: attempt += 1 time.sleep(2) setMsg("The iface " + nicname + " is ready.") except Exception as e: setFailed() setMsg("Error getting the state of " + nicname + ".") setMsg(str(e)) return False return True def get_DC(self, dc_name): return self.conn.datacenters.get(name=dc_name) def get_DC_byid(self, dc_id): return self.conn.datacenters.get(id=dc_id) def get_VM(self, vm_name): return self.conn.vms.get(name=vm_name) def get_cluster_byid(self, cluster_id): return self.conn.clusters.get(id=cluster_id) def get_cluster(self, cluster_name): return self.conn.clusters.get(name=cluster_name) def get_domain_byid(self, dom_id): return self.conn.storagedomains.get(id=dom_id) def get_domain(self, domain_name): return self.conn.storagedomains.get(name=domain_name) def get_disk(self, disk): return self.conn.disks.get(disk) def get_network(self, dc_name, network_name): return self.get_DC(dc_name).networks.get(network_name) def get_network_byid(self, network_id): return self.conn.networks.get(id=network_id) def get_NIC(self, vm_name, nic_name): return self.get_VM(vm_name).nics.get(nic_name) def get_Host(self, host_name): return self.conn.hosts.get(name=host_name) def get_Host_byid(self, host_id): return self.conn.hosts.get(id=host_id) def set_Memory(self, name, memory): VM = self.get_VM(name) VM.memory = int(int(memory) * 1024 * 1024 * 1024) try: VM.update() setMsg("The Memory has been updated.") setChanged() return True except Exception as e: setMsg("Failed to update memory.") setMsg(str(e)) setFailed() return False def set_Memory_Policy(self, name, memory_policy): VM = self.get_VM(name) VM.memory_policy.guaranteed = int(int(memory_policy) * 1024 * 1024 * 1024) try: VM.update() setMsg("The memory policy has been updated.") setChanged() return True except Exception as e: setMsg("Failed to update memory policy.") setMsg(str(e)) setFailed() return False def set_CPU(self, name, cpu): VM = self.get_VM(name) VM.cpu.topology.cores = int(cpu) try: VM.update() setMsg("The number of CPUs has been updated.") setChanged() return True except Exception as e: setMsg("Failed to update the number of CPUs.") setMsg(str(e)) setFailed() return False def set_CPU_share(self, name, cpu_share): VM = self.get_VM(name) VM.cpu_shares = int(cpu_share) try: VM.update() setMsg("The CPU share has been updated.") setChanged() return True except Exception as e: setMsg("Failed to update the CPU share.") setMsg(str(e)) setFailed() return False def set_Disk(self, diskname, disksize, diskinterface, diskboot): DISK = self.get_disk(diskname) setMsg("Checking disk " + diskname) if DISK.get_bootable() != diskboot: try: DISK.set_bootable(diskboot) setMsg("Updated the boot option on the disk.") setChanged() except Exception as e: setMsg("Failed to set the boot option on the disk.") setMsg(str(e)) setFailed() return False else: setMsg("The boot option of the disk is correct") if int(DISK.size) < (1024 * 1024 * 1024 * int(disksize)): try: DISK.size = (1024 * 1024 * 1024 * int(disksize)) setMsg("Updated the size of the disk.") setChanged() except Exception as e: setMsg("Failed to update the size of the disk.") setMsg(str(e)) setFailed() return False elif int(DISK.size) < (1024 * 1024 * 1024 * int(disksize)): setMsg("Shrinking disks is not supported") setMsg(str(e)) setFailed() return False else: setMsg("The size of the disk is correct") if str(DISK.interface) != str(diskinterface): try: DISK.interface = diskinterface setMsg("Updated the interface of the disk.") setChanged() except Exception as e: setMsg("Failed to update the interface of the disk.") setMsg(str(e)) setFailed() return False else: setMsg("The interface of the disk is correct") return True def set_NIC(self, vmname, nicname, newname, vlan, interface): NIC = self.get_NIC(vmname, nicname) VM = self.get_VM(vmname) CLUSTER = self.get_cluster_byid(VM.cluster.id) DC = self.get_DC_byid(CLUSTER.data_center.id) NETWORK = self.get_network(str(DC.name), vlan) checkFail() if NIC.name != newname: NIC.name = newname setMsg('Updating iface name to ' + newname) setChanged() if str(NIC.network.id) != str(NETWORK.id): NIC.set_network(NETWORK) setMsg('Updating iface network to ' + vlan) setChanged() if NIC.interface != interface: NIC.interface = interface setMsg('Updating iface interface to ' + interface) setChanged() try: NIC.update() setMsg('iface has successfully been updated.') except Exception as e: setMsg("Failed to update the iface.") setMsg(str(e)) setFailed() return False return True def set_DeleteProtection(self, vmname, del_prot): VM = self.get_VM(vmname) VM.delete_protected = del_prot try: VM.update() setChanged() except Exception as e: setMsg("Failed to update delete protection.") setMsg(str(e)) setFailed() return False return True def set_BootOrder(self, vmname, boot_order): VM = self.get_VM(vmname) bootorder = [] for device in boot_order: bootorder.append(params.Boot(dev=device)) VM.os.boot = bootorder try: VM.update() setChanged() except Exception as e: setMsg("Failed to update the boot order.") setMsg(str(e)) setFailed() return False return True def set_Host(self, host_name, cluster, ifaces): HOST = self.get_Host(host_name) CLUSTER = self.get_cluster(cluster) if HOST is None: setMsg("Host does not exist.") ifacelist = dict() networklist = [] manageip = '' try: for iface in ifaces: try: setMsg('creating host interface ' + iface['name']) if 'management' in iface: manageip = iface['ip'] if 'boot_protocol' not in iface: if 'ip' in iface: iface['boot_protocol'] = 'static' else: iface['boot_protocol'] = 'none' if 'ip' not in iface: iface['ip'] = '' if 'netmask' not in iface: iface['netmask'] = '' if 'gateway' not in iface: iface['gateway'] = '' if 'network' in iface: if 'bond' in iface: bond = [] for slave in iface['bond']: bond.append(ifacelist[slave]) try: tmpiface = params.Bonding( slaves=params.Slaves(host_nic=bond), options=params.Options( option=[ params.Option(name='miimon', value='100'), params.Option(name='mode', value='4') ] ) ) except Exception as e: setMsg('Failed to create the bond for ' + iface['name']) setFailed() setMsg(str(e)) return False try: tmpnetwork = params.HostNIC( network=params.Network(name=iface['network']), name=iface['name'], boot_protocol=iface['boot_protocol'], ip=params.IP( address=iface['ip'], netmask=iface['netmask'], gateway=iface['gateway'] ), override_configuration=True, bonding=tmpiface) networklist.append(tmpnetwork) setMsg('Applying network ' + iface['name']) except Exception as e: setMsg('Failed to set' + iface['name'] + ' as network interface') setFailed() setMsg(str(e)) return False else: tmpnetwork = params.HostNIC( network=params.Network(name=iface['network']), name=iface['name'], boot_protocol=iface['boot_protocol'], ip=params.IP( address=iface['ip'], netmask=iface['netmask'], gateway=iface['gateway'] )) networklist.append(tmpnetwork) setMsg('Applying network ' + iface['name']) else: tmpiface = params.HostNIC( name=iface['name'], network=params.Network(), boot_protocol=iface['boot_protocol'], ip=params.IP( address=iface['ip'], netmask=iface['netmask'], gateway=iface['gateway'] )) ifacelist[iface['name']] = tmpiface except Exception as e: setMsg('Failed to set ' + iface['name']) setFailed() setMsg(str(e)) return False except Exception as e: setMsg('Failed to set networks') setMsg(str(e)) setFailed() return False if manageip == '': setMsg('No management network is defined') setFailed() return False try: HOST = params.Host(name=host_name, address=manageip, cluster=CLUSTER, ssh=params.SSH(authentication_method='publickey')) if self.conn.hosts.add(HOST): setChanged() HOST = self.get_Host(host_name) state = HOST.status.state while (state != 'non_operational' and state != 'up'): HOST = self.get_Host(host_name) state = HOST.status.state time.sleep(1) if state == 'non_responsive': setMsg('Failed to add host to RHEVM') setFailed() return False setMsg('status host: up') time.sleep(5) HOST = self.get_Host(host_name) state = HOST.status.state setMsg('State before setting to maintenance: ' + str(state)) HOST.deactivate() while state != 'maintenance': HOST = self.get_Host(host_name) state = HOST.status.state time.sleep(1) setMsg('status host: maintenance') try: HOST.nics.setupnetworks(params.Action( force=True, check_connectivity=False, host_nics=params.HostNics(host_nic=networklist) )) setMsg('nics are set') except Exception as e: setMsg('Failed to apply networkconfig') setFailed() setMsg(str(e)) return False try: HOST.commitnetconfig() setMsg('Network config is saved') except Exception as e: setMsg('Failed to save networkconfig') setFailed() setMsg(str(e)) return False except Exception as e: if 'The Host name is already in use' in str(e): setMsg("Host already exists") else: setMsg("Failed to add host") setFailed() setMsg(str(e)) return False HOST.activate() while state != 'up': HOST = self.get_Host(host_name) state = HOST.status.state time.sleep(1) if state == 'non_responsive': setMsg('Failed to apply networkconfig.') setFailed() return False setMsg('status host: up') else: setMsg("Host exists.") return True def del_NIC(self, vmname, nicname): return self.get_NIC(vmname, nicname).delete() def remove_VM(self, vmname): VM = self.get_VM(vmname) try: VM.delete() except Exception as e: setMsg("Failed to remove VM.") setMsg(str(e)) setFailed() return False return True def start_VM(self, vmname, timeout): VM = self.get_VM(vmname) try: VM.start() except Exception as e: setMsg("Failed to start VM.") setMsg(str(e)) setFailed() return False return self.wait_VM(vmname, "up", timeout) def wait_VM(self, vmname, state, timeout): VM = self.get_VM(vmname) while VM.status.state != state: VM = self.get_VM(vmname) time.sleep(10) if timeout is not False: timeout -= 10 if timeout <= 0: setMsg("Timeout expired") setFailed() return False return True def stop_VM(self, vmname, timeout): VM = self.get_VM(vmname) try: VM.stop() except Exception as e: setMsg("Failed to stop VM.") setMsg(str(e)) setFailed() return False return self.wait_VM(vmname, "down", timeout) def set_CD(self, vmname, cd_drive): VM = self.get_VM(vmname) try: if str(VM.status.state) == 'down': cdrom = params.CdRom(file=cd_drive) VM.cdroms.add(cdrom) setMsg("Attached the image.") setChanged() else: cdrom = VM.cdroms.get(id="00000000-0000-0000-0000-000000000000") cdrom.set_file(cd_drive) cdrom.update(current=True) setMsg("Attached the image.") setChanged() except Exception as e: setMsg("Failed to attach image.") setMsg(str(e)) setFailed() return False return True def set_VM_Host(self, vmname, vmhost): VM = self.get_VM(vmname) HOST = self.get_Host(vmhost) try: VM.placement_policy.host = HOST VM.update() setMsg("Set startup host to " + vmhost) setChanged() except Exception as e: setMsg("Failed to set startup host.") setMsg(str(e)) setFailed() return False return True def migrate_VM(self, vmname, vmhost): VM = self.get_VM(vmname) HOST = self.get_Host_byid(VM.host.id) if str(HOST.name) != vmhost: try: VM.migrate( action=params.Action( host=params.Host( name=vmhost, ) ), ) setChanged() setMsg("VM migrated to " + vmhost) except Exception as e: setMsg("Failed to set startup host.") setMsg(str(e)) setFailed() return False return True def remove_CD(self, vmname): VM = self.get_VM(vmname) try: VM.cdroms.get(id="00000000-0000-0000-0000-000000000000").delete() setMsg("Removed the image.") setChanged() except Exception as e: setMsg("Failed to remove the image.") setMsg(str(e)) setFailed() return False return True class RHEV(object): def __init__(self, module): self.module = module def __get_conn(self): self.conn = RHEVConn(self.module) return self.conn def test(self): self.__get_conn() return "OK" def getVM(self, name): self.__get_conn() VM = self.conn.get_VM(name) if VM: vminfo = dict() vminfo['uuid'] = VM.id vminfo['name'] = VM.name vminfo['status'] = VM.status.state vminfo['cpu_cores'] = VM.cpu.topology.cores vminfo['cpu_sockets'] = VM.cpu.topology.sockets vminfo['cpu_shares'] = VM.cpu_shares vminfo['memory'] = (int(VM.memory) // 1024 // 1024 // 1024) vminfo['mem_pol'] = (int(VM.memory_policy.guaranteed) // 1024 // 1024 // 1024) vminfo['os'] = VM.get_os().type_ vminfo['del_prot'] = VM.delete_protected try: vminfo['host'] = str(self.conn.get_Host_byid(str(VM.host.id)).name) except Exception: vminfo['host'] = None vminfo['boot_order'] = [] for boot_dev in VM.os.get_boot(): vminfo['boot_order'].append(str(boot_dev.dev)) vminfo['disks'] = [] for DISK in VM.disks.list(): disk = dict() disk['name'] = DISK.name disk['size'] = (int(DISK.size) // 1024 // 1024 // 1024) disk['domain'] = str((self.conn.get_domain_byid(DISK.get_storage_domains().get_storage_domain()[0].id)).name) disk['interface'] = DISK.interface vminfo['disks'].append(disk) vminfo['ifaces'] = [] for NIC in VM.nics.list(): iface = dict() iface['name'] = str(NIC.name) iface['vlan'] = str(self.conn.get_network_byid(NIC.get_network().id).name) iface['interface'] = NIC.interface iface['mac'] = NIC.mac.address vminfo['ifaces'].append(iface) vminfo[str(NIC.name)] = NIC.mac.address CLUSTER = self.conn.get_cluster_byid(VM.cluster.id) if CLUSTER: vminfo['cluster'] = CLUSTER.name else: vminfo = False return vminfo def createVMimage(self, name, cluster, template, disks): self.__get_conn() return self.conn.createVMimage(name, cluster, template, disks) def createVM(self, name, cluster, os, actiontype): self.__get_conn() return self.conn.createVM(name, cluster, os, actiontype) def setMemory(self, name, memory): self.__get_conn() return self.conn.set_Memory(name, memory) def setMemoryPolicy(self, name, memory_policy): self.__get_conn() return self.conn.set_Memory_Policy(name, memory_policy) def setCPU(self, name, cpu): self.__get_conn() return self.conn.set_CPU(name, cpu) def setCPUShare(self, name, cpu_share): self.__get_conn() return self.conn.set_CPU_share(name, cpu_share) def setDisks(self, name, disks): self.__get_conn() counter = 0 bootselect = False for disk in disks: if 'bootable' in disk: if disk['bootable'] is True: bootselect = True for disk in disks: diskname = name + "_Disk" + str(counter) + "_" + disk.get('name', '').replace('/', '_') disksize = disk.get('size', 1) diskdomain = disk.get('domain', None) if diskdomain is None: setMsg("`domain` is a required disk key.") setFailed() return False diskinterface = disk.get('interface', 'virtio') diskformat = disk.get('format', 'raw') diskallocationtype = disk.get('thin', False) diskboot = disk.get('bootable', False) if bootselect is False and counter == 0: diskboot = True DISK = self.conn.get_disk(diskname) if DISK is None: self.conn.createDisk(name, diskname, disksize, diskdomain, diskinterface, diskformat, diskallocationtype, diskboot) else: self.conn.set_Disk(diskname, disksize, diskinterface, diskboot) checkFail() counter += 1 return True def setNetworks(self, vmname, ifaces): self.__get_conn() VM = self.conn.get_VM(vmname) counter = 0 length = len(ifaces) for NIC in VM.nics.list(): if counter < length: iface = ifaces[counter] name = iface.get('name', None) if name is None: setMsg("`name` is a required iface key.") setFailed() elif str(name) != str(NIC.name): setMsg("ifaces are in the wrong order, rebuilding everything.") for NIC in VM.nics.list(): self.conn.del_NIC(vmname, NIC.name) self.setNetworks(vmname, ifaces) checkFail() return True vlan = iface.get('vlan', None) if vlan is None: setMsg("`vlan` is a required iface key.") setFailed() checkFail() interface = iface.get('interface', 'virtio') self.conn.set_NIC(vmname, str(NIC.name), name, vlan, interface) else: self.conn.del_NIC(vmname, NIC.name) counter += 1 checkFail() while counter < length: iface = ifaces[counter] name = iface.get('name', None) if name is None: setMsg("`name` is a required iface key.") setFailed() vlan = iface.get('vlan', None) if vlan is None: setMsg("`vlan` is a required iface key.") setFailed() if failed is True: return False interface = iface.get('interface', 'virtio') self.conn.createNIC(vmname, name, vlan, interface) counter += 1 checkFail() return True def setDeleteProtection(self, vmname, del_prot): self.__get_conn() VM = self.conn.get_VM(vmname) if bool(VM.delete_protected) != bool(del_prot): self.conn.set_DeleteProtection(vmname, del_prot) checkFail() setMsg("`delete protection` has been updated.") else: setMsg("`delete protection` already has the right value.") return True def setBootOrder(self, vmname, boot_order): self.__get_conn() VM = self.conn.get_VM(vmname) bootorder = [] for boot_dev in VM.os.get_boot(): bootorder.append(str(boot_dev.dev)) if boot_order != bootorder: self.conn.set_BootOrder(vmname, boot_order) setMsg('The boot order has been set') else: setMsg('The boot order has already been set') return True def removeVM(self, vmname): self.__get_conn() self.setPower(vmname, "down", 300) return self.conn.remove_VM(vmname) def setPower(self, vmname, state, timeout): self.__get_conn() VM = self.conn.get_VM(vmname) if VM is None: setMsg("VM does not exist.") setFailed() return False if state == VM.status.state: setMsg("VM state was already " + state) else: if state == "up": setMsg("VM is going to start") self.conn.start_VM(vmname, timeout) setChanged() elif state == "down": setMsg("VM is going to stop") self.conn.stop_VM(vmname, timeout) setChanged() elif state == "restarted": self.setPower(vmname, "down", timeout) checkFail() self.setPower(vmname, "up", timeout) checkFail() setMsg("the vm state is set to " + state) return True def setCD(self, vmname, cd_drive): self.__get_conn() if cd_drive: return self.conn.set_CD(vmname, cd_drive) else: return self.conn.remove_CD(vmname) def setVMHost(self, vmname, vmhost): self.__get_conn() return self.conn.set_VM_Host(vmname, vmhost) # pylint: disable=unreachable VM = self.conn.get_VM(vmname) HOST = self.conn.get_Host(vmhost) if VM.placement_policy.host is None: self.conn.set_VM_Host(vmname, vmhost) elif str(VM.placement_policy.host.id) != str(HOST.id): self.conn.set_VM_Host(vmname, vmhost) else: setMsg("VM's startup host was already set to " + vmhost) checkFail() if str(VM.status.state) == "up": self.conn.migrate_VM(vmname, vmhost) checkFail() return True def setHost(self, hostname, cluster, ifaces): self.__get_conn() return self.conn.set_Host(hostname, cluster, ifaces) def checkFail(): if failed: module.fail_json(msg=msg) else: return True def setFailed(): global failed failed = True def setChanged(): global changed changed = True def setMsg(message): global failed msg.append(message) def core(module): r = RHEV(module) state = module.params.get('state', 'present') if state == 'ping': r.test() return RHEV_SUCCESS, {"ping": "pong"} elif state == 'info': name = module.params.get('name') if not name: setMsg("`name` is a required argument.") return RHEV_FAILED, msg vminfo = r.getVM(name) return RHEV_SUCCESS, {'changed': changed, 'msg': msg, 'vm': vminfo} elif state == 'present': created = False name = module.params.get('name') if not name: setMsg("`name` is a required argument.") return RHEV_FAILED, msg actiontype = module.params.get('type') if actiontype == 'server' or actiontype == 'desktop': vminfo = r.getVM(name) if vminfo: setMsg('VM exists') else: # Create VM cluster = module.params.get('cluster') if cluster is None: setMsg("cluster is a required argument.") setFailed() template = module.params.get('image') if template: disks = module.params.get('disks') if disks is None: setMsg("disks is a required argument.") setFailed() checkFail() if r.createVMimage(name, cluster, template, disks) is False: return RHEV_FAILED, vminfo else: os = module.params.get('osver') if os is None: setMsg("osver is a required argument.") setFailed() checkFail() if r.createVM(name, cluster, os, actiontype) is False: return RHEV_FAILED, vminfo created = True # Set MEMORY and MEMORY POLICY vminfo = r.getVM(name) memory = module.params.get('vmmem') if memory is not None: memory_policy = module.params.get('mempol') if int(memory_policy) == 0: memory_policy = memory mem_pol_nok = True if int(vminfo['mem_pol']) == int(memory_policy): setMsg("Memory is correct") mem_pol_nok = False mem_nok = True if int(vminfo['memory']) == int(memory): setMsg("Memory is correct") mem_nok = False if memory_policy > memory: setMsg('memory_policy cannot have a higher value than memory.') return RHEV_FAILED, msg if mem_nok and mem_pol_nok: if int(memory_policy) > int(vminfo['memory']): r.setMemory(vminfo['name'], memory) r.setMemoryPolicy(vminfo['name'], memory_policy) else: r.setMemoryPolicy(vminfo['name'], memory_policy) r.setMemory(vminfo['name'], memory) elif mem_nok: r.setMemory(vminfo['name'], memory) elif mem_pol_nok: r.setMemoryPolicy(vminfo['name'], memory_policy) checkFail() # Set CPU cpu = module.params.get('vmcpu') if int(vminfo['cpu_cores']) == int(cpu): setMsg("Number of CPUs is correct") else: if r.setCPU(vminfo['name'], cpu) is False: return RHEV_FAILED, msg # Set CPU SHARE cpu_share = module.params.get('cpu_share') if cpu_share is not None: if int(vminfo['cpu_shares']) == int(cpu_share): setMsg("CPU share is correct.") else: if r.setCPUShare(vminfo['name'], cpu_share) is False: return RHEV_FAILED, msg # Set DISKS disks = module.params.get('disks') if disks is not None: if r.setDisks(vminfo['name'], disks) is False: return RHEV_FAILED, msg # Set NETWORKS ifaces = module.params.get('ifaces', None) if ifaces is not None: if r.setNetworks(vminfo['name'], ifaces) is False: return RHEV_FAILED, msg # Set Delete Protection del_prot = module.params.get('del_prot') if r.setDeleteProtection(vminfo['name'], del_prot) is False: return RHEV_FAILED, msg # Set Boot Order boot_order = module.params.get('boot_order') if r.setBootOrder(vminfo['name'], boot_order) is False: return RHEV_FAILED, msg # Set VM Host vmhost = module.params.get('vmhost') if vmhost is not False and vmhost is not "False": if r.setVMHost(vminfo['name'], vmhost) is False: return RHEV_FAILED, msg vminfo = r.getVM(name) vminfo['created'] = created return RHEV_SUCCESS, {'changed': changed, 'msg': msg, 'vm': vminfo} if actiontype == 'host': cluster = module.params.get('cluster') if cluster is None: setMsg("cluster is a required argument.") setFailed() ifaces = module.params.get('ifaces') if ifaces is None: setMsg("ifaces is a required argument.") setFailed() if r.setHost(name, cluster, ifaces) is False: return RHEV_FAILED, msg return RHEV_SUCCESS, {'changed': changed, 'msg': msg} elif state == 'absent': name = module.params.get('name') if not name: setMsg("`name` is a required argument.") return RHEV_FAILED, msg actiontype = module.params.get('type') if actiontype == 'server' or actiontype == 'desktop': vminfo = r.getVM(name) if vminfo: setMsg('VM exists') # Set Delete Protection del_prot = module.params.get('del_prot') if r.setDeleteProtection(vminfo['name'], del_prot) is False: return RHEV_FAILED, msg # Remove VM if r.removeVM(vminfo['name']) is False: return RHEV_FAILED, msg setMsg('VM has been removed.') vminfo['state'] = 'DELETED' else: setMsg('VM was already removed.') return RHEV_SUCCESS, {'changed': changed, 'msg': msg, 'vm': vminfo} elif state == 'up' or state == 'down' or state == 'restarted': name = module.params.get('name') if not name: setMsg("`name` is a required argument.") return RHEV_FAILED, msg timeout = module.params.get('timeout') if r.setPower(name, state, timeout) is False: return RHEV_FAILED, msg vminfo = r.getVM(name) return RHEV_SUCCESS, {'changed': changed, 'msg': msg, 'vm': vminfo} elif state == 'cd': name = module.params.get('name') cd_drive = module.params.get('cd_drive') if r.setCD(name, cd_drive) is False: return RHEV_FAILED, msg return RHEV_SUCCESS, {'changed': changed, 'msg': msg} def main(): global module module = AnsibleModule( argument_spec=dict( state=dict(default='present', choices=['ping', 'present', 'absent', 'up', 'down', 'restarted', 'cd', 'info']), user=dict(default="admin@internal"), password=dict(required=True, no_log=True), server=dict(default="127.0.0.1"), port=dict(default="443"), insecure_api=dict(default=False, type='bool'), name=dict(), image=dict(default=False), datacenter=dict(default="Default"), type=dict(default="server", choices=['server', 'desktop', 'host']), cluster=dict(default=''), vmhost=dict(default=False), vmcpu=dict(default="2"), vmmem=dict(default="1"), disks=dict(), osver=dict(default="rhel_6x64"), ifaces=dict(aliases=['nics', 'interfaces']), timeout=dict(default=False), mempol=dict(default="1"), vm_ha=dict(default=True), cpu_share=dict(default="0"), boot_order=dict(default=["network", "hd"]), del_prot=dict(default=True, type="bool"), cd_drive=dict(default=False) ), ) if not HAS_SDK: module.fail_json( msg='The `ovirtsdk` module is not importable. Check the requirements.' ) rc = RHEV_SUCCESS try: rc, result = core(module) except Exception as e: module.fail_json(msg=str(e)) if rc != 0: # something went wrong emit the msg module.fail_json(rc=rc, msg=result) else: module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 7800, 12, 377, 73, 573, 273, 89, 812, 290, 848, 66, 1312, 271, 665, 280, 573, 273, 89, 14, 20662, 848, 66, 1312, 271, 32, 6799, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 519, 426, 2611, 199, 2502, 26, 377, 73, 573, 273, 89, 812, 290, 848, 66, 1312, 271, 199, 3612, 63, 1802, 26, 820, 1645, 54, 15, 79, 17146, 25461, 199, 1802, 26, 272, 446, 961, 859, 1454, 5171, 312, 17146, 15, 50, 1645, 54, 1015, 650, 14, 437, 15666, 859, 603, 8, 23334, 63, 16092, 9, 5171, 312, 17146, 15, 50, 16566, 1015, 841, 14, 272, 446, 22819, 1265, 370, 1218, 15, 2168, 15, 873, 503, 7074, 9053, 5791, 20601, 641, 282, 820, 1645, 54, 15, 79, 17146, 4298, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 7538, 26, 272, 446, 312, 1042, 1086, 6341, 199, 1419, 26, 272, 922, 26, 267, 1369, 26, 288, 446, 710, 922, 370, 12895, 543, 14, 267, 849, 26, 298, 2113, 32, 4672, 2, 267, 1415, 26, 3055, 272, 1654, 26, 267, 1369, 26, 288, 446, 710, 536, 15, 711, 402, 2195, 820, 1645, 54, 13, 77, 15, 79, 17146, 1256, 14, 267, 849, 26, 298, 4195, 14, 16, 14, 16, 14, 17, 2, 267, 1415, 26, 3055, 272, 1844, 26, 267, 1369, 26, 288, 446, 710, 1844, 641, 1314, 314, 3261, 365, 295, 21481, 461, 14, 267, 849, 26, 298, 16284, 2, 267, 1415, 26, 3055, 272, 26097, 63, 1246, 26, 267, 1369, 26, 288, 446, 437, 5046, 6258, 370, 1852, 282, 11153, 503, 26097, 1950, 370, 314, 1654, 14, 267, 849, 26, 3055, 267, 1415, 26, 3055, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 7525, 14, 272, 4350, 26, 267, 1369, 26, 288, 446, 710, 519, 23511, 15, 23334, 4350, 315, 1314, 1265, 2934, 1265, 7525, 370, 1343, 14, 267, 1415, 26, 3055, 272, 16606, 26, 267, 1369, 26, 288, 446, 710, 519, 23511, 15, 23334, 16606, 315, 1314, 1265, 2934, 1265, 7525, 370, 1343, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 2698, 2, 272, 1174, 26, 267, 1369, 26, 288, 446, 961, 23739, 370, 1218, 15, 2168, 15, 873, 503, 7074, 9053, 2195, 7525, 14, 267, 849, 26, 298, 1881, 2, 267, 1415, 26, 3055, 267, 3415, 26, 788, 4073, 297, 283, 1881, 297, 283, 5575, 297, 283, 384, 297, 283, 2110, 297, 283, 3911, 5015, 297, 283, 2866, 297, 283, 815, 418, 272, 1834, 26, 267, 1369, 26, 288, 446, 710, 1978, 370, 675, 367, 314, 7525, 14, 267, 849, 26, 2973, 267, 1415, 26, 3055, 272, 730, 26, 267, 1369, 26, 288, 446, 4005, 5627, 340, 314, 7525, 365, 282, 1654, 503, 19763, 14, 267, 849, 26, 1654, 267, 1415, 26, 3055, 267, 3415, 26, 359, 283, 1000, 297, 283, 14487, 297, 283, 1102, 7, 1622, 272, 4169, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 1265, 13809, 2195, 7525, 370, 1255, 641, 14, 267, 1415, 26, 3055, 272, 4169, 3541, 26, 267, 1369, 26, 288, 446, 710, 1329, 402, 28504, 1265, 2934, 315, 2195, 7525, 14, 267, 849, 26, 298, 18, 2, 267, 1415, 26, 3055, 272, 5033, 63, 6251, 26, 267, 1369, 26, 288, 446, 961, 2725, 365, 1202, 370, 7908, 314, 5033, 8663, 14, 267, 849, 26, 298, 16, 2, 267, 1415, 26, 3055, 272, 4169, 5286, 26, 267, 1369, 26, 288, 446, 710, 5982, 402, 4402, 1265, 2934, 2195, 7525, 370, 675, 334, 262, 18553, 680, 267, 849, 26, 298, 17, 2, 267, 1415, 26, 3055, 272, 747, 422, 26, 267, 1369, 26, 288, 446, 710, 3439, 2253, 945, 315, 820, 1645, 54, 15, 79, 17146, 14, 267, 849, 26, 298, 17157, 352, 63, 22, 88, 772, 2, 267, 1415, 26, 3055, 272, 562, 311, 393, 26, 267, 1369, 26, 288, 446, 710, 7481, 5982, 402, 4402, 1265, 13809, 370, 32606, 367, 642, 2656, 14, 267, 849, 26, 298, 17, 2, 267, 1415, 26, 3055, 272, 4169, 63, 2411, 26, 267, 1369, 26, 288, 446, 4005, 1852, 2195, 7525, 16332, 23840, 14, 267, 849, 26, 2549, 267, 1415, 26, 3055, 272, 17602, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 17602, 543, 314, 1511, 536, 12, 1568, 436, 2881, 14, 267, 1415, 26, 3055, 272, 340, 65, 823, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 8386, 543, 314, 1511, 536, 436, 10119, 14, 267, 5481, 26, 788, 28004, 297, 283, 7436, 418, 267, 1415, 26, 3055, 272, 8498, 63, 1648, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 2974, 626, 4165, 314, 8498, 1648, 14, 267, 849, 26, 2097, 1200, 2266, 7952, 937, 267, 1415, 26, 3055, 272, 2150, 63, 2745, 26, 267, 1369, 26, 288, 446, 961, 945, 5951, 314, 3145, 23977, 24190, 14, 267, 849, 26, 2549, 267, 1415, 26, 3055, 272, 12829, 63, 9541, 26, 267, 1369, 26, 288, 446, 710, 445, 36, 1265, 13809, 370, 1172, 27979, 641, 314, 7525, 1380, 473, 8, 929, 275, 283, 7695, 1959, 267, 849, 26, 2973, 267, 1415, 26, 3055, 272, 2653, 26, 267, 1369, 26, 288, 446, 710, 2653, 1265, 13809, 370, 5627, 367, 7074, 5445, 14, 288, 446, 3979, 473, 8, 929, 275, 283, 384, 358, 288, 446, 3979, 473, 8, 929, 275, 283, 2110, 358, 288, 446, 3979, 473, 8, 929, 275, 283, 3911, 5015, 358, 267, 849, 26, 2973, 267, 1415, 26, 3055, 199, 2344, 199, 199, 9677, 275, 1449 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 7800, 12, 377, 73, 573, 273, 89, 812, 290, 848, 66, 1312, 271, 665, 280, 573, 273, 89, 14, 20662, 848, 66, 1312, 271, 32, 6799, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 519, 426, 2611, 199, 2502, 26, 377, 73, 573, 273, 89, 812, 290, 848, 66, 1312, 271, 199, 3612, 63, 1802, 26, 820, 1645, 54, 15, 79, 17146, 25461, 199, 1802, 26, 272, 446, 961, 859, 1454, 5171, 312, 17146, 15, 50, 1645, 54, 1015, 650, 14, 437, 15666, 859, 603, 8, 23334, 63, 16092, 9, 5171, 312, 17146, 15, 50, 16566, 1015, 841, 14, 272, 446, 22819, 1265, 370, 1218, 15, 2168, 15, 873, 503, 7074, 9053, 5791, 20601, 641, 282, 820, 1645, 54, 15, 79, 17146, 4298, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 7538, 26, 272, 446, 312, 1042, 1086, 6341, 199, 1419, 26, 272, 922, 26, 267, 1369, 26, 288, 446, 710, 922, 370, 12895, 543, 14, 267, 849, 26, 298, 2113, 32, 4672, 2, 267, 1415, 26, 3055, 272, 1654, 26, 267, 1369, 26, 288, 446, 710, 536, 15, 711, 402, 2195, 820, 1645, 54, 13, 77, 15, 79, 17146, 1256, 14, 267, 849, 26, 298, 4195, 14, 16, 14, 16, 14, 17, 2, 267, 1415, 26, 3055, 272, 1844, 26, 267, 1369, 26, 288, 446, 710, 1844, 641, 1314, 314, 3261, 365, 295, 21481, 461, 14, 267, 849, 26, 298, 16284, 2, 267, 1415, 26, 3055, 272, 26097, 63, 1246, 26, 267, 1369, 26, 288, 446, 437, 5046, 6258, 370, 1852, 282, 11153, 503, 26097, 1950, 370, 314, 1654, 14, 267, 849, 26, 3055, 267, 1415, 26, 3055, 272, 536, 26, 267, 1369, 26, 288, 446, 710, 536, 402, 314, 7525, 14, 272, 4350, 26, 267, 1369, 26, 288, 446, 710, 519, 23511, 15, 23334, 4350, 315, 1314, 1265, 2934, 1265, 7525, 370, 1343, 14, 267, 1415, 26, 3055, 272, 16606, 26, 267, 1369, 26, 288, 446, 710, 519, 23511, 15, 23334, 16606, 315, 1314, 1265, 2934, 1265, 7525, 370, 1343, 14, 267, 1415, 26, 3055, 267, 849, 26, 298, 2698, 2, 272, 1174, 26, 267, 1369, 26, 288, 446, 961, 23739, 370, 1218, 15, 2168, 15, 873, 503, 7074, 9053, 2195, 7525, 14, 267, 849, 26, 298, 1881, 2, 267, 1415, 26, 3055, 267, 3415, 26, 788, 4073, 297, 283, 1881, 297, 283, 5575, 297, 283, 384, 297, 283, 2110, 297, 283, 3911, 5015, 297, 283, 2866, 297, 283, 815, 418, 272, 1834, 26, 267, 1369, 26, 288, 446, 710, 1978, 370, 675, 367, 314, 7525, 14, 267, 849, 26, 2973, 267, 1415, 26, 3055, 272, 730, 26, 267, 1369, 26, 288, 446, 4005, 5627, 340, 314, 7525, 365, 282, 1654, 503, 19763, 14, 267, 849, 26, 1654, 267, 1415, 26, 3055, 267, 3415, 26, 359, 283, 1000, 297, 283, 14487, 297, 283, 1102, 7, 1622, 272, 4169, 1102, 26, 267, 1369, 26, 288, 446, 710, 1591, 1265, 13809, 2195, 7525, 370, 1255, 641, 14, 267, 1415, 26, 3055, 272, 4169, 3541, 26, 267, 1369, 26, 288, 446, 710, 1329, 402, 28504, 1265, 2934, 315, 2195, 7525, 14, 267, 849, 26, 298, 18, 2, 267, 1415, 26, 3055, 272, 5033, 63, 6251, 26, 267, 1369, 26, 288, 446, 961, 2725, 365, 1202, 370, 7908, 314, 5033, 8663, 14, 267, 849, 26, 298, 16, 2, 267, 1415, 26, 3055, 272, 4169, 5286, 26, 267, 1369, 26, 288, 446, 710, 5982, 402, 4402, 1265, 2934, 2195, 7525, 370, 675, 334, 262, 18553, 680, 267, 849, 26, 298, 17, 2, 267, 1415, 26, 3055, 272, 747, 422, 26, 267, 1369, 26, 288, 446, 710, 3439, 2253, 945, 315, 820, 1645, 54, 15, 79, 17146, 14, 267, 849, 26, 298, 17157, 352, 63, 22, 88, 772, 2, 267, 1415, 26, 3055, 272, 562, 311, 393, 26, 267, 1369, 26, 288, 446, 710, 7481, 5982, 402, 4402, 1265, 13809, 370, 32606, 367, 642, 2656, 14, 267, 849, 26, 298, 17, 2, 267, 1415, 26, 3055, 272, 4169, 63, 2411, 26, 267, 1369, 26, 288, 446, 4005, 1852, 2195, 7525, 16332, 23840, 14, 267, 849, 26, 2549, 267, 1415, 26, 3055, 272, 17602, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 17602, 543, 314, 1511, 536, 12, 1568, 436, 2881, 14, 267, 1415, 26, 3055, 272, 340, 65, 823, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 8386, 543, 314, 1511, 536, 436, 10119, 14, 267, 5481, 26, 788, 28004, 297, 283, 7436, 418, 267, 1415, 26, 3055, 272, 8498, 63, 1648, 26, 267, 1369, 26, 288, 446, 961, 945, 4440, 6114, 2368, 436, 365, 282, 769, 402, 2974, 626, 4165, 314, 8498, 1648, 14, 267, 849, 26, 2097, 1200, 2266, 7952, 937, 267, 1415, 26, 3055, 272, 2150, 63, 2745, 26, 267, 1369, 26, 288, 446, 961, 945, 5951, 314, 3145, 23977, 24190, 14, 267, 849, 26, 2549, 267, 1415, 26, 3055, 272, 12829, 63, 9541, 26, 267, 1369, 26, 288, 446, 710, 445, 36, 1265, 13809, 370, 1172, 27979, 641, 314, 7525, 1380, 473, 8, 929, 275, 283, 7695, 1959, 267, 849, 26, 2973, 267, 1415, 26, 3055, 272, 2653, 26, 267, 1369, 26, 288, 446, 710, 2653, 1265, 13809, 370, 5627, 367, 7074, 5445, 14, 288, 446, 3979, 473, 8, 929, 275, 283, 384, 358, 288, 446, 3979, 473, 8, 929, 275, 283, 2110, 358, 288, 446, 3979, 473, 8, 929, 275, 283, 3911, 5015, 358, 267, 849, 26, 2973, 267, 1415, 26, 3055, 199, 2344, 199, 199, 9677, 275, 1449, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
emidln/django_roa
env/lib/python2.7/site-packages/django/contrib/localflavor/id/id_choices.py
439
3217
import warnings from django.utils.translation import ugettext_lazy as _ # Reference: http://id.wikipedia.org/wiki/Daftar_provinsi_Indonesia # Indonesia does not have an official Province code standard. # I decided to use unambiguous and consistent (some are common) 3-letter codes. warnings.warn( 'There have been recent changes to the ID localflavor. See the release notes for details', RuntimeWarning ) PROVINCE_CHOICES = ( ('ACE', _('Aceh')), ('BLI', _('Bali')), ('BTN', _('Banten')), ('BKL', _('Bengkulu')), ('DIY', _('Yogyakarta')), ('JKT', _('Jakarta')), ('GOR', _('Gorontalo')), ('JMB', _('Jambi')), ('JBR', _('Jawa Barat')), ('JTG', _('Jawa Tengah')), ('JTM', _('Jawa Timur')), ('KBR', _('Kalimantan Barat')), ('KSL', _('Kalimantan Selatan')), ('KTG', _('Kalimantan Tengah')), ('KTM', _('Kalimantan Timur')), ('BBL', _('Kepulauan Bangka-Belitung')), ('KRI', _('Kepulauan Riau')), ('LPG', _('Lampung')), ('MLK', _('Maluku')), ('MUT', _('Maluku Utara')), ('NTB', _('Nusa Tenggara Barat')), ('NTT', _('Nusa Tenggara Timur')), ('PPA', _('Papua')), ('PPB', _('Papua Barat')), ('RIU', _('Riau')), ('SLB', _('Sulawesi Barat')), ('SLS', _('Sulawesi Selatan')), ('SLT', _('Sulawesi Tengah')), ('SLR', _('Sulawesi Tenggara')), ('SLU', _('Sulawesi Utara')), ('SMB', _('Sumatera Barat')), ('SMS', _('Sumatera Selatan')), ('SMU', _('Sumatera Utara')), ) LICENSE_PLATE_PREFIX_CHOICES = ( ('A', _('Banten')), ('AA', _('Magelang')), ('AB', _('Yogyakarta')), ('AD', _('Surakarta - Solo')), ('AE', _('Madiun')), ('AG', _('Kediri')), ('B', _('Jakarta')), ('BA', _('Sumatera Barat')), ('BB', _('Tapanuli')), ('BD', _('Bengkulu')), ('BE', _('Lampung')), ('BG', _('Sumatera Selatan')), ('BH', _('Jambi')), ('BK', _('Sumatera Utara')), ('BL', _('Nanggroe Aceh Darussalam')), ('BM', _('Riau')), ('BN', _('Kepulauan Bangka Belitung')), ('BP', _('Kepulauan Riau')), ('CC', _('Corps Consulate')), ('CD', _('Corps Diplomatic')), ('D', _('Bandung')), ('DA', _('Kalimantan Selatan')), ('DB', _('Sulawesi Utara Daratan')), ('DC', _('Sulawesi Barat')), ('DD', _('Sulawesi Selatan')), ('DE', _('Maluku')), ('DG', _('Maluku Utara')), ('DH', _('NTT - Timor')), ('DK', _('Bali')), ('DL', _('Sulawesi Utara Kepulauan')), ('DM', _('Gorontalo')), ('DN', _('Sulawesi Tengah')), ('DR', _('NTB - Lombok')), ('DS', _('Papua dan Papua Barat')), ('DT', _('Sulawesi Tenggara')), ('E', _('Cirebon')), ('EA', _('NTB - Sumbawa')), ('EB', _('NTT - Flores')), ('ED', _('NTT - Sumba')), ('F', _('Bogor')), ('G', _('Pekalongan')), ('H', _('Semarang')), ('K', _('Pati')), ('KB', _('Kalimantan Barat')), ('KH', _('Kalimantan Tengah')), ('KT', _('Kalimantan Timur')), ('L', _('Surabaya')), ('M', _('Madura')), ('N', _('Malang')), ('P', _('Jember')), ('R', _('Banyumas')), ('RI', _('Federal Government')), ('S', _('Bojonegoro')), ('T', _('Purwakarta')), ('W', _('Sidoarjo')), ('Z', _('Garut')), )
bsd-3-clause
[ 646, 3598, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 10944, 26, 1455, 921, 344, 14, 13961, 14, 1308, 15, 6797, 15, 25014, 856, 285, 63, 496, 11908, 338, 63, 607, 4456, 10971, 199, 199, 3, 473, 977, 368, 10971, 1630, 440, 1172, 376, 25410, 2165, 86, 2855, 1233, 4465, 14, 199, 3, 473, 12985, 770, 370, 675, 625, 26465, 436, 12137, 334, 3972, 787, 2863, 9, 650, 13, 9269, 9479, 14, 199, 199, 5451, 14, 4050, 8, 272, 283, 10924, 1172, 2757, 8058, 4493, 370, 314, 2870, 560, 696, 276, 4271, 14, 1666, 314, 4683, 12681, 367, 2436, 297, 272, 25178, 199, 9, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 4121, 297, 4018, 33, 301, 72, 3855, 272, 661, 34, 2673, 297, 4018, 34, 10874, 3855, 272, 661, 19162, 46, 297, 4018, 28018, 724, 3855, 272, 661, 34, 14307, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 1914, 57, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 42, 12362, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 39, 726, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 42, 4567, 297, 4018, 42, 455, 4492, 3855, 272, 661, 42, 7184, 297, 4018, 42, 65, 758, 12377, 292, 3855, 272, 661, 42, 6332, 297, 4018, 42, 65, 758, 377, 287, 5294, 72, 3855, 272, 661, 42, 20690, 297, 4018, 42, 65, 758, 26244, 300, 3855, 272, 661, 43, 7184, 297, 4018, 43, 279, 1017, 867, 290, 12377, 292, 3855, 272, 661, 43, 4929, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 43, 6332, 297, 4018, 43, 279, 1017, 867, 290, 377, 287, 5294, 72, 3855, 272, 661, 12362, 45, 297, 4018, 43, 279, 1017, 867, 290, 26244, 300, 3855, 272, 661, 5342, 44, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 13, 3655, 1051, 10335, 3855, 272, 661, 43, 6129, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 9257, 39, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 1698, 43, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 25890, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 12460, 34, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 12377, 292, 3855, 272, 661, 46, 1481, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 26244, 300, 3855, 272, 661, 7701, 33, 297, 4018, 48, 439, 1458, 3855, 272, 661, 7701, 34, 297, 4018, 48, 439, 1458, 12377, 292, 3855, 272, 661, 6129, 53, 297, 4018, 28522, 3844, 3855, 272, 661, 4929, 34, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 4929, 51, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 4929, 52, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4929, 50, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 4929, 53, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 3855, 272, 661, 23304, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 51, 3053, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 4029, 53, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 199, 9, 199, 199, 3961, 63, 2749, 1951, 63, 6351, 63, 16236, 275, 334, 272, 661, 33, 297, 4018, 28018, 724, 3855, 272, 661, 2276, 297, 4018, 45, 474, 4159, 3855, 272, 661, 1217, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 1554, 297, 4018, 11762, 1151, 29549, 446, 2002, 320, 3855, 272, 661, 12500, 297, 4018, 11903, 328, 324, 3855, 272, 661, 1254, 297, 4018, 1136, 328, 322, 3855, 272, 661, 34, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 4134, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 5342, 297, 4018, 27746, 290, 13987, 3855, 272, 661, 11156, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 6773, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 18998, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 29931, 297, 4018, 42, 455, 4492, 3855, 272, 661, 17672, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 272, 661, 7847, 297, 4018, 46, 621, 23260, 69, 437, 301, 72, 577, 285, 27678, 279, 455, 3855, 272, 661, 15225, 297, 4018, 28522, 3844, 3855, 272, 661, 18273, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 6423, 1051, 10335, 3855, 272, 661, 24408, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 2571, 297, 4018, 8380, 1190, 1448, 83, 5434, 3855, 272, 661, 7695, 297, 4018, 8380, 1190, 577, 711, 320, 3889, 3855, 272, 661, 36, 297, 4018, 11675, 10335, 3855, 272, 661, 8980, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 2846, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 577, 285, 16080, 3855, 272, 661, 5196, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 5745, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 1093, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 29173, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 13860, 297, 4018, 46, 1481, 446, 26244, 269, 3855, 272, 661, 10892, 297, 4018, 34, 10874, 3855, 272, 661, 8045, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 25645, 80, 348, 3844, 290, 3855, 272, 661, 17751, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 10872, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4564, 297, 4018, 12460, 34, 446, 491, 676, 656, 75, 3855, 272, 661, 3177, 297, 4018, 48, 439, 1458, 366, 290, 510, 439, 1458, 12377, 292, 3855, 272, 661, 7438, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 37, 297, 4018, 35, 3621, 13520, 3855, 272, 661, 11765, 297, 4018, 12460, 34, 446, 12094, 2470, 758, 3855, 272, 661, 14138, 297, 4018, 46, 1481, 446, 481, 320, 470, 3855, 272, 661, 1149, 297, 4018, 46, 1481, 446, 12094, 2470, 3855, 272, 661, 38, 297, 4018, 34, 974, 269, 3855, 272, 661, 39, 297, 4018, 48, 5711, 21632, 290, 3855, 272 ]
[ 3598, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 3, 10944, 26, 1455, 921, 344, 14, 13961, 14, 1308, 15, 6797, 15, 25014, 856, 285, 63, 496, 11908, 338, 63, 607, 4456, 10971, 199, 199, 3, 473, 977, 368, 10971, 1630, 440, 1172, 376, 25410, 2165, 86, 2855, 1233, 4465, 14, 199, 3, 473, 12985, 770, 370, 675, 625, 26465, 436, 12137, 334, 3972, 787, 2863, 9, 650, 13, 9269, 9479, 14, 199, 199, 5451, 14, 4050, 8, 272, 283, 10924, 1172, 2757, 8058, 4493, 370, 314, 2870, 560, 696, 276, 4271, 14, 1666, 314, 4683, 12681, 367, 2436, 297, 272, 25178, 199, 9, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 4121, 297, 4018, 33, 301, 72, 3855, 272, 661, 34, 2673, 297, 4018, 34, 10874, 3855, 272, 661, 19162, 46, 297, 4018, 28018, 724, 3855, 272, 661, 34, 14307, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 1914, 57, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 42, 12362, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 39, 726, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 42, 4567, 297, 4018, 42, 455, 4492, 3855, 272, 661, 42, 7184, 297, 4018, 42, 65, 758, 12377, 292, 3855, 272, 661, 42, 6332, 297, 4018, 42, 65, 758, 377, 287, 5294, 72, 3855, 272, 661, 42, 20690, 297, 4018, 42, 65, 758, 26244, 300, 3855, 272, 661, 43, 7184, 297, 4018, 43, 279, 1017, 867, 290, 12377, 292, 3855, 272, 661, 43, 4929, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 43, 6332, 297, 4018, 43, 279, 1017, 867, 290, 377, 287, 5294, 72, 3855, 272, 661, 12362, 45, 297, 4018, 43, 279, 1017, 867, 290, 26244, 300, 3855, 272, 661, 5342, 44, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 13, 3655, 1051, 10335, 3855, 272, 661, 43, 6129, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 9257, 39, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 1698, 43, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 25890, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 12460, 34, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 12377, 292, 3855, 272, 661, 46, 1481, 297, 4018, 46, 527, 65, 377, 287, 2721, 17956, 26244, 300, 3855, 272, 661, 7701, 33, 297, 4018, 48, 439, 1458, 3855, 272, 661, 7701, 34, 297, 4018, 48, 439, 1458, 12377, 292, 3855, 272, 661, 6129, 53, 297, 4018, 28522, 3844, 3855, 272, 661, 4929, 34, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 4929, 51, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 4929, 52, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4929, 50, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 4929, 53, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 3855, 272, 661, 23304, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 51, 3053, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 4029, 53, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 199, 9, 199, 199, 3961, 63, 2749, 1951, 63, 6351, 63, 16236, 275, 334, 272, 661, 33, 297, 4018, 28018, 724, 3855, 272, 661, 2276, 297, 4018, 45, 474, 4159, 3855, 272, 661, 1217, 297, 4018, 57, 974, 89, 1151, 29549, 3855, 272, 661, 1554, 297, 4018, 11762, 1151, 29549, 446, 2002, 320, 3855, 272, 661, 12500, 297, 4018, 11903, 328, 324, 3855, 272, 661, 1254, 297, 4018, 1136, 328, 322, 3855, 272, 661, 34, 297, 4018, 42, 1151, 29549, 3855, 272, 661, 4134, 297, 4018, 6959, 323, 345, 12377, 292, 3855, 272, 661, 5342, 297, 4018, 27746, 290, 13987, 3855, 272, 661, 11156, 297, 4018, 34, 7420, 75, 348, 85, 3855, 272, 661, 6773, 297, 4018, 44, 5282, 10335, 3855, 272, 661, 18998, 297, 4018, 6959, 323, 345, 428, 352, 16080, 3855, 272, 661, 29931, 297, 4018, 42, 455, 4492, 3855, 272, 661, 17672, 297, 4018, 6959, 323, 345, 738, 5369, 65, 3855, 272, 661, 7847, 297, 4018, 46, 621, 23260, 69, 437, 301, 72, 577, 285, 27678, 279, 455, 3855, 272, 661, 15225, 297, 4018, 28522, 3844, 3855, 272, 661, 18273, 297, 4018, 1136, 80, 348, 3844, 290, 699, 621, 7351, 6423, 1051, 10335, 3855, 272, 661, 24408, 297, 4018, 1136, 80, 348, 3844, 290, 820, 73, 3844, 3855, 272, 661, 2571, 297, 4018, 8380, 1190, 1448, 83, 5434, 3855, 272, 661, 7695, 297, 4018, 8380, 1190, 577, 711, 320, 3889, 3855, 272, 661, 36, 297, 4018, 11675, 10335, 3855, 272, 661, 8980, 297, 4018, 43, 279, 1017, 867, 290, 428, 352, 16080, 3855, 272, 661, 2846, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 577, 285, 16080, 3855, 272, 661, 5196, 297, 4018, 51, 7586, 1129, 338, 12377, 292, 3855, 272, 661, 5745, 297, 4018, 51, 7586, 1129, 338, 428, 352, 16080, 3855, 272, 661, 1093, 297, 4018, 31147, 3210, 85, 3855, 272, 661, 29173, 297, 4018, 31147, 3210, 85, 738, 5369, 65, 3855, 272, 661, 13860, 297, 4018, 46, 1481, 446, 26244, 269, 3855, 272, 661, 10892, 297, 4018, 34, 10874, 3855, 272, 661, 8045, 297, 4018, 51, 7586, 1129, 338, 738, 5369, 65, 25645, 80, 348, 3844, 290, 3855, 272, 661, 17751, 297, 4018, 39, 269, 1888, 12201, 3855, 272, 661, 10872, 297, 4018, 51, 7586, 1129, 338, 377, 287, 5294, 72, 3855, 272, 661, 4564, 297, 4018, 12460, 34, 446, 491, 676, 656, 75, 3855, 272, 661, 3177, 297, 4018, 48, 439, 1458, 366, 290, 510, 439, 1458, 12377, 292, 3855, 272, 661, 7438, 297, 4018, 51, 7586, 1129, 338, 377, 287, 2721, 17956, 3855, 272, 661, 37, 297, 4018, 35, 3621, 13520, 3855, 272, 661, 11765, 297, 4018, 12460, 34, 446, 12094, 2470, 758, 3855, 272, 661, 14138, 297, 4018, 46, 1481, 446, 481, 320, 470, 3855, 272, 661, 1149, 297, 4018, 46, 1481, 446, 12094, 2470, 3855, 272, 661, 38, 297, 4018, 34, 974, 269, 3855, 272, 661, 39, 297, 4018, 48, 5711, 21632, 290, 3855, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
switchboardOp/ansible
lib/ansible/modules/identity/ipa/ipa_dnsrecord.py
23
8076
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2017, Abhijeet Kasurde (akasurde@redhat.com) # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = { 'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' --- module: ipa_dnsrecord author: Abhijeet Kasurde (@akasurde) short_description: Manage FreeIPA DNS records description: - Add, modify and delete an IPA DNS Record using IPA API options: zone_name: description: - The DNS zone name to which DNS record needs to be managed. required: true record_name: description: - The DNS record name to manage. required: true aliases: ["name"] record_type: description: - The type of DNS record name - Currently, 'A', 'AAAA' is supported required: false default: 'A' choices: ['A', 'AAAA'] record_ip: description: - Manage DNS record name with this IP address. required: true state: description: State to ensure required: false default: present choices: ["present", "absent"] ipa_port: description: Port of IPA server required: false default: 443 ipa_host: description: IP or hostname of IPA server required: false default: ipa.example.com ipa_user: description: Administrative account used on IPA server required: false default: admin ipa_pass: description: Password of administrative user required: true ipa_prot: description: Protocol used by IPA server required: false default: https choices: ["http", "https"] validate_certs: description: - This only applies if C(ipa_prot) is I(https). - If set to C(no), the SSL certificates will not be validated. - This should only set to C(no) used on personally controlled sites using self-signed certificates. required: false default: true version_added: "2.4" ''' EXAMPLES = ''' # Ensure dns record is present - ipa_dnsrecord: ipa_host: spider.example.com ipa_pass: Passw0rd! state: present zone_name: example.com record_name: vm-001 record_type: 'AAAA' record_ip: '::1' # Ensure that dns record is removed - ipa_dnsrecord: name: host01 zone_name: example.com record_type: 'AAAA' record_ip: '::1' ipa_host: ipa.example.com ipa_user: admin ipa_pass: topsecret state: absent ''' RETURN = ''' dnsrecord: description: DNS record as returned by IPA API. returned: always type: dict ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient class DNSRecordIPAClient(IPAClient): def __init__(self, module, host, port, protocol): super(DNSRecordIPAClient, self).__init__(module, host, port, protocol) def dnsrecord_find(self, zone_name, record_name): return self._post_json(method='dnsrecord_find', name=zone_name, item={'idnsname': record_name}) def dnsrecord_add(self, zone_name=None, record_name=None, details=None): item = dict(idnsname=record_name) if details['record_type'] == 'A': item.update(a_part_ip_address=details['record_ip']) elif details['record_type'] == 'AAAA': item.update(aaaa_part_ip_address=details['record_ip']) return self._post_json(method='dnsrecord_add', name=zone_name, item=item) def dnsrecord_mod(self, zone_name=None, record_name=None, details=None): item = get_dnsrecord_dict(details) item.update(idnsname=record_name) return self._post_json(method='dnsrecord_mod', name=zone_name, item=item) def dnsrecord_del(self, zone_name=None, record_name=None, details=None): item = get_dnsrecord_dict(details) item.update(idnsname=record_name) return self._post_json(method='dnsrecord_del', name=zone_name, item=item) def get_dnsrecord_dict(details=None): module_dnsrecord = dict() if details['record_type'] == 'A' and details['record_ip']: module_dnsrecord.update(arecord=details['record_ip']) elif details['record_type'] == 'AAAA' and details['record_ip']: module_dnsrecord.update(aaaarecord=details['record_ip']) return module_dnsrecord def get_dnsrecord_diff(client, ipa_dnsrecord, module_dnsrecord): details = get_dnsrecord_dict(module_dnsrecord) return client.get_diff(ipa_data=ipa_dnsrecord, module_data=details) def ensure(module, client): zone_name = module.params['zone_name'] record_name = module.params['record_name'] state = module.params['state'] ipa_dnsrecord = client.dnsrecord_find(zone_name, record_name) module_dnsrecord = dict(record_type=module.params['record_type'], record_ip=module.params['record_ip']) changed = False if state == 'present': if not ipa_dnsrecord: changed = True if not module.check_mode: client.dnsrecord_add(zone_name=zone_name, record_name=record_name, details=module_dnsrecord) else: diff = get_dnsrecord_diff(client, ipa_dnsrecord, module_dnsrecord) if len(diff) > 0: changed = True if not module.check_mode: client.dnsrecord_mod(zone_name=zone_name, record_name=record_name, details=module_dnsrecord) else: if ipa_dnsrecord: changed = True if not module.check_mode: client.dnsrecord_del(zone_name=zone_name, record_name=record_name, details=module_dnsrecord) return changed, client.dnsrecord_find(zone_name, record_name) def main(): record_types = ['A', 'AAAA'] module = AnsibleModule( argument_spec=dict( zone_name=dict(type='str', required=True), record_name=dict(type='str', required=True, aliases=['name']), record_type=dict(type='str', required=False, default='A', choices=record_types), record_ip=dict(type='str', required=True), state=dict(type='str', required=False, default='present', choices=['present', 'absent']), ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), ipa_host=dict(type='str', required=False, default='ipa.example.com'), ipa_port=dict(type='int', required=False, default=443), ipa_user=dict(type='str', required=False, default='admin'), ipa_pass=dict(type='str', required=True, no_log=True), validate_certs=dict(type='bool', required=False, default=True), ), supports_check_mode=True, ) client = DNSRecordIPAClient(module=module, host=module.params['ipa_host'], port=module.params['ipa_port'], protocol=module.params['ipa_prot']) try: client.login(username=module.params['ipa_user'], password=module.params['ipa_pass']) changed, record = ensure(module, client) module.exit_json(changed=changed, record=record) except Exception: e = get_exception() module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 9708, 12, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 334, 1151, 305, 300, 271, 32, 17164, 14, 957, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18210, 63, 5797, 3059, 199, 2502, 26, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 8593, 1151, 305, 300, 271, 9, 199, 3612, 63, 1802, 26, 14944, 2868, 1772, 33, 10237, 5767, 199, 1802, 26, 199, 13, 2654, 12, 2811, 436, 3145, 376, 3531, 33, 10237, 12651, 1808, 3531, 33, 3261, 199, 1419, 26, 523, 5718, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 10237, 5718, 536, 370, 1314, 10237, 2777, 4839, 370, 506, 12883, 14, 272, 1415, 26, 2549, 523, 2777, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 10237, 2777, 536, 370, 9635, 14, 272, 1415, 26, 2549, 272, 5481, 26, 2097, 354, 937, 523, 2777, 63, 466, 26, 272, 1369, 26, 272, 446, 710, 730, 402, 10237, 2777, 536, 272, 446, 13550, 12, 283, 33, 297, 283, 6151, 7, 365, 3748, 272, 1415, 26, 3055, 272, 849, 26, 283, 33, 7, 272, 3415, 26, 788, 33, 297, 283, 6151, 418, 523, 2777, 63, 711, 26, 272, 1369, 26, 272, 446, 14944, 10237, 2777, 536, 543, 642, 3531, 2287, 14, 272, 1415, 26, 2549, 523, 1174, 26, 272, 1369, 26, 8511, 370, 4868, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 18210, 63, 719, 26, 272, 1369, 26, 10977, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 3531, 503, 6246, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 18210, 14, 2694, 14, 957, 523, 18210, 63, 751, 26, 272, 1369, 26, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 4628, 523, 18210, 63, 1529, 26, 272, 1369, 26, 13635, 402, 4628, 25124, 922, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 11557, 1202, 701, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 4178, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 6715, 2777, 365, 3451, 199, 13, 18210, 63, 5797, 3059, 26, 272, 18210, 63, 1102, 26, 18094, 14, 2694, 14, 957, 272, 18210, 63, 1529, 26, 8325, 87, 16, 6883, 1, 272, 1174, 26, 3451, 272, 5718, 63, 354, 26, 2893, 14, 957, 272, 2777, 63, 354, 26, 4169, 13, 4587, 272, 2777, 63, 466, 26, 283, 6151, 7, 272, 2777, 63, 711, 26, 19069, 17, 7, 199, 199, 3, 7523, 626, 6715, 2777, 365, 4829, 199, 13, 18210, 63, 5797, 3059, 26, 272, 536, 26, 1591, 614, 272, 5718, 63, 354, 26, 2893, 14, 957, 272, 2777, 63, 466, 26, 283, 6151, 7, 272, 2777, 63, 711, 26, 19069, 17, 7, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5797, 3059, 26, 523, 1369, 26, 10237, 2777, 465, 2138, 701, 3531, 33, 3261, 14, 523, 2138, 26, 3544, 523, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 20014, 492, 3531, 1348, 864, 421, 199, 533, 10237, 5433, 1772, 1348, 864, 8, 1772, 1348, 864, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1591, 12, 1844, 12, 4113, 304, 267, 1613, 8, 12323, 5433, 1772, 1348, 864, 12, 291, 2843, 826, 721, 578, 12, 1591, 12, 1844, 12, 4113, 9, 339, 347, 6715, 3059, 63, 1623, 8, 277, 12, 5718, 63, 354, 12, 2777, 63, 354, 304, 267, 372, 291, 423, 1932, 63, 1001, 8, 765, 534, 5797, 3059, 63, 1623, 297, 536, 29, 2619, 63, 354, 12, 1242, 3713, 344, 561, 354, 356, 2777, 63, 354, 1552, 339, 347, 6715, 3059, 63, 525, 8, 277, 12, 5718, 63, 354, 29, 403, 12, 2777, 63, 354, 29, 403, 12, 2436, 29, 403, 304, 267, 1242, 275, 1211, 8, 344, 561, 354, 29, 3059, 63, 354, 9, 267, 340, 2436, 459, 3059, 63, 466, 418, 508, 283, 33, 356, 288, 1242, 14, 873 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 9708, 12, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 334, 1151, 305, 300, 271, 32, 17164, 14, 957, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18210, 63, 5797, 3059, 199, 2502, 26, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 8593, 1151, 305, 300, 271, 9, 199, 3612, 63, 1802, 26, 14944, 2868, 1772, 33, 10237, 5767, 199, 1802, 26, 199, 13, 2654, 12, 2811, 436, 3145, 376, 3531, 33, 10237, 12651, 1808, 3531, 33, 3261, 199, 1419, 26, 523, 5718, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 10237, 5718, 536, 370, 1314, 10237, 2777, 4839, 370, 506, 12883, 14, 272, 1415, 26, 2549, 523, 2777, 63, 354, 26, 272, 1369, 26, 272, 446, 710, 10237, 2777, 536, 370, 9635, 14, 272, 1415, 26, 2549, 272, 5481, 26, 2097, 354, 937, 523, 2777, 63, 466, 26, 272, 1369, 26, 272, 446, 710, 730, 402, 10237, 2777, 536, 272, 446, 13550, 12, 283, 33, 297, 283, 6151, 7, 365, 3748, 272, 1415, 26, 3055, 272, 849, 26, 283, 33, 7, 272, 3415, 26, 788, 33, 297, 283, 6151, 418, 523, 2777, 63, 711, 26, 272, 1369, 26, 272, 446, 14944, 10237, 2777, 536, 543, 642, 3531, 2287, 14, 272, 1415, 26, 2549, 523, 1174, 26, 272, 1369, 26, 8511, 370, 4868, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 18210, 63, 719, 26, 272, 1369, 26, 10977, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 3531, 503, 6246, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 18210, 14, 2694, 14, 957, 523, 18210, 63, 751, 26, 272, 1369, 26, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 4628, 523, 18210, 63, 1529, 26, 272, 1369, 26, 13635, 402, 4628, 25124, 922, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 11557, 1202, 701, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 4178, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 6715, 2777, 365, 3451, 199, 13, 18210, 63, 5797, 3059, 26, 272, 18210, 63, 1102, 26, 18094, 14, 2694, 14, 957, 272, 18210, 63, 1529, 26, 8325, 87, 16, 6883, 1, 272, 1174, 26, 3451, 272, 5718, 63, 354, 26, 2893, 14, 957, 272, 2777, 63, 354, 26, 4169, 13, 4587, 272, 2777, 63, 466, 26, 283, 6151, 7, 272, 2777, 63, 711, 26, 19069, 17, 7, 199, 199, 3, 7523, 626, 6715, 2777, 365, 4829, 199, 13, 18210, 63, 5797, 3059, 26, 272, 536, 26, 1591, 614, 272, 5718, 63, 354, 26, 2893, 14, 957, 272, 2777, 63, 466, 26, 283, 6151, 7, 272, 2777, 63, 711, 26, 19069, 17, 7, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5797, 3059, 26, 523, 1369, 26, 10237, 2777, 465, 2138, 701, 3531, 33, 3261, 14, 523, 2138, 26, 3544, 523, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 20014, 492, 3531, 1348, 864, 421, 199, 533, 10237, 5433, 1772, 1348, 864, 8, 1772, 1348, 864, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1591, 12, 1844, 12, 4113, 304, 267, 1613, 8, 12323, 5433, 1772, 1348, 864, 12, 291, 2843, 826, 721, 578, 12, 1591, 12, 1844, 12, 4113, 9, 339, 347, 6715, 3059, 63, 1623, 8, 277, 12, 5718, 63, 354, 12, 2777, 63, 354, 304, 267, 372, 291, 423, 1932, 63, 1001, 8, 765, 534, 5797, 3059, 63, 1623, 297, 536, 29, 2619, 63, 354, 12, 1242, 3713, 344, 561, 354, 356, 2777, 63, 354, 1552, 339, 347, 6715, 3059, 63, 525, 8, 277, 12, 5718, 63, 354, 29, 403, 12, 2777, 63, 354, 29, 403, 12, 2436, 29, 403, 304, 267, 1242, 275, 1211, 8, 344, 561, 354, 29, 3059, 63, 354, 9, 267, 340, 2436, 459, 3059, 63, 466, 418, 508, 283, 33, 356, 288, 1242, 14, 873, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
47lining/ansible-modules-core
cloud/amazon/rds_param_group.py
19
11052
#!/usr/bin/python # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: rds_param_group version_added: "1.5" short_description: manage RDS parameter groups description: - Creates, modifies, and deletes RDS parameter groups. This module has a dependency on python-boto >= 2.5. options: state: description: - Specifies whether the group should be present or absent. required: true default: present aliases: [] choices: [ 'present' , 'absent' ] name: description: - Database parameter group identifier. required: true default: null aliases: [] description: description: - Database parameter group description. Only set when a new group is added. required: false default: null aliases: [] engine: description: - The type of database for this group. Required for state=present. required: false default: null aliases: [] choices: [ 'mysql5.1', 'mysql5.5', 'mysql5.6', 'oracle-ee-11.2', 'oracle-se-11.2', 'oracle-se1-11.2', 'postgres9.3', 'sqlserver-ee-10.5', 'sqlserver-ee-11.0', 'sqlserver-ex-10.5', 'sqlserver-ex-11.0', 'sqlserver-se-10.5', 'sqlserver-se-11.0', 'sqlserver-web-10.5', 'sqlserver-web-11.0'] immediate: description: - Whether to apply the changes immediately, or after the next reboot of any associated instances. required: false default: null aliases: [] params: description: - Map of parameter names and values. Numeric values may be represented as K for kilo (1024), M for mega (1024^2), G for giga (1024^3), or T for tera (1024^4), and these values will be expanded into the appropriate number before being set in the parameter group. required: false default: null aliases: [] choices: [ 'mysql5.1', 'mysql5.5', 'mysql5.6', 'oracle-ee-11.2', 'oracle-se-11.2', 'oracle-se1-11.2', 'postgres9.3', 'sqlserver-ee-10.5', 'sqlserver-ee-11.0', 'sqlserver-ex-10.5', 'sqlserver-ex-11.0', 'sqlserver-se-10.5', 'sqlserver-se-11.0', 'sqlserver-web-10.5', 'sqlserver-web-11.0'] region: description: - The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. required: true default: null aliases: [ 'aws_region', 'ec2_region' ] aws_access_key: description: - AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used. required: false default: null aliases: [ 'ec2_access_key', 'access_key' ] aws_secret_key: description: - AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used. required: false default: null aliases: [ 'ec2_secret_key', 'secret_key' ] requirements: [ "boto" ] author: Scott Anderson ''' EXAMPLES = ''' # Add or change a parameter group, in this case setting auto_increment_increment to 42 * 1024 - rds_param_group: state: present name: norwegian_blue description: 'My Fancy Ex Parrot Group' engine: 'mysql5.6' params: auto_increment_increment: "42K" # Remove a parameter group - rds_param_group: state: absent name: norwegian_blue ''' import sys import time VALID_ENGINES = [ 'mysql5.1', 'mysql5.5', 'mysql5.6', 'oracle-ee-11.2', 'oracle-se-11.2', 'oracle-se1-11.2', 'postgres9.3', 'sqlserver-ee-10.5', 'sqlserver-ee-11.0', 'sqlserver-ex-10.5', 'sqlserver-ex-11.0', 'sqlserver-se-10.5', 'sqlserver-se-11.0', 'sqlserver-web-10.5', 'sqlserver-web-11.0', ] try: import boto.rds from boto.exception import BotoServerError except ImportError: print "failed=True msg='boto required for this module'" sys.exit(1) # returns a tuple: (whether or not a parameter was changed, the remaining parameters that weren't found in this parameter group) class NotModifiableError(StandardError): def __init__(self, error_message, *args): super(NotModifiableError, self).__init__(error_message, *args) self.error_message = error_message def __repr__(self): return 'NotModifiableError: %s' % self.error_message def __str__(self): return 'NotModifiableError: %s' % self.error_message INT_MODIFIERS = { 'K': 1024, 'M': pow(1024, 2), 'G': pow(1024, 3), 'T': pow(1024, 4), } TRUE_VALUES = ('on', 'true', 'yes', '1',) def set_parameter(param, value, immediate): """ Allows setting parameters with 10M = 10* 1024 * 1024 and so on. """ converted_value = value if param.type == 'string': converted_value = str(value) elif param.type == 'integer': if isinstance(value, basestring): try: for modifier in INT_MODIFIERS.keys(): if value.endswith(modifier): converted_value = int(value[:-1]) * INT_MODIFIERS[modifier] converted_value = int(converted_value) except ValueError: # may be based on a variable (ie. {foo*3/4}) so # just pass it on through to boto converted_value = str(value) elif type(value) == bool: converted_value = 1 if value else 0 else: converted_value = int(value) elif param.type == 'boolean': if isinstance(value, basestring): converted_value = value in TRUE_VALUES else: converted_value = bool(value) param.value = converted_value param.apply(immediate) def modify_group(group, params, immediate=False): """ Set all of the params in a group to the provided new params. Raises NotModifiableError if any of the params to be changed are read only. """ changed = {} new_params = dict(params) for key in new_params.keys(): if group.has_key(key): param = group[key] new_value = new_params[key] try: old_value = param.value except ValueError: # some versions of boto have problems with retrieving # integer values from params that may have their value # based on a variable (ie. {foo*3/4}), so grab it in a # way that bypasses the property functions old_value = param._value if old_value != new_value: if not param.is_modifiable: raise NotModifiableError('Parameter %s is not modifiable.' % key) changed[key] = {'old': param.value, 'new': new_value} set_parameter(param, new_value, immediate) del new_params[key] return changed, new_params def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( state = dict(required=True, choices=['present', 'absent']), name = dict(required=True), engine = dict(required=False, choices=VALID_ENGINES), description = dict(required=False), params = dict(required=False, aliases=['parameters'], type='dict'), immediate = dict(required=False, type='bool'), ) ) module = AnsibleModule(argument_spec=argument_spec) state = module.params.get('state') group_name = module.params.get('name').lower() group_engine = module.params.get('engine') group_description = module.params.get('description') group_params = module.params.get('params') or {} immediate = module.params.get('immediate') or False if state == 'present': for required in ['name', 'description', 'engine', 'params']: if not module.params.get(required): module.fail_json(msg = str("Parameter %s required for state='present'" % required)) else: for not_allowed in ['description', 'engine', 'params']: if module.params.get(not_allowed): module.fail_json(msg = str("Parameter %s not allowed for state='absent'" % not_allowed)) # Retrieve any AWS settings from the environment. ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module) if not region: module.fail_json(msg = str("region not specified and unable to determine region from EC2_REGION.")) try: conn = boto.rds.connect_to_region(region, aws_access_key_id=aws_access_key, aws_secret_access_key=aws_secret_key) except boto.exception.BotoServerError, e: module.fail_json(msg = e.error_message) group_was_added = False try: changed = False try: all_groups = conn.get_all_dbparameter_groups(group_name, max_records=100) exists = len(all_groups) > 0 except BotoServerError, e: if e.error_code != 'DBParameterGroupNotFound': module.fail_json(msg = e.error_message) exists = False if state == 'absent': if exists: conn.delete_parameter_group(group_name) changed = True else: changed = {} if not exists: new_group = conn.create_parameter_group(group_name, engine=group_engine, description=group_description) group_was_added = True # If a "Marker" is present, this group has more attributes remaining to check. Get the next batch, but only # if there are parameters left to set. marker = None while len(group_params): next_group = conn.get_all_dbparameters(group_name, marker=marker) changed_params, group_params = modify_group(next_group, group_params, immediate) changed.update(changed_params) if hasattr(next_group, 'Marker'): marker = next_group.Marker else: break except BotoServerError, e: module.fail_json(msg = e.error_message) except NotModifiableError, e: msg = e.error_message if group_was_added: msg = '%s The group "%s" was added first.' % (msg, group_name) module.fail_json(msg=msg) module.exit_json(changed=changed) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.ec2 import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 519, 795, 63, 635, 63, 923, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 3612, 63, 1802, 26, 9635, 820, 3177, 2725, 4652, 199, 1802, 26, 1362, 446, 10560, 12, 26473, 12, 436, 21812, 820, 3177, 2725, 4652, 14, 961, 859, 965, 282, 5936, 641, 2366, 13, 10914, 2356, 499, 14, 21, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 11015, 3775, 314, 1572, 1077, 506, 3451, 503, 9552, 14, 272, 1415, 26, 2549, 272, 849, 26, 3451, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 1881, 7, 2360, 283, 5575, 7, 1622, 523, 536, 26, 272, 1369, 26, 489, 446, 8692, 2725, 1572, 5148, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 1369, 26, 272, 1369, 26, 489, 446, 8692, 2725, 1572, 1369, 14, 5972, 663, 1380, 282, 892, 1572, 365, 3483, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 6869, 26, 272, 1369, 26, 489, 446, 710, 730, 402, 3050, 367, 642, 1572, 14, 11105, 367, 1174, 29, 1881, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 8644, 21, 14, 17, 297, 283, 8644, 21, 14, 21, 297, 283, 8644, 21, 14, 22, 297, 283, 16404, 13, 1024, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 17, 13, 845, 14, 18, 297, 283, 10675, 25, 14, 19, 297, 283, 3009, 1000, 13, 1024, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 1024, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 476, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 476, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 261, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 261, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 2520, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 2520, 13, 845, 14, 16, 418, 523, 8569, 26, 272, 1369, 26, 489, 446, 7480, 370, 4838, 314, 4493, 9939, 12, 503, 2410, 314, 2163, 19457, 402, 1263, 4568, 4454, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 1862, 26, 272, 1369, 26, 489, 446, 9672, 402, 2725, 1561, 436, 1338, 14, 19378, 1338, 1443, 506, 11159, 465, 1804, 367, 1022, 11737, 334, 7727, 395, 603, 367, 562, 5294, 334, 7727, 62, 18, 395, 598, 367, 486, 29055, 334, 7727, 62, 19, 395, 503, 377, 367, 1565, 345, 334, 7727, 62, 20, 395, 436, 3520, 1338, 911, 506, 11507, 1901, 314, 5827, 1329, 2544, 3769, 663, 315, 314, 2725, 1572, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 8644, 21, 14, 17, 297, 283, 8644, 21, 14, 21, 297, 283, 8644, 21, 14, 22, 297, 283, 16404, 13, 1024, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 17, 13, 845, 14, 18, 297, 283, 10675, 25, 14, 19, 297, 283, 3009, 1000, 13, 1024, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 1024, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 476, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 476, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 261, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 261, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 2520, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 2520, 13, 845, 14, 16, 418, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 7, 1622, 523, 11488, 63, 2732, 63, 498, 26, 272, 1369, 26, 489, 446, 10168, 2879, 790, 14, 982, 440, 663, 2066, 314, 574, 402, 314, 10168, 63, 11074, 63, 3078, 3734, 1750, 365, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 825, 18, 63, 2732, 63, 498, 297, 283, 2732, 63, 498, 7, 1622, 523, 11488, 63, 4731, 63, 498, 26, 272, 1369, 26, 489, 446, 10168, 7565, 790, 14, 982, 440, 663, 2066, 314, 574, 402, 314, 10168, 63, 12961, 63, 3078, 3734, 1750, 365, 1202, 14, 5591, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 825, 18, 63, 4731, 63, 498, 297, 283, 4731, 63, 498, 7, 1622, 199, 7538, 26, 359, 298, 10914, 2, 1622, 199, 2502, 26, 428, 331, 6215, 1626, 424, 834, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2654, 503, 1570, 282, 2725, 1572, 12, 315, 642, 1930, 4260, 2599, 63, 9728, 63, 9728, 370, 5685, 627, 6619, 199, 13, 519, 795, 63, 635, 63, 923, 26, 489, 1174, 26, 3451, 489, 536, 26, 6590, 1129, 71, 5653, 63, 6304, 489, 1369, 26, 283, 5713, 481, 9844, 1316, 2235, 4571, 5611, 7, 489, 6869, 26, 283 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 519, 795, 63, 635, 63, 923, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 3612, 63, 1802, 26, 9635, 820, 3177, 2725, 4652, 199, 1802, 26, 1362, 446, 10560, 12, 26473, 12, 436, 21812, 820, 3177, 2725, 4652, 14, 961, 859, 965, 282, 5936, 641, 2366, 13, 10914, 2356, 499, 14, 21, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 11015, 3775, 314, 1572, 1077, 506, 3451, 503, 9552, 14, 272, 1415, 26, 2549, 272, 849, 26, 3451, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 1881, 7, 2360, 283, 5575, 7, 1622, 523, 536, 26, 272, 1369, 26, 489, 446, 8692, 2725, 1572, 5148, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 1369, 26, 272, 1369, 26, 489, 446, 8692, 2725, 1572, 1369, 14, 5972, 663, 1380, 282, 892, 1572, 365, 3483, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 6869, 26, 272, 1369, 26, 489, 446, 710, 730, 402, 3050, 367, 642, 1572, 14, 11105, 367, 1174, 29, 1881, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 8644, 21, 14, 17, 297, 283, 8644, 21, 14, 21, 297, 283, 8644, 21, 14, 22, 297, 283, 16404, 13, 1024, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 17, 13, 845, 14, 18, 297, 283, 10675, 25, 14, 19, 297, 283, 3009, 1000, 13, 1024, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 1024, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 476, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 476, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 261, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 261, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 2520, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 2520, 13, 845, 14, 16, 418, 523, 8569, 26, 272, 1369, 26, 489, 446, 7480, 370, 4838, 314, 4493, 9939, 12, 503, 2410, 314, 2163, 19457, 402, 1263, 4568, 4454, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 1862, 26, 272, 1369, 26, 489, 446, 9672, 402, 2725, 1561, 436, 1338, 14, 19378, 1338, 1443, 506, 11159, 465, 1804, 367, 1022, 11737, 334, 7727, 395, 603, 367, 562, 5294, 334, 7727, 62, 18, 395, 598, 367, 486, 29055, 334, 7727, 62, 19, 395, 503, 377, 367, 1565, 345, 334, 7727, 62, 20, 395, 436, 3520, 1338, 911, 506, 11507, 1901, 314, 5827, 1329, 2544, 3769, 663, 315, 314, 2725, 1572, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 942, 272, 3415, 26, 359, 283, 8644, 21, 14, 17, 297, 283, 8644, 21, 14, 21, 297, 283, 8644, 21, 14, 22, 297, 283, 16404, 13, 1024, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 13, 845, 14, 18, 297, 283, 16404, 13, 261, 17, 13, 845, 14, 18, 297, 283, 10675, 25, 14, 19, 297, 283, 3009, 1000, 13, 1024, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 1024, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 476, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 476, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 261, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 261, 13, 845, 14, 16, 297, 283, 3009, 1000, 13, 2520, 13, 709, 14, 21, 297, 283, 3009, 1000, 13, 2520, 13, 845, 14, 16, 418, 523, 4897, 26, 272, 1369, 26, 489, 446, 710, 10168, 4897, 370, 675, 14, 982, 440, 2013, 2066, 314, 574, 402, 314, 15352, 18, 63, 23030, 3734, 1750, 12, 340, 1263, 12, 365, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 7231, 63, 4551, 297, 283, 825, 18, 63, 4551, 7, 1622, 523, 11488, 63, 2732, 63, 498, 26, 272, 1369, 26, 489, 446, 10168, 2879, 790, 14, 982, 440, 663, 2066, 314, 574, 402, 314, 10168, 63, 11074, 63, 3078, 3734, 1750, 365, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 825, 18, 63, 2732, 63, 498, 297, 283, 2732, 63, 498, 7, 1622, 523, 11488, 63, 4731, 63, 498, 26, 272, 1369, 26, 489, 446, 10168, 7565, 790, 14, 982, 440, 663, 2066, 314, 574, 402, 314, 10168, 63, 12961, 63, 3078, 3734, 1750, 365, 1202, 14, 5591, 1415, 26, 3055, 272, 849, 26, 2973, 272, 5481, 26, 359, 283, 825, 18, 63, 4731, 63, 498, 297, 283, 4731, 63, 498, 7, 1622, 199, 7538, 26, 359, 298, 10914, 2, 1622, 199, 2502, 26, 428, 331, 6215, 1626, 424, 834, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2654, 503, 1570, 282, 2725, 1572, 12, 315, 642, 1930, 4260, 2599, 63, 9728, 63, 9728, 370, 5685, 627, 6619, 199, 13, 519, 795, 63, 635, 63, 923, 26, 489, 1174, 26, 3451, 489, 536, 26, 6590, 1129, 71, 5653, 63, 6304, 489, 1369, 26, 283, 5713, 481, 9844, 1316, 2235, 4571, 5611, 7, 489, 6869, 26, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sclabs/sccms-nonrel
django/conf/locale/lv/formats.py
316
1490
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = r'Y. \g\a\d\a j. F' TIME_FORMAT = 'H:i:s' DATETIME_FORMAT = r'Y. \g\a\d\a j. F, H:i:s' YEAR_MONTH_FORMAT = r'Y. \g. F' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = r'j.m.Y' SHORT_DATETIME_FORMAT = 'j.m.Y H:i:s' FIRST_DAY_OF_WEEK = 1 #Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = ( '%Y-%m-%d', '%d.%m.%Y', '%d.%m.%y', # '2006-10-25', '25.10.2006', '25.10.06' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M', # '14:30' '%H.%M.%S', # '14.30.59' '%H.%M', # '14.30' ) DATETIME_INPUT_FORMATS = ( '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' '%d.%m.%y %H:%M:%S', # '25.10.06 14:30:59' '%d.%m.%y %H:%M', # '25.10.06 14:30' '%d.%m.%y %H.%M.%S', # '25.10.06 14.30.59' '%d.%m.%y %H.%M', # '25.10.06 14.30' '%d.%m.%y', # '25.10.06' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = u' ' # Non-breaking space NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 60, 65, 60, 68, 60, 65, 1335, 14, 481, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 60, 65, 60, 68, 60, 65, 1335, 14, 481, 12, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 14, 481, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 519, 7, 74, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 6671, 2977, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 258, 327, 283, 1079, 26, 1216, 7, 272, 1543, 40, 4111, 45, 4111, 51, 297, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 297, 327, 283, 1079, 14, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 399, 7, 10619, 7, 327, 10172, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 60, 65, 60, 68, 60, 65, 1335, 14, 481, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 60, 65, 60, 68, 60, 65, 1335, 14, 481, 12, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 519, 7, 57, 14, 971, 71, 14, 481, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 519, 7, 74, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 6671, 2977, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 258, 327, 283, 1079, 26, 1216, 7, 272, 1543, 40, 4111, 45, 4111, 51, 297, 327, 283, 1079, 14, 1216, 14, 1427, 7, 272, 1543, 40, 4111, 45, 297, 327, 283, 1079, 14, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 263, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 4111, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 14, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 4111, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 14, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 399, 7, 10619, 7, 327, 10172, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rwgdrummer/maskgen
setuptools-version/setuptools_maskgen_version.py
1
1613
from pkg_resources import get_distribution from subprocess import check_output import requests import json repos = 'rwgdrummer/maskgen' giturl = 'https://api.github.com/repos' def get_commit(): url = giturl + '/' + repos + '/pulls?state=closed' resp = requests.get(url) if resp.status_code == requests.codes.ok: content = json.loads(resp.content) for item in content: if 'merged_at' in item and 'merge_commit_sha' in item: return item['merge_commit_sha'] return None def get_version(): import os filename = 'VERSION' #if os.path.exists('.git/ORIG_HEAD'): # filename = '.git/ORIG_HEAD' #else: print os.path.abspath(filename) with open(filename) as fp: return fp.readline() def validate_version_format(dist, attr, value): try: version = get_version().strip() except: version = get_distribution(dist.get_name()).version else: version = format_version(version=version, fmt=value) dist.metadata.version = version def format_version(version, fmt='{gitsha}'): return fmt.format(gitsha=version) if __name__ == "__main__": # determine version from git git_version = get_version().strip() git_version = format_version(version=git_version) # monkey-patch `setuptools.setup` to inject the git version import setuptools original_setup = setuptools.setup def setup(version=None, *args, **kw): return original_setup(version=git_version, *args, **kw) setuptools.setup = setup # import the packages's setup module import setup
bsd-3-clause
[ 504, 5496, 63, 4435, 492, 664, 63, 4972, 199, 504, 3873, 492, 1104, 63, 1199, 199, 646, 4145, 199, 646, 2022, 199, 199, 11857, 275, 283, 13057, 71, 5012, 453, 2626, 15, 2629, 2268, 7, 199, 3187, 633, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 7, 199, 199, 318, 664, 63, 3543, 837, 272, 1166, 275, 6135, 633, 435, 7324, 435, 20416, 435, 1994, 80, 13072, 31, 929, 29, 5938, 7, 272, 3085, 275, 4145, 14, 362, 8, 633, 9, 272, 340, 3085, 14, 1205, 63, 600, 508, 4145, 14, 6021, 14, 745, 26, 267, 1564, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 367, 1242, 315, 1564, 26, 288, 340, 283, 15269, 63, 292, 7, 315, 1242, 436, 283, 5628, 63, 3543, 63, 4835, 7, 315, 1242, 26, 355, 372, 221, 1242, 459, 5628, 63, 3543, 63, 4835, 418, 272, 372, 488, 199, 199, 318, 664, 63, 1023, 837, 272, 492, 747, 272, 1788, 275, 283, 4612, 7, 272, 327, 692, 747, 14, 515, 14, 2444, 5175, 3187, 15, 20332, 63, 5211, 735, 272, 327, 259, 1788, 275, 1987, 3187, 15, 20332, 63, 5211, 7, 272, 327, 2836, 26, 272, 870, 747, 14, 515, 14, 4832, 8, 1501, 9, 272, 543, 1551, 8, 1501, 9, 465, 4090, 26, 267, 372, 4090, 14, 6407, 342, 199, 199, 318, 4107, 63, 1023, 63, 908, 8, 2686, 12, 1921, 12, 574, 304, 272, 862, 26, 267, 1015, 275, 664, 63, 1023, 1252, 1913, 342, 272, 871, 26, 267, 1015, 275, 664, 63, 4972, 8, 2686, 14, 362, 63, 354, 8801, 1023, 272, 587, 26, 267, 1015, 275, 1475, 63, 1023, 8, 1023, 29, 1023, 12, 7104, 29, 585, 9, 272, 2917, 14, 2343, 14, 1023, 275, 1015, 421, 199, 318, 1475, 63, 1023, 8, 1023, 12, 7104, 32134, 3187, 4835, 93, 735, 272, 372, 7104, 14, 908, 8, 3187, 4835, 29, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 6705, 1015, 687, 6135, 272, 6135, 63, 1023, 275, 664, 63, 1023, 1252, 1913, 342, 272, 6135, 63, 1023, 275, 1475, 63, 1023, 8, 1023, 29, 3187, 63, 1023, 9, 339, 327, 14198, 13, 2068, 658, 13623, 14, 2758, 64, 370, 16182, 314, 6135, 1015, 272, 492, 9116, 272, 3379, 63, 2758, 275, 9116, 14, 2758, 339, 347, 3272, 8, 1023, 29, 403, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 3379, 63, 2758, 8, 1023, 29, 3187, 63, 1023, 12, 627, 589, 12, 1011, 829, 9, 339, 9116, 14, 2758, 275, 3272, 339, 327, 492, 314, 6117, 1159, 3272, 859, 272, 492, 3272, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5496, 63, 4435, 492, 664, 63, 4972, 199, 504, 3873, 492, 1104, 63, 1199, 199, 646, 4145, 199, 646, 2022, 199, 199, 11857, 275, 283, 13057, 71, 5012, 453, 2626, 15, 2629, 2268, 7, 199, 3187, 633, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 7, 199, 199, 318, 664, 63, 3543, 837, 272, 1166, 275, 6135, 633, 435, 7324, 435, 20416, 435, 1994, 80, 13072, 31, 929, 29, 5938, 7, 272, 3085, 275, 4145, 14, 362, 8, 633, 9, 272, 340, 3085, 14, 1205, 63, 600, 508, 4145, 14, 6021, 14, 745, 26, 267, 1564, 275, 2022, 14, 3640, 8, 4518, 14, 1317, 9, 267, 367, 1242, 315, 1564, 26, 288, 340, 283, 15269, 63, 292, 7, 315, 1242, 436, 283, 5628, 63, 3543, 63, 4835, 7, 315, 1242, 26, 355, 372, 221, 1242, 459, 5628, 63, 3543, 63, 4835, 418, 272, 372, 488, 199, 199, 318, 664, 63, 1023, 837, 272, 492, 747, 272, 1788, 275, 283, 4612, 7, 272, 327, 692, 747, 14, 515, 14, 2444, 5175, 3187, 15, 20332, 63, 5211, 735, 272, 327, 259, 1788, 275, 1987, 3187, 15, 20332, 63, 5211, 7, 272, 327, 2836, 26, 272, 870, 747, 14, 515, 14, 4832, 8, 1501, 9, 272, 543, 1551, 8, 1501, 9, 465, 4090, 26, 267, 372, 4090, 14, 6407, 342, 199, 199, 318, 4107, 63, 1023, 63, 908, 8, 2686, 12, 1921, 12, 574, 304, 272, 862, 26, 267, 1015, 275, 664, 63, 1023, 1252, 1913, 342, 272, 871, 26, 267, 1015, 275, 664, 63, 4972, 8, 2686, 14, 362, 63, 354, 8801, 1023, 272, 587, 26, 267, 1015, 275, 1475, 63, 1023, 8, 1023, 29, 1023, 12, 7104, 29, 585, 9, 272, 2917, 14, 2343, 14, 1023, 275, 1015, 421, 199, 318, 1475, 63, 1023, 8, 1023, 12, 7104, 32134, 3187, 4835, 93, 735, 272, 372, 7104, 14, 908, 8, 3187, 4835, 29, 1023, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 327, 6705, 1015, 687, 6135, 272, 6135, 63, 1023, 275, 664, 63, 1023, 1252, 1913, 342, 272, 6135, 63, 1023, 275, 1475, 63, 1023, 8, 1023, 29, 3187, 63, 1023, 9, 339, 327, 14198, 13, 2068, 658, 13623, 14, 2758, 64, 370, 16182, 314, 6135, 1015, 272, 492, 9116, 272, 3379, 63, 2758, 275, 9116, 14, 2758, 339, 347, 3272, 8, 1023, 29, 403, 12, 627, 589, 12, 1011, 829, 304, 267, 372, 3379, 63, 2758, 8, 1023, 29, 3187, 63, 1023, 12, 627, 589, 12, 1011, 829, 9, 339, 9116, 14, 2758, 275, 3272, 339, 327, 492, 314, 6117, 1159, 3272, 859, 272, 492, 3272, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hryamzik/ansible
lib/ansible/modules/cloud/openstack/os_network.py
35
7411
#!/usr/bin/python # Copyright (c) 2014 Hewlett-Packard Development Company, L.P. # Copyright (c) 2013, Benno Joy <benno@ansible.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: os_network short_description: Creates/removes networks from OpenStack extends_documentation_fragment: openstack version_added: "2.0" author: "Monty Taylor (@emonty)" description: - Add or remove network from OpenStack. options: name: description: - Name to be assigned to the network. required: true shared: description: - Whether this network is shared or not. type: bool default: 'no' admin_state_up: description: - Whether the state should be marked as up or down. type: bool default: 'yes' external: description: - Whether this network is externally accessible. type: bool default: 'no' state: description: - Indicate desired state of the resource. choices: ['present', 'absent'] default: present provider_physical_network: description: - The physical network where this network object is implemented. version_added: "2.1" provider_network_type: description: - The type of physical network that maps to this network resource. version_added: "2.1" provider_segmentation_id: description: - An isolated segment on the physical network. The I(network_type) attribute defines the segmentation model. For example, if the I(network_type) value is vlan, this ID is a vlan identifier. If the I(network_type) value is gre, this ID is a gre key. version_added: "2.1" project: description: - Project name or ID containing the network (name admin-only) version_added: "2.1" availability_zone: description: - Ignored. Present for backwards compatibility requirements: ["openstacksdk"] ''' EXAMPLES = ''' # Create an externally accessible network named 'ext_network'. - os_network: cloud: mycloud state: present name: ext_network external: true ''' RETURN = ''' network: description: Dictionary describing the network. returned: On success when I(state) is 'present'. type: complex contains: id: description: Network ID. type: string sample: "4bb4f9a5-3bd2-4562-bf6a-d17a6341bb56" name: description: Network name. type: string sample: "ext_network" shared: description: Indicates whether this network is shared across all tenants. type: bool sample: false status: description: Network status. type: string sample: "ACTIVE" mtu: description: The MTU of a network resource. type: integer sample: 0 admin_state_up: description: The administrative state of the network. type: bool sample: true port_security_enabled: description: The port security status type: bool sample: true router:external: description: Indicates whether this network is externally accessible. type: bool sample: true tenant_id: description: The tenant ID. type: string sample: "06820f94b9f54b119636be2728d216fc" subnets: description: The associated subnets. type: list sample: [] "provider:physical_network": description: The physical network where this network object is implemented. type: string sample: my_vlan_net "provider:network_type": description: The type of physical network that maps to this network resource. type: string sample: vlan "provider:segmentation_id": description: An isolated segment on the physical network. type: string sample: 101 ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module def main(): argument_spec = openstack_full_argument_spec( name=dict(required=True), shared=dict(default=False, type='bool'), admin_state_up=dict(default=True, type='bool'), external=dict(default=False, type='bool'), provider_physical_network=dict(required=False), provider_network_type=dict(required=False), provider_segmentation_id=dict(required=False), state=dict(default='present', choices=['absent', 'present']), project=dict(default=None) ) module_kwargs = openstack_module_kwargs() module = AnsibleModule(argument_spec, **module_kwargs) state = module.params['state'] name = module.params['name'] shared = module.params['shared'] admin_state_up = module.params['admin_state_up'] external = module.params['external'] provider_physical_network = module.params['provider_physical_network'] provider_network_type = module.params['provider_network_type'] provider_segmentation_id = module.params['provider_segmentation_id'] project = module.params.get('project') sdk, cloud = openstack_cloud_from_module(module) try: if project is not None: proj = cloud.get_project(project) if proj is None: module.fail_json(msg='Project %s could not be found' % project) project_id = proj['id'] filters = {'tenant_id': project_id} else: project_id = None filters = None net = cloud.get_network(name, filters=filters) if state == 'present': if not net: provider = {} if provider_physical_network: provider['physical_network'] = provider_physical_network if provider_network_type: provider['network_type'] = provider_network_type if provider_segmentation_id: provider['segmentation_id'] = provider_segmentation_id if project_id is not None: net = cloud.create_network(name, shared, admin_state_up, external, provider, project_id) else: net = cloud.create_network(name, shared, admin_state_up, external, provider) changed = True else: changed = False module.exit_json(changed=changed, network=net, id=net['id']) elif state == 'absent': if not net: module.exit_json(changed=False) else: cloud.delete_network(name) module.exit_json(changed=True) except sdk.exceptions.OpenStackCloudException as e: module.fail_json(msg=str(e)) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 12, 26844, 889, 7135, 89, 665, 18486, 889, 32, 4853, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 1200, 199, 3612, 63, 1802, 26, 10560, 15, 264, 4912, 11759, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 6671, 369, 377, 1187, 25339, 8593, 69, 2106, 369, 2924, 199, 1802, 26, 2043, 446, 2654, 503, 2813, 2784, 687, 14260, 14, 199, 1419, 26, 2043, 536, 26, 1362, 1369, 26, 267, 446, 2812, 370, 506, 7943, 370, 314, 2784, 14, 1362, 1415, 26, 2549, 2043, 5709, 26, 1362, 1369, 26, 267, 446, 7480, 642, 2784, 365, 5709, 503, 440, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 889, 7, 2043, 4628, 63, 929, 63, 384, 26, 1362, 1369, 26, 267, 446, 7480, 314, 1174, 1077, 506, 11584, 465, 1536, 503, 3224, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 5066, 7, 2043, 5957, 26, 1362, 1369, 26, 267, 446, 7480, 642, 2784, 365, 21815, 1183, 17909, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 889, 7, 2043, 1174, 26, 1362, 1369, 26, 267, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 14, 1362, 3415, 26, 788, 1881, 297, 283, 5575, 418, 1362, 849, 26, 3451, 2043, 5022, 63, 15020, 63, 1200, 26, 1362, 1369, 26, 267, 446, 710, 14095, 2784, 2382, 642, 2784, 909, 365, 6366, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 5022, 63, 1200, 63, 466, 26, 1362, 1369, 26, 267, 446, 710, 730, 402, 14095, 2784, 626, 9033, 370, 642, 2784, 2073, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 5022, 63, 26926, 63, 344, 26, 1362, 1369, 26, 267, 446, 1626, 23348, 8135, 641, 314, 14095, 2784, 14, 710, 473, 8, 1200, 63, 466, 9, 881, 2225, 7890, 314, 27315, 1402, 14, 2104, 2893, 12, 340, 314, 881, 473, 8, 1200, 63, 466, 9, 574, 365, 10119, 12, 642, 2870, 365, 282, 10119, 5148, 14, 982, 881, 314, 473, 8, 1200, 63, 466, 9, 574, 365, 486, 264, 12, 642, 2870, 365, 282, 486, 264, 790, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 2199, 26, 1362, 1369, 26, 267, 446, 7290, 536, 503, 2870, 3035, 314, 2784, 334, 354, 4628, 13, 2118, 9, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 199, 7538, 26, 2097, 8512, 9277, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 376, 21815, 1183, 17909, 2784, 4310, 283, 832, 63, 1200, 1370, 199, 13, 747, 63, 1200, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 1599, 63, 1200, 272, 5957, 26, 2549, 199, 2344, 199, 199, 9677, 275, 1449, 199, 1200, 26, 272, 1369, 26, 11932, 13660, 314, 2784, 14, 272, 2138, 26, 4068, 3182, 1380, 473, 8, 929, 9, 365, 283, 1881, 1370, 272, 730, 26, 6114, 272, 3509, 26, 267, 1305, 26, 288, 1369, 26, 7220, 2870, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 20, 2501, 20, 70, 25, 65, 21, 13, 19, 3691, 18, 13, 11419, 18, 13, 4361, 22, 65, 13, 68, 1196, 65, 22, 15590, 2501, 1367, 2, 267, 536, 26, 288, 1369, 26, 7220, 536, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 832, 63, 1200, 2, 267, 5709, 26, 288, 1369, 26, 19334, 3775, 642, 2784, 365, 5709, 9371, 1006, 16685, 2285, 14, 288, 730, 26, 2155, 288, 2690, 26, 3055, 267, 2004, 26, 288, 1369, 26, 7220, 2004, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 10401, 2, 267, 28270, 26, 288, 1369, 26, 710, 603, 21364, 402, 282, 2784, 2073, 14, 288, 730, 26, 3000, 288, 2690, 26, 378, 267, 4628, 63, 929, 63, 384, 26, 288, 1369, 26, 710, 4628, 25124, 1174, 402, 314, 2784, 14, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 1844, 63, 4416, 63, 3827, 26, 288, 1369, 26, 710, 1844, 6391, 2004, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 6197, 26, 5159, 26, 288, 1369, 26, 19334, 3775, 642, 2784, 365, 21815, 1183, 17909, 14, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 8261, 63, 344, 26, 288, 1369, 26, 710, 8261, 2870, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 19846, 1165, 70, 2635, 66, 25, 70, 1477, 66, 845, 2534, 1344, 1235, 1465, 1651, 68, 9669, 3003, 2, 267, 18709, 26, 288, 1369, 26, 710, 4568, 18709, 14, 288, 730, 26, 769, 288, 2690, 26, 942, 267, 298, 3780, 26, 15020, 63, 1200, 582, 288, 1369, 26, 710, 14095, 2784, 2382, 642, 2784, 909, 365, 6366, 14, 288, 730, 26, 1059, 288, 2690, 26, 3002, 63, 7175, 63, 846, 267, 298, 3780, 26, 1200, 63, 466, 582, 288, 1369, 26, 710, 730, 402, 14095, 2784, 626, 9033, 370, 642, 2784, 2073, 14, 288, 730, 26, 1059, 288, 2690, 26, 10119, 267, 298, 3780, 26, 26926, 63, 344, 582, 288, 1369, 26, 1626, 23348, 8135, 641, 314, 14095, 2784, 14, 288, 730, 26, 1059, 288, 2690, 26, 14313, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 8512, 492, 13869, 63, 2861, 63, 2094, 63, 1650, 12, 13869, 63, 578, 63, 958, 12, 13869, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1898, 334, 67, 9, 6171, 12, 26844, 889, 7135, 89, 665, 18486, 889, 32, 4853, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 1200, 199, 3612, 63, 1802, 26, 10560, 15, 264, 4912, 11759, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 6671, 369, 377, 1187, 25339, 8593, 69, 2106, 369, 2924, 199, 1802, 26, 2043, 446, 2654, 503, 2813, 2784, 687, 14260, 14, 199, 1419, 26, 2043, 536, 26, 1362, 1369, 26, 267, 446, 2812, 370, 506, 7943, 370, 314, 2784, 14, 1362, 1415, 26, 2549, 2043, 5709, 26, 1362, 1369, 26, 267, 446, 7480, 642, 2784, 365, 5709, 503, 440, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 889, 7, 2043, 4628, 63, 929, 63, 384, 26, 1362, 1369, 26, 267, 446, 7480, 314, 1174, 1077, 506, 11584, 465, 1536, 503, 3224, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 5066, 7, 2043, 5957, 26, 1362, 1369, 26, 267, 446, 7480, 642, 2784, 365, 21815, 1183, 17909, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 889, 7, 2043, 1174, 26, 1362, 1369, 26, 267, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 14, 1362, 3415, 26, 788, 1881, 297, 283, 5575, 418, 1362, 849, 26, 3451, 2043, 5022, 63, 15020, 63, 1200, 26, 1362, 1369, 26, 267, 446, 710, 14095, 2784, 2382, 642, 2784, 909, 365, 6366, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 5022, 63, 1200, 63, 466, 26, 1362, 1369, 26, 267, 446, 710, 730, 402, 14095, 2784, 626, 9033, 370, 642, 2784, 2073, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 5022, 63, 26926, 63, 344, 26, 1362, 1369, 26, 267, 446, 1626, 23348, 8135, 641, 314, 14095, 2784, 14, 710, 473, 8, 1200, 63, 466, 9, 881, 2225, 7890, 314, 27315, 1402, 14, 2104, 2893, 12, 340, 314, 881, 473, 8, 1200, 63, 466, 9, 574, 365, 10119, 12, 642, 2870, 365, 282, 10119, 5148, 14, 982, 881, 314, 473, 8, 1200, 63, 466, 9, 574, 365, 486, 264, 12, 642, 2870, 365, 282, 486, 264, 790, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 2199, 26, 1362, 1369, 26, 267, 446, 7290, 536, 503, 2870, 3035, 314, 2784, 334, 354, 4628, 13, 2118, 9, 1362, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 199, 7538, 26, 2097, 8512, 9277, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 376, 21815, 1183, 17909, 2784, 4310, 283, 832, 63, 1200, 1370, 199, 13, 747, 63, 1200, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 1599, 63, 1200, 272, 5957, 26, 2549, 199, 2344, 199, 199, 9677, 275, 1449, 199, 1200, 26, 272, 1369, 26, 11932, 13660, 314, 2784, 14, 272, 2138, 26, 4068, 3182, 1380, 473, 8, 929, 9, 365, 283, 1881, 1370, 272, 730, 26, 6114, 272, 3509, 26, 267, 1305, 26, 288, 1369, 26, 7220, 2870, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 20, 2501, 20, 70, 25, 65, 21, 13, 19, 3691, 18, 13, 11419, 18, 13, 4361, 22, 65, 13, 68, 1196, 65, 22, 15590, 2501, 1367, 2, 267, 536, 26, 288, 1369, 26, 7220, 536, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 832, 63, 1200, 2, 267, 5709, 26, 288, 1369, 26, 19334, 3775, 642, 2784, 365, 5709, 9371, 1006, 16685, 2285, 14, 288, 730, 26, 2155, 288, 2690, 26, 3055, 267, 2004, 26, 288, 1369, 26, 7220, 2004, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 10401, 2, 267, 28270, 26, 288, 1369, 26, 710, 603, 21364, 402, 282, 2784, 2073, 14, 288, 730, 26, 3000, 288, 2690, 26, 378, 267, 4628, 63, 929, 63, 384, 26, 288, 1369, 26, 710, 4628, 25124, 1174, 402, 314, 2784, 14, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 1844, 63, 4416, 63, 3827, 26, 288, 1369, 26, 710, 1844, 6391, 2004, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 6197, 26, 5159, 26, 288, 1369, 26, 19334, 3775, 642, 2784, 365, 21815, 1183, 17909, 14, 288, 730, 26, 2155, 288, 2690, 26, 2549, 267, 8261, 63, 344, 26, 288, 1369, 26, 710, 8261, 2870, 14, 288, 730, 26, 1059, 288, 2690, 26, 298, 19846, 1165, 70, 2635, 66, 25, 70, 1477, 66, 845, 2534, 1344, 1235, 1465, 1651, 68, 9669, 3003, 2, 267, 18709, 26, 288, 1369, 26, 710, 4568, 18709, 14, 288, 730, 26, 769, 288, 2690, 26, 942, 267, 298, 3780, 26, 15020, 63, 1200, 582, 288, 1369, 26, 710, 14095, 2784, 2382, 642, 2784, 909, 365, 6366, 14, 288, 730, 26, 1059, 288, 2690, 26, 3002, 63, 7175, 63, 846, 267, 298, 3780, 26, 1200, 63, 466, 582, 288, 1369, 26, 710, 730, 402, 14095, 2784, 626, 9033, 370, 642, 2784, 2073, 14, 288, 730, 26, 1059, 288, 2690, 26, 10119, 267, 298, 3780, 26, 26926, 63, 344, 582, 288, 1369, 26, 1626, 23348, 8135, 641, 314, 14095, 2784, 14, 288, 730, 26, 1059, 288, 2690, 26, 14313, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 8512, 492, 13869, 63, 2861, 63, 2094, 63, 1650, 12, 13869, 63, 578, 63, 958, 12, 13869, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lmazuel/azure-sdk-for-python
azure-mgmt-machinelearningcompute/azure/mgmt/machinelearningcompute/models/storage_account_credentials.py
2
1557
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.serialization import Model class StorageAccountCredentials(Model): """Access information for the storage account. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_id: The ARM resource ID of the storage account. :vartype resource_id: str :ivar primary_key: The primary key of the storage account. :vartype primary_key: str :ivar secondary_key: The secondary key of the storage account. :vartype secondary_key: str """ _validation = { 'resource_id': {'readonly': True}, 'primary_key': {'readonly': True}, 'secondary_key': {'readonly': True}, } _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, 'primary_key': {'key': 'primaryKey', 'type': 'str'}, 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, } def __init__(self): super(StorageAccountCredentials, self).__init__() self.resource_id = None self.primary_key = None self.secondary_key = None
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 10533, 6009, 13428, 8, 1685, 304, 272, 408, 3946, 2556, 367, 314, 4887, 2933, 14, 339, 17198, 787, 1454, 16460, 701, 314, 1654, 12, 436, 911, 506, 5525, 1380, 272, 10209, 282, 1056, 14, 339, 520, 7725, 2073, 63, 344, 26, 710, 27155, 2073, 2870, 402, 314, 4887, 2933, 14, 272, 520, 19729, 2073, 63, 344, 26, 620, 272, 520, 7725, 5062, 63, 498, 26, 710, 5062, 790, 402, 314, 4887, 2933, 14, 272, 520, 19729, 5062, 63, 498, 26, 620, 272, 520, 7725, 13851, 63, 498, 26, 710, 13851, 790, 402, 314, 4887, 2933, 14, 272, 520, 19729, 13851, 63, 498, 26, 620, 272, 408, 339, 485, 6136, 275, 469, 267, 283, 1927, 63, 344, 356, 791, 6753, 356, 715, 1386, 267, 283, 3327, 63, 498, 356, 791, 6753, 356, 715, 1386, 267, 283, 12371, 63, 498, 356, 791, 6753, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 1927, 63, 344, 356, 791, 498, 356, 283, 1927, 1304, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 3327, 63, 498, 356, 791, 498, 356, 283, 3327, 1197, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 12371, 63, 498, 356, 791, 498, 356, 283, 12371, 1197, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 6408, 6009, 13428, 12, 291, 2843, 826, 4533, 267, 291, 14, 1927, 63, 344, 275, 488, 267, 291, 14, 3327, 63, 498, 275, 488, 267, 291, 14, 12371, 63, 498, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 6605, 3911, 14, 12161, 492, 5822, 421, 199, 533, 10533, 6009, 13428, 8, 1685, 304, 272, 408, 3946, 2556, 367, 314, 4887, 2933, 14, 339, 17198, 787, 1454, 16460, 701, 314, 1654, 12, 436, 911, 506, 5525, 1380, 272, 10209, 282, 1056, 14, 339, 520, 7725, 2073, 63, 344, 26, 710, 27155, 2073, 2870, 402, 314, 4887, 2933, 14, 272, 520, 19729, 2073, 63, 344, 26, 620, 272, 520, 7725, 5062, 63, 498, 26, 710, 5062, 790, 402, 314, 4887, 2933, 14, 272, 520, 19729, 5062, 63, 498, 26, 620, 272, 520, 7725, 13851, 63, 498, 26, 710, 13851, 790, 402, 314, 4887, 2933, 14, 272, 520, 19729, 13851, 63, 498, 26, 620, 272, 408, 339, 485, 6136, 275, 469, 267, 283, 1927, 63, 344, 356, 791, 6753, 356, 715, 1386, 267, 283, 3327, 63, 498, 356, 791, 6753, 356, 715, 1386, 267, 283, 12371, 63, 498, 356, 791, 6753, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 1927, 63, 344, 356, 791, 498, 356, 283, 1927, 1304, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 3327, 63, 498, 356, 791, 498, 356, 283, 3327, 1197, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 12371, 63, 498, 356, 791, 498, 356, 283, 12371, 1197, 297, 283, 466, 356, 283, 495, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 6408, 6009, 13428, 12, 291, 2843, 826, 4533, 267, 291, 14, 1927, 63, 344, 275, 488, 267, 291, 14, 3327, 63, 498, 275, 488, 267, 291, 14, 12371, 63, 498, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bulldy80/gyp_unofficial
test/lib/TestGyp.py
18
40246
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ TestGyp.py: a testing framework for GYP integration tests. """ import collections from contextlib import contextmanager import itertools import os import re import shutil import subprocess import sys import tempfile import TestCmd import TestCommon from TestCommon import __all__ __all__.extend([ 'TestGyp', ]) def remove_debug_line_numbers(contents): """Function to remove the line numbers from the debug output of gyp and thus reduce the extreme fragility of the stdout comparison tests. """ lines = contents.splitlines() # split each line on ":" lines = [l.split(":", 3) for l in lines] # join each line back together while ignoring the # 3rd column which is the line number lines = [len(l) > 3 and ":".join(l[3:]) or l for l in lines] return "\n".join(lines) def match_modulo_line_numbers(contents_a, contents_b): """File contents matcher that ignores line numbers.""" contents_a = remove_debug_line_numbers(contents_a) contents_b = remove_debug_line_numbers(contents_b) return TestCommon.match_exact(contents_a, contents_b) @contextmanager def LocalEnv(local_env): """Context manager to provide a local OS environment.""" old_env = os.environ.copy() os.environ.update(local_env) try: yield finally: os.environ.clear() os.environ.update(old_env) class TestGypBase(TestCommon.TestCommon): """ Class for controlling end-to-end tests of gyp generators. Instantiating this class will create a temporary directory and arrange for its destruction (via the TestCmd superclass) and copy all of the non-gyptest files in the directory hierarchy of the executing script. The default behavior is to test the 'gyp' or 'gyp.bat' file in the current directory. An alternative may be specified explicitly on instantiation, or by setting the TESTGYP_GYP environment variable. This class should be subclassed for each supported gyp generator (format). Various abstract methods below define calling signatures used by the test scripts to invoke builds on the generated build configuration and to run executables generated by those builds. """ formats = [] build_tool = None build_tool_list = [] _exe = TestCommon.exe_suffix _obj = TestCommon.obj_suffix shobj_ = TestCommon.shobj_prefix _shobj = TestCommon.shobj_suffix lib_ = TestCommon.lib_prefix _lib = TestCommon.lib_suffix dll_ = TestCommon.dll_prefix _dll = TestCommon.dll_suffix # Constants to represent different targets. ALL = '__all__' DEFAULT = '__default__' # Constants for different target types. EXECUTABLE = '__executable__' STATIC_LIB = '__static_lib__' SHARED_LIB = '__shared_lib__' def __init__(self, gyp=None, *args, **kw): self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) self.extra_args = sys.argv[1:] if not gyp: gyp = os.environ.get('TESTGYP_GYP') if not gyp: if sys.platform == 'win32': gyp = 'gyp.bat' else: gyp = 'gyp' self.gyp = os.path.abspath(gyp) self.no_parallel = False self.formats = [self.format] self.initialize_build_tool() kw.setdefault('match', TestCommon.match_exact) # Put test output in out/testworkarea by default. # Use temporary names so there are no collisions. workdir = os.path.join('out', kw.get('workdir', 'testworkarea')) # Create work area if it doesn't already exist. if not os.path.isdir(workdir): os.makedirs(workdir) kw['workdir'] = tempfile.mktemp(prefix='testgyp.', dir=workdir) formats = kw.pop('formats', []) super(TestGypBase, self).__init__(*args, **kw) real_format = self.format.split('-')[-1] excluded_formats = set([f for f in formats if f[0] == '!']) included_formats = set(formats) - excluded_formats if ('!'+real_format in excluded_formats or included_formats and real_format not in included_formats): msg = 'Invalid test for %r format; skipping test.\n' self.skip_test(msg % self.format) self.copy_test_configuration(self.origin_cwd, self.workdir) self.set_configuration(None) # Set $HOME so that gyp doesn't read the user's actual # ~/.gyp/include.gypi file, which may contain variables # and other settings that would change the output. os.environ['HOME'] = self.workpath() # Clear $GYP_DEFINES for the same reason. if 'GYP_DEFINES' in os.environ: del os.environ['GYP_DEFINES'] # Override the user's language settings, which could # otherwise make the output vary from what is expected. os.environ['LC_ALL'] = 'C' def built_file_must_exist(self, name, type=None, **kw): """ Fails the test if the specified built file name does not exist. """ return self.must_exist(self.built_file_path(name, type, **kw)) def built_file_must_not_exist(self, name, type=None, **kw): """ Fails the test if the specified built file name exists. """ return self.must_not_exist(self.built_file_path(name, type, **kw)) def built_file_must_match(self, name, contents, **kw): """ Fails the test if the contents of the specified built file name do not match the specified contents. """ return self.must_match(self.built_file_path(name, **kw), contents) def built_file_must_not_match(self, name, contents, **kw): """ Fails the test if the contents of the specified built file name match the specified contents. """ return self.must_not_match(self.built_file_path(name, **kw), contents) def built_file_must_not_contain(self, name, contents, **kw): """ Fails the test if the specified built file name contains the specified contents. """ return self.must_not_contain(self.built_file_path(name, **kw), contents) def copy_test_configuration(self, source_dir, dest_dir): """ Copies the test configuration from the specified source_dir (the directory in which the test script lives) to the specified dest_dir (a temporary working directory). This ignores all files and directories that begin with the string 'gyptest', and all '.svn' subdirectories. """ for root, dirs, files in os.walk(source_dir): if '.svn' in dirs: dirs.remove('.svn') dirs = [ d for d in dirs if not d.startswith('gyptest') ] files = [ f for f in files if not f.startswith('gyptest') ] for dirname in dirs: source = os.path.join(root, dirname) destination = source.replace(source_dir, dest_dir) os.mkdir(destination) if sys.platform != 'win32': shutil.copystat(source, destination) for filename in files: source = os.path.join(root, filename) destination = source.replace(source_dir, dest_dir) shutil.copy2(source, destination) def initialize_build_tool(self): """ Initializes the .build_tool attribute. Searches the .build_tool_list for an executable name on the user's $PATH. The first tool on the list is used as-is if nothing is found on the current $PATH. """ for build_tool in self.build_tool_list: if not build_tool: continue if os.path.isabs(build_tool): self.build_tool = build_tool return build_tool = self.where_is(build_tool) if build_tool: self.build_tool = build_tool return if self.build_tool_list: self.build_tool = self.build_tool_list[0] def relocate(self, source, destination): """ Renames (relocates) the specified source (usually a directory) to the specified destination, creating the destination directory first if necessary. Note: Don't use this as a generic "rename" operation. In the future, "relocating" parts of a GYP tree may affect the state of the test to modify the behavior of later method calls. """ destination_dir = os.path.dirname(destination) if not os.path.exists(destination_dir): self.subdir(destination_dir) os.rename(source, destination) def report_not_up_to_date(self): """ Reports that a build is not up-to-date. This provides common reporting for formats that have complicated conditions for checking whether a build is up-to-date. Formats that expect exact output from the command (make) can just set stdout= when they call the run_build() method. """ print "Build is not up-to-date:" print self.banner('STDOUT ') print self.stdout() stderr = self.stderr() if stderr: print self.banner('STDERR ') print stderr def run_gyp(self, gyp_file, *args, **kw): """ Runs gyp against the specified gyp_file with the specified args. """ # When running gyp, and comparing its output we use a comparitor # that ignores the line numbers that gyp logs in its debug output. if kw.pop('ignore_line_numbers', False): kw.setdefault('match', match_modulo_line_numbers) # TODO: --depth=. works around Chromium-specific tree climbing. depth = kw.pop('depth', '.') run_args = ['--depth='+depth] run_args.extend(['--format='+f for f in self.formats]); run_args.append(gyp_file) if self.no_parallel: run_args += ['--no-parallel'] # TODO: if extra_args contains a '--build' flag # we really want that to only apply to the last format (self.format). run_args.extend(self.extra_args) # Default xcode_ninja_target_pattern to ^.*$ to fix xcode-ninja tests xcode_ninja_target_pattern = kw.pop('xcode_ninja_target_pattern', '.*') run_args.extend( ['-G', 'xcode_ninja_target_pattern=%s' % xcode_ninja_target_pattern]) run_args.extend(args) return self.run(program=self.gyp, arguments=run_args, **kw) def run(self, *args, **kw): """ Executes a program by calling the superclass .run() method. This exists to provide a common place to filter out keyword arguments implemented in this layer, without having to update the tool-specific subclasses or clutter the tests themselves with platform-specific code. """ if kw.has_key('SYMROOT'): del kw['SYMROOT'] super(TestGypBase, self).run(*args, **kw) def set_configuration(self, configuration): """ Sets the configuration, to be used for invoking the build tool and testing potential built output. """ self.configuration = configuration def configuration_dirname(self): if self.configuration: return self.configuration.split('|')[0] else: return 'Default' def configuration_buildname(self): if self.configuration: return self.configuration else: return 'Default' # # Abstract methods to be defined by format-specific subclasses. # def build(self, gyp_file, target=None, **kw): """ Runs a build of the specified target against the configuration generated from the specified gyp_file. A 'target' argument of None or the special value TestGyp.DEFAULT specifies the default argument for the underlying build tool. A 'target' argument of TestGyp.ALL specifies the 'all' target (if any) of the underlying build tool. """ raise NotImplementedError def built_file_path(self, name, type=None, **kw): """ Returns a path to the specified file name, of the specified type. """ raise NotImplementedError def built_file_basename(self, name, type=None, **kw): """ Returns the base name of the specified file name, of the specified type. A bare=True keyword argument specifies that prefixes and suffixes shouldn't be applied. """ if not kw.get('bare'): if type == self.EXECUTABLE: name = name + self._exe elif type == self.STATIC_LIB: name = self.lib_ + name + self._lib elif type == self.SHARED_LIB: name = self.dll_ + name + self._dll return name def run_built_executable(self, name, *args, **kw): """ Runs an executable program built from a gyp-generated configuration. The specified name should be independent of any particular generator. Subclasses should find the output executable in the appropriate output build directory, tack on any necessary executable suffix, etc. """ raise NotImplementedError def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified target is up to date. The subclass should implement this by calling build() (or a reasonable equivalent), checking whatever conditions will tell it the build was an "up to date" null build, and failing if it isn't. """ raise NotImplementedError class TestGypGypd(TestGypBase): """ Subclass for testing the GYP 'gypd' generator (spit out the internal data structure as pretty-printed Python). """ format = 'gypd' def __init__(self, gyp=None, *args, **kw): super(TestGypGypd, self).__init__(*args, **kw) # gypd implies the use of 'golden' files, so parallelizing conflicts as it # causes ordering changes. self.no_parallel = True class TestGypCustom(TestGypBase): """ Subclass for testing the GYP with custom generator """ def __init__(self, gyp=None, *args, **kw): self.format = kw.pop("format") super(TestGypCustom, self).__init__(*args, **kw) class TestGypCMake(TestGypBase): """ Subclass for testing the GYP CMake generator, using cmake's ninja backend. """ format = 'cmake' build_tool_list = ['cmake'] ALL = 'all' def cmake_build(self, gyp_file, target=None, **kw): arguments = kw.get('arguments', [])[:] self.build_tool_list = ['cmake'] self.initialize_build_tool() chdir = os.path.join(kw.get('chdir', '.'), 'out', self.configuration_dirname()) kw['chdir'] = chdir arguments.append('-G') arguments.append('Ninja') kw['arguments'] = arguments stderr = kw.get('stderr', None) if stderr: kw['stderr'] = stderr.split('$$$')[0] self.run(program=self.build_tool, **kw) def ninja_build(self, gyp_file, target=None, **kw): arguments = kw.get('arguments', [])[:] self.build_tool_list = ['ninja'] self.initialize_build_tool() # Add a -C output/path to the command line. arguments.append('-C') arguments.append(os.path.join('out', self.configuration_dirname())) if target not in (None, self.DEFAULT): arguments.append(target) kw['arguments'] = arguments stderr = kw.get('stderr', None) if stderr: stderrs = stderr.split('$$$') kw['stderr'] = stderrs[1] if len(stderrs) > 1 else '' return self.run(program=self.build_tool, **kw) def build(self, gyp_file, target=None, status=0, **kw): # Two tools must be run to build, cmake and the ninja. # Allow cmake to succeed when the overall expectation is to fail. if status is None: kw['status'] = None else: if not isinstance(status, collections.Iterable): status = (status,) kw['status'] = list(itertools.chain((0,), status)) self.cmake_build(gyp_file, target, **kw) kw['status'] = status self.ninja_build(gyp_file, target, **kw) def run_built_executable(self, name, *args, **kw): # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] if sys.platform == 'darwin': configuration = self.configuration_dirname() os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration) return self.run(program=program, *args, **kw) def built_file_path(self, name, type=None, **kw): result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) result.append('out') result.append(self.configuration_dirname()) if type == self.STATIC_LIB: if sys.platform != 'darwin': result.append('obj.target') elif type == self.SHARED_LIB: if sys.platform != 'darwin' and sys.platform != 'win32': result.append('lib.target') subdir = kw.get('subdir') if subdir and type != self.SHARED_LIB: result.append(subdir) result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) def up_to_date(self, gyp_file, target=None, **kw): result = self.ninja_build(gyp_file, target, **kw) if not result: stdout = self.stdout() if 'ninja: no work to do' not in stdout: self.report_not_up_to_date() self.fail_test() return result class TestGypMake(TestGypBase): """ Subclass for testing the GYP Make generator. """ format = 'make' build_tool_list = ['make'] ALL = 'all' def build(self, gyp_file, target=None, **kw): """ Runs a Make build using the Makefiles generated from the specified gyp_file. """ arguments = kw.get('arguments', [])[:] if self.configuration: arguments.append('BUILDTYPE=' + self.configuration) if target not in (None, self.DEFAULT): arguments.append(target) # Sub-directory builds provide per-gyp Makefiles (i.e. # Makefile.gyp_filename), so use that if there is no Makefile. chdir = kw.get('chdir', '') if not os.path.exists(os.path.join(chdir, 'Makefile')): print "NO Makefile in " + os.path.join(chdir, 'Makefile') arguments.insert(0, '-f') arguments.insert(1, os.path.splitext(gyp_file)[0] + '.Makefile') kw['arguments'] = arguments return self.run(program=self.build_tool, **kw) def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified Make target is up to date. """ if target in (None, self.DEFAULT): message_target = 'all' else: message_target = target kw['stdout'] = "make: Nothing to be done for `%s'.\n" % message_target return self.build(gyp_file, target, **kw) def run_built_executable(self, name, *args, **kw): """ Runs an executable built by Make. """ configuration = self.configuration_dirname() libdir = os.path.join('out', configuration, 'lib') # TODO(piman): when everything is cross-compile safe, remove lib.target if sys.platform == 'darwin': # Mac puts target shared libraries right in the product directory. configuration = self.configuration_dirname() os.environ['DYLD_LIBRARY_PATH'] = ( libdir + '.host:' + os.path.join('out', configuration)) else: os.environ['LD_LIBRARY_PATH'] = libdir + '.host:' + libdir + '.target' # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] return self.run(program=program, *args, **kw) def built_file_path(self, name, type=None, **kw): """ Returns a path to the specified file name, of the specified type, as built by Make. Built files are in the subdirectory 'out/{configuration}'. The default is 'out/Default'. A chdir= keyword argument specifies the source directory relative to which the output subdirectory can be found. "type" values of STATIC_LIB or SHARED_LIB append the necessary prefixes and suffixes to a platform-independent library base name. A subdir= keyword argument specifies a library subdirectory within the default 'obj.target'. """ result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) configuration = self.configuration_dirname() result.extend(['out', configuration]) if type == self.STATIC_LIB and sys.platform != 'darwin': result.append('obj.target') elif type == self.SHARED_LIB and sys.platform != 'darwin': result.append('lib.target') subdir = kw.get('subdir') if subdir and type != self.SHARED_LIB: result.append(subdir) result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) def ConvertToCygpath(path): """Convert to cygwin path if we are using cygwin.""" if sys.platform == 'cygwin': p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE) path = p.communicate()[0].strip() return path def FindMSBuildInstallation(msvs_version = 'auto'): """Returns path to MSBuild for msvs_version or latest available. Looks in the registry to find install location of MSBuild. MSBuild before v4.0 will not build c++ projects, so only use newer versions. """ import TestWin registry = TestWin.Registry() msvs_to_msbuild = { '2013': r'12.0', '2012': r'4.0', # Really v4.0.30319 which comes with .NET 4.5. '2010': r'4.0'} msbuild_basekey = r'HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions' if not registry.KeyExists(msbuild_basekey): print 'Error: could not find MSBuild base registry entry' return None msbuild_version = None if msvs_version in msvs_to_msbuild: msbuild_test_version = msvs_to_msbuild[msvs_version] if registry.KeyExists(msbuild_basekey + '\\' + msbuild_test_version): msbuild_version = msbuild_test_version else: print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" ' 'but corresponding MSBuild "%s" was not found.' % (msvs_version, msbuild_version)) if not msbuild_version: for msvs_version in sorted(msvs_to_msbuild, reverse=True): msbuild_test_version = msvs_to_msbuild[msvs_version] if registry.KeyExists(msbuild_basekey + '\\' + msbuild_test_version): msbuild_version = msbuild_test_version break if not msbuild_version: print 'Error: could not find MSBuild registry entry' return None msbuild_path = registry.GetValue(msbuild_basekey + '\\' + msbuild_version, 'MSBuildToolsPath') if not msbuild_path: print 'Error: could not get MSBuild registry entry value' return None return os.path.join(msbuild_path, 'MSBuild.exe') def FindVisualStudioInstallation(): """Returns appropriate values for .build_tool and .uses_msbuild fields of TestGypBase for Visual Studio. We use the value specified by GYP_MSVS_VERSION. If not specified, we search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable. Failing that, we search for likely deployment paths. """ possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix) for drive in range(ord('C'), ord('Z') + 1) for suffix in ['', ' (x86)']] possible_paths = { '2013': r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com', '2012': r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com', '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com', '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com', '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'} possible_roots = [ConvertToCygpath(r) for r in possible_roots] msvs_version = 'auto' for flag in (f for f in sys.argv if f.startswith('msvs_version=')): msvs_version = flag.split('=')[-1] msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version) if msvs_version in possible_paths: # Check that the path to the specified GYP_MSVS_VERSION exists. path = possible_paths[msvs_version] for r in possible_roots: build_tool = os.path.join(r, path) if os.path.exists(build_tool): uses_msbuild = msvs_version >= '2010' msbuild_path = FindMSBuildInstallation(msvs_version) return build_tool, uses_msbuild, msbuild_path else: print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" ' 'but corresponding "%s" was not found.' % (msvs_version, path)) # Neither GYP_MSVS_VERSION nor the path help us out. Iterate through # the choices looking for a match. for version in sorted(possible_paths, reverse=True): path = possible_paths[version] for r in possible_roots: build_tool = os.path.join(r, path) if os.path.exists(build_tool): uses_msbuild = msvs_version >= '2010' msbuild_path = FindMSBuildInstallation(msvs_version) return build_tool, uses_msbuild, msbuild_path print 'Error: could not find devenv' sys.exit(1) class TestGypOnMSToolchain(TestGypBase): """ Common subclass for testing generators that target the Microsoft Visual Studio toolchain (cl, link, dumpbin, etc.) """ @staticmethod def _ComputeVsvarsPath(devenv_path): devenv_dir = os.path.split(devenv_path)[0] vsvars_path = os.path.join(devenv_path, '../../Tools/vsvars32.bat') return vsvars_path def initialize_build_tool(self): super(TestGypOnMSToolchain, self).initialize_build_tool() if sys.platform in ('win32', 'cygwin'): build_tools = FindVisualStudioInstallation() self.devenv_path, self.uses_msbuild, self.msbuild_path = build_tools self.vsvars_path = TestGypOnMSToolchain._ComputeVsvarsPath( self.devenv_path) def run_dumpbin(self, *dumpbin_args): """Run the dumpbin tool with the specified arguments, and capturing and returning stdout.""" assert sys.platform in ('win32', 'cygwin') cmd = os.environ.get('COMSPEC', 'cmd.exe') arguments = [cmd, '/c', self.vsvars_path, '&&', 'dumpbin'] arguments.extend(dumpbin_args) proc = subprocess.Popen(arguments, stdout=subprocess.PIPE) output = proc.communicate()[0] assert not proc.returncode return output class TestGypNinja(TestGypOnMSToolchain): """ Subclass for testing the GYP Ninja generator. """ format = 'ninja' build_tool_list = ['ninja'] ALL = 'all' DEFAULT = 'all' def run_gyp(self, gyp_file, *args, **kw): TestGypBase.run_gyp(self, gyp_file, *args, **kw) def build(self, gyp_file, target=None, **kw): arguments = kw.get('arguments', [])[:] # Add a -C output/path to the command line. arguments.append('-C') arguments.append(os.path.join('out', self.configuration_dirname())) if target is None: target = 'all' arguments.append(target) kw['arguments'] = arguments return self.run(program=self.build_tool, **kw) def run_built_executable(self, name, *args, **kw): # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] if sys.platform == 'darwin': configuration = self.configuration_dirname() os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration) return self.run(program=program, *args, **kw) def built_file_path(self, name, type=None, **kw): result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) result.append('out') result.append(self.configuration_dirname()) if type == self.STATIC_LIB: if sys.platform != 'darwin': result.append('obj') elif type == self.SHARED_LIB: if sys.platform != 'darwin' and sys.platform != 'win32': result.append('lib') subdir = kw.get('subdir') if subdir and type != self.SHARED_LIB: result.append(subdir) result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) def up_to_date(self, gyp_file, target=None, **kw): result = self.build(gyp_file, target, **kw) if not result: stdout = self.stdout() if 'ninja: no work to do' not in stdout: self.report_not_up_to_date() self.fail_test() return result class TestGypMSVS(TestGypOnMSToolchain): """ Subclass for testing the GYP Visual Studio generator. """ format = 'msvs' u = r'=== Build: 0 succeeded, 0 failed, (\d+) up-to-date, 0 skipped ===' up_to_date_re = re.compile(u, re.M) # Initial None element will indicate to our .initialize_build_tool() # method below that 'devenv' was not found on %PATH%. # # Note: we must use devenv.com to be able to capture build output. # Directly executing devenv.exe only sends output to BuildLog.htm. build_tool_list = [None, 'devenv.com'] def initialize_build_tool(self): super(TestGypMSVS, self).initialize_build_tool() self.build_tool = self.devenv_path def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw): """ Runs a Visual Studio build using the configuration generated from the specified gyp_file. """ configuration = self.configuration_buildname() if clean: build = '/Clean' elif rebuild: build = '/Rebuild' else: build = '/Build' arguments = kw.get('arguments', [])[:] arguments.extend([gyp_file.replace('.gyp', '.sln'), build, configuration]) # Note: the Visual Studio generator doesn't add an explicit 'all' # target, so we just treat it the same as the default. if target not in (None, self.ALL, self.DEFAULT): arguments.extend(['/Project', target]) if self.configuration: arguments.extend(['/ProjectConfig', self.configuration]) kw['arguments'] = arguments return self.run(program=self.build_tool, **kw) def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified Visual Studio target is up to date. Beware that VS2010 will behave strangely if you build under C:\USERS\yourname\AppData\Local. It will cause needless work. The ouptut will be "1 succeeded and 0 up to date". MSBuild tracing reveals that: "Project 'C:\Users\...\AppData\Local\...vcxproj' not up to date because 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 10.0\VC\BIN\1033\CLUI.DLL' was modified at 02/21/2011 17:03:30, which is newer than '' which was modified at 01/01/0001 00:00:00. The workaround is to specify a workdir when instantiating the test, e.g. test = TestGyp.TestGyp(workdir='workarea') """ result = self.build(gyp_file, target, **kw) if not result: stdout = self.stdout() m = self.up_to_date_re.search(stdout) up_to_date = m and int(m.group(1)) > 0 if not up_to_date: self.report_not_up_to_date() self.fail_test() return result def run_built_executable(self, name, *args, **kw): """ Runs an executable built by Visual Studio. """ configuration = self.configuration_dirname() # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] return self.run(program=program, *args, **kw) def built_file_path(self, name, type=None, **kw): """ Returns a path to the specified file name, of the specified type, as built by Visual Studio. Built files are in a subdirectory that matches the configuration name. The default is 'Default'. A chdir= keyword argument specifies the source directory relative to which the output subdirectory can be found. "type" values of STATIC_LIB or SHARED_LIB append the necessary prefixes and suffixes to a platform-independent library base name. """ result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) result.append(self.configuration_dirname()) if type == self.STATIC_LIB: result.append('lib') result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) class TestGypMSVSNinja(TestGypNinja): """ Subclass for testing the GYP Visual Studio Ninja generator. """ format = 'msvs-ninja' def initialize_build_tool(self): super(TestGypMSVSNinja, self).initialize_build_tool() # When using '--build', make sure ninja is first in the format list. self.formats.insert(0, 'ninja') def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw): """ Runs a Visual Studio build using the configuration generated from the specified gyp_file. """ arguments = kw.get('arguments', [])[:] if target in (None, self.ALL, self.DEFAULT): # Note: the Visual Studio generator doesn't add an explicit 'all' target. # This will build each project. This will work if projects are hermetic, # but may fail if they are not (a project may run more than once). # It would be nice to supply an all.metaproj for MSBuild. arguments.extend([gyp_file.replace('.gyp', '.sln')]) else: # MSBuild documentation claims that one can specify a sln but then build a # project target like 'msbuild a.sln /t:proj:target' but this format only # supports 'Clean', 'Rebuild', and 'Publish' (with none meaning Default). # This limitation is due to the .sln -> .sln.metaproj conversion. # The ':' is not special, 'proj:target' is a target in the metaproj. arguments.extend([target+'.vcxproj']) if clean: build = 'Clean' elif rebuild: build = 'Rebuild' else: build = 'Build' arguments.extend(['/target:'+build]) configuration = self.configuration_buildname() config = configuration.split('|') arguments.extend(['/property:Configuration='+config[0]]) if len(config) > 1: arguments.extend(['/property:Platform='+config[1]]) arguments.extend(['/property:BuildInParallel=false']) arguments.extend(['/verbosity:minimal']) kw['arguments'] = arguments return self.run(program=self.msbuild_path, **kw) class TestGypXcode(TestGypBase): """ Subclass for testing the GYP Xcode generator. """ format = 'xcode' build_tool_list = ['xcodebuild'] phase_script_execution = ("\n" "PhaseScriptExecution /\\S+/Script-[0-9A-F]+\\.sh\n" " cd /\\S+\n" " /bin/sh -c /\\S+/Script-[0-9A-F]+\\.sh\n" "(make: Nothing to be done for `all'\\.\n)?") strip_up_to_date_expressions = [ # Various actions or rules can run even when the overall build target # is up to date. Strip those phases' GYP-generated output. re.compile(phase_script_execution, re.S), # The message from distcc_pump can trail the "BUILD SUCCEEDED" # message, so strip that, too. re.compile('__________Shutting down distcc-pump include server\n', re.S), ] up_to_date_endings = ( 'Checking Dependencies...\n** BUILD SUCCEEDED **\n', # Xcode 3.0/3.1 'Check dependencies\n** BUILD SUCCEEDED **\n\n', # Xcode 3.2 'Check dependencies\n\n\n** BUILD SUCCEEDED **\n\n', # Xcode 4.2 'Check dependencies\n\n** BUILD SUCCEEDED **\n\n', # Xcode 5.0 ) def build(self, gyp_file, target=None, **kw): """ Runs an xcodebuild using the .xcodeproj generated from the specified gyp_file. """ # Be sure we're working with a copy of 'arguments' since we modify it. # The caller may not be expecting it to be modified. arguments = kw.get('arguments', [])[:] arguments.extend(['-project', gyp_file.replace('.gyp', '.xcodeproj')]) if target == self.ALL: arguments.append('-alltargets',) elif target not in (None, self.DEFAULT): arguments.extend(['-target', target]) if self.configuration: arguments.extend(['-configuration', self.configuration]) symroot = kw.get('SYMROOT', '$SRCROOT/build') if symroot: arguments.append('SYMROOT='+symroot) kw['arguments'] = arguments # Work around spurious stderr output from Xcode 4, http://crbug.com/181012 match = kw.pop('match', self.match) def match_filter_xcode(actual, expected): if actual: if not TestCmd.is_List(actual): actual = actual.split('\n') if not TestCmd.is_List(expected): expected = expected.split('\n') actual = [a for a in actual if 'No recorder, buildTask: <Xcode3BuildTask:' not in a] return match(actual, expected) kw['match'] = match_filter_xcode return self.run(program=self.build_tool, **kw) def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified Xcode target is up to date. """ result = self.build(gyp_file, target, **kw) if not result: output = self.stdout() for expression in self.strip_up_to_date_expressions: output = expression.sub('', output) if not output.endswith(self.up_to_date_endings): self.report_not_up_to_date() self.fail_test() return result def run_built_executable(self, name, *args, **kw): """ Runs an executable built by xcodebuild. """ configuration = self.configuration_dirname() os.environ['DYLD_LIBRARY_PATH'] = os.path.join('build', configuration) # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] return self.run(program=program, *args, **kw) def built_file_path(self, name, type=None, **kw): """ Returns a path to the specified file name, of the specified type, as built by Xcode. Built files are in the subdirectory 'build/{configuration}'. The default is 'build/Default'. A chdir= keyword argument specifies the source directory relative to which the output subdirectory can be found. "type" values of STATIC_LIB or SHARED_LIB append the necessary prefixes and suffixes to a platform-independent library base name. """ result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) configuration = self.configuration_dirname() result.extend(['build', configuration]) result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) class TestGypXcodeNinja(TestGypXcode): """ Subclass for testing the GYP Xcode Ninja generator. """ format = 'xcode-ninja' def initialize_build_tool(self): super(TestGypXcodeNinja, self).initialize_build_tool() # When using '--build', make sure ninja is first in the format list. self.formats.insert(0, 'ninja') def build(self, gyp_file, target=None, **kw): """ Runs an xcodebuild using the .xcodeproj generated from the specified gyp_file. """ build_config = self.configuration if build_config and build_config.endswith(('-iphoneos', '-iphonesimulator')): build_config, sdk = self.configuration.split('-') kw['arguments'] = kw.get('arguments', []) + ['-sdk', sdk] with self._build_configuration(build_config): return super(TestGypXcodeNinja, self).build( gyp_file.replace('.gyp', '.ninja.gyp'), target, **kw) @contextmanager def _build_configuration(self, build_config): config = self.configuration self.configuration = build_config try: yield finally: self.configuration = config def built_file_path(self, name, type=None, **kw): result = [] chdir = kw.get('chdir') if chdir: result.append(chdir) result.append('out') result.append(self.configuration_dirname()) subdir = kw.get('subdir') if subdir and type != self.SHARED_LIB: result.append(subdir) result.append(self.built_file_basename(name, type, **kw)) return self.workpath(*result) def up_to_date(self, gyp_file, target=None, **kw): result = self.build(gyp_file, target, **kw) if not result: stdout = self.stdout() if 'ninja: no work to do' not in stdout: self.report_not_up_to_date() self.fail_test() return result def run_built_executable(self, name, *args, **kw): """ Runs an executable built by xcodebuild + ninja. """ configuration = self.configuration_dirname() os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration) # Enclosing the name in a list avoids prepending the original dir. program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] return self.run(program=program, *args, **kw) format_class_list = [ TestGypGypd, TestGypCMake, TestGypMake, TestGypMSVS, TestGypMSVSNinja, TestGypNinja, TestGypXcode, TestGypXcodeNinja, ] def TestGyp(*args, **kw): """ Returns an appropriate TestGyp* instance for a specified GYP format. """ format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) for format_class in format_class_list: if format == format_class.format: return format_class(*args, **kw) raise Exception, "unknown format %r" % format
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 774, 13899, 14, 647, 26, 221, 282, 5343, 10059, 367, 25686, 13150, 2295, 14, 199, 624, 199, 199, 646, 5055, 199, 504, 15502, 492, 27608, 199, 646, 7975, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 646, 1379, 7874, 199, 646, 1379, 7844, 199, 504, 1379, 7844, 492, 636, 452, 363, 199, 199, 363, 452, 4343, 2880, 779, 523, 283, 774, 13899, 297, 199, 566, 421, 199, 318, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 304, 523, 408, 3481, 370, 2813, 314, 1004, 5579, 687, 314, 3105, 1072, 523, 402, 4902, 436, 12850, 7114, 314, 30503, 11101, 2012, 402, 314, 3839, 523, 9132, 2295, 14, 523, 408, 523, 2385, 275, 4072, 14, 7644, 342, 523, 327, 3715, 1924, 1004, 641, 14725, 523, 2385, 275, 359, 76, 14, 1294, 480, 6783, 650, 9, 367, 634, 315, 2385, 61, 523, 327, 4263, 1924, 1004, 1771, 10451, 1830, 17289, 314, 523, 327, 650, 6883, 2763, 1314, 365, 314, 1004, 1329, 523, 2385, 275, 359, 552, 8, 76, 9, 690, 650, 436, 7244, 1674, 904, 8, 76, 59, 19, 5728, 503, 634, 367, 634, 315, 2385, 61, 523, 372, 1867, 78, 1674, 904, 8, 1278, 9, 421, 199, 318, 1336, 63, 1494, 13957, 63, 604, 63, 10548, 8, 4407, 63, 65, 12, 4072, 63, 66, 304, 523, 408, 1173, 4072, 15990, 626, 24010, 1004, 5579, 1041, 523, 4072, 63, 65, 275, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 63, 65, 9, 523, 4072, 63, 66, 275, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 63, 66, 9, 523, 372, 1379, 7844, 14, 1431, 63, 7327, 8, 4407, 63, 65, 12, 4072, 63, 66, 9, 421, 199, 32, 14237, 199, 318, 10111, 7744, 8, 1832, 63, 1813, 304, 523, 408, 2998, 5256, 370, 5647, 282, 2257, 4403, 3734, 1041, 523, 2269, 63, 1813, 275, 747, 14, 2314, 14, 1574, 342, 523, 747, 14, 2314, 14, 873, 8, 1832, 63, 1813, 9, 523, 862, 26, 272, 1995, 523, 3753, 26, 272, 747, 14, 2314, 14, 3584, 342, 272, 747, 14, 2314, 14, 873, 8, 1753, 63, 1813, 9, 421, 199, 533, 25688, 1563, 8, 774, 7844, 14, 774, 7844, 304, 523, 408, 523, 8089, 367, 30350, 1284, 13, 475, 13, 500, 2295, 402, 4902, 16952, 14, 819, 14089, 4466, 1958, 642, 1021, 911, 1218, 282, 7937, 2082, 436, 523, 601, 1842, 367, 2399, 477, 4742, 334, 12897, 314, 1379, 7874, 17035, 9, 436, 523, 1331, 1006, 402, 314, 2222, 13, 6179, 396, 1584, 315, 314, 2082, 14446, 402, 314, 523, 14043, 2884, 14, 819, 710, 849, 5953, 365, 370, 511, 314, 283, 6179, 7, 503, 283, 6179, 14, 13475, 7, 570, 315, 314, 523, 1453, 2082, 14, 221, 1626, 13943, 1443, 506, 2013, 7662, 641, 523, 26621, 12, 503, 701, 4260, 314, 7393, 14884, 63, 14884, 3734, 1750, 14, 819, 961, 1021, 1077, 506, 1007, 28271, 367, 1924, 3748, 4902, 4306, 523, 334, 908, 680, 221, 21107, 1785, 9006, 3102, 5084, 5627, 6358, 17597, 523, 1202, 701, 314, 511, 10554, 370, 12677, 14723, 641, 314, 4046, 1900, 523, 2897, 436, 370, 1255, 31172, 4046, 701, 5204, 14723, 14, 523, 408, 819, 6752, 275, 942, 523, 1900, 63, 3557, 275, 488, 523, 1900, 63, 3557, 63, 513, 275, 942, 819, 485, 5803, 275, 1379, 7844, 14, 5803, 63, 4511, 523, 485, 1113, 275, 1379, 7844, 14, 1113, 63, 4511, 523, 930, 468, 63, 275, 1379, 7844, 14, 13927, 468, 63, 1861, 523, 485, 13927, 468, 275, 1379, 7844, 14, 13927, 468, 63, 4511, 523, 1973, 63, 275, 1379, 7844, 14, 773, 63, 1861, 523, 485, 773, 275, 1379, 7844, 14, 773, 63, 4511, 523, 17112, 63, 275, 1379, 7844, 14, 9259, 63, 1861, 523, 485, 9259, 275, 1379, 7844, 14, 9259, 63, 4511, 819, 327, 22296, 370, 2954, 3365, 4545, 14, 523, 11727, 275, 2560, 452, 12217, 523, 6186, 275, 2560, 885, 12217, 819, 327, 22296, 367, 3365, 1347, 2943, 14, 523, 3651, 4220, 934, 2617, 275, 2560, 5904, 12217, 523, 27815, 63, 5617, 275, 2560, 1986, 63, 773, 12217, 523, 4410, 689, 1149, 63, 5617, 275, 2560, 5555, 63, 773, 12217, 819, 347, 636, 826, 721, 277, 12, 4902, 29, 403, 12, 627, 589, 12, 1011, 829, 304, 272, 291, 14, 6493, 63, 6525, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2459, 272, 291, 14, 2911, 63, 589, 275, 984, 14, 3020, 59, 17, 2938, 339, 340, 440, 4902, 26, 489, 4902, 275, 747, 14, 2314, 14, 362, 360, 2864, 14884, 63, 14884, 358, 489, 340, 440, 4902, 26, 267, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 881, 4902, 275, 283, 6179, 14, 13475, 7, 267, 587, 26, 881, 4902, 275, 283, 6179, 7, 272, 291, 14, 6179, 275, 747, 14, 515, 14, 4832, 8, 6179, 9, 272, 291, 14, 889, 63, 11887, 275, 756, 339, 291, 14, 6321, 275, 359, 277, 14, 908, 61, 339, 291, 14, 8489, 63, 1506, 63, 3557, 342, 339, 4775, 14, 5486, 360, 1431, 297, 1379, 7844, 14, 1431, 63, 7327, 9, 339, 327, 16280, 511, 1072, 315, 734, 15, 396, 800, 6789, 701, 849, 14, 272, 327, 3645, 7937, 1561, 880, 2337, 787, 949, 30063, 14, 272, 1736, 694, 275, 747, 14, 515, 14, 904, 360, 548, 297, 4775, 14, 362, 360, 19132, 297, 283, 396, 800, 6789, 1333, 272, 327, 2790, 1736, 9150, 340, 652, 3181, 1133, 2575, 2187, 14, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 19132, 304, 489, 747, 14, 8347, 8, 19132, 9, 339, 4775, 459, 19132, 418, 275, 5549, 14, 22136, 8, 1861, 534, 396, 6179, 3130, 2935, 29, 19132, 9, 339, 6752, 275, 4775, 14, 1935, 360, 6321, 297, 3073, 339, 1613, 8, 774, 13899, 1563, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 339, 3363, 63, 908, 275, 291 ]
[ 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 774, 13899, 14, 647, 26, 221, 282, 5343, 10059, 367, 25686, 13150, 2295, 14, 199, 624, 199, 199, 646, 5055, 199, 504, 15502, 492, 27608, 199, 646, 7975, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 199, 199, 646, 1379, 7874, 199, 646, 1379, 7844, 199, 504, 1379, 7844, 492, 636, 452, 363, 199, 199, 363, 452, 4343, 2880, 779, 523, 283, 774, 13899, 297, 199, 566, 421, 199, 318, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 304, 523, 408, 3481, 370, 2813, 314, 1004, 5579, 687, 314, 3105, 1072, 523, 402, 4902, 436, 12850, 7114, 314, 30503, 11101, 2012, 402, 314, 3839, 523, 9132, 2295, 14, 523, 408, 523, 2385, 275, 4072, 14, 7644, 342, 523, 327, 3715, 1924, 1004, 641, 14725, 523, 2385, 275, 359, 76, 14, 1294, 480, 6783, 650, 9, 367, 634, 315, 2385, 61, 523, 327, 4263, 1924, 1004, 1771, 10451, 1830, 17289, 314, 523, 327, 650, 6883, 2763, 1314, 365, 314, 1004, 1329, 523, 2385, 275, 359, 552, 8, 76, 9, 690, 650, 436, 7244, 1674, 904, 8, 76, 59, 19, 5728, 503, 634, 367, 634, 315, 2385, 61, 523, 372, 1867, 78, 1674, 904, 8, 1278, 9, 421, 199, 318, 1336, 63, 1494, 13957, 63, 604, 63, 10548, 8, 4407, 63, 65, 12, 4072, 63, 66, 304, 523, 408, 1173, 4072, 15990, 626, 24010, 1004, 5579, 1041, 523, 4072, 63, 65, 275, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 63, 65, 9, 523, 4072, 63, 66, 275, 2813, 63, 1757, 63, 604, 63, 10548, 8, 4407, 63, 66, 9, 523, 372, 1379, 7844, 14, 1431, 63, 7327, 8, 4407, 63, 65, 12, 4072, 63, 66, 9, 421, 199, 32, 14237, 199, 318, 10111, 7744, 8, 1832, 63, 1813, 304, 523, 408, 2998, 5256, 370, 5647, 282, 2257, 4403, 3734, 1041, 523, 2269, 63, 1813, 275, 747, 14, 2314, 14, 1574, 342, 523, 747, 14, 2314, 14, 873, 8, 1832, 63, 1813, 9, 523, 862, 26, 272, 1995, 523, 3753, 26, 272, 747, 14, 2314, 14, 3584, 342, 272, 747, 14, 2314, 14, 873, 8, 1753, 63, 1813, 9, 421, 199, 533, 25688, 1563, 8, 774, 7844, 14, 774, 7844, 304, 523, 408, 523, 8089, 367, 30350, 1284, 13, 475, 13, 500, 2295, 402, 4902, 16952, 14, 819, 14089, 4466, 1958, 642, 1021, 911, 1218, 282, 7937, 2082, 436, 523, 601, 1842, 367, 2399, 477, 4742, 334, 12897, 314, 1379, 7874, 17035, 9, 436, 523, 1331, 1006, 402, 314, 2222, 13, 6179, 396, 1584, 315, 314, 2082, 14446, 402, 314, 523, 14043, 2884, 14, 819, 710, 849, 5953, 365, 370, 511, 314, 283, 6179, 7, 503, 283, 6179, 14, 13475, 7, 570, 315, 314, 523, 1453, 2082, 14, 221, 1626, 13943, 1443, 506, 2013, 7662, 641, 523, 26621, 12, 503, 701, 4260, 314, 7393, 14884, 63, 14884, 3734, 1750, 14, 819, 961, 1021, 1077, 506, 1007, 28271, 367, 1924, 3748, 4902, 4306, 523, 334, 908, 680, 221, 21107, 1785, 9006, 3102, 5084, 5627, 6358, 17597, 523, 1202, 701, 314, 511, 10554, 370, 12677, 14723, 641, 314, 4046, 1900, 523, 2897, 436, 370, 1255, 31172, 4046, 701, 5204, 14723, 14, 523, 408, 819, 6752, 275, 942, 523, 1900, 63, 3557, 275, 488, 523, 1900, 63, 3557, 63, 513, 275, 942, 819, 485, 5803, 275, 1379, 7844, 14, 5803, 63, 4511, 523, 485, 1113, 275, 1379, 7844, 14, 1113, 63, 4511, 523, 930, 468, 63, 275, 1379, 7844, 14, 13927, 468, 63, 1861, 523, 485, 13927, 468, 275, 1379, 7844, 14, 13927, 468, 63, 4511, 523, 1973, 63, 275, 1379, 7844, 14, 773, 63, 1861, 523, 485, 773, 275, 1379, 7844, 14, 773, 63, 4511, 523, 17112, 63, 275, 1379, 7844, 14, 9259, 63, 1861, 523, 485, 9259, 275, 1379, 7844, 14, 9259, 63, 4511, 819, 327, 22296, 370, 2954, 3365, 4545, 14, 523, 11727, 275, 2560, 452, 12217, 523, 6186, 275, 2560, 885, 12217, 819, 327, 22296, 367, 3365, 1347, 2943, 14, 523, 3651, 4220, 934, 2617, 275, 2560, 5904, 12217, 523, 27815, 63, 5617, 275, 2560, 1986, 63, 773, 12217, 523, 4410, 689, 1149, 63, 5617, 275, 2560, 5555, 63, 773, 12217, 819, 347, 636, 826, 721, 277, 12, 4902, 29, 403, 12, 627, 589, 12, 1011, 829, 304, 272, 291, 14, 6493, 63, 6525, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 2459, 272, 291, 14, 2911, 63, 589, 275, 984, 14, 3020, 59, 17, 2938, 339, 340, 440, 4902, 26, 489, 4902, 275, 747, 14, 2314, 14, 362, 360, 2864, 14884, 63, 14884, 358, 489, 340, 440, 4902, 26, 267, 340, 984, 14, 3246, 508, 283, 2676, 708, 356, 881, 4902, 275, 283, 6179, 14, 13475, 7, 267, 587, 26, 881, 4902, 275, 283, 6179, 7, 272, 291, 14, 6179, 275, 747, 14, 515, 14, 4832, 8, 6179, 9, 272, 291, 14, 889, 63, 11887, 275, 756, 339, 291, 14, 6321, 275, 359, 277, 14, 908, 61, 339, 291, 14, 8489, 63, 1506, 63, 3557, 342, 339, 4775, 14, 5486, 360, 1431, 297, 1379, 7844, 14, 1431, 63, 7327, 9, 339, 327, 16280, 511, 1072, 315, 734, 15, 396, 800, 6789, 701, 849, 14, 272, 327, 3645, 7937, 1561, 880, 2337, 787, 949, 30063, 14, 272, 1736, 694, 275, 747, 14, 515, 14, 904, 360, 548, 297, 4775, 14, 362, 360, 19132, 297, 283, 396, 800, 6789, 1333, 272, 327, 2790, 1736, 9150, 340, 652, 3181, 1133, 2575, 2187, 14, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 19132, 304, 489, 747, 14, 8347, 8, 19132, 9, 339, 4775, 459, 19132, 418, 275, 5549, 14, 22136, 8, 1861, 534, 396, 6179, 3130, 2935, 29, 19132, 9, 339, 6752, 275, 4775, 14, 1935, 360, 6321, 297, 3073, 339, 1613, 8, 774, 13899, 1563, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 339, 3363, 63, 908, 275, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
edx/edx-platform
common/lib/capa/capa/correctmap.py
5
7375
# lint-amnesty, pylint: disable=missing-module-docstring # ----------------------------------------------------------------------------- # class used to store graded responses to CAPA questions # # Used by responsetypes and capa_problem class CorrectMap(object): """ Stores map between answer_id and response evaluation result for each question in a capa problem. The response evaluation result for each answer_id includes (correctness, npoints, msg, hint, hintmode). - correctness : 'correct', 'incorrect', 'partially-correct', or 'incomplete' - npoints : None, or integer specifying number of points awarded for this answer_id - msg : string (may have HTML) giving extra message response (displayed below textline or textbox) - hint : string (may have HTML) giving optional hint (displayed below textline or textbox, above msg) - hintmode : one of (None,'on_request','always') criteria for displaying hint - queuestate : Dict {key:'', time:''} where key is a secret string, and time is a string dump of a DateTime object in the format '%Y%m%d%H%M%S'. Is None when not queued Behaves as a dict. """ def __init__(self, *args, **kwargs): # start with empty dict self.cmap = dict() self.items = self.cmap.items self.keys = self.cmap.keys self.overall_message = "" self.set(*args, **kwargs) def __getitem__(self, *args, **kwargs): return self.cmap.__getitem__(*args, **kwargs) def __iter__(self): return self.cmap.__iter__() # See the documentation for 'set_dict' for the use of kwargs def set( # lint-amnesty, pylint: disable=missing-function-docstring self, # lint-amnesty, pylint: disable=unused-argument answer_id=None, correctness=None, npoints=None, msg='', hint='', hintmode=None, queuestate=None, answervariable=None, **kwargs ): if answer_id is not None: self.cmap[answer_id] = { 'correctness': correctness, 'npoints': npoints, 'msg': msg, 'hint': hint, 'hintmode': hintmode, 'queuestate': queuestate, 'answervariable': answervariable, } def __repr__(self): return repr(self.cmap) def get_dict(self): """ return dict version of self """ return self.cmap def set_dict(self, correct_map): """ Set internal dict of CorrectMap to provided correct_map dict correct_map is saved by LMS as a plaintext JSON dump of the correctmap dict. This means that when the definition of CorrectMap (e.g. its properties) are altered, an existing correct_map dict will not coincide with the newest CorrectMap format as defined by self.set. For graceful migration, feed the contents of each correct map to self.set, rather than making a direct copy of the given correct_map dict. This way, the common keys between the incoming correct_map dict and the new CorrectMap instance will be written, while mismatched keys will be gracefully ignored. Special migration case: If correct_map is a one-level dict, then convert it to the new dict of dicts format. """ # empty current dict self.__init__() if not correct_map: return # create new dict entries if not isinstance(list(correct_map.values())[0], dict): # special migration for k in correct_map: self.set(k, correctness=correct_map[k]) else: for k in correct_map: self.set(k, **correct_map[k]) def is_correct(self, answer_id): """ Takes an answer_id Returns true if the problem is correct OR partially correct. """ if answer_id in self.cmap: return self.cmap[answer_id]['correctness'] in ['correct', 'partially-correct'] return None def is_partially_correct(self, answer_id): """ Takes an answer_id Returns true if the problem is partially correct. """ if answer_id in self.cmap: return self.cmap[answer_id]['correctness'] == 'partially-correct' return None def is_queued(self, answer_id): return answer_id in self.cmap and self.cmap[answer_id]['queuestate'] is not None def is_right_queuekey(self, answer_id, test_key): return self.is_queued(answer_id) and self.cmap[answer_id]['queuestate']['key'] == test_key def get_queuetime_str(self, answer_id): if self.cmap[answer_id]['queuestate']: return self.cmap[answer_id]['queuestate']['time'] else: return None def get_npoints(self, answer_id): """Return the number of points for an answer, used for partial credit.""" npoints = self.get_property(answer_id, 'npoints') if npoints is not None: return npoints elif self.is_correct(answer_id): return 1 # if not correct and no points have been assigned, return 0 return 0 def set_property(self, answer_id, property, value): # lint-amnesty, pylint: disable=redefined-builtin if answer_id in self.cmap: self.cmap[answer_id][property] = value else: self.cmap[answer_id] = {property: value} def get_property(self, answer_id, property, default=None): # lint-amnesty, pylint: disable=redefined-builtin if answer_id in self.cmap: return self.cmap[answer_id].get(property, default) return default def get_correctness(self, answer_id): return self.get_property(answer_id, 'correctness') def get_msg(self, answer_id): return self.get_property(answer_id, 'msg', '') def get_hint(self, answer_id): return self.get_property(answer_id, 'hint', '') def get_hintmode(self, answer_id): return self.get_property(answer_id, 'hintmode', None) def set_hint_and_mode(self, answer_id, hint, hintmode): """ - hint : (string) HTML text for hint - hintmode : (string) mode for hint display ('always' or 'on_request') """ self.set_property(answer_id, 'hint', hint) self.set_property(answer_id, 'hintmode', hintmode) def update(self, other_cmap): """ Update this CorrectMap with the contents of another CorrectMap """ if not isinstance(other_cmap, CorrectMap): raise Exception('CorrectMap.update called with invalid argument %s' % other_cmap) self.cmap.update(other_cmap.get_dict()) self.set_overall_message(other_cmap.get_overall_message()) def set_overall_message(self, message_str): """ Set a message that applies to the question as a whole, rather than to individual inputs. """ self.overall_message = str(message_str) if message_str else "" def get_overall_message(self): """ Retrieve a message that applies to the question as a whole. If no message is available, returns the empty string """ return self.overall_message
agpl-3.0
[ 3, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 4752, 13, 578, 13, 12485, 199, 3, 13722, 199, 3, 1021, 1202, 370, 3877, 1999, 770, 9320, 370, 445, 1282, 33, 23071, 199, 3, 199, 3, 8051, 701, 1177, 1313, 436, 28068, 63, 6462, 421, 199, 533, 31057, 2956, 8, 785, 304, 272, 408, 272, 31299, 2341, 3382, 6385, 63, 344, 436, 1177, 11735, 754, 367, 1924, 7894, 272, 315, 282, 28068, 5160, 14, 221, 710, 1177, 11735, 754, 367, 1924, 6385, 63, 344, 6952, 272, 334, 4525, 4171, 12, 302, 3438, 12, 1499, 12, 8328, 12, 8328, 632, 680, 339, 446, 29102, 520, 283, 4525, 297, 283, 15448, 297, 283, 462, 9406, 13, 4525, 297, 503, 283, 24575, 7, 272, 446, 302, 3438, 258, 520, 488, 12, 503, 3000, 9176, 1329, 402, 4501, 282, 15295, 367, 642, 6385, 63, 344, 272, 446, 1499, 260, 520, 1059, 334, 7551, 1172, 4163, 9, 15131, 2402, 1245, 1177, 490, 334, 22283, 5084, 1318, 604, 503, 1318, 1977, 9, 272, 446, 8328, 263, 520, 1059, 334, 7551, 1172, 4163, 9, 15131, 2716, 8328, 490, 334, 22283, 5084, 1318, 604, 503, 1318, 1977, 12, 3432, 1499, 9, 272, 446, 8328, 632, 259, 520, 1373, 402, 334, 403, 2584, 265, 63, 1069, 1673, 9223, 358, 15647, 367, 20589, 8328, 272, 446, 4126, 929, 221, 520, 7448, 469, 498, 4881, 297, 900, 26, 891, 93, 2382, 790, 365, 282, 7565, 1059, 12, 436, 900, 365, 282, 1059, 5461, 490, 402, 282, 13686, 909, 315, 314, 1475, 1543, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 1370, 6596, 488, 1380, 440, 26102, 339, 6423, 72, 7047, 465, 282, 1211, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 1343, 543, 2701, 1211, 267, 291, 14, 16513, 275, 1211, 342, 267, 291, 14, 1744, 275, 291, 14, 16513, 14, 1744, 267, 291, 14, 1612, 275, 291, 14, 16513, 14, 1612, 267, 291, 14, 1883, 452, 63, 1188, 275, 3087, 267, 291, 14, 409, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 6095, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 16513, 855, 6095, 9308, 589, 12, 1011, 958, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 14, 16513, 855, 1661, 4533, 339, 327, 1666, 314, 3794, 367, 283, 409, 63, 807, 7, 367, 314, 675, 402, 2074, 272, 347, 663, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 4752, 13, 1593, 13, 12485, 267, 291, 12, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 6385, 63, 344, 29, 403, 12, 267, 29102, 29, 403, 12, 267, 302, 3438, 29, 403, 12, 267, 1499, 4581, 267, 8328, 4581, 267, 8328, 632, 29, 403, 12, 267, 4126, 929, 29, 403, 12, 267, 6385, 1975, 29, 403, 12, 267, 1011, 958, 272, 3461, 398, 340, 6385, 63, 344, 365, 440, 488, 26, 288, 291, 14, 16513, 59, 5934, 63, 344, 61, 275, 469, 355, 283, 4525, 4171, 356, 29102, 12, 355, 283, 78, 3438, 356, 302, 3438, 12, 355, 283, 1328, 356, 1499, 12, 355, 283, 6479, 356, 8328, 12, 355, 283, 6479, 632, 356, 8328, 632, 12, 355, 283, 1825, 929, 356, 4126, 929, 12, 355, 283, 5934, 1975, 356, 6385, 1975, 12, 288, 789, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 16513, 9, 339, 347, 664, 63, 807, 8, 277, 304, 267, 408, 267, 372, 1211, 1015, 402, 291, 267, 408, 267, 372, 291, 14, 16513, 339, 347, 663, 63, 807, 8, 277, 12, 3211, 63, 1130, 304, 267, 408, 267, 2494, 5007, 1211, 402, 31057, 2956, 370, 2741, 3211, 63, 1130, 1211, 398, 3211, 63, 1130, 365, 6290, 701, 27540, 465, 282, 18577, 4840, 5461, 402, 314, 3211, 1130, 1211, 14, 961, 267, 4910, 626, 1380, 314, 5492, 402, 31057, 2956, 334, 69, 14, 71, 14, 2399, 4382, 9, 787, 29815, 12, 267, 376, 3411, 3211, 63, 1130, 1211, 911, 440, 21914, 559, 271, 543, 314, 29608, 31057, 2956, 1475, 465, 267, 3247, 701, 291, 14, 409, 14, 398, 2104, 19756, 1893, 8367, 12, 4733, 314, 4072, 402, 1924, 3211, 2341, 370, 291, 14, 409, 12, 7830, 2419, 267, 10663, 282, 4125, 1331, 402, 314, 1627, 3211, 63, 1130, 1211, 14, 961, 4340, 12, 314, 2863, 2883, 3382, 267, 314, 12467, 3211, 63, 1130, 1211, 436, 314, 892, 31057, 2956, 1256, 911, 506, 5313, 12, 1830, 267, 3201, 10151, 2883, 911, 506, 19756, 5836, 5525, 14, 398, 12568, 8367, 1930, 26, 288, 982, 3211, 63, 1130, 365, 282, 1373, 13, 1896, 1211, 12, 2066, 3957, 652, 370, 314, 892, 1211, 402, 10809, 1475, 14, 398, 408, 267, 327, 2701, 1453, 1211, 267, 291, 855, 826, 4533, 398, 340, 440, 3211, 63, 1130, 26, 288, 372, 398, 327, 1218, 892, 1211, 4811, 267, 340, 440, 1228, 8, 513, 8, 4525, 63, 1130, 14, 1459, 18756, 16, 467, 1211, 304, 288, 327, 4539, 8367, 288, 367, 1022, 315, 3211, 63, 1130, 26, 355, 291, 14, 409, 8, 75, 12, 29102, 29, 4525, 63, 1130, 59, 75, 566, 267, 587, 26, 288, 367, 1022, 315, 3211, 63, 1130, 26, 355, 291, 14, 409, 8, 75, 12, 1011, 4525, 63, 1130, 59, 75, 566, 339, 347, 365, 63, 4525, 8, 277, 12, 6385, 63, 344, 304, 267, 408, 267, 17415, 376, 6385, 63, 344, 267, 1803, 2549, 340, 314, 5160, 365, 3211, 1549, 25172, 3211, 14, 267, 408, 267, 340, 6385, 63, 344, 315, 291, 14, 16513, 26, 288, 372, 291, 14, 16513, 59, 5934, 63, 344, 2733, 4525, 4171, 418, 315, 788, 4525, 297, 283, 462, 9406, 13, 4525, 418, 267, 372, 488, 339, 347, 365, 63, 462, 9406, 63, 4525, 8, 277, 12, 6385, 63, 344, 304, 267, 408, 267, 17415, 376, 6385, 63, 344, 267, 1803, 2549, 340, 314, 5160, 365, 25172, 3211, 14, 267, 408, 267, 340, 6385, 63, 344, 315, 291, 14, 16513, 26, 288, 372, 291, 14, 16513, 59, 5934, 63, 344, 2733, 4525, 4171, 418, 508, 283, 462, 9406, 13, 4525, 7, 267, 372, 488, 339, 347, 365 ]
[ 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 4752, 13, 578, 13, 12485, 199, 3, 13722, 199, 3, 1021, 1202, 370, 3877, 1999, 770, 9320, 370, 445, 1282, 33, 23071, 199, 3, 199, 3, 8051, 701, 1177, 1313, 436, 28068, 63, 6462, 421, 199, 533, 31057, 2956, 8, 785, 304, 272, 408, 272, 31299, 2341, 3382, 6385, 63, 344, 436, 1177, 11735, 754, 367, 1924, 7894, 272, 315, 282, 28068, 5160, 14, 221, 710, 1177, 11735, 754, 367, 1924, 6385, 63, 344, 6952, 272, 334, 4525, 4171, 12, 302, 3438, 12, 1499, 12, 8328, 12, 8328, 632, 680, 339, 446, 29102, 520, 283, 4525, 297, 283, 15448, 297, 283, 462, 9406, 13, 4525, 297, 503, 283, 24575, 7, 272, 446, 302, 3438, 258, 520, 488, 12, 503, 3000, 9176, 1329, 402, 4501, 282, 15295, 367, 642, 6385, 63, 344, 272, 446, 1499, 260, 520, 1059, 334, 7551, 1172, 4163, 9, 15131, 2402, 1245, 1177, 490, 334, 22283, 5084, 1318, 604, 503, 1318, 1977, 9, 272, 446, 8328, 263, 520, 1059, 334, 7551, 1172, 4163, 9, 15131, 2716, 8328, 490, 334, 22283, 5084, 1318, 604, 503, 1318, 1977, 12, 3432, 1499, 9, 272, 446, 8328, 632, 259, 520, 1373, 402, 334, 403, 2584, 265, 63, 1069, 1673, 9223, 358, 15647, 367, 20589, 8328, 272, 446, 4126, 929, 221, 520, 7448, 469, 498, 4881, 297, 900, 26, 891, 93, 2382, 790, 365, 282, 7565, 1059, 12, 436, 900, 365, 282, 1059, 5461, 490, 402, 282, 13686, 909, 315, 314, 1475, 1543, 57, 5, 77, 5, 68, 5, 40, 5, 45, 5, 51, 1370, 6596, 488, 1380, 440, 26102, 339, 6423, 72, 7047, 465, 282, 1211, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 1343, 543, 2701, 1211, 267, 291, 14, 16513, 275, 1211, 342, 267, 291, 14, 1744, 275, 291, 14, 16513, 14, 1744, 267, 291, 14, 1612, 275, 291, 14, 16513, 14, 1612, 267, 291, 14, 1883, 452, 63, 1188, 275, 3087, 267, 291, 14, 409, 2031, 589, 12, 1011, 958, 9, 339, 347, 636, 6095, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 16513, 855, 6095, 9308, 589, 12, 1011, 958, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 14, 16513, 855, 1661, 4533, 339, 327, 1666, 314, 3794, 367, 283, 409, 63, 807, 7, 367, 314, 675, 402, 2074, 272, 347, 663, 8, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 4752, 13, 1593, 13, 12485, 267, 291, 12, 221, 327, 24620, 13, 455, 15272, 89, 12, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 6385, 63, 344, 29, 403, 12, 267, 29102, 29, 403, 12, 267, 302, 3438, 29, 403, 12, 267, 1499, 4581, 267, 8328, 4581, 267, 8328, 632, 29, 403, 12, 267, 4126, 929, 29, 403, 12, 267, 6385, 1975, 29, 403, 12, 267, 1011, 958, 272, 3461, 398, 340, 6385, 63, 344, 365, 440, 488, 26, 288, 291, 14, 16513, 59, 5934, 63, 344, 61, 275, 469, 355, 283, 4525, 4171, 356, 29102, 12, 355, 283, 78, 3438, 356, 302, 3438, 12, 355, 283, 1328, 356, 1499, 12, 355, 283, 6479, 356, 8328, 12, 355, 283, 6479, 632, 356, 8328, 632, 12, 355, 283, 1825, 929, 356, 4126, 929, 12, 355, 283, 5934, 1975, 356, 6385, 1975, 12, 288, 789, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 16513, 9, 339, 347, 664, 63, 807, 8, 277, 304, 267, 408, 267, 372, 1211, 1015, 402, 291, 267, 408, 267, 372, 291, 14, 16513, 339, 347, 663, 63, 807, 8, 277, 12, 3211, 63, 1130, 304, 267, 408, 267, 2494, 5007, 1211, 402, 31057, 2956, 370, 2741, 3211, 63, 1130, 1211, 398, 3211, 63, 1130, 365, 6290, 701, 27540, 465, 282, 18577, 4840, 5461, 402, 314, 3211, 1130, 1211, 14, 961, 267, 4910, 626, 1380, 314, 5492, 402, 31057, 2956, 334, 69, 14, 71, 14, 2399, 4382, 9, 787, 29815, 12, 267, 376, 3411, 3211, 63, 1130, 1211, 911, 440, 21914, 559, 271, 543, 314, 29608, 31057, 2956, 1475, 465, 267, 3247, 701, 291, 14, 409, 14, 398, 2104, 19756, 1893, 8367, 12, 4733, 314, 4072, 402, 1924, 3211, 2341, 370, 291, 14, 409, 12, 7830, 2419, 267, 10663, 282, 4125, 1331, 402, 314, 1627, 3211, 63, 1130, 1211, 14, 961, 4340, 12, 314, 2863, 2883, 3382, 267, 314, 12467, 3211, 63, 1130, 1211, 436, 314, 892, 31057, 2956, 1256, 911, 506, 5313, 12, 1830, 267, 3201, 10151, 2883, 911, 506, 19756, 5836, 5525, 14, 398, 12568, 8367, 1930, 26, 288, 982, 3211, 63, 1130, 365, 282, 1373, 13, 1896, 1211, 12, 2066, 3957, 652, 370, 314, 892, 1211, 402, 10809, 1475, 14, 398, 408, 267, 327, 2701, 1453, 1211, 267, 291, 855, 826, 4533, 398, 340, 440, 3211, 63, 1130, 26, 288, 372, 398, 327, 1218, 892, 1211, 4811, 267, 340, 440, 1228, 8, 513, 8, 4525, 63, 1130, 14, 1459, 18756, 16, 467, 1211, 304, 288, 327, 4539, 8367, 288, 367, 1022, 315, 3211, 63, 1130, 26, 355, 291, 14, 409, 8, 75, 12, 29102, 29, 4525, 63, 1130, 59, 75, 566, 267, 587, 26, 288, 367, 1022, 315, 3211, 63, 1130, 26, 355, 291, 14, 409, 8, 75, 12, 1011, 4525, 63, 1130, 59, 75, 566, 339, 347, 365, 63, 4525, 8, 277, 12, 6385, 63, 344, 304, 267, 408, 267, 17415, 376, 6385, 63, 344, 267, 1803, 2549, 340, 314, 5160, 365, 3211, 1549, 25172, 3211, 14, 267, 408, 267, 340, 6385, 63, 344, 315, 291, 14, 16513, 26, 288, 372, 291, 14, 16513, 59, 5934, 63, 344, 2733, 4525, 4171, 418, 315, 788, 4525, 297, 283, 462, 9406, 13, 4525, 418, 267, 372, 488, 339, 347, 365, 63, 462, 9406, 63, 4525, 8, 277, 12, 6385, 63, 344, 304, 267, 408, 267, 17415, 376, 6385, 63, 344, 267, 1803, 2549, 340, 314, 5160, 365, 25172, 3211, 14, 267, 408, 267, 340, 6385, 63, 344, 315, 291, 14, 16513, 26, 288, 372, 291, 14, 16513, 59, 5934, 63, 344, 2733, 4525, 4171, 418, 508, 283, 462, 9406, 13, 4525, 7, 267, 372, 488, 339, 347, 365, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
coder-chenzhi/shadowsocks
shadowsocks/lru_cache.py
983
4290
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2015 clowwindy # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from __future__ import absolute_import, division, print_function, \ with_statement import collections import logging import time # this LRUCache is optimized for concurrency, not QPS # n: concurrency, keys stored in the cache # m: visits not timed out, proportional to QPS * timeout # get & set is O(1), not O(n). thus we can support very large n # TODO: if timeout or QPS is too large, then this cache is not very efficient, # as sweep() causes long pause class LRUCache(collections.MutableMapping): """This class is not thread safe""" def __init__(self, timeout=60, close_callback=None, *args, **kwargs): self.timeout = timeout self.close_callback = close_callback self._store = {} self._time_to_keys = collections.defaultdict(list) self._keys_to_last_time = {} self._last_visits = collections.deque() self._closed_values = set() self.update(dict(*args, **kwargs)) # use the free update to set keys def __getitem__(self, key): # O(1) t = time.time() self._keys_to_last_time[key] = t self._time_to_keys[t].append(key) self._last_visits.append(t) return self._store[key] def __setitem__(self, key, value): # O(1) t = time.time() self._keys_to_last_time[key] = t self._store[key] = value self._time_to_keys[t].append(key) self._last_visits.append(t) def __delitem__(self, key): # O(1) del self._store[key] del self._keys_to_last_time[key] def __iter__(self): return iter(self._store) def __len__(self): return len(self._store) def sweep(self): # O(m) now = time.time() c = 0 while len(self._last_visits) > 0: least = self._last_visits[0] if now - least <= self.timeout: break if self.close_callback is not None: for key in self._time_to_keys[least]: if key in self._store: if now - self._keys_to_last_time[key] > self.timeout: value = self._store[key] if value not in self._closed_values: self.close_callback(value) self._closed_values.add(value) for key in self._time_to_keys[least]: self._last_visits.popleft() if key in self._store: if now - self._keys_to_last_time[key] > self.timeout: del self._store[key] del self._keys_to_last_time[key] c += 1 del self._time_to_keys[least] if c: self._closed_values.clear() logging.debug('%d keys swept' % c) def test(): c = LRUCache(timeout=0.3) c['a'] = 1 assert c['a'] == 1 time.sleep(0.5) c.sweep() assert 'a' not in c c['a'] = 2 c['b'] = 3 time.sleep(0.2) c.sweep() assert c['a'] == 2 assert c['b'] == 3 time.sleep(0.2) c.sweep() c['b'] time.sleep(0.2) c.sweep() assert 'a' not in c assert c['b'] == 3 time.sleep(0.5) c.sweep() assert 'a' not in c assert 'b' not in c global close_cb_called close_cb_called = False def close_cb(t): global close_cb_called assert not close_cb_called close_cb_called = True c = LRUCache(timeout=0.1, close_callback=close_cb) c['s'] = 1 c['s'] time.sleep(0.1) c['s'] time.sleep(0.3) c.sweep() if __name__ == '__main__': test()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 5055, 199, 646, 2050, 199, 646, 900, 421, 199, 3, 642, 491, 9500, 4437, 365, 20212, 367, 406, 4968, 12, 440, 1413, 5067, 199, 3, 302, 26, 406, 4968, 12, 2883, 5489, 315, 314, 2581, 199, 3, 333, 26, 1321, 30066, 440, 18590, 734, 12, 24382, 279, 370, 1413, 5067, 627, 2653, 199, 3, 664, 1253, 663, 365, 593, 8, 17, 395, 440, 593, 8, 78, 680, 12850, 781, 883, 2291, 7437, 7031, 302, 199, 3, 3254, 26, 340, 2653, 503, 1413, 5067, 365, 4634, 7031, 12, 2066, 642, 2581, 365, 440, 7437, 13402, 12, 199, 3, 755, 465, 5584, 7840, 342, 14486, 1846, 16834, 421, 199, 533, 491, 9500, 4437, 8, 7882, 14, 17707, 7674, 304, 272, 408, 2765, 1021, 365, 440, 2462, 5048, 624, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 2259, 12, 4002, 63, 3058, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1600, 63, 3058, 275, 4002, 63, 3058, 267, 291, 423, 1617, 275, 1052, 267, 291, 423, 521, 63, 475, 63, 1612, 275, 5055, 14, 21501, 8, 513, 9, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 275, 1052, 267, 291, 423, 2019, 63, 433, 30066, 275, 5055, 14, 22983, 342, 267, 291, 423, 5938, 63, 1459, 275, 663, 342, 267, 291, 14, 873, 8, 807, 2031, 589, 12, 1011, 958, 430, 221, 327, 675, 314, 2867, 1678, 370, 663, 2883, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 267, 372, 291, 423, 1617, 59, 498, 61, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 1617, 59, 498, 61, 275, 574, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 2150, 291, 423, 1617, 59, 498, 61, 267, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1617, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5584, 7840, 8, 277, 304, 267, 327, 593, 8, 77, 9, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 275, 378, 267, 1830, 822, 8, 277, 423, 2019, 63, 433, 30066, 9, 690, 378, 26, 288, 5210, 275, 291, 423, 2019, 63, 433, 30066, 59, 16, 61, 288, 340, 3063, 446, 5210, 2695, 291, 14, 2593, 26, 355, 2059, 288, 340, 291, 14, 1600, 63, 3058, 365, 440, 488, 26, 355, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 490, 340, 790, 315, 291, 423, 1617, 26, 717, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 1169, 574, 275, 291, 423, 1617, 59, 498, 61, 1169, 340, 574, 440, 315, 291, 423, 5938, 63, 1459, 26, 1816, 291, 14, 1600, 63, 3058, 8, 585, 9, 1816, 291, 423, 5938, 63, 1459, 14, 525, 8, 585, 9, 288, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 355, 291, 423, 2019, 63, 433, 30066, 14, 25704, 342, 355, 340, 790, 315, 291, 423, 1617, 26, 490, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 717, 2150, 291, 423, 1617, 59, 498, 61, 717, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 717, 286, 847, 413, 288, 2150, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 61, 267, 340, 286, 26, 288, 291, 423, 5938, 63, 1459, 14, 3584, 342, 288, 2050, 14, 1757, 3508, 68, 2883, 308, 1129, 541, 7, 450, 286, 9, 421, 199, 318, 511, 837, 272, 286, 275, 491, 9500, 4437, 8, 2593, 29, 16, 14, 19, 9, 339, 286, 459, 65, 418, 275, 413, 272, 702, 286, 459, 65, 418, 508, 413, 339, 900, 14, 4532, 8, 16, 14, 21, 9, 272, 286, 14, 31701, 342, 272, 702, 283, 65, 7, 440, 315, 286, 339, 286, 459, 65, 418, 275, 499, 272, 286, 459, 66, 418, 275, 650, 272, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 702, 286, 459, 65, 418, 508, 499, 272, 702, 286, 459, 66, 418, 508, 650, 339, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 286 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 5055, 199, 646, 2050, 199, 646, 900, 421, 199, 3, 642, 491, 9500, 4437, 365, 20212, 367, 406, 4968, 12, 440, 1413, 5067, 199, 3, 302, 26, 406, 4968, 12, 2883, 5489, 315, 314, 2581, 199, 3, 333, 26, 1321, 30066, 440, 18590, 734, 12, 24382, 279, 370, 1413, 5067, 627, 2653, 199, 3, 664, 1253, 663, 365, 593, 8, 17, 395, 440, 593, 8, 78, 680, 12850, 781, 883, 2291, 7437, 7031, 302, 199, 3, 3254, 26, 340, 2653, 503, 1413, 5067, 365, 4634, 7031, 12, 2066, 642, 2581, 365, 440, 7437, 13402, 12, 199, 3, 755, 465, 5584, 7840, 342, 14486, 1846, 16834, 421, 199, 533, 491, 9500, 4437, 8, 7882, 14, 17707, 7674, 304, 272, 408, 2765, 1021, 365, 440, 2462, 5048, 624, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 2259, 12, 4002, 63, 3058, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1600, 63, 3058, 275, 4002, 63, 3058, 267, 291, 423, 1617, 275, 1052, 267, 291, 423, 521, 63, 475, 63, 1612, 275, 5055, 14, 21501, 8, 513, 9, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 275, 1052, 267, 291, 423, 2019, 63, 433, 30066, 275, 5055, 14, 22983, 342, 267, 291, 423, 5938, 63, 1459, 275, 663, 342, 267, 291, 14, 873, 8, 807, 2031, 589, 12, 1011, 958, 430, 221, 327, 675, 314, 2867, 1678, 370, 663, 2883, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 267, 372, 291, 423, 1617, 59, 498, 61, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 1617, 59, 498, 61, 275, 574, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 2150, 291, 423, 1617, 59, 498, 61, 267, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1617, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5584, 7840, 8, 277, 304, 267, 327, 593, 8, 77, 9, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 275, 378, 267, 1830, 822, 8, 277, 423, 2019, 63, 433, 30066, 9, 690, 378, 26, 288, 5210, 275, 291, 423, 2019, 63, 433, 30066, 59, 16, 61, 288, 340, 3063, 446, 5210, 2695, 291, 14, 2593, 26, 355, 2059, 288, 340, 291, 14, 1600, 63, 3058, 365, 440, 488, 26, 355, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 490, 340, 790, 315, 291, 423, 1617, 26, 717, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 1169, 574, 275, 291, 423, 1617, 59, 498, 61, 1169, 340, 574, 440, 315, 291, 423, 5938, 63, 1459, 26, 1816, 291, 14, 1600, 63, 3058, 8, 585, 9, 1816, 291, 423, 5938, 63, 1459, 14, 525, 8, 585, 9, 288, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 355, 291, 423, 2019, 63, 433, 30066, 14, 25704, 342, 355, 340, 790, 315, 291, 423, 1617, 26, 490, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 717, 2150, 291, 423, 1617, 59, 498, 61, 717, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 717, 286, 847, 413, 288, 2150, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 61, 267, 340, 286, 26, 288, 291, 423, 5938, 63, 1459, 14, 3584, 342, 288, 2050, 14, 1757, 3508, 68, 2883, 308, 1129, 541, 7, 450, 286, 9, 421, 199, 318, 511, 837, 272, 286, 275, 491, 9500, 4437, 8, 2593, 29, 16, 14, 19, 9, 339, 286, 459, 65, 418, 275, 413, 272, 702, 286, 459, 65, 418, 508, 413, 339, 900, 14, 4532, 8, 16, 14, 21, 9, 272, 286, 14, 31701, 342, 272, 702, 283, 65, 7, 440, 315, 286, 339, 286, 459, 65, 418, 275, 499, 272, 286, 459, 66, 418, 275, 650, 272, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 702, 286, 459, 65, 418, 508, 499, 272, 702, 286, 459, 66, 418, 508, 650, 339, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 286, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
manipopopo/tensorflow
tensorflow/contrib/mixed_precision/python/loss_scale_optimizer.py
4
6828
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Loss scaling optimizer.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.eager import context from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_control_flow_ops from tensorflow.python.ops import gen_math_ops from tensorflow.python.ops import math_ops from tensorflow.python.training import optimizer class LossScaleOptimizer(optimizer.Optimizer): # TODO(jamesqin): move mixed precision training explanation to __init__ # docstring. """An optimizer that applies loss scaling in backprop. This class is useful for "mixed precision training" on GPUs (or other potential accelerators), an approach to improve compute throughput without compromising model quality. The canonical way to perform mixed precision training is the following: * Model variables are kept in high precision (e.g. float32). * Computations are done in lower precision (e.g. float16), which enjoys performance speedup by virtue of hardware support. Variables are casted to lower precision before they're used. * Final gradients are casted back to high precision dtype, then used to update variables. The side-effect of performing computation in lower precision, is that it comes with smaller numerical range. During backproping, small gradients might underflow in the reduced numerical range, causing a model to converge at suboptimal level. To prevent underflow, this optimizer multiplies the loss by a factor before backprop starts. Consequently, the gradients are linearly scaled up by the same factor, thus not falling into the underflow zone. After that, to perserve the correctness of backprop, the gradients are down-scaled by the same factor, casted to the (higher) variable precision, then applied on the variables. See [Nvidia's manual on mixed precision training]( https://docs.nvidia.com/deeplearning/sdk/mixed-precision-training/index.html) for more details. To use loss scale optimizer, one only needs choose a loss scale strategy and wrap a regular optimizer. See examples below. ``` loss = loss_fn() opt = tf.AdamOptimizer(learning_rate=...) # Choose a loss scale manager which decides how to pick the right loss scale # throughout the training process. loss_scale_manger = tf.contrib.mixed_precision.FixedLossScaleManager(5000) # Wraps the original optimizer in a LossScaleOptimizer. loss_scale_optimizer = LossScaleOptimizer(opt, loss_scale_manager) # Call minimize() on the loss scale optimizer. train_op = loss_scale_optimizer.minimize(loss) ``` If gradients clipping is applied, one can call `optimizer.compute_gradients()` and `optimizer.apply_gradients()` separately. Notice the following way of using LossScaleOptimizer is not intended. Always use `loss_scale_optimizer.compute_gradients()` to compute gradients instead of `tf.gradients()` if doing mixed precision training. ``` # The following is a wrong way to use LossScaleOptimizer along with # tf.gradients(). # Always use loss_scale_optimizer.compute_gradients() to compute grads, or # loss scale is not correctly applied. grads = tf.gradients(loss, ...) # Do some custom grad clipping. grads = clip_grads(grads, ...) loss_scale_optimizer.apply(grads_and_vars) ``` """ def __init__(self, opt, loss_scale_manager): """Construct a loss scaling optimizer. Args: opt: The actual optimizer that will be used to compute and apply the gradients. Must be an implementation of the `tf.train.Optimizer` interface. loss_scale_manager: A LossScaleManager object. """ self._opt = opt self._loss_scale_manager = loss_scale_manager def compute_gradients(self, loss, var_list=None, gate_gradients=optimizer.Optimizer.GATE_OP, aggregation_method=None, colocate_gradients_with_ops=False, grad_loss=None): """Compute gradients. See base class `tf.train.Optimizer`.""" loss_scale = self._loss_scale_manager.get_loss_scale() if context.executing_eagerly(): def scaled_loss(): loss_val = loss() return loss_val * math_ops.cast(loss_scale, loss_val.dtype.base_dtype) else: if callable(loss): loss_val = loss() else: loss_val = loss scaled_loss = loss_val * math_ops.cast(loss_scale, loss_val.dtype.base_dtype) grads_and_vars = self._opt.compute_gradients( scaled_loss, var_list=var_list, gate_gradients=gate_gradients, aggregation_method=aggregation_method, colocate_gradients_with_ops=colocate_gradients_with_ops, grad_loss=grad_loss) return self._down_scale(grads_and_vars, loss_scale) def apply_gradients(self, grads_and_vars, global_step=None, name=None): """Apply gradients. See base class `tf.train.Optimizer`.""" grads = [g for (g, _) in grads_and_vars] is_finite_grad = [] for g in grads: is_finite_grad.append(math_ops.reduce_all(gen_math_ops.is_finite(g))) is_overall_finite = math_ops.reduce_all(is_finite_grad) # Only update gradients when all grads are finite. def true_apply_gradients_fn(): return self._opt.apply_gradients(grads_and_vars, global_step, name) update_vars = control_flow_ops.cond( is_overall_finite, true_apply_gradients_fn, gen_control_flow_ops.no_op) # Potentially adjust gradient scale in case of finite gradients. return control_flow_ops.group( update_vars, self._loss_scale_manager.update_loss_scale(is_overall_finite)) def _down_scale(self, grads_vars, loss_scale): # Down scale grads by the loss_scale. gv = [] inv_loss_scale = gen_math_ops.reciprocal(loss_scale) for g, v in grads_vars: if g is not None: gv.append((g * math_ops.cast(inv_loss_scale, g.dtype.base_dtype), v)) else: gv.append((g, v)) return gv
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 8610, 13690, 10736, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 2785, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 3442, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 421, 199, 533, 3835, 385, 9944, 13946, 8, 12290, 14, 13946, 304, 523, 327, 3254, 8, 74, 313, 3526, 262, 304, 4057, 13492, 7151, 6093, 17531, 370, 636, 826, 363, 523, 327, 9214, 14, 523, 408, 2493, 10736, 626, 12966, 5621, 13690, 315, 1771, 4469, 14, 819, 961, 1021, 365, 2997, 367, 298, 10455, 7151, 6093, 2, 641, 18613, 83, 334, 269, 1163, 523, 12330, 1066, 11338, 2750, 395, 376, 18140, 370, 19053, 4526, 4012, 524, 1928, 523, 1013, 417, 11136, 1402, 11030, 14, 819, 710, 11358, 4340, 370, 5147, 13492, 7151, 6093, 365, 314, 2569, 26, 523, 627, 5822, 2860, 787, 16204, 315, 4721, 7151, 334, 69, 14, 71, 14, 2069, 708, 680, 523, 627, 3599, 337, 1298, 787, 4224, 315, 5117, 7151, 334, 69, 14, 71, 14, 2069, 975, 395, 1314, 655, 743, 588, 272, 10238, 8112, 384, 701, 12043, 310, 402, 14991, 2291, 14, 17198, 787, 14984, 471, 370, 272, 5117, 7151, 2544, 2985, 3984, 1202, 14, 523, 627, 21789, 12661, 787, 14984, 471, 1771, 370, 4721, 7151, 2152, 12, 2066, 1202, 370, 1678, 272, 2860, 14, 819, 710, 5366, 13, 5881, 402, 19203, 14009, 315, 5117, 7151, 12, 365, 626, 652, 12477, 523, 543, 12700, 15470, 1425, 14, 577, 4039, 1771, 496, 4073, 12, 7425, 12661, 5594, 523, 1334, 1659, 315, 314, 14953, 15470, 1425, 12, 25498, 282, 1402, 370, 3818, 303, 737, 523, 1007, 411, 16757, 2166, 14, 819, 4005, 7981, 1334, 1659, 12, 642, 10736, 8897, 6528, 314, 5621, 701, 282, 6535, 2544, 523, 1771, 4469, 9174, 14, 1448, 11277, 590, 12, 314, 12661, 787, 7798, 590, 17923, 1536, 701, 314, 523, 2011, 6535, 12, 12850, 440, 32039, 1901, 314, 1334, 1659, 5718, 14, 12836, 626, 12, 370, 1126, 4909, 523, 314, 29102, 402, 1771, 4469, 12, 314, 12661, 787, 3224, 13, 15120, 701, 314, 2011, 6535, 12, 523, 14984, 471, 370, 314, 334, 32357, 9, 1750, 7151, 12, 2066, 6781, 641, 314, 2860, 14, 819, 1666, 359, 46, 433, 2391, 1159, 8722, 641, 13492, 7151, 6093, 8738, 523, 4178, 921, 4757, 14, 78, 433, 2391, 14, 957, 15, 16131, 10546, 15, 9277, 15, 10455, 13, 6833, 13, 7588, 15, 1080, 14, 1360, 9, 523, 367, 1655, 2436, 14, 819, 4005, 675, 5621, 4666, 10736, 12, 1373, 1454, 4839, 11496, 282, 5621, 4666, 10054, 436, 523, 4816, 282, 5578, 10736, 14, 1666, 7251, 5084, 14, 819, 10841, 523, 5621, 275, 5621, 63, 2324, 342, 523, 2450, 275, 2833, 14, 32408, 13946, 8, 10546, 63, 1866, 29, 11965, 819, 327, 29826, 282, 5621, 4666, 5256, 1314, 12985, 3424, 4212, 370, 3732, 314, 2451, 5621, 4666, 523, 327, 23088, 314, 6093, 2112, 14, 523, 5621, 63, 3467, 63, 77, 12974, 275, 2833, 14, 2828, 14, 10455, 63, 6833, 14, 9515, 8610, 9944, 2988, 8, 13128, 9, 819, 327, 644, 8146, 314, 3379, 10736, 315, 282, 3835, 385, 9944, 13946, 14, 523, 5621, 63, 3467, 63, 12290, 275, 3835, 385, 9944, 13946, 8, 2992, 12, 5621, 63, 3467, 63, 2609, 9, 819, 327, 6523, 24720, 342, 641, 314, 5621, 4666, 10736, 14, 523, 3560, 63, 411, 275, 5621, 63, 3467, 63, 12290, 14, 19333, 8, 4358, 9, 523, 10841, 819, 982, 12661, 5053, 3637, 365, 6781, 12, 1373, 883, 1240, 523, 658, 12290, 14, 3357, 63, 13065, 11995, 436, 658, 12290, 14, 4998, 63, 13065, 11995, 523, 18159, 14, 819, 3091, 3548, 314, 2569, 4340, 402, 1808, 3835, 385, 9944, 13946, 365, 440, 11619, 14, 16763, 523, 675, 658, 4358, 63, 3467, 63, 12290, 14, 3357, 63, 13065, 11995, 370, 4526, 12661, 3140, 402, 523, 658, 3249, 14, 13065, 11995, 340, 9689, 13492, 7151, 6093, 14, 819, 10841, 523, 327, 710, 2569, 365, 282, 6835, 4340, 370, 675, 3835, 385, 9944, 13946, 3180, 543, 523, 327, 2833, 14, 13065, 1252, 819, 327, 16763, 675, 5621, 63, 3467, 63, 12290, 14, 3357, 63, 13065, 342, 370, 4526, 18300, 12, 503, 523, 327, 5621, 4666, 365, 440, 6657, 6781, 14, 523, 18300, 275, 2833, 14, 13065, 8, 4358, 12, 19172, 819, 327, 4226, 2005, 3537, 7659, 5053, 3637, 14, 523, 18300, 275, 11353, 63, 16525, 8, 16525, 12, 19172, 819, 5621, 63, 3467, 63, 12290, 14, 4998, 8, 16525, 63, 460, 63, 2936, 9, 523, 10841, 523, 408, 819, 347, 636, 826, 721, 277, 12, 2450, 12, 5621, 63, 3467, 63, 2609, 304, 272, 408, 11493, 282, 5621, 13690, 10736, 14, 339, 3033, 26, 489, 2450, 26, 710, 3503, 10736, 626, 911, 506, 1202, 370, 4526, 436, 4838, 314, 267, 12661, 14, 9498, 506, 376, 4514, 402, 314, 658, 3249, 14, 2834, 14, 13946, 64, 267, 3217, 14, 489, 5621, 63, 3467, 63, 2609, 26, 437, 3835, 385, 9944, 2988, 909, 14, 272, 408, 272, 291 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 8610, 13690, 10736, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 10283, 492, 1067, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 2785, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 3442, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 7588, 492, 10736, 421, 199, 533, 3835, 385, 9944, 13946, 8, 12290, 14, 13946, 304, 523, 327, 3254, 8, 74, 313, 3526, 262, 304, 4057, 13492, 7151, 6093, 17531, 370, 636, 826, 363, 523, 327, 9214, 14, 523, 408, 2493, 10736, 626, 12966, 5621, 13690, 315, 1771, 4469, 14, 819, 961, 1021, 365, 2997, 367, 298, 10455, 7151, 6093, 2, 641, 18613, 83, 334, 269, 1163, 523, 12330, 1066, 11338, 2750, 395, 376, 18140, 370, 19053, 4526, 4012, 524, 1928, 523, 1013, 417, 11136, 1402, 11030, 14, 819, 710, 11358, 4340, 370, 5147, 13492, 7151, 6093, 365, 314, 2569, 26, 523, 627, 5822, 2860, 787, 16204, 315, 4721, 7151, 334, 69, 14, 71, 14, 2069, 708, 680, 523, 627, 3599, 337, 1298, 787, 4224, 315, 5117, 7151, 334, 69, 14, 71, 14, 2069, 975, 395, 1314, 655, 743, 588, 272, 10238, 8112, 384, 701, 12043, 310, 402, 14991, 2291, 14, 17198, 787, 14984, 471, 370, 272, 5117, 7151, 2544, 2985, 3984, 1202, 14, 523, 627, 21789, 12661, 787, 14984, 471, 1771, 370, 4721, 7151, 2152, 12, 2066, 1202, 370, 1678, 272, 2860, 14, 819, 710, 5366, 13, 5881, 402, 19203, 14009, 315, 5117, 7151, 12, 365, 626, 652, 12477, 523, 543, 12700, 15470, 1425, 14, 577, 4039, 1771, 496, 4073, 12, 7425, 12661, 5594, 523, 1334, 1659, 315, 314, 14953, 15470, 1425, 12, 25498, 282, 1402, 370, 3818, 303, 737, 523, 1007, 411, 16757, 2166, 14, 819, 4005, 7981, 1334, 1659, 12, 642, 10736, 8897, 6528, 314, 5621, 701, 282, 6535, 2544, 523, 1771, 4469, 9174, 14, 1448, 11277, 590, 12, 314, 12661, 787, 7798, 590, 17923, 1536, 701, 314, 523, 2011, 6535, 12, 12850, 440, 32039, 1901, 314, 1334, 1659, 5718, 14, 12836, 626, 12, 370, 1126, 4909, 523, 314, 29102, 402, 1771, 4469, 12, 314, 12661, 787, 3224, 13, 15120, 701, 314, 2011, 6535, 12, 523, 14984, 471, 370, 314, 334, 32357, 9, 1750, 7151, 12, 2066, 6781, 641, 314, 2860, 14, 819, 1666, 359, 46, 433, 2391, 1159, 8722, 641, 13492, 7151, 6093, 8738, 523, 4178, 921, 4757, 14, 78, 433, 2391, 14, 957, 15, 16131, 10546, 15, 9277, 15, 10455, 13, 6833, 13, 7588, 15, 1080, 14, 1360, 9, 523, 367, 1655, 2436, 14, 819, 4005, 675, 5621, 4666, 10736, 12, 1373, 1454, 4839, 11496, 282, 5621, 4666, 10054, 436, 523, 4816, 282, 5578, 10736, 14, 1666, 7251, 5084, 14, 819, 10841, 523, 5621, 275, 5621, 63, 2324, 342, 523, 2450, 275, 2833, 14, 32408, 13946, 8, 10546, 63, 1866, 29, 11965, 819, 327, 29826, 282, 5621, 4666, 5256, 1314, 12985, 3424, 4212, 370, 3732, 314, 2451, 5621, 4666, 523, 327, 23088, 314, 6093, 2112, 14, 523, 5621, 63, 3467, 63, 77, 12974, 275, 2833, 14, 2828, 14, 10455, 63, 6833, 14, 9515, 8610, 9944, 2988, 8, 13128, 9, 819, 327, 644, 8146, 314, 3379, 10736, 315, 282, 3835, 385, 9944, 13946, 14, 523, 5621, 63, 3467, 63, 12290, 275, 3835, 385, 9944, 13946, 8, 2992, 12, 5621, 63, 3467, 63, 2609, 9, 819, 327, 6523, 24720, 342, 641, 314, 5621, 4666, 10736, 14, 523, 3560, 63, 411, 275, 5621, 63, 3467, 63, 12290, 14, 19333, 8, 4358, 9, 523, 10841, 819, 982, 12661, 5053, 3637, 365, 6781, 12, 1373, 883, 1240, 523, 658, 12290, 14, 3357, 63, 13065, 11995, 436, 658, 12290, 14, 4998, 63, 13065, 11995, 523, 18159, 14, 819, 3091, 3548, 314, 2569, 4340, 402, 1808, 3835, 385, 9944, 13946, 365, 440, 11619, 14, 16763, 523, 675, 658, 4358, 63, 3467, 63, 12290, 14, 3357, 63, 13065, 11995, 370, 4526, 12661, 3140, 402, 523, 658, 3249, 14, 13065, 11995, 340, 9689, 13492, 7151, 6093, 14, 819, 10841, 523, 327, 710, 2569, 365, 282, 6835, 4340, 370, 675, 3835, 385, 9944, 13946, 3180, 543, 523, 327, 2833, 14, 13065, 1252, 819, 327, 16763, 675, 5621, 63, 3467, 63, 12290, 14, 3357, 63, 13065, 342, 370, 4526, 18300, 12, 503, 523, 327, 5621, 4666, 365, 440, 6657, 6781, 14, 523, 18300, 275, 2833, 14, 13065, 8, 4358, 12, 19172, 819, 327, 4226, 2005, 3537, 7659, 5053, 3637, 14, 523, 18300, 275, 11353, 63, 16525, 8, 16525, 12, 19172, 819, 5621, 63, 3467, 63, 12290, 14, 4998, 8, 16525, 63, 460, 63, 2936, 9, 523, 10841, 523, 408, 819, 347, 636, 826, 721, 277, 12, 2450, 12, 5621, 63, 3467, 63, 2609, 304, 272, 408, 11493, 282, 5621, 13690, 10736, 14, 339, 3033, 26, 489, 2450, 26, 710, 3503, 10736, 626, 911, 506, 1202, 370, 4526, 436, 4838, 314, 267, 12661, 14, 9498, 506, 376, 4514, 402, 314, 658, 3249, 14, 2834, 14, 13946, 64, 267, 3217, 14, 489, 5621, 63, 3467, 63, 2609, 26, 437, 3835, 385, 9944, 2988, 909, 14, 272, 408, 272, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
brainstorm-ai/DIGITS
tools/create_db.py
3
25568
#!/usr/bin/env python2 # Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. import argparse from collections import Counter import logging import math import os import Queue import random import re import shutil import sys import threading import time # Find the best implementation available try: from cStringIO import StringIO except ImportError: from StringIO import StringIO import h5py import lmdb import numpy as np import PIL.Image # Add path for DIGITS package sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import digits.config digits.config.load_config() from digits import utils, log # must call digits.config.load_config() before caffe to set the path import caffe.io import caffe_pb2 logger = logging.getLogger('digits.tools.create_db') class Error(Exception): pass class BadInputFileError(Error): """Input file is empty""" pass class ParseLineError(Error): """Failed to parse a line in the input file""" pass class LoadError(Error): """Failed to load image[s]""" pass class WriteError(Error): """Failed to write image[s]""" pass class Hdf5DatasetExtendError(Error): """Failed to extend an hdf5 dataset""" pass class DbWriter(object): """ Abstract class for writing to databases """ def __init__(self, output_dir, image_height, image_width, image_channels): self._dir = output_dir os.makedirs(output_dir) self._image_height = image_height self._image_width = image_width self._image_channels = image_channels self._count = 0 def write_batch(self, batch): raise NotImplementedError def count(self): return self._count class LmdbWriter(DbWriter): # TODO pass class Hdf5Writer(DbWriter): """ A class for writing to HDF5 files """ LIST_FILENAME = 'list.txt' DTYPE = 'float32' def __init__(self, **kwargs): """ Keyword arguments: compression -- the type of dataset compression dset_limit -- the dataset size limit """ self._compression = kwargs.pop('compression', None) self._dset_limit = kwargs.pop('dset_limit', None) super(Hdf5Writer, self).__init__(**kwargs) self._db = None if self._dset_limit is not None: self._max_count = self._dset_limit / ( self._image_height * self._image_width * self._image_channels) else: self._max_count = None def write_batch(self, batch): # convert batch to numpy arrays if batch[0][0].ndim == 2: # add channel axis for grayscale images data_batch = np.array([i[0][...,np.newaxis] for i in batch]) else: data_batch = np.array([i[0] for i in batch]) # Transpose to (channels, height, width) data_batch = data_batch.transpose((0,3,1,2)) label_batch = np.array([i[1] for i in batch]) # first batch if self._db is None: self._create_new_file(len(batch)) self._db['data'][:] = data_batch self._db['label'][:] = label_batch self._count += len(batch) return current_count = self._db['data'].len() # will fit in current dataset if current_count + len(batch) <= self._max_count: self._db['data'].resize(current_count+len(batch),axis=0) self._db['label'].resize(current_count+len(batch),axis=0) self._db['data'][-len(batch):] = data_batch self._db['label'][-len(batch):] = label_batch self._count += len(batch) return # calculate how many will fit in current dataset split = self._max_count - current_count if split > 0: # put what we can into the current dataset self._db['data'].resize(self._max_count,axis=0) self._db['label'].resize(self._max_count,axis=0) self._db['data'][-split:] = data_batch[:split] self._db['label'][-split:] = label_batch[:split] self._count += split self._create_new_file(len(batch) - split) self._db['data'][:] = data_batch[split:] self._db['label'][:] = label_batch[split:] self._count += len(batch) - split def _create_new_file(self, initial_count): assert self._max_count is None or initial_count <= self._max_count, \ 'Your batch size is too large for your dataset limit - %d vs %d' % \ (initial_count, self._max_count) # close the old file if self._db is not None: self._db.close() mode = 'a' else: mode = 'w' # get the filename filename = self._new_filename() logger.info('Creating HDF5 database at "%s" ...' % os.path.join(*filename.split(os.sep)[-2:])) # update the list with open(self._list_filename(), mode) as outfile: outfile.write('%s\n' % filename) # create the new file self._db = h5py.File(os.path.join(self._dir, filename), 'w') # initialize the datasets self._db.create_dataset('data', (initial_count,self._image_channels, self._image_height,self._image_width), maxshape=(self._max_count,self._image_channels, self._image_height,self._image_width), chunks=True, compression=self._compression, dtype=self.DTYPE) self._db.create_dataset('label', (initial_count,), maxshape=(self._max_count,), chunks=True, compression=self._compression, dtype=self.DTYPE) def _list_filename(self): return os.path.join(self._dir, self.LIST_FILENAME) def _new_filename(self): return '%s.h5' % self.count() def create_db(input_file, output_dir, image_width, image_height, image_channels, backend, resize_mode = None, image_folder = None, shuffle = True, mean_files = None, **kwargs): """ Create a database of images from a list of image paths Raises exceptions on errors Arguments: input_file -- a textfile containing labelled image paths output_dir -- the location to store the created database image_width -- image resize width image_height -- image resize height image_channels -- image channels backend -- the DB format (lmdb/hdf5) Keyword arguments: resize_mode -- passed to utils.image.resize_image() shuffle -- if True, shuffle the images in the list before creating mean_files -- a list of mean files to save """ ### Validate arguments if not os.path.exists(input_file): raise ValueError('input_file does not exist') if os.path.exists(output_dir): logger.warning('removing existing database') if os.path.isdir(output_dir): shutil.rmtree(output_dir, ignore_errors=True) else: os.remove(output_dir) if image_width <= 0: raise ValueError('invalid image width') if image_height <= 0: raise ValueError('invalid image height') if image_channels not in [1,3]: raise ValueError('invalid number of channels') if resize_mode not in [None, 'crop', 'squash', 'fill', 'half_crop']: raise ValueError('invalid resize_mode') if image_folder is not None and not os.path.exists(image_folder): raise ValueError('image_folder does not exist') if mean_files: for mean_file in mean_files: if os.path.exists(mean_file): logger.warning('overwriting existing mean file "%s"!' % mean_file) else: dirname = os.path.dirname(mean_file) if not dirname: dirname = '.' if not os.path.exists(dirname): raise ValueError('Cannot save mean file at "%s"' % mean_file) compute_mean = bool(mean_files) ### Load lines from input_file into a load_queue load_queue = Queue.Queue() image_count = _fill_load_queue(input_file, load_queue, shuffle) # Start some load threads batch_size = _calculate_batch_size(image_count, bool(backend=='hdf5'), kwargs.get('hdf5_dset_limit'), image_channels, image_height, image_width) num_threads = _calculate_num_threads(batch_size, shuffle) write_queue = Queue.Queue(2*batch_size) summary_queue = Queue.Queue() for _ in xrange(num_threads): p = threading.Thread(target=_load_thread, args=(load_queue, write_queue, summary_queue, image_width, image_height, image_channels, resize_mode, image_folder, compute_mean), kwargs={'backend': backend, 'encoding': kwargs.get('encoding', None)}, ) p.daemon = True p.start() start = time.time() if backend == 'lmdb': _create_lmdb(image_count, write_queue, batch_size, output_dir, summary_queue, num_threads, mean_files, **kwargs) elif backend == 'hdf5': _create_hdf5(image_count, write_queue, batch_size, output_dir, image_width, image_height, image_channels, summary_queue, num_threads, mean_files, **kwargs) else: raise ValueError('invalid backend') logger.info('Database created after %d seconds.' % (time.time() - start)) def _create_lmdb(image_count, write_queue, batch_size, output_dir, summary_queue, num_threads, mean_files = None, encoding = None, lmdb_map_size = None, **kwargs): """ Create an LMDB Keyword arguments: encoding -- image encoding format lmdb_map_size -- the initial LMDB map size """ wait_time = time.time() threads_done = 0 images_loaded = 0 images_written = 0 image_sum = None batch = [] compute_mean = bool(mean_files) db = lmdb.open(output_dir, map_size=lmdb_map_size, map_async=True, max_dbs=0) while (threads_done < num_threads) or not write_queue.empty(): # Send update every 2 seconds if time.time() - wait_time > 2: logger.debug('Processed %d/%d' % (images_written, image_count)) wait_time = time.time() processed_something = False if not summary_queue.empty(): result_count, result_sum = summary_queue.get() images_loaded += result_count # Update total_image_sum if compute_mean and result_count > 0 and result_sum is not None: if image_sum is None: image_sum = result_sum else: image_sum += result_sum threads_done += 1 processed_something = True if not write_queue.empty(): datum = write_queue.get() batch.append(datum) if len(batch) == batch_size: _write_batch_lmdb(db, batch, images_written) images_written += len(batch) batch = [] processed_something = True if not processed_something: time.sleep(0.2) if len(batch) > 0: _write_batch_lmdb(db, batch, images_written) images_written += len(batch) if images_loaded == 0: raise LoadError('no images loaded from input file') logger.debug('%s images loaded' % images_loaded) if images_written == 0: raise WriteError('no images written to database') logger.info('%s images written to database' % images_written) if compute_mean: _save_means(image_sum, images_written, mean_files) db.close() def _create_hdf5(image_count, write_queue, batch_size, output_dir, image_width, image_height, image_channels, summary_queue, num_threads, mean_files = None, compression = None, hdf5_dset_limit = None, **kwargs): """ Create an HDF5 file Keyword arguments: compression -- dataset compression format """ wait_time = time.time() threads_done = 0 images_loaded = 0 images_written = 0 image_sum = None batch = [] compute_mean = bool(mean_files) writer = Hdf5Writer( output_dir = output_dir, image_height = image_height, image_width = image_width, image_channels = image_channels, dset_limit = hdf5_dset_limit, compression = compression, ) while (threads_done < num_threads) or not write_queue.empty(): # Send update every 2 seconds if time.time() - wait_time > 2: logger.debug('Processed %d/%d' % (images_written, image_count)) wait_time = time.time() processed_something = False if not summary_queue.empty(): result_count, result_sum = summary_queue.get() images_loaded += result_count # Update total_image_sum if compute_mean and result_count > 0 and result_sum is not None: if image_sum is None: image_sum = result_sum else: image_sum += result_sum threads_done += 1 processed_something = True if not write_queue.empty(): batch.append(write_queue.get()) if len(batch) == batch_size: writer.write_batch(batch) images_written += len(batch) batch = [] processed_something = True if not processed_something: time.sleep(0.2) if len(batch) > 0: writer.write_batch(batch) images_written += len(batch) assert images_written == writer.count() if images_loaded == 0: raise LoadError('no images loaded from input file') logger.debug('%s images loaded' % images_loaded) if images_written == 0: raise WriteError('no images written to database') logger.info('%s images written to database' % images_written) if compute_mean: _save_means(image_sum, images_written, mean_files) def _fill_load_queue(filename, queue, shuffle): """ Fill the queue with data from the input file Print the category distribution Returns the number of lines added to the queue NOTE: This can be slow on a large input file, but we need the total image count in order to report the progress, so we might as well read it all """ total_lines = 0 valid_lines = 0 distribution = Counter() with open(filename) as infile: if shuffle: lines = infile.readlines() # less memory efficient random.shuffle(lines) for line in lines: total_lines += 1 try: result = _parse_line(line, distribution) valid_lines += 1 queue.put(result) except ParseLineError: pass else: for line in infile: # more memory efficient total_lines += 1 try: result = _parse_line(line, distribution) valid_lines += 1 queue.put(result) except ParseLineError: pass logger.debug('%s total lines in file' % total_lines) if valid_lines == 0: raise BadInputFileError('No valid lines in input file') logger.info('%s valid lines in file' % valid_lines) for key in sorted(distribution): logger.debug('Category %s has %d images.' % (key, distribution[key])) return valid_lines def _parse_line(line, distribution): """ Parse a line in the input file into (path, label) """ line = line.strip() if not line: raise ParseLineError # Expect format - [/]path/to/file.jpg 123 match = re.match(r'(.+)\s+(\d+)\s*$', line) if match is None: raise ParseLineError path = match.group(1) label = int(match.group(2)) distribution[label] += 1 return path, label def _calculate_batch_size(image_count, is_hdf5=False, hdf5_dset_limit=None, image_channels=None, image_height=None, image_width=None): """ Calculates an appropriate batch size for creating this database """ if is_hdf5 and hdf5_dset_limit is not None: return min(100, image_count, hdf5_dset_limit/(image_channels*image_height*image_width)) else: return min(100, image_count) def _calculate_num_threads(batch_size, shuffle): """ Calculates an appropriate number of threads for creating this database """ if shuffle: return min(10, int(round(math.sqrt(batch_size)))) else: #XXX This is the only way to preserve order for now # This obviously hurts performance considerably return 1 def _load_thread(load_queue, write_queue, summary_queue, image_width, image_height, image_channels, resize_mode, image_folder, compute_mean, backend=None, encoding=None): """ Consumes items in load_queue Produces items to write_queue Stores cumulative results in summary_queue """ images_added = 0 if compute_mean: image_sum = _initial_image_sum(image_width, image_height, image_channels) else: image_sum = None while not load_queue.empty(): try: path, label = load_queue.get(True, 0.05) except Queue.Empty: continue # prepend path with image_folder, if appropriate if not utils.is_url(path) and image_folder and not os.path.isabs(path): path = os.path.join(image_folder, path) try: image = utils.image.load_image(path) except utils.errors.LoadImageError as e: logger.warning('[%s] %s: %s' % (path, type(e).__name__, e) ) continue image = utils.image.resize_image(image, image_height, image_width, channels = image_channels, resize_mode = resize_mode, ) if compute_mean: image_sum += image if backend == 'lmdb': datum = _array_to_datum(image, label, encoding) write_queue.put(datum) else: write_queue.put((image, label)) images_added += 1 summary_queue.put((images_added, image_sum)) def _initial_image_sum(width, height, channels): """ Returns an array of zeros that will be used to store the accumulated sum of images """ if channels == 1: return np.zeros((height, width), np.float64) else: return np.zeros((height, width, channels), np.float64) def _array_to_datum(image, label, encoding): """ Create a caffe Datum from a numpy.ndarray """ if not encoding: # Transform to caffe's format requirements if image.ndim == 3: # Transpose to (channels, height, width) image = image.transpose((2,0,1)) if image.shape[0] == 3: # channel swap # XXX see issue #59 image = image[[2,1,0],...] elif image.ndim == 2: # Add a channels axis image = image[np.newaxis,:,:] else: raise Exception('Image has unrecognized shape: "%s"' % image.shape) datum = caffe.io.array_to_datum(image, label) else: datum = caffe_pb2.Datum() if image.ndim == 3: datum.channels = image.shape[2] else: datum.channels = 1 datum.height = image.shape[0] datum.width = image.shape[1] datum.label = label s = StringIO() if encoding == 'png': PIL.Image.fromarray(image).save(s, format='PNG') elif encoding == 'jpg': PIL.Image.fromarray(image).save(s, format='JPEG', quality=90) else: raise ValueError('Invalid encoding type') datum.data = s.getvalue() datum.encoded = True return datum def _write_batch_lmdb(db, batch, image_count): """ Write a batch to an LMDB database """ try: with db.begin(write=True) as lmdb_txn: for i, datum in enumerate(batch): key = '%08d_%d' % (image_count + i, datum.label) lmdb_txn.put(key, datum.SerializeToString()) except lmdb.MapFullError: # double the map_size curr_limit = db.info()['map_size'] new_limit = curr_limit*2 logger.debug('Doubling LMDB map size to %sMB ...' % (new_limit>>20,)) try: db.set_mapsize(new_limit) # double it except AttributeError as e: version = tuple(int(x) for x in lmdb.__version__.split('.')) if version < (0,87): raise Error('py-lmdb is out of date (%s vs 0.87)' % lmdb.__version__) else: raise e # try again _write_batch_lmdb(db, batch, image_count) def _save_means(image_sum, image_count, mean_files): """ Save mean[s] to file """ mean = np.around(image_sum / image_count).astype(np.uint8) for mean_file in mean_files: if mean_file.lower().endswith('.npy'): np.save(mean_file, mean) elif mean_file.lower().endswith('.binaryproto'): data = mean # Transform to caffe's format requirements if data.ndim == 3: # Transpose to (channels, height, width) data = data.transpose((2,0,1)) if data.shape[0] == 3: # channel swap # XXX see issue #59 data = data[[2,1,0],...] elif mean.ndim == 2: # Add a channels axis data = data[np.newaxis,:,:] blob = caffe_pb2.BlobProto() blob.num = 1 blob.channels, blob.height, blob.width = data.shape blob.data.extend(data.astype(float).flat) with open(mean_file, 'wb') as outfile: outfile.write(blob.SerializeToString()) elif mean_file.lower().endswith(('.jpg', '.jpeg', '.png')): image = PIL.Image.fromarray(mean) image.save(mean_file) else: logger.warning('Unrecognized file extension for mean file: "%s"' % mean_file) continue logger.info('Mean saved at "%s"' % mean_file) if __name__ == '__main__': parser = argparse.ArgumentParser(description='Create-Db tool - DIGITS') ### Positional arguments parser.add_argument('input_file', help='An input file of labeled images') parser.add_argument('output_dir', help='Path to the output database') parser.add_argument('width', type=int, help='width of resized images' ) parser.add_argument('height', type=int, help='height of resized images' ) ### Optional arguments parser.add_argument('-c', '--channels', type=int, default=3, help='channels of resized images (1 for grayscale, 3 for color [default])' ) parser.add_argument('-r', '--resize_mode', help='resize mode for images (must be "crop", "squash" [default], "fill" or "half_crop")' ) parser.add_argument('-m', '--mean_file', action='append', help="location to output the image mean (doesn't save mean if not specified)") parser.add_argument('-f', '--image_folder', help='folder containing the images (if the paths in input_file are not absolute)') parser.add_argument('-s', '--shuffle', action='store_true', help='Shuffle images before saving' ) parser.add_argument('-e', '--encoding', help = 'Image encoding format (jpg/png)' ) parser.add_argument('-C', '--compression', help = 'Database compression format (gzip)' ) parser.add_argument('-b', '--backend', default='lmdb', help = 'The database backend - lmdb[default] or hdf5') parser.add_argument('--lmdb_map_size', type=int, help = 'The initial map size for LMDB (in MB)') parser.add_argument('--hdf5_dset_limit', type=int, default=2**31, help = 'The size limit for HDF5 datasets') args = vars(parser.parse_args()) if args['lmdb_map_size']: # convert from MB to B args['lmdb_map_size'] <<= 20 try: create_db(args['input_file'], args['output_dir'], args['width'], args['height'], args['channels'], args['backend'], resize_mode = args['resize_mode'], image_folder = args['image_folder'], shuffle = args['shuffle'], mean_files = args['mean_file'], encoding = args['encoding'], compression = args['compression'], lmdb_map_size = args['lmdb_map_size'], hdf5_dset_limit = args['hdf5_dset_limit'], ) except Exception as e: logger.error('%s: %s' % (type(e).__name__, e.message)) raise
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 9261, 12, 653, 5437, 13033, 27072, 14, 221, 2900, 4481, 4644, 14, 199, 199, 646, 7534, 199, 504, 5055, 492, 14427, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 10703, 199, 646, 2196, 199, 646, 295, 199, 646, 5145, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 199, 3, 6668, 314, 5526, 4514, 2808, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 646, 394, 21, 647, 199, 646, 24546, 697, 199, 646, 2680, 465, 980, 199, 646, 14937, 14, 3491, 199, 199, 3, 2654, 931, 367, 577, 1277, 5930, 2559, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 363, 7845, 199, 646, 7576, 14, 888, 199, 7022, 14, 888, 14, 912, 63, 888, 342, 199, 504, 7576, 492, 3778, 12, 943, 199, 199, 3, 1471, 1240, 7576, 14, 888, 14, 912, 63, 888, 342, 2544, 1704, 2026, 370, 663, 314, 931, 199, 646, 1704, 2026, 14, 2308, 199, 646, 1704, 2026, 63, 3317, 18, 199, 199, 2921, 275, 2050, 14, 5572, 360, 7022, 14, 2537, 14, 981, 63, 697, 358, 199, 199, 533, 4520, 8, 1726, 304, 272, 986, 199, 199, 533, 8857, 3205, 25212, 8, 547, 304, 272, 408, 3205, 570, 365, 2701, 624, 272, 986, 199, 199, 533, 6077, 3049, 547, 8, 547, 304, 272, 408, 4276, 370, 2198, 282, 1004, 315, 314, 1324, 570, 624, 272, 986, 199, 199, 533, 7190, 547, 8, 547, 304, 272, 408, 4276, 370, 2248, 1834, 59, 83, 61, 624, 272, 986, 199, 199, 533, 6990, 547, 8, 547, 304, 272, 408, 4276, 370, 2218, 1834, 59, 83, 61, 624, 272, 986, 199, 199, 533, 869, 1587, 21, 9271, 30775, 547, 8, 547, 304, 272, 408, 4276, 370, 12247, 376, 394, 1587, 21, 4789, 624, 272, 986, 421, 199, 533, 28822, 6261, 8, 785, 304, 272, 408, 272, 11836, 1021, 367, 3575, 370, 16219, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1072, 63, 694, 12, 1834, 63, 3333, 12, 1834, 63, 2063, 12, 1834, 63, 6324, 304, 267, 291, 423, 694, 275, 1072, 63, 694, 267, 747, 14, 8347, 8, 1199, 63, 694, 9, 267, 291, 423, 1569, 63, 3333, 275, 1834, 63, 3333, 267, 291, 423, 1569, 63, 2063, 275, 1834, 63, 2063, 267, 291, 423, 1569, 63, 6324, 275, 1834, 63, 6324, 267, 291, 423, 835, 275, 378, 339, 347, 2218, 63, 2912, 8, 277, 12, 3522, 304, 267, 746, 4279, 339, 347, 2338, 8, 277, 304, 267, 372, 291, 423, 835, 199, 199, 533, 491, 77, 697, 6261, 8, 8882, 6261, 304, 272, 327, 3254, 272, 986, 199, 199, 533, 869, 1587, 21, 6261, 8, 8882, 6261, 304, 272, 408, 272, 437, 1021, 367, 3575, 370, 24521, 21, 1584, 272, 408, 272, 21716, 63, 15440, 275, 283, 513, 14, 2424, 7, 272, 577, 2711, 275, 283, 1609, 708, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 408, 267, 6431, 2368, 26, 267, 10291, 1553, 314, 730, 402, 4789, 10291, 267, 366, 409, 63, 3097, 1553, 314, 4789, 1568, 2304, 267, 408, 267, 291, 423, 12849, 275, 2074, 14, 1935, 360, 12849, 297, 488, 9, 267, 291, 423, 68, 409, 63, 3097, 275, 2074, 14, 1935, 360, 68, 409, 63, 3097, 297, 488, 9, 267, 1613, 8, 40, 1587, 21, 6261, 12, 291, 2843, 826, 14155, 958, 9, 267, 291, 423, 697, 275, 488, 398, 340, 291, 423, 68, 409, 63, 3097, 365, 440, 488, 26, 288, 291, 423, 988, 63, 835, 275, 291, 423, 68, 409, 63, 3097, 1182, 334, 490, 291, 423, 1569, 63, 3333, 627, 291, 423, 1569, 63, 2063, 627, 291, 423, 1569, 63, 6324, 9, 267, 587, 26, 288, 291, 423, 988, 63, 835, 275, 488, 339, 347, 2218, 63, 2912, 8, 277, 12, 3522, 304, 267, 327, 3957, 3522, 370, 2680, 6572, 267, 340, 3522, 59, 16, 1527, 16, 1055, 8322, 508, 499, 26, 288, 327, 1050, 3623, 3114, 367, 21977, 3467, 5935, 288, 666, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 16, 1527, 11577, 1590, 14, 14483, 61, 367, 284, 315, 3522, 566, 267, 587, 26, 288, 666, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 16, 61, 367, 284, 315, 3522, 566, 267, 327, 6266, 4070, 370, 334, 6324, 12, 4569, 12, 3462, 9, 267, 666, 63, 2912, 275, 666, 63, 2912, 14, 10483, 1332, 16, 12, 19, 12, 17, 12, 18, 430, 267, 1768, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 17, 61, 367, 284, 315, 3522, 566, 7318, 327, 1642, 3522, 267, 340, 291, 423, 697, 365, 488, 26, 288, 291, 423, 981, 63, 1222, 63, 493, 8, 552, 8, 2912, 430, 288, 291, 423, 697, 459, 576, 418, 5873, 275, 666, 63, 2912, 288, 291, 423, 697, 459, 1302, 418, 5873, 275, 1768, 63, 2912, 288, 291, 423, 835, 847, 822, 8, 2912, 9, 288, 372, 398, 1453, 63, 835, 275, 291, 423, 697, 459, 576, 2278, 552, 342, 398, 327, 911, 5542, 315, 1453, 4789, 267, 340, 1453, 63, 835, 435, 822, 8, 2912, 9, 2695, 291, 423, 988, 63, 835, 26, 288, 291, 423, 697, 459, 576, 2278, 8709, 8, 1818, 63, 835, 11, 552, 8, 2912, 395, 3127, 29, 16, 9, 288, 291, 423, 697, 459, 1302, 2278, 8709, 8, 1818, 63, 835, 11, 552, 8, 2912, 395, 3127, 29, 16, 9, 288, 291, 423, 697, 459, 576, 31942, 552, 8, 2912, 15405, 275, 666, 63, 2912, 288, 291, 423, 697, 459, 1302, 31942, 552, 8, 2912, 15405, 275, 1768, 63, 2912, 288, 291, 423, 835, 847, 822, 8, 2912, 9, 288, 372, 398, 327, 8671, 4212, 5002, 911, 5542, 315, 1453, 4789, 267, 3715, 275, 291, 423, 988, 63, 835, 446, 1453, 63, 835, 398, 340, 3715, 690, 378, 26, 288, 327, 5324, 4052, 781, 883, 1901, 314, 1453, 4789, 288, 291, 423, 697, 459, 576, 2278, 8709, 8, 277, 423, 988, 63, 835, 12, 3127 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 9261, 12, 653, 5437, 13033, 27072, 14, 221, 2900, 4481, 4644, 14, 199, 199, 646, 7534, 199, 504, 5055, 492, 14427, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 10703, 199, 646, 2196, 199, 646, 295, 199, 646, 5145, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 199, 3, 6668, 314, 5526, 4514, 2808, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 646, 394, 21, 647, 199, 646, 24546, 697, 199, 646, 2680, 465, 980, 199, 646, 14937, 14, 3491, 199, 199, 3, 2654, 931, 367, 577, 1277, 5930, 2559, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 363, 7845, 199, 646, 7576, 14, 888, 199, 7022, 14, 888, 14, 912, 63, 888, 342, 199, 504, 7576, 492, 3778, 12, 943, 199, 199, 3, 1471, 1240, 7576, 14, 888, 14, 912, 63, 888, 342, 2544, 1704, 2026, 370, 663, 314, 931, 199, 646, 1704, 2026, 14, 2308, 199, 646, 1704, 2026, 63, 3317, 18, 199, 199, 2921, 275, 2050, 14, 5572, 360, 7022, 14, 2537, 14, 981, 63, 697, 358, 199, 199, 533, 4520, 8, 1726, 304, 272, 986, 199, 199, 533, 8857, 3205, 25212, 8, 547, 304, 272, 408, 3205, 570, 365, 2701, 624, 272, 986, 199, 199, 533, 6077, 3049, 547, 8, 547, 304, 272, 408, 4276, 370, 2198, 282, 1004, 315, 314, 1324, 570, 624, 272, 986, 199, 199, 533, 7190, 547, 8, 547, 304, 272, 408, 4276, 370, 2248, 1834, 59, 83, 61, 624, 272, 986, 199, 199, 533, 6990, 547, 8, 547, 304, 272, 408, 4276, 370, 2218, 1834, 59, 83, 61, 624, 272, 986, 199, 199, 533, 869, 1587, 21, 9271, 30775, 547, 8, 547, 304, 272, 408, 4276, 370, 12247, 376, 394, 1587, 21, 4789, 624, 272, 986, 421, 199, 533, 28822, 6261, 8, 785, 304, 272, 408, 272, 11836, 1021, 367, 3575, 370, 16219, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1072, 63, 694, 12, 1834, 63, 3333, 12, 1834, 63, 2063, 12, 1834, 63, 6324, 304, 267, 291, 423, 694, 275, 1072, 63, 694, 267, 747, 14, 8347, 8, 1199, 63, 694, 9, 267, 291, 423, 1569, 63, 3333, 275, 1834, 63, 3333, 267, 291, 423, 1569, 63, 2063, 275, 1834, 63, 2063, 267, 291, 423, 1569, 63, 6324, 275, 1834, 63, 6324, 267, 291, 423, 835, 275, 378, 339, 347, 2218, 63, 2912, 8, 277, 12, 3522, 304, 267, 746, 4279, 339, 347, 2338, 8, 277, 304, 267, 372, 291, 423, 835, 199, 199, 533, 491, 77, 697, 6261, 8, 8882, 6261, 304, 272, 327, 3254, 272, 986, 199, 199, 533, 869, 1587, 21, 6261, 8, 8882, 6261, 304, 272, 408, 272, 437, 1021, 367, 3575, 370, 24521, 21, 1584, 272, 408, 272, 21716, 63, 15440, 275, 283, 513, 14, 2424, 7, 272, 577, 2711, 275, 283, 1609, 708, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 408, 267, 6431, 2368, 26, 267, 10291, 1553, 314, 730, 402, 4789, 10291, 267, 366, 409, 63, 3097, 1553, 314, 4789, 1568, 2304, 267, 408, 267, 291, 423, 12849, 275, 2074, 14, 1935, 360, 12849, 297, 488, 9, 267, 291, 423, 68, 409, 63, 3097, 275, 2074, 14, 1935, 360, 68, 409, 63, 3097, 297, 488, 9, 267, 1613, 8, 40, 1587, 21, 6261, 12, 291, 2843, 826, 14155, 958, 9, 267, 291, 423, 697, 275, 488, 398, 340, 291, 423, 68, 409, 63, 3097, 365, 440, 488, 26, 288, 291, 423, 988, 63, 835, 275, 291, 423, 68, 409, 63, 3097, 1182, 334, 490, 291, 423, 1569, 63, 3333, 627, 291, 423, 1569, 63, 2063, 627, 291, 423, 1569, 63, 6324, 9, 267, 587, 26, 288, 291, 423, 988, 63, 835, 275, 488, 339, 347, 2218, 63, 2912, 8, 277, 12, 3522, 304, 267, 327, 3957, 3522, 370, 2680, 6572, 267, 340, 3522, 59, 16, 1527, 16, 1055, 8322, 508, 499, 26, 288, 327, 1050, 3623, 3114, 367, 21977, 3467, 5935, 288, 666, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 16, 1527, 11577, 1590, 14, 14483, 61, 367, 284, 315, 3522, 566, 267, 587, 26, 288, 666, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 16, 61, 367, 284, 315, 3522, 566, 267, 327, 6266, 4070, 370, 334, 6324, 12, 4569, 12, 3462, 9, 267, 666, 63, 2912, 275, 666, 63, 2912, 14, 10483, 1332, 16, 12, 19, 12, 17, 12, 18, 430, 267, 1768, 63, 2912, 275, 980, 14, 1144, 779, 73, 59, 17, 61, 367, 284, 315, 3522, 566, 7318, 327, 1642, 3522, 267, 340, 291, 423, 697, 365, 488, 26, 288, 291, 423, 981, 63, 1222, 63, 493, 8, 552, 8, 2912, 430, 288, 291, 423, 697, 459, 576, 418, 5873, 275, 666, 63, 2912, 288, 291, 423, 697, 459, 1302, 418, 5873, 275, 1768, 63, 2912, 288, 291, 423, 835, 847, 822, 8, 2912, 9, 288, 372, 398, 1453, 63, 835, 275, 291, 423, 697, 459, 576, 2278, 552, 342, 398, 327, 911, 5542, 315, 1453, 4789, 267, 340, 1453, 63, 835, 435, 822, 8, 2912, 9, 2695, 291, 423, 988, 63, 835, 26, 288, 291, 423, 697, 459, 576, 2278, 8709, 8, 1818, 63, 835, 11, 552, 8, 2912, 395, 3127, 29, 16, 9, 288, 291, 423, 697, 459, 1302, 2278, 8709, 8, 1818, 63, 835, 11, 552, 8, 2912, 395, 3127, 29, 16, 9, 288, 291, 423, 697, 459, 576, 31942, 552, 8, 2912, 15405, 275, 666, 63, 2912, 288, 291, 423, 697, 459, 1302, 31942, 552, 8, 2912, 15405, 275, 1768, 63, 2912, 288, 291, 423, 835, 847, 822, 8, 2912, 9, 288, 372, 398, 327, 8671, 4212, 5002, 911, 5542, 315, 1453, 4789, 267, 3715, 275, 291, 423, 988, 63, 835, 446, 1453, 63, 835, 398, 340, 3715, 690, 378, 26, 288, 327, 5324, 4052, 781, 883, 1901, 314, 1453, 4789, 288, 291, 423, 697, 459, 576, 2278, 8709, 8, 277, 423, 988, 63, 835, 12, 3127, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rishig/zulip
zproject/urls.py
1
36270
from django.conf import settings from django.conf.urls import url, include from django.conf.urls.i18n import i18n_patterns from django.http import HttpResponseBadRequest, HttpRequest, HttpResponse from django.views.generic import TemplateView, RedirectView from django.utils.module_loading import import_string import os import zerver.forms from zproject import dev_urls from zproject.legacy_urls import legacy_urls from zerver.views.documentation import IntegrationView, MarkdownDirectoryView from zerver.lib.integrations import WEBHOOK_INTEGRATIONS from django.contrib.auth.views import (login, password_reset_done, password_reset_confirm, password_reset_complete) import zerver.tornado.views import zerver.views import zerver.views.auth import zerver.views.archive import zerver.views.camo import zerver.views.compatibility import zerver.views.home import zerver.views.email_mirror import zerver.views.registration import zerver.views.zephyr import zerver.views.users import zerver.views.unsubscribe import zerver.views.documentation import zerver.views.user_groups import zerver.views.user_settings import zerver.views.muting import zerver.views.streams import zerver.views.realm import zerver.views.digest import zerver.views.messages from zerver.context_processors import latest_info_context import zerver.views.public_export from zerver.lib.rest import rest_dispatch if settings.TWO_FACTOR_AUTHENTICATION_ENABLED: from two_factor.urls import urlpatterns as tf_urls from two_factor.gateways.twilio.urls import urlpatterns as tf_twilio_urls # NB: There are several other pieces of code which route requests by URL: # # - legacy_urls.py contains API endpoint written before the redesign # and should not be added to. # # - runtornado.py has its own URL list for Tornado views. See the # invocation of web.Application in that file. # # - The Nginx config knows which URLs to route to Django or Tornado. # # - Likewise for the local dev server in tools/run-dev.py. # These endpoints constitute the currently designed API (V1), which uses: # * REST verbs # * Basic auth (username:password is email:apiKey) # * Take and return json-formatted data # # If you're adding a new endpoint to the code that requires authentication, # please add it here. # See rest_dispatch in zerver.lib.rest for an explanation of auth methods used # # All of these paths are accessed by either a /json or /api/v1 prefix; # e.g. `PATCH /json/realm` or `PATCH /api/v1/realm`. v1_api_and_json_patterns = [ # realm-level calls url(r'^realm$', rest_dispatch, {'PATCH': 'zerver.views.realm.update_realm'}), # Returns a 204, used by desktop app to verify connectivity status url(r'generate_204$', zerver.views.registration.generate_204, name='zerver.views.registration.generate_204'), url(r'realm/subdomain/(?P<subdomain>\S+)$', zerver.views.realm.check_subdomain_available, name='zerver.views.realm.check_subdomain_available'), # realm/domains -> zerver.views.realm_domains url(r'^realm/domains$', rest_dispatch, {'GET': 'zerver.views.realm_domains.list_realm_domains', 'POST': 'zerver.views.realm_domains.create_realm_domain'}), url(r'^realm/domains/(?P<domain>\S+)$', rest_dispatch, {'PATCH': 'zerver.views.realm_domains.patch_realm_domain', 'DELETE': 'zerver.views.realm_domains.delete_realm_domain'}), # realm/emoji -> zerver.views.realm_emoji url(r'^realm/emoji$', rest_dispatch, {'GET': 'zerver.views.realm_emoji.list_emoji'}), url(r'^realm/emoji/(?P<emoji_name>.*)$', rest_dispatch, {'POST': 'zerver.views.realm_emoji.upload_emoji', 'DELETE': ('zerver.views.realm_emoji.delete_emoji', {"intentionally_undocumented"})}), # this endpoint throws a status code 400 JsonableError when it should be a 404. # realm/icon -> zerver.views.realm_icon url(r'^realm/icon$', rest_dispatch, {'POST': 'zerver.views.realm_icon.upload_icon', 'DELETE': 'zerver.views.realm_icon.delete_icon_backend', 'GET': 'zerver.views.realm_icon.get_icon_backend'}), # realm/logo -> zerver.views.realm_logo url(r'^realm/logo$', rest_dispatch, {'POST': 'zerver.views.realm_logo.upload_logo', 'DELETE': 'zerver.views.realm_logo.delete_logo_backend', 'GET': 'zerver.views.realm_logo.get_logo_backend'}), # realm/filters -> zerver.views.realm_filters url(r'^realm/filters$', rest_dispatch, {'GET': 'zerver.views.realm_filters.list_filters', 'POST': 'zerver.views.realm_filters.create_filter'}), url(r'^realm/filters/(?P<filter_id>\d+)$', rest_dispatch, {'DELETE': 'zerver.views.realm_filters.delete_filter'}), # realm/profile_fields -> zerver.views.custom_profile_fields url(r'^realm/profile_fields$', rest_dispatch, {'GET': 'zerver.views.custom_profile_fields.list_realm_custom_profile_fields', 'PATCH': 'zerver.views.custom_profile_fields.reorder_realm_custom_profile_fields', 'POST': 'zerver.views.custom_profile_fields.create_realm_custom_profile_field'}), url(r'^realm/profile_fields/(?P<field_id>\d+)$', rest_dispatch, {'PATCH': 'zerver.views.custom_profile_fields.update_realm_custom_profile_field', 'DELETE': 'zerver.views.custom_profile_fields.delete_realm_custom_profile_field'}), # realm/deactivate -> zerver.views.deactivate_realm url(r'^realm/deactivate$', rest_dispatch, {'POST': 'zerver.views.realm.deactivate_realm'}), url(r'^realm/presence$', rest_dispatch, {'GET': 'zerver.views.presence.get_statuses_for_realm'}), # users -> zerver.views.users # # Since some of these endpoints do something different if used on # yourself with `/me` as the email, we need to make sure that we # don't accidentally trigger these. The cleanest way to do that # is to add a regular expression assertion that it isn't `/me/` # (or ends with `/me`, in the case of hitting the root URL). url(r'^users$', rest_dispatch, {'GET': 'zerver.views.users.get_members_backend', 'POST': 'zerver.views.users.create_user_backend'}), url(r'^users/(?P<user_id>[0-9]+)/reactivate$', rest_dispatch, {'POST': 'zerver.views.users.reactivate_user_backend'}), url(r'^users/(?!me/)(?P<email>[^/]*)/presence$', rest_dispatch, {'GET': 'zerver.views.presence.get_presence_backend'}), url(r'^users/(?P<user_id>[0-9]+)$', rest_dispatch, {'PATCH': 'zerver.views.users.update_user_backend', 'DELETE': 'zerver.views.users.deactivate_user_backend'}), url(r'^bots$', rest_dispatch, {'GET': 'zerver.views.users.get_bots_backend', 'POST': 'zerver.views.users.add_bot_backend'}), url(r'^bots/(?P<bot_id>[0-9]+)/api_key/regenerate$', rest_dispatch, {'POST': 'zerver.views.users.regenerate_bot_api_key'}), url(r'^bots/(?P<bot_id>[0-9]+)$', rest_dispatch, {'PATCH': 'zerver.views.users.patch_bot_backend', 'DELETE': 'zerver.views.users.deactivate_bot_backend'}), # invites -> zerver.views.invite url(r'^invites$', rest_dispatch, {'GET': 'zerver.views.invite.get_user_invites', 'POST': 'zerver.views.invite.invite_users_backend'}), url(r'^invites/(?P<prereg_id>[0-9]+)$', rest_dispatch, {'DELETE': 'zerver.views.invite.revoke_user_invite'}), url(r'^invites/(?P<prereg_id>[0-9]+)/resend$', rest_dispatch, {'POST': 'zerver.views.invite.resend_user_invite_email'}), # invites/multiuse -> zerver.views.invite url(r'^invites/multiuse$', rest_dispatch, {'POST': 'zerver.views.invite.generate_multiuse_invite_backend'}), # invites/multiuse -> zerver.views.invite url(r'^invites/multiuse/(?P<invite_id>[0-9]+)$', rest_dispatch, {'DELETE': 'zerver.views.invite.revoke_multiuse_invite'}), # mark messages as read (in bulk) url(r'^mark_all_as_read$', rest_dispatch, {'POST': 'zerver.views.messages.mark_all_as_read'}), url(r'^mark_stream_as_read$', rest_dispatch, {'POST': 'zerver.views.messages.mark_stream_as_read'}), url(r'^mark_topic_as_read$', rest_dispatch, {'POST': 'zerver.views.messages.mark_topic_as_read'}), url(r'^zcommand$', rest_dispatch, {'POST': 'zerver.views.messages.zcommand_backend'}), # messages -> zerver.views.messages # GET returns messages, possibly filtered, POST sends a message url(r'^messages$', rest_dispatch, {'GET': 'zerver.views.messages.get_messages_backend', 'POST': ('zerver.views.messages.send_message_backend', {'allow_incoming_webhooks'})}), url(r'^messages/(?P<message_id>[0-9]+)$', rest_dispatch, {'GET': 'zerver.views.messages.json_fetch_raw_message', 'PATCH': 'zerver.views.messages.update_message_backend', 'DELETE': 'zerver.views.messages.delete_message_backend'}), url(r'^messages/render$', rest_dispatch, {'POST': 'zerver.views.messages.render_message_backend'}), url(r'^messages/flags$', rest_dispatch, {'POST': 'zerver.views.messages.update_message_flags'}), url(r'^messages/(?P<message_id>\d+)/history$', rest_dispatch, {'GET': 'zerver.views.messages.get_message_edit_history'}), url(r'^messages/matches_narrow$', rest_dispatch, {'GET': 'zerver.views.messages.messages_in_narrow_backend'}), url(r'^users/me/subscriptions/properties$', rest_dispatch, {'POST': 'zerver.views.streams.update_subscription_properties_backend'}), url(r'^users/me/subscriptions/(?P<stream_id>\d+)$', rest_dispatch, {'PATCH': 'zerver.views.streams.update_subscriptions_property'}), url(r'^submessage$', rest_dispatch, {'POST': 'zerver.views.submessage.process_submessage'}), # New endpoint for handling reactions. url(r'^messages/(?P<message_id>[0-9]+)/reactions$', rest_dispatch, {'POST': 'zerver.views.reactions.add_reaction', 'DELETE': 'zerver.views.reactions.remove_reaction'}), # reactions -> zerver.view.reactions # PUT adds a reaction to a message # DELETE removes a reaction from a message url(r'^messages/(?P<message_id>[0-9]+)/emoji_reactions/(?P<emoji_name>.*)$', rest_dispatch, {'PUT': 'zerver.views.reactions.add_reaction_legacy', 'DELETE': 'zerver.views.reactions.remove_reaction_legacy'}), # attachments -> zerver.views.attachments url(r'^attachments$', rest_dispatch, {'GET': 'zerver.views.attachments.list_by_user'}), url(r'^attachments/(?P<attachment_id>[0-9]+)$', rest_dispatch, {'DELETE': 'zerver.views.attachments.remove'}), # typing -> zerver.views.typing # POST sends a typing notification event to recipients url(r'^typing$', rest_dispatch, {'POST': 'zerver.views.typing.send_notification_backend'}), # user_uploads -> zerver.views.upload url(r'^user_uploads$', rest_dispatch, {'POST': 'zerver.views.upload.upload_file_backend'}), # bot_storage -> zerver.views.storage url(r'^bot_storage$', rest_dispatch, {'PUT': 'zerver.views.storage.update_storage', 'GET': 'zerver.views.storage.get_storage', 'DELETE': 'zerver.views.storage.remove_storage'}), # users/me -> zerver.views url(r'^users/me$', rest_dispatch, {'GET': 'zerver.views.users.get_profile_backend', 'DELETE': 'zerver.views.users.deactivate_user_own_backend'}), # PUT is currently used by mobile apps, we intend to remove the PUT version # as soon as possible. POST exists to correct the erroneous use of PUT. url(r'^users/me/pointer$', rest_dispatch, {'GET': 'zerver.views.pointer.get_pointer_backend', 'PUT': 'zerver.views.pointer.update_pointer_backend', 'POST': 'zerver.views.pointer.update_pointer_backend'}), url(r'^users/me/presence$', rest_dispatch, {'POST': 'zerver.views.presence.update_active_status_backend'}), url(r'^users/me/status$', rest_dispatch, {'POST': 'zerver.views.presence.update_user_status_backend'}), # Endpoint used by mobile devices to register their push # notification credentials url(r'^users/me/apns_device_token$', rest_dispatch, {'POST': 'zerver.views.push_notifications.add_apns_device_token', 'DELETE': 'zerver.views.push_notifications.remove_apns_device_token'}), url(r'^users/me/android_gcm_reg_id$', rest_dispatch, {'POST': 'zerver.views.push_notifications.add_android_reg_id', 'DELETE': 'zerver.views.push_notifications.remove_android_reg_id'}), # user_groups -> zerver.views.user_groups url(r'^user_groups$', rest_dispatch, {'GET': 'zerver.views.user_groups.get_user_group'}), url(r'^user_groups/create$', rest_dispatch, {'POST': 'zerver.views.user_groups.add_user_group'}), url(r'^user_groups/(?P<user_group_id>\d+)$', rest_dispatch, {'PATCH': 'zerver.views.user_groups.edit_user_group', 'DELETE': 'zerver.views.user_groups.delete_user_group'}), url(r'^user_groups/(?P<user_group_id>\d+)/members$', rest_dispatch, {'POST': 'zerver.views.user_groups.update_user_group_backend'}), # users/me -> zerver.views.user_settings url(r'^users/me/api_key/regenerate$', rest_dispatch, {'POST': 'zerver.views.user_settings.regenerate_api_key'}), url(r'^users/me/enter-sends$', rest_dispatch, {'POST': ('zerver.views.user_settings.change_enter_sends', # This endpoint should be folded into user settings {'intentionally_undocumented'})}), url(r'^users/me/avatar$', rest_dispatch, {'POST': 'zerver.views.user_settings.set_avatar_backend', 'DELETE': 'zerver.views.user_settings.delete_avatar_backend'}), # users/me/hotspots -> zerver.views.hotspots url(r'^users/me/hotspots$', rest_dispatch, {'POST': ('zerver.views.hotspots.mark_hotspot_as_read', # This endpoint is low priority for documentation as # it is part of the webapp-specific tutorial. {'intentionally_undocumented'})}), # users/me/tutorial_status -> zerver.views.tutorial url(r'^users/me/tutorial_status$', rest_dispatch, {'POST': ('zerver.views.tutorial.set_tutorial_status', # This is a relic of an old Zulip tutorial model and # should be deleted. {'intentionally_undocumented'})}), # settings -> zerver.views.user_settings url(r'^settings$', rest_dispatch, {'PATCH': 'zerver.views.user_settings.json_change_settings'}), url(r'^settings/display$', rest_dispatch, {'PATCH': 'zerver.views.user_settings.update_display_settings_backend'}), url(r'^settings/notifications$', rest_dispatch, {'PATCH': 'zerver.views.user_settings.json_change_notify_settings'}), # users/me/alert_words -> zerver.views.alert_words url(r'^users/me/alert_words$', rest_dispatch, {'GET': 'zerver.views.alert_words.list_alert_words', 'POST': 'zerver.views.alert_words.add_alert_words', 'DELETE': 'zerver.views.alert_words.remove_alert_words'}), # users/me/custom_profile_data -> zerver.views.custom_profile_data url(r'^users/me/profile_data$', rest_dispatch, {'PATCH': 'zerver.views.custom_profile_fields.update_user_custom_profile_data', 'DELETE': 'zerver.views.custom_profile_fields.remove_user_custom_profile_data'}), url(r'^users/me/(?P<stream_id>\d+)/topics$', rest_dispatch, {'GET': 'zerver.views.streams.get_topics_backend'}), # streams -> zerver.views.streams # (this API is only used externally) url(r'^streams$', rest_dispatch, {'GET': 'zerver.views.streams.get_streams_backend'}), # GET returns `stream_id`, stream name should be encoded in the url query (in `stream` param) url(r'^get_stream_id$', rest_dispatch, {'GET': 'zerver.views.streams.json_get_stream_id'}), # GET returns "stream info" (undefined currently?), HEAD returns whether stream exists (200 or 404) url(r'^streams/(?P<stream_id>\d+)/members$', rest_dispatch, {'GET': 'zerver.views.streams.get_subscribers_backend'}), url(r'^streams/(?P<stream_id>\d+)$', rest_dispatch, {'PATCH': 'zerver.views.streams.update_stream_backend', 'DELETE': 'zerver.views.streams.deactivate_stream_backend'}), # Delete topic in stream url(r'^streams/(?P<stream_id>\d+)/delete_topic$', rest_dispatch, {'POST': 'zerver.views.streams.delete_in_topic'}), url(r'^default_streams$', rest_dispatch, {'POST': 'zerver.views.streams.add_default_stream', 'DELETE': 'zerver.views.streams.remove_default_stream'}), url(r'^default_stream_groups/create$', rest_dispatch, {'POST': 'zerver.views.streams.create_default_stream_group'}), url(r'^default_stream_groups/(?P<group_id>\d+)$', rest_dispatch, {'PATCH': 'zerver.views.streams.update_default_stream_group_info', 'DELETE': 'zerver.views.streams.remove_default_stream_group'}), url(r'^default_stream_groups/(?P<group_id>\d+)/streams$', rest_dispatch, {'PATCH': 'zerver.views.streams.update_default_stream_group_streams'}), # GET lists your streams, POST bulk adds, PATCH bulk modifies/removes url(r'^users/me/subscriptions$', rest_dispatch, {'GET': 'zerver.views.streams.list_subscriptions_backend', 'POST': 'zerver.views.streams.add_subscriptions_backend', 'PATCH': 'zerver.views.streams.update_subscriptions_backend', 'DELETE': 'zerver.views.streams.remove_subscriptions_backend'}), # muting -> zerver.views.muting url(r'^users/me/subscriptions/muted_topics$', rest_dispatch, {'PATCH': 'zerver.views.muting.update_muted_topic'}), # used to register for an event queue in tornado url(r'^register$', rest_dispatch, {'POST': 'zerver.views.events_register.events_register_backend'}), # events -> zerver.tornado.views url(r'^events$', rest_dispatch, {'GET': 'zerver.tornado.views.get_events', 'DELETE': 'zerver.tornado.views.cleanup_event_queue'}), # report -> zerver.views.report # # These endpoints are for internal error/performance reporting # from the browser to the webapp, and we don't expect to ever # include in our API documentation. url(r'^report/error$', rest_dispatch, # Logged-out browsers can hit this endpoint, for portico page JS exceptions. {'POST': ('zerver.views.report.report_error', {'allow_anonymous_user_web', 'intentionally_undocumented'})}), url(r'^report/send_times$', rest_dispatch, {'POST': ('zerver.views.report.report_send_times', {'intentionally_undocumented'})}), url(r'^report/narrow_times$', rest_dispatch, {'POST': ('zerver.views.report.report_narrow_times', {'intentionally_undocumented'})}), url(r'^report/unnarrow_times$', rest_dispatch, {'POST': ('zerver.views.report.report_unnarrow_times', {'intentionally_undocumented'})}), # Used to generate a Zoom video call URL url(r'^calls/create$', rest_dispatch, {'GET': 'zerver.views.video_calls.get_zoom_url'}), # Used for public-only realm exporting url(r'^export/realm$', rest_dispatch, {'POST': 'zerver.views.public_export.public_only_realm_export'}), ] # These views serve pages (HTML). As such, their internationalization # must depend on the url. # # If you're adding a new page to the website (as opposed to a new # endpoint for use by code), you should add it here. i18n_urls = [ url(r'^$', zerver.views.home.home, name='zerver.views.home.home'), # We have a desktop-specific landing page in case we change our / # to not log in in the future. We don't want to require a new # desktop app build for everyone in that case url(r'^desktop_home/$', zerver.views.home.desktop_home, name='zerver.views.home.desktop_home'), url(r'^accounts/login/sso/$', zerver.views.auth.remote_user_sso, name='login-sso'), url(r'^accounts/login/jwt/$', zerver.views.auth.remote_user_jwt, name='login-jwt'), url(r'^accounts/login/social/([\w,-]+)$', zerver.views.auth.start_social_login, name='login-social'), url(r'^accounts/register/social/([\w,-]+)$', zerver.views.auth.start_social_signup, name='signup-social'), url(r'^accounts/login/google/$', zerver.views.auth.start_google_oauth2, name='zerver.views.auth.start_google_oauth2'), url(r'^accounts/login/google/send/$', zerver.views.auth.send_oauth_request_to_google, name='zerver.views.auth.send_oauth_request_to_google'), url(r'^accounts/login/google/done/$', zerver.views.auth.finish_google_oauth2, name='zerver.views.auth.finish_google_oauth2'), url(r'^accounts/login/subdomain/([^/]+)$', zerver.views.auth.log_into_subdomain, name='zerver.views.auth.log_into_subdomain'), url(r'^accounts/login/local/$', zerver.views.auth.dev_direct_login, name='zerver.views.auth.dev_direct_login'), # We have two entries for accounts/login; only the first one is # used for URL resolution. The second here is to allow # reverse("django.contrib.auth.views.login") in templates to # return `/accounts/login/`. url(r'^accounts/login/', zerver.views.auth.login_page, {'template_name': 'zerver/login.html'}, name='zerver.views.auth.login_page'), url(r'^accounts/login/', login, {'template_name': 'zerver/login.html'}, name='django.contrib.auth.views.login'), url(r'^accounts/logout/', zerver.views.auth.logout_then_login, name='zerver.views.auth.logout_then_login'), url(r'^accounts/webathena_kerberos_login/', zerver.views.zephyr.webathena_kerberos_login, name='zerver.views.zephyr.webathena_kerberos_login'), url(r'^accounts/password/reset/$', zerver.views.auth.password_reset, name='zerver.views.auth.password_reset'), url(r'^accounts/password/reset/done/$', password_reset_done, {'template_name': 'zerver/reset_emailed.html'}), url(r'^accounts/password/reset/(?P<uidb64>[0-9A-Za-z]+)/(?P<token>.+)/$', password_reset_confirm, {'post_reset_redirect': '/accounts/password/done/', 'template_name': 'zerver/reset_confirm.html', 'set_password_form': zerver.forms.LoggingSetPasswordForm}, name='django.contrib.auth.views.password_reset_confirm'), url(r'^accounts/password/done/$', password_reset_complete, {'template_name': 'zerver/reset_done.html'}), url(r'^accounts/deactivated/', zerver.views.auth.show_deactivation_notice, name='zerver.views.auth.show_deactivation_notice'), # Displays digest email content in browser. url(r'^digest/$', zerver.views.digest.digest_page), # Registration views, require a confirmation ID. url(r'^accounts/home/', zerver.views.registration.accounts_home, name='zerver.views.registration.accounts_home'), url(r'^accounts/send_confirm/(?P<email>[\S]+)?', TemplateView.as_view(template_name='zerver/accounts_send_confirm.html'), name='signup_send_confirm'), url(r'^accounts/new/send_confirm/(?P<email>[\S]+)?', TemplateView.as_view(template_name='zerver/accounts_send_confirm.html'), {'realm_creation': True}, name='new_realm_send_confirm'), url(r'^accounts/register/', zerver.views.registration.accounts_register, name='zerver.views.registration.accounts_register'), url(r'^accounts/do_confirm/(?P<confirmation_key>[\w]+)', zerver.views.registration.check_prereg_key_and_redirect, name='check_prereg_key_and_redirect'), url(r'^accounts/confirm_new_email/(?P<confirmation_key>[\w]+)', zerver.views.user_settings.confirm_email_change, name='zerver.views.user_settings.confirm_email_change'), # Email unsubscription endpoint. Allows for unsubscribing from various types of emails, # including the welcome emails (day 1 & 2), missed PMs, etc. url(r'^accounts/unsubscribe/(?P<email_type>[\w]+)/(?P<confirmation_key>[\w]+)', zerver.views.unsubscribe.email_unsubscribe, name='zerver.views.unsubscribe.email_unsubscribe'), # Portico-styled page used to provide email confirmation of terms acceptance. url(r'^accounts/accept_terms/$', zerver.views.home.accounts_accept_terms, name='zerver.views.home.accounts_accept_terms'), # Find your account url(r'^accounts/find/$', zerver.views.registration.find_account, name='zerver.views.registration.find_account'), # Go to organization subdomain url(r'^accounts/go/$', zerver.views.registration.realm_redirect, name='zerver.views.registration.realm_redirect'), # Realm Creation url(r'^new/$', zerver.views.registration.create_realm, name='zerver.views.create_realm'), url(r'^new/(?P<creation_key>[\w]+)$', zerver.views.registration.create_realm, name='zerver.views.create_realm'), # Realm Reactivation url(r'^reactivate/(?P<confirmation_key>[\w]+)', zerver.views.realm.realm_reactivation, name='zerver.views.realm.realm_reactivation'), # Global public streams (Zulip's way of doing archives) url(r'^archive/streams/(?P<stream_id>\d+)/topics/(?P<topic_name>[^/]+)$', zerver.views.archive.archive, name='zerver.views.archive.archive'), url(r'^archive/streams/(?P<stream_id>\d+)/topics$', zerver.views.archive.get_web_public_topics_backend, name='zerver.views.archive.get_web_public_topics_backend'), # Login/registration url(r'^register/$', zerver.views.registration.accounts_home, name='register'), url(r'^login/$', zerver.views.auth.login_page, {'template_name': 'zerver/login.html'}, name='zerver.views.auth.login_page'), url(r'^join/(?P<confirmation_key>\S+)/$', zerver.views.registration.accounts_home_from_multiuse_invite, name='zerver.views.registration.accounts_home_from_multiuse_invite'), # API and integrations documentation url(r'^integrations/doc-html/(?P<integration_name>[^/]*)$', zerver.views.documentation.integration_doc, name="zerver.views.documentation.integration_doc"), url(r'^integrations/(.*)', IntegrationView.as_view()), url(r'^team/$', zerver.views.users.team_view), url(r'^history/$', TemplateView.as_view(template_name='zerver/history.html')), url(r'^apps/(.*)', zerver.views.home.apps_view, name='zerver.views.home.apps_view'), url(r'^plans/$', zerver.views.home.plans_view, name='plans'), # Landing page, features pages, signup form, etc. url(r'^hello/$', TemplateView.as_view(template_name='zerver/hello.html', get_context_data=latest_info_context), name='landing-page'), url(r'^new-user/$', RedirectView.as_view(url='/hello', permanent=True)), url(r'^features/$', TemplateView.as_view(template_name='zerver/features.html')), url(r'^why-zulip/$', TemplateView.as_view(template_name='zerver/why-zulip.html')), url(r'^for/open-source/$', TemplateView.as_view(template_name='zerver/for-open-source.html')), url(r'^for/companies/$', TemplateView.as_view(template_name='zerver/for-companies.html')), url(r'^for/working-groups-and-communities/$', TemplateView.as_view(template_name='zerver/for-working-groups-and-communities.html')), url(r'^for/mystery-hunt/$', TemplateView.as_view(template_name='zerver/for-mystery-hunt.html')), url(r'^security/$', TemplateView.as_view(template_name='zerver/security.html')), url(r'^atlassian/$', TemplateView.as_view(template_name='zerver/atlassian.html')), # Terms of Service and privacy pages. url(r'^terms/$', TemplateView.as_view(template_name='zerver/terms.html'), name='terms'), url(r'^privacy/$', TemplateView.as_view(template_name='zerver/privacy.html'), name='privacy'), url(r'^config-error/google$', TemplateView.as_view( template_name='zerver/config_error.html',), {'google_error': True},), url(r'^config-error/github$', TemplateView.as_view( template_name='zerver/config_error.html',), {'github_error': True},), url(r'^config-error/smtp$', TemplateView.as_view( template_name='zerver/config_error.html',), {'smtp_error': True},), url(r'^config-error/ldap$', TemplateView.as_view( template_name='zerver/config_error.html',), {'ldap_error_realm_is_none': True}, name='ldap_error_realm_is_none'), url(r'^config-error/dev$', TemplateView.as_view( template_name='zerver/config_error.html',), {'dev_not_supported_error': True}, name='dev_not_supported'), ] # Make a copy of i18n_urls so that they appear without prefix for english urls = list(i18n_urls) # Include the dual-use patterns twice urls += [ url(r'^api/v1/', include(v1_api_and_json_patterns)), url(r'^json/', include(v1_api_and_json_patterns)), ] # user_uploads -> zerver.views.upload.serve_file_backend # # This url is an exception to the url naming schemes for endpoints. It # supports both API and session cookie authentication, using a single # URL for both (not 'api/v1/' or 'json/' prefix). This is required to # easily support the mobile apps fetching uploaded files without # having to rewrite URLs, and is implemented using the # 'override_api_url_scheme' flag passed to rest_dispatch urls += [ url(r'^user_uploads/(?P<realm_id_str>(\d*|unk))/(?P<filename>.*)', rest_dispatch, {'GET': ('zerver.views.upload.serve_file_backend', {'override_api_url_scheme'})}), # This endpoint serves thumbnailed versions of images using thumbor; # it requires an exception for the same reason. url(r'^thumbnail', rest_dispatch, {'GET': ('zerver.views.thumbnail.backend_serve_thumbnail', {'override_api_url_scheme'})}), # Avatars have the same constraint due to `!avatar` syntax. url(r'^avatar/(?P<email_or_id>[\S]+)/(?P<medium>[\S]+)?', rest_dispatch, {'GET': ('zerver.views.users.avatar', {'override_api_url_scheme'})}), url(r'^avatar/(?P<email_or_id>[\S]+)', rest_dispatch, {'GET': ('zerver.views.users.avatar', {'override_api_url_scheme'})}), ] # This url serves as a way to recieve CSP violation reports from the users. # We use this endpoint to just log these reports. urls += url(r'^report/csp_violations$', zerver.views.report.report_csp_violations, name='zerver.views.report.report_csp_violations'), # This url serves as a way to provide backward compatibility to messages # rendered at the time Zulip used camo for doing http -> https conversion for # such links with images previews. Now thumbor can be used for serving such # images. urls += url(r'^external_content/(?P<digest>[\S]+)/(?P<received_url>[\S]+)', zerver.views.camo.handle_camo_url, name='zerver.views.camo.handle_camo_url'), # Incoming webhook URLs # We don't create urls for particular git integrations here # because of generic one below for incoming_webhook in WEBHOOK_INTEGRATIONS: if incoming_webhook.url_object: urls.append(incoming_webhook.url_object) # Desktop-specific authentication URLs urls += [ url(r'^json/fetch_api_key$', rest_dispatch, {'POST': 'zerver.views.auth.json_fetch_api_key'}), ] # Mobile-specific authentication URLs urls += [ # This json format view used by the mobile apps lists which # authentication backends the server allows as well as details # like the requested subdomains'd realm icon (if known) and # server-specific compatibility. url(r'^api/v1/server_settings', zerver.views.auth.api_get_server_settings), # This is a deprecated old version of api/v1/server_settings that only returns auth backends. url(r'^api/v1/get_auth_backends', zerver.views.auth.api_get_auth_backends, name='zerver.views.auth.api_get_auth_backends'), # Used as a global check by all mobile clients, which currently send # requests to https://zulipchat.com/compatibility almost immediately after # starting up. url(r'^compatibility$', zerver.views.compatibility.check_global_compatibility), # This json format view used by the mobile apps accepts a username # password/pair and returns an API key. url(r'^api/v1/fetch_api_key$', zerver.views.auth.api_fetch_api_key, name='zerver.views.auth.api_fetch_api_key'), # This is for the signing in through the devAuthBackEnd on mobile apps. url(r'^api/v1/dev_fetch_api_key$', zerver.views.auth.api_dev_fetch_api_key, name='zerver.views.auth.api_dev_fetch_api_key'), # This is for fetching the emails of the admins and the users. url(r'^api/v1/dev_list_users$', zerver.views.auth.api_dev_list_users, name='zerver.views.auth.api_dev_list_users'), # Used to present the GOOGLE_CLIENT_ID to mobile apps url(r'^api/v1/fetch_google_client_id$', zerver.views.auth.api_fetch_google_client_id, name='zerver.views.auth.api_fetch_google_client_id'), ] # View for uploading messages from email mirror urls += [ url(r'^email_mirror_message$', zerver.views.email_mirror.email_mirror_message, name='zerver.views.email_mirror.email_mirror_message'), ] # Include URL configuration files for site-specified extra installed # Django apps for app_name in settings.EXTRA_INSTALLED_APPS: app_dir = os.path.join(settings.DEPLOY_ROOT, app_name) if os.path.exists(os.path.join(app_dir, 'urls.py')): urls += [url(r'^', include('%s.urls' % (app_name,)))] i18n_urls += import_string("{}.urls.i18n_urlpatterns".format(app_name)) # Tornado views urls += [ # Used internally for communication between Django and Tornado processes url(r'^notify_tornado$', zerver.tornado.views.notify, name='zerver.tornado.views.notify'), url(r'^api/v1/events/internal$', zerver.tornado.views.get_events_internal), ] # Python Social Auth urls += [url(r'^', include('social_django.urls', namespace='social'))] # User documentation site urls += [url(r'^help/(?P<article>.*)$', MarkdownDirectoryView.as_view(template_name='zerver/documentation_main.html', path_template='/zerver/help/%s.md'))] urls += [url(r'^api/(?P<article>[-\w]*\/?)$', MarkdownDirectoryView.as_view(template_name='zerver/documentation_main.html', path_template='/zerver/api/%s.md'))] # Two Factor urls if settings.TWO_FACTOR_AUTHENTICATION_ENABLED: urls += [url(r'', include(tf_urls)), url(r'', include(tf_twilio_urls))] if settings.DEVELOPMENT: urls += dev_urls.urls i18n_urls += dev_urls.i18n_urls # The sequence is important; if i18n urls don't come first then # reverse url mapping points to i18n urls which causes the frontend # tests to fail urlpatterns = i18n_patterns(*i18n_urls) + urls + legacy_urls def handler400(request: HttpRequest, exception: Exception) -> HttpResponse: # (This workaround should become obsolete with Django 2.1; the # issue was fixed upstream in commit 7ec0fdf62 on 2018-02-14.) # # This behaves exactly like the default Django implementation in # the case where you haven't made a template "400.html", which we # haven't -- except that it doesn't call `@requires_csrf_token` to # attempt to set a `csrf_token` variable that the template could # use if there were a template. We skip @requires_csrf_token # because that codepath can raise an error on a bad request, which # is exactly the case we're trying to handle when we get here. # Bug filed upstream: https://code.djangoproject.com/ticket/28693 # # This function is used just because it has this special name in # the root urls.py file; for more details, see: # https://docs.djangoproject.com/en/1.11/topics/http/views/#customizing-error-views return HttpResponseBadRequest( '<h1>Bad Request (400)</h1>', content_type='text/html')
apache-2.0
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 12, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 14, 73, 1085, 78, 492, 284, 1085, 78, 63, 7435, 199, 504, 1639, 14, 1014, 492, 6183, 12380, 12, 20730, 12, 6183, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 12, 18532, 2768, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 646, 747, 199, 646, 19959, 14, 3351, 199, 504, 1315, 1715, 492, 4866, 63, 3603, 199, 504, 1315, 1715, 14, 10000, 63, 3603, 492, 12139, 63, 3603, 199, 504, 19959, 14, 4196, 14, 9970, 492, 27561, 2768, 12, 24537, 6231, 2768, 199, 504, 19959, 14, 773, 14, 5707, 926, 852, 492, 644, 14138, 28706, 63, 2919, 37, 3975, 12969, 421, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 334, 2886, 12, 2505, 63, 3958, 63, 4456, 12, 4318, 2505, 63, 3958, 63, 9548, 12, 2505, 63, 3958, 63, 4883, 9, 199, 199, 646, 19959, 14, 18443, 14, 4196, 199, 646, 19959, 14, 4196, 199, 646, 19959, 14, 4196, 14, 1178, 199, 646, 19959, 14, 4196, 14, 6404, 199, 646, 19959, 14, 4196, 14, 67, 4393, 199, 646, 19959, 14, 4196, 14, 15390, 199, 646, 19959, 14, 4196, 14, 4219, 199, 646, 19959, 14, 4196, 14, 2123, 63, 12324, 199, 646, 19959, 14, 4196, 14, 8054, 199, 646, 19959, 14, 4196, 14, 806, 32248, 199, 646, 19959, 14, 4196, 14, 3707, 199, 646, 19959, 14, 4196, 14, 25592, 199, 646, 19959, 14, 4196, 14, 9970, 199, 646, 19959, 14, 4196, 14, 751, 63, 2634, 199, 646, 19959, 14, 4196, 14, 751, 63, 1751, 199, 646, 19959, 14, 4196, 14, 77, 4655, 199, 646, 19959, 14, 4196, 14, 11231, 199, 646, 19959, 14, 4196, 14, 7728, 199, 646, 19959, 14, 4196, 14, 5671, 199, 646, 19959, 14, 4196, 14, 3431, 199, 504, 19959, 14, 1100, 63, 10547, 492, 8839, 63, 815, 63, 1100, 199, 646, 19959, 14, 4196, 14, 3455, 63, 3790, 199, 199, 504, 19959, 14, 773, 14, 3911, 492, 4618, 63, 6052, 199, 199, 692, 2202, 14, 52, 11325, 63, 26393, 63, 29599, 63, 15704, 26, 272, 687, 2877, 63, 4778, 14, 3603, 492, 26177, 465, 2833, 63, 3603, 272, 687, 2877, 63, 4778, 14, 3237, 2885, 14, 8122, 23533, 14, 3603, 492, 26177, 465, 2833, 63, 8122, 23533, 63, 3603, 199, 199, 3, 25377, 26, 6006, 787, 9978, 1163, 10338, 402, 1233, 1314, 7475, 4145, 701, 2851, 26, 199, 3, 199, 3, 257, 446, 12139, 63, 3603, 14, 647, 3509, 3261, 6037, 5313, 2544, 314, 295, 14748, 199, 3, 258, 436, 1077, 440, 506, 3483, 370, 14, 199, 3, 199, 3, 257, 446, 519, 638, 8622, 14, 647, 965, 2399, 5705, 2851, 769, 367, 377, 8622, 6858, 14, 221, 1666, 314, 199, 3, 258, 19569, 402, 3330, 14, 5039, 315, 626, 570, 14, 199, 3, 199, 3, 257, 446, 710, 653, 19101, 1101, 19428, 1314, 10867, 370, 7475, 370, 5634, 503, 377, 8622, 14, 199, 3, 199, 3, 257, 446, 16485, 2605, 367, 314, 2257, 4866, 1654, 315, 7249, 15, 1065, 13, 2374, 14, 647, 14, 199, 199, 3, 5723, 16173, 950, 390, 938, 314, 5544, 19829, 3261, 334, 54, 17, 395, 1314, 4440, 26, 199, 3, 627, 14880, 809, 1533, 199, 3, 627, 10082, 1790, 334, 2473, 26, 2060, 365, 3031, 26, 1246, 1197, 9, 199, 3, 627, 18146, 436, 372, 2022, 13, 15317, 666, 199, 3, 199, 3, 982, 1265, 3984, 7791, 282, 892, 6037, 370, 314, 1233, 626, 5074, 6299, 12, 199, 3, 8749, 1050, 652, 2348, 14, 199, 3, 1666, 4618, 63, 6052, 315, 19959, 14, 773, 14, 3911, 367, 376, 17531, 402, 1790, 3102, 1202, 199, 3, 199, 3, 2900, 402, 3520, 3792, 787, 13810, 701, 1902, 282, 1182, 1001, 503, 1182, 1246, 15, 86, 17, 2403, 27, 199, 3, 325, 14, 71, 14, 658, 17073, 1182, 1001, 15, 7728, 64, 503, 658, 17073, 1182, 1246, 15, 86, 17, 15, 7728, 2313, 199, 86, 17, 63, 1246, 63, 460, 63, 1001, 63, 7435, 275, 359, 272, 327, 10482, 13, 1896, 4882, 272, 1166, 8, 82, 4289, 7728, 4268, 4618, 63, 6052, 12, 267, 791, 17073, 356, 283, 26996, 14, 4196, 14, 7728, 14, 873, 63, 7728, 1604, 339, 327, 1803, 282, 14785, 12, 1202, 701, 19763, 1145, 370, 4911, 20170, 2004, 272, 1166, 8, 82, 7, 4208, 63, 6686, 4268, 19959, 14, 4196, 14, 8054, 14, 4208, 63, 6686, 12, 267, 536, 534, 26996, 14, 4196, 14, 8054, 14, 4208, 63, 6686, 659, 339, 1166, 8, 82, 3984, 279, 77, 15, 22806, 9448, 48, 28, 22806, 3072, 51, 8771, 4268, 19959, 14, 4196, 14, 7728, 14, 1074, 63, 22806, 63, 4561, 12, 267, 536, 534, 26996, 14, 4196, 14, 7728, 14, 1074, 63, 22806, 63, 4561, 659, 339, 327, 10482, 15, 9756, 1035, 19959, 14, 4196, 14, 7728, 63, 9756, 272, 1166, 8, 82, 4289, 7728, 15, 9756, 4268, 4618, 63, 6052, 12, 267, 791, 2970, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 513, 63, 7728, 63, 9756, 297, 268, 283, 4030, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 981, 63, 7728, 63, 2261, 1604, 272, 1166, 8, 82, 4289, 7728, 15, 9756, 9448, 48, 28, 2261, 3072, 51, 8771, 4268, 4618, 63, 6052, 12, 267, 791, 17073, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 2068, 63, 7728, 63, 2261, 297, 268, 283, 7014, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 1807, 63, 7728, 63, 2261, 1604, 339, 327, 10482, 15, 26445, 1035, 19959, 14, 4196, 14, 7728, 63, 26445, 272, 1166, 8, 82, 4289, 7728, 15, 26445, 4268, 4618, 63, 6052, 12, 267, 791, 2970, 356, 283, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 513, 63, 26445, 1604, 272, 1166, 8, 82, 4289, 7728, 15, 26445, 9448, 48, 28, 26445, 63, 354, 26343, 4268, 4618, 63, 6052, 12, 267, 791, 4030, 356, 283, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 5064, 63, 26445, 297, 268, 283, 7014, 356, 661, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 1807, 63, 26445, 297, 2420, 262, 9553, 1183, 63, 30107, 12546 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 12, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 14, 73, 1085, 78, 492, 284, 1085, 78, 63, 7435, 199, 504, 1639, 14, 1014, 492, 6183, 12380, 12, 20730, 12, 6183, 199, 504, 1639, 14, 4196, 14, 6767, 492, 5458, 2768, 12, 18532, 2768, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 875, 199, 646, 747, 199, 646, 19959, 14, 3351, 199, 504, 1315, 1715, 492, 4866, 63, 3603, 199, 504, 1315, 1715, 14, 10000, 63, 3603, 492, 12139, 63, 3603, 199, 504, 19959, 14, 4196, 14, 9970, 492, 27561, 2768, 12, 24537, 6231, 2768, 199, 504, 19959, 14, 773, 14, 5707, 926, 852, 492, 644, 14138, 28706, 63, 2919, 37, 3975, 12969, 421, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 334, 2886, 12, 2505, 63, 3958, 63, 4456, 12, 4318, 2505, 63, 3958, 63, 9548, 12, 2505, 63, 3958, 63, 4883, 9, 199, 199, 646, 19959, 14, 18443, 14, 4196, 199, 646, 19959, 14, 4196, 199, 646, 19959, 14, 4196, 14, 1178, 199, 646, 19959, 14, 4196, 14, 6404, 199, 646, 19959, 14, 4196, 14, 67, 4393, 199, 646, 19959, 14, 4196, 14, 15390, 199, 646, 19959, 14, 4196, 14, 4219, 199, 646, 19959, 14, 4196, 14, 2123, 63, 12324, 199, 646, 19959, 14, 4196, 14, 8054, 199, 646, 19959, 14, 4196, 14, 806, 32248, 199, 646, 19959, 14, 4196, 14, 3707, 199, 646, 19959, 14, 4196, 14, 25592, 199, 646, 19959, 14, 4196, 14, 9970, 199, 646, 19959, 14, 4196, 14, 751, 63, 2634, 199, 646, 19959, 14, 4196, 14, 751, 63, 1751, 199, 646, 19959, 14, 4196, 14, 77, 4655, 199, 646, 19959, 14, 4196, 14, 11231, 199, 646, 19959, 14, 4196, 14, 7728, 199, 646, 19959, 14, 4196, 14, 5671, 199, 646, 19959, 14, 4196, 14, 3431, 199, 504, 19959, 14, 1100, 63, 10547, 492, 8839, 63, 815, 63, 1100, 199, 646, 19959, 14, 4196, 14, 3455, 63, 3790, 199, 199, 504, 19959, 14, 773, 14, 3911, 492, 4618, 63, 6052, 199, 199, 692, 2202, 14, 52, 11325, 63, 26393, 63, 29599, 63, 15704, 26, 272, 687, 2877, 63, 4778, 14, 3603, 492, 26177, 465, 2833, 63, 3603, 272, 687, 2877, 63, 4778, 14, 3237, 2885, 14, 8122, 23533, 14, 3603, 492, 26177, 465, 2833, 63, 8122, 23533, 63, 3603, 199, 199, 3, 25377, 26, 6006, 787, 9978, 1163, 10338, 402, 1233, 1314, 7475, 4145, 701, 2851, 26, 199, 3, 199, 3, 257, 446, 12139, 63, 3603, 14, 647, 3509, 3261, 6037, 5313, 2544, 314, 295, 14748, 199, 3, 258, 436, 1077, 440, 506, 3483, 370, 14, 199, 3, 199, 3, 257, 446, 519, 638, 8622, 14, 647, 965, 2399, 5705, 2851, 769, 367, 377, 8622, 6858, 14, 221, 1666, 314, 199, 3, 258, 19569, 402, 3330, 14, 5039, 315, 626, 570, 14, 199, 3, 199, 3, 257, 446, 710, 653, 19101, 1101, 19428, 1314, 10867, 370, 7475, 370, 5634, 503, 377, 8622, 14, 199, 3, 199, 3, 257, 446, 16485, 2605, 367, 314, 2257, 4866, 1654, 315, 7249, 15, 1065, 13, 2374, 14, 647, 14, 199, 199, 3, 5723, 16173, 950, 390, 938, 314, 5544, 19829, 3261, 334, 54, 17, 395, 1314, 4440, 26, 199, 3, 627, 14880, 809, 1533, 199, 3, 627, 10082, 1790, 334, 2473, 26, 2060, 365, 3031, 26, 1246, 1197, 9, 199, 3, 627, 18146, 436, 372, 2022, 13, 15317, 666, 199, 3, 199, 3, 982, 1265, 3984, 7791, 282, 892, 6037, 370, 314, 1233, 626, 5074, 6299, 12, 199, 3, 8749, 1050, 652, 2348, 14, 199, 3, 1666, 4618, 63, 6052, 315, 19959, 14, 773, 14, 3911, 367, 376, 17531, 402, 1790, 3102, 1202, 199, 3, 199, 3, 2900, 402, 3520, 3792, 787, 13810, 701, 1902, 282, 1182, 1001, 503, 1182, 1246, 15, 86, 17, 2403, 27, 199, 3, 325, 14, 71, 14, 658, 17073, 1182, 1001, 15, 7728, 64, 503, 658, 17073, 1182, 1246, 15, 86, 17, 15, 7728, 2313, 199, 86, 17, 63, 1246, 63, 460, 63, 1001, 63, 7435, 275, 359, 272, 327, 10482, 13, 1896, 4882, 272, 1166, 8, 82, 4289, 7728, 4268, 4618, 63, 6052, 12, 267, 791, 17073, 356, 283, 26996, 14, 4196, 14, 7728, 14, 873, 63, 7728, 1604, 339, 327, 1803, 282, 14785, 12, 1202, 701, 19763, 1145, 370, 4911, 20170, 2004, 272, 1166, 8, 82, 7, 4208, 63, 6686, 4268, 19959, 14, 4196, 14, 8054, 14, 4208, 63, 6686, 12, 267, 536, 534, 26996, 14, 4196, 14, 8054, 14, 4208, 63, 6686, 659, 339, 1166, 8, 82, 3984, 279, 77, 15, 22806, 9448, 48, 28, 22806, 3072, 51, 8771, 4268, 19959, 14, 4196, 14, 7728, 14, 1074, 63, 22806, 63, 4561, 12, 267, 536, 534, 26996, 14, 4196, 14, 7728, 14, 1074, 63, 22806, 63, 4561, 659, 339, 327, 10482, 15, 9756, 1035, 19959, 14, 4196, 14, 7728, 63, 9756, 272, 1166, 8, 82, 4289, 7728, 15, 9756, 4268, 4618, 63, 6052, 12, 267, 791, 2970, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 513, 63, 7728, 63, 9756, 297, 268, 283, 4030, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 981, 63, 7728, 63, 2261, 1604, 272, 1166, 8, 82, 4289, 7728, 15, 9756, 9448, 48, 28, 2261, 3072, 51, 8771, 4268, 4618, 63, 6052, 12, 267, 791, 17073, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 2068, 63, 7728, 63, 2261, 297, 268, 283, 7014, 356, 283, 26996, 14, 4196, 14, 7728, 63, 9756, 14, 1807, 63, 7728, 63, 2261, 1604, 339, 327, 10482, 15, 26445, 1035, 19959, 14, 4196, 14, 7728, 63, 26445, 272, 1166, 8, 82, 4289, 7728, 15, 26445, 4268, 4618, 63, 6052, 12, 267, 791, 2970, 356, 283, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 513, 63, 26445, 1604, 272, 1166, 8, 82, 4289, 7728, 15, 26445, 9448, 48, 28, 26445, 63, 354, 26343, 4268, 4618, 63, 6052, 12, 267, 791, 4030, 356, 283, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 5064, 63, 26445, 297, 268, 283, 7014, 356, 661, 26996, 14, 4196, 14, 7728, 63, 26445, 14, 1807, 63, 26445, 297, 2420, 262, 9553, 1183, 63, 30107, 12546, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
omprakasha/odoo
addons/l10n_multilang/__openerp__.py
339
1670
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Multi Language Chart of Accounts', 'version': '1.1', 'author': 'OpenERP SA', 'category': 'Hidden/Dependency', 'description': """ * Multi language support for Chart of Accounts, Taxes, Tax Codes, Journals, Accounting Templates, Analytic Chart of Accounts and Analytic Journals. * Setup wizard changes - Copy translations for COA, Tax, Tax Code and Fiscal Position from templates to target objects. """, 'website': 'http://www.openerp.com', 'depends' : ['account'], 'data': [], 'demo': [], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 3947, 8466, 24874, 402, 4473, 6851, 297, 272, 283, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 14983, 15, 14403, 297, 272, 283, 1802, 356, 408, 272, 627, 6879, 2637, 2291, 367, 24874, 402, 4473, 6851, 12, 377, 6402, 12, 30174, 5495, 83, 12, 7135, 31212, 12, 489, 9973, 316, 31273, 12, 14279, 764, 24874, 402, 4473, 6851, 436, 14279, 764, 7135, 31212, 14, 272, 627, 12439, 12262, 4493, 267, 446, 11247, 15547, 367, 5099, 33, 12, 30174, 12, 30174, 5495, 436, 481, 15734, 15483, 687, 881, 7009, 370, 1347, 2251, 14, 272, 10327, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 8912, 7, 520, 788, 2048, 995, 272, 283, 576, 356, 990, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 3947, 8466, 24874, 402, 4473, 6851, 297, 272, 283, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 14983, 15, 14403, 297, 272, 283, 1802, 356, 408, 272, 627, 6879, 2637, 2291, 367, 24874, 402, 4473, 6851, 12, 377, 6402, 12, 30174, 5495, 83, 12, 7135, 31212, 12, 489, 9973, 316, 31273, 12, 14279, 764, 24874, 402, 4473, 6851, 436, 14279, 764, 7135, 31212, 14, 272, 627, 12439, 12262, 4493, 267, 446, 11247, 15547, 367, 5099, 33, 12, 30174, 12, 30174, 5495, 436, 481, 15734, 15483, 687, 881, 7009, 370, 1347, 2251, 14, 272, 10327, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 8912, 7, 520, 788, 2048, 995, 272, 283, 576, 356, 990, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ilya-epifanov/ansible-modules-core
utilities/helper/accelerate.py
90
27254
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2013, James Cammarata <jcammarata@ansible.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: accelerate short_description: Enable accelerated mode on remote node description: - This modules launches an ephemeral I(accelerate) daemon on the remote node which Ansible can use to communicate with nodes at high speed. - The daemon listens on a configurable port for a configurable amount of time. - Fireball mode is AES encrypted version_added: "1.3" options: port: description: - TCP port for the socket connection required: false default: 5099 aliases: [] timeout: description: - The number of seconds the socket will wait for data. If none is received when the timeout value is reached, the connection will be closed. required: false default: 300 aliases: [] minutes: description: - The I(accelerate) listener daemon is started on nodes and will stay around for this number of minutes before turning itself off. required: false default: 30 ipv6: description: - The listener daemon on the remote host will bind to the ipv6 localhost socket if this parameter is set to true. required: false default: false multi_key: description: - When enabled, the daemon will open a local socket file which can be used by future daemon executions to upload a new key to the already running daemon, so that multiple users can connect using different keys. This access still requires an ssh connection as the uid for which the daemon is currently running. required: false default: no version_added: "1.6" notes: - See the advanced playbooks chapter for more about using accelerated mode. requirements: - "python >= 2.6" - "python-keyczar" author: "James Cammarata (@jimi-c)" ''' EXAMPLES = ''' # To use accelerate mode, simply add "accelerate: true" to your play. The initial # key exchange and starting up of the daemon will occur over SSH, but all commands and # subsequent actions will be conducted over the raw socket connection using AES encryption - hosts: devservers accelerate: true tasks: - command: /usr/bin/anything ''' import base64 import errno import getpass import json import os import os.path import pwd import signal import socket import struct import sys import syslog import tempfile import time import traceback import SocketServer from datetime import datetime from threading import Thread, Lock # import module snippets # we must import this here at the top so we can use get_module_path() from ansible.module_utils.basic import * syslog.openlog('ansible-%s' % os.path.basename(__file__)) # the chunk size to read and send, assuming mtu 1500 and # leaving room for base64 (+33%) encoding and header (100 bytes) # 4 * (975/3) + 100 = 1400 # which leaves room for the TCP/IP header CHUNK_SIZE=10240 # FIXME: this all should be moved to module_common, as it's # pretty much a copy from the callbacks/util code DEBUG_LEVEL=0 def log(msg, cap=0): global DEBUG_LEVEL if DEBUG_LEVEL >= cap: syslog.syslog(syslog.LOG_NOTICE|syslog.LOG_DAEMON, msg) def v(msg): log(msg, cap=1) def vv(msg): log(msg, cap=2) def vvv(msg): log(msg, cap=3) def vvvv(msg): log(msg, cap=4) HAS_KEYCZAR = False try: from keyczar.keys import AesKey HAS_KEYCZAR = True except ImportError: pass SOCKET_FILE = os.path.join(get_module_path(), '.ansible-accelerate', ".local.socket") def get_pid_location(module): """ Try to find a pid directory in the common locations, falling back to the user's home directory if no others exist """ for dir in ['/var/run', '/var/lib/run', '/run', os.path.expanduser("~/")]: try: if os.path.isdir(dir) and os.access(dir, os.R_OK|os.W_OK): return os.path.join(dir, '.accelerate.pid') except: pass module.fail_json(msg="couldn't find any valid directory to use for the accelerate pid file") # NOTE: this shares a fair amount of code in common with async_wrapper, if async_wrapper were a new module we could move # this into utils.module_common and probably should anyway def daemonize_self(module, password, port, minutes, pid_file): # daemonizing code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 try: pid = os.fork() if pid > 0: vvv("exiting pid %s" % pid) # exit first parent module.exit_json(msg="daemonized accelerate on port %s for %s minutes with pid %s" % (port, minutes, str(pid))) except OSError, e: log("fork #1 failed: %d (%s)" % (e.errno, e.strerror)) sys.exit(1) # decouple from parent environment os.chdir("/") os.setsid() os.umask(022) # do second fork try: pid = os.fork() if pid > 0: log("daemon pid %s, writing %s" % (pid, pid_file)) pid_file = open(pid_file, "w") pid_file.write("%s" % pid) pid_file.close() vvv("pid file written") sys.exit(0) except OSError, e: log("fork #2 failed: %d (%s)" % (e.errno, e.strerror)) sys.exit(1) dev_null = file('/dev/null','rw') os.dup2(dev_null.fileno(), sys.stdin.fileno()) os.dup2(dev_null.fileno(), sys.stdout.fileno()) os.dup2(dev_null.fileno(), sys.stderr.fileno()) log("daemonizing successful") class LocalSocketThread(Thread): server = None terminated = False def __init__(self, group=None, target=None, name=None, args=(), kwargs={}, Verbose=None): self.server = kwargs.get('server') Thread.__init__(self, group, target, name, args, kwargs, Verbose) def run(self): try: if os.path.exists(SOCKET_FILE): os.remove(SOCKET_FILE) else: dir = os.path.dirname(SOCKET_FILE) if os.path.exists(dir): if not os.path.isdir(dir): log("The socket file path (%s) exists, but is not a directory. No local connections will be available" % dir) return else: # make sure the directory is accessible only to this # user, as socket files derive their permissions from # the directory that contains them os.chmod(dir, 0700) elif not os.path.exists(dir): os.makedirs(dir, 0700) except OSError: pass self.s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.s.bind(SOCKET_FILE) self.s.listen(5) while not self.terminated: try: conn, addr = self.s.accept() vv("received local connection") data = "" while "\n" not in data: data += conn.recv(2048) try: try: new_key = AesKey.Read(data.strip()) found = False for key in self.server.key_list: try: new_key.Decrypt(key.Encrypt("foo")) found = True break except: pass if not found: vv("adding new key to the key list") self.server.key_list.append(new_key) conn.sendall("OK\n") else: vv("key already exists in the key list, ignoring") conn.sendall("EXISTS\n") # update the last event time so the server doesn't # shutdown sooner than expected for new cliets try: self.server.last_event_lock.acquire() self.server.last_event = datetime.now() finally: self.server.last_event_lock.release() except Exception, e: vv("key loaded locally was invalid, ignoring (%s)" % e) conn.sendall("BADKEY\n") finally: try: conn.close() except: pass except: pass def terminate(self): self.terminated = True self.s.shutdown(socket.SHUT_RDWR) self.s.close() class ThreadWithReturnValue(Thread): def __init__(self, group=None, target=None, name=None, args=(), kwargs={}, Verbose=None): Thread.__init__(self, group, target, name, args, kwargs, Verbose) self._return = None def run(self): if self._Thread__target is not None: self._return = self._Thread__target(*self._Thread__args, **self._Thread__kwargs) def join(self,timeout=None): Thread.join(self, timeout=timeout) return self._return class ThreadedTCPServer(SocketServer.ThreadingTCPServer): key_list = [] last_event = datetime.now() last_event_lock = Lock() def __init__(self, server_address, RequestHandlerClass, module, password, timeout, use_ipv6=False): self.module = module self.key_list.append(AesKey.Read(password)) self.allow_reuse_address = True self.timeout = timeout if use_ipv6: self.address_family = socket.AF_INET6 if self.module.params.get('multi_key', False): vv("starting thread to handle local connections for multiple keys") self.local_thread = LocalSocketThread(kwargs=dict(server=self)) self.local_thread.start() SocketServer.ThreadingTCPServer.__init__(self, server_address, RequestHandlerClass) def shutdown(self): self.local_thread.terminate() self.running = False SocketServer.ThreadingTCPServer.shutdown(self) class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): # the key to use for this connection active_key = None def send_data(self, data): try: self.server.last_event_lock.acquire() self.server.last_event = datetime.now() finally: self.server.last_event_lock.release() packed_len = struct.pack('!Q', len(data)) return self.request.sendall(packed_len + data) def recv_data(self): header_len = 8 # size of a packed unsigned long long data = "" vvvv("in recv_data(), waiting for the header") while len(data) < header_len: try: d = self.request.recv(header_len - len(data)) if not d: vvv("received nothing, bailing out") return None data += d except: # probably got a connection reset vvvv("exception received while waiting for recv(), returning None") return None vvvv("in recv_data(), got the header, unpacking") data_len = struct.unpack('!Q',data[:header_len])[0] data = data[header_len:] vvvv("data received so far (expecting %d): %d" % (data_len,len(data))) while len(data) < data_len: try: d = self.request.recv(data_len - len(data)) if not d: vvv("received nothing, bailing out") return None data += d vvvv("data received so far (expecting %d): %d" % (data_len,len(data))) except: # probably got a connection reset vvvv("exception received while waiting for recv(), returning None") return None vvvv("received all of the data, returning") try: self.server.last_event_lock.acquire() self.server.last_event = datetime.now() finally: self.server.last_event_lock.release() return data def handle(self): try: while True: vvvv("waiting for data") data = self.recv_data() if not data: vvvv("received nothing back from recv_data(), breaking out") break vvvv("got data, decrypting") if not self.active_key: for key in self.server.key_list: try: data = key.Decrypt(data) self.active_key = key break except: pass else: vv("bad decrypt, exiting the connection handler") return else: try: data = self.active_key.Decrypt(data) except: vv("bad decrypt, exiting the connection handler") return vvvv("decryption done, loading json from the data") data = json.loads(data) mode = data['mode'] response = {} last_pong = datetime.now() if mode == 'command': vvvv("received a command request, running it") twrv = ThreadWithReturnValue(target=self.command, args=(data,)) twrv.start() response = None while twrv.is_alive(): if (datetime.now() - last_pong).seconds >= 15: last_pong = datetime.now() vvvv("command still running, sending keepalive packet") data2 = json.dumps(dict(pong=True)) data2 = self.active_key.Encrypt(data2) self.send_data(data2) time.sleep(0.1) response = twrv._return vvvv("thread is done, response from join was %s" % response) elif mode == 'put': vvvv("received a put request, putting it") response = self.put(data) elif mode == 'fetch': vvvv("received a fetch request, getting it") response = self.fetch(data) elif mode == 'validate_user': vvvv("received a request to validate the user id") response = self.validate_user(data) vvvv("response result is %s" % str(response)) json_response = json.dumps(response) vvvv("dumped json is %s" % json_response) data2 = self.active_key.Encrypt(json_response) vvvv("sending the response back to the controller") self.send_data(data2) vvvv("done sending the response") if mode == 'validate_user' and response.get('rc') == 1: vvvv("detected a uid mismatch, shutting down") self.server.shutdown() except: tb = traceback.format_exc() log("encountered an unhandled exception in the handle() function") log("error was:\n%s" % tb) if self.active_key: data2 = json.dumps(dict(rc=1, failed=True, msg="unhandled error in the handle() function")) data2 = self.active_key.Encrypt(data2) self.send_data(data2) def validate_user(self, data): if 'username' not in data: return dict(failed=True, msg='No username specified') vvvv("validating we're running as %s" % data['username']) # get the current uid c_uid = os.getuid() try: # the target uid t_uid = pwd.getpwnam(data['username']).pw_uid except: vvvv("could not find user %s" % data['username']) return dict(failed=True, msg='could not find user %s' % data['username']) # and return rc=0 for success, rc=1 for failure if c_uid == t_uid: return dict(rc=0) else: return dict(rc=1) def command(self, data): if 'cmd' not in data: return dict(failed=True, msg='internal error: cmd is required') if 'tmp_path' not in data: return dict(failed=True, msg='internal error: tmp_path is required') vvvv("executing: %s" % data['cmd']) use_unsafe_shell = False executable = data.get('executable') if executable: use_unsafe_shell = True rc, stdout, stderr = self.server.module.run_command(data['cmd'], executable=executable, use_unsafe_shell=use_unsafe_shell, close_fds=True) if stdout is None: stdout = '' if stderr is None: stderr = '' vvvv("got stdout: %s" % stdout) vvvv("got stderr: %s" % stderr) return dict(rc=rc, stdout=stdout, stderr=stderr) def fetch(self, data): if 'in_path' not in data: return dict(failed=True, msg='internal error: in_path is required') try: fd = file(data['in_path'], 'rb') fstat = os.stat(data['in_path']) vvv("FETCH file is %d bytes" % fstat.st_size) while fd.tell() < fstat.st_size: data = fd.read(CHUNK_SIZE) last = False if fd.tell() >= fstat.st_size: last = True data = dict(data=base64.b64encode(data), last=last) data = json.dumps(data) data = self.active_key.Encrypt(data) if self.send_data(data): return dict(failed=True, stderr="failed to send data") response = self.recv_data() if not response: log("failed to get a response, aborting") return dict(failed=True, stderr="Failed to get a response from %s" % self.host) response = self.active_key.Decrypt(response) response = json.loads(response) if response.get('failed',False): log("got a failed response from the master") return dict(failed=True, stderr="Master reported failure, aborting transfer") except Exception, e: fd.close() tb = traceback.format_exc() log("failed to fetch the file: %s" % tb) return dict(failed=True, stderr="Could not fetch the file: %s" % str(e)) fd.close() return dict() def put(self, data): if 'data' not in data: return dict(failed=True, msg='internal error: data is required') if 'out_path' not in data: return dict(failed=True, msg='internal error: out_path is required') final_path = None if 'user' in data and data.get('user') != getpass.getuser(): vvv("the target user doesn't match this user, we'll move the file into place via sudo") tmp_path = os.path.expanduser('~/.ansible/tmp/') if not os.path.exists(tmp_path): try: os.makedirs(tmp_path, 0700) except: return dict(failed=True, msg='could not create a temporary directory at %s' % tmp_path) (fd,out_path) = tempfile.mkstemp(prefix='ansible.', dir=tmp_path) out_fd = os.fdopen(fd, 'w', 0) final_path = data['out_path'] else: out_path = data['out_path'] out_fd = open(out_path, 'w') try: bytes=0 while True: out = base64.b64decode(data['data']) bytes += len(out) out_fd.write(out) response = json.dumps(dict()) response = self.active_key.Encrypt(response) self.send_data(response) if data['last']: break data = self.recv_data() if not data: raise "" data = self.active_key.Decrypt(data) data = json.loads(data) except: out_fd.close() tb = traceback.format_exc() log("failed to put the file: %s" % tb) return dict(failed=True, stdout="Could not write the file") vvvv("wrote %d bytes" % bytes) out_fd.close() if final_path: vvv("moving %s to %s" % (out_path, final_path)) self.server.module.atomic_move(out_path, final_path) return dict() def daemonize(module, password, port, timeout, minutes, use_ipv6, pid_file): try: daemonize_self(module, password, port, minutes, pid_file) def timer_handler(signum, _): try: try: server.last_event_lock.acquire() td = datetime.now() - server.last_event # older python timedelta objects don't have total_seconds(), # so we use the formula from the docs to calculate it total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 if total_seconds >= minutes * 60: log("server has been idle longer than the timeout, shutting down") server.running = False server.shutdown() else: # reschedule the check vvvv("daemon idle for %d seconds (timeout=%d)" % (total_seconds,minutes*60)) signal.alarm(30) except: pass finally: server.last_event_lock.release() signal.signal(signal.SIGALRM, timer_handler) signal.alarm(30) tries = 5 while tries > 0: try: if use_ipv6: address = ("::", port) else: address = ("0.0.0.0", port) server = ThreadedTCPServer(address, ThreadedTCPRequestHandler, module, password, timeout, use_ipv6=use_ipv6) server.allow_reuse_address = True break except Exception, e: vv("Failed to create the TCP server (tries left = %d) (error: %s) " % (tries,e)) tries -= 1 time.sleep(0.2) if tries == 0: vv("Maximum number of attempts to create the TCP server reached, bailing out") raise Exception("max # of attempts to serve reached") # run the server in a separate thread to make signal handling work server_thread = Thread(target=server.serve_forever, kwargs=dict(poll_interval=0.1)) server_thread.start() server.running = True v("serving!") while server.running: time.sleep(1) # wait for the thread to exit fully server_thread.join() v("server thread terminated, exiting!") sys.exit(0) except Exception, e: tb = traceback.format_exc() log("exception caught, exiting accelerated mode: %s\n%s" % (e, tb)) sys.exit(0) def main(): global DEBUG_LEVEL module = AnsibleModule( argument_spec = dict( port=dict(required=False, default=5099), ipv6=dict(required=False, default=False, type='bool'), multi_key=dict(required=False, default=False, type='bool'), timeout=dict(required=False, default=300), password=dict(required=True), minutes=dict(required=False, default=30), debug=dict(required=False, default=0, type='int') ), supports_check_mode=True ) password = base64.b64decode(module.params['password']) port = int(module.params['port']) timeout = int(module.params['timeout']) minutes = int(module.params['minutes']) debug = int(module.params['debug']) ipv6 = module.params['ipv6'] multi_key = module.params['multi_key'] if not HAS_KEYCZAR: module.fail_json(msg="keyczar is not installed (on the remote side)") DEBUG_LEVEL=debug pid_file = get_pid_location(module) daemon_pid = None daemon_running = False if os.path.exists(pid_file): try: daemon_pid = int(open(pid_file).read()) try: # sending signal 0 doesn't do anything to the # process, other than tell the calling program # whether other signals can be sent os.kill(daemon_pid, 0) except OSError, e: if e.errno == errno.EPERM: # no permissions means the pid is probably # running, but as a different user, so fail module.fail_json(msg="the accelerate daemon appears to be running as a different user that this user cannot access (pid=%d)" % daemon_pid) else: daemon_running = True except ValueError: # invalid pid file, unlink it - otherwise we don't care try: os.unlink(pid_file) except: pass if daemon_running and multi_key: # try to connect to the file socket for the daemon if it exists s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: try: s.connect(SOCKET_FILE) s.sendall(password + '\n') data = "" while '\n' not in data: data += s.recv(2048) res = data.strip() except: module.fail_json(msg="failed to connect to the local socket file") finally: try: s.close() except: pass if res in ("OK", "EXISTS"): module.exit_json(msg="transferred new key to the existing daemon") else: module.fail_json(msg="could not transfer new key: %s" % data.strip()) else: # try to start up the daemon daemonize(module, password, port, timeout, minutes, ipv6, pid_file) main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 1603, 14015, 445, 455, 4584, 419, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1066, 11338, 323, 199, 3612, 63, 1802, 26, 12030, 1066, 15730, 818, 641, 3982, 1031, 199, 1802, 26, 1362, 446, 961, 4621, 10623, 397, 376, 26288, 473, 8, 645, 11338, 323, 9, 11128, 641, 314, 3982, 1031, 1314, 2126, 2622, 883, 675, 370, 26808, 543, 3380, 737, 4721, 8112, 14, 1362, 446, 710, 11128, 1212, 1597, 561, 641, 282, 30241, 1844, 367, 282, 30241, 5982, 402, 900, 14, 1362, 446, 15967, 8571, 818, 365, 19093, 14862, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 1419, 26, 523, 1844, 26, 272, 1369, 26, 489, 446, 13488, 1844, 367, 314, 2838, 1950, 272, 1415, 26, 3055, 272, 849, 26, 5238, 1020, 272, 5481, 26, 942, 523, 2653, 26, 272, 1369, 26, 489, 446, 710, 1329, 402, 4696, 314, 2838, 911, 3618, 367, 666, 14, 982, 7179, 365, 3086, 1380, 314, 2653, 574, 365, 13075, 12, 314, 1950, 911, 506, 6876, 14, 272, 1415, 26, 3055, 272, 849, 26, 9601, 272, 5481, 26, 942, 523, 9395, 26, 272, 1369, 26, 489, 446, 710, 473, 8, 645, 11338, 323, 9, 11647, 11128, 365, 8239, 641, 3380, 436, 911, 25578, 6818, 367, 267, 642, 1329, 402, 9395, 2544, 7485, 316, 6337, 2331, 14, 272, 1415, 26, 3055, 272, 849, 26, 4233, 523, 3278, 22, 26, 272, 1369, 26, 489, 446, 710, 11647, 11128, 641, 314, 3982, 1591, 911, 5398, 370, 314, 3278, 22, 11667, 2838, 267, 340, 642, 2725, 365, 663, 370, 2549, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 523, 3510, 63, 498, 26, 272, 1369, 26, 489, 446, 3979, 5223, 12, 314, 11128, 911, 1551, 282, 2257, 2838, 570, 1314, 883, 506, 1202, 701, 6466, 11128, 2146, 8653, 370, 4960, 5802, 282, 892, 790, 370, 314, 2575, 3879, 11128, 12, 880, 626, 3663, 4390, 883, 4907, 1808, 3365, 2883, 14, 267, 961, 2879, 5139, 5074, 376, 8635, 1950, 465, 314, 1747, 367, 1314, 314, 11128, 365, 5544, 3879, 14, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 5983, 26, 272, 446, 1666, 314, 19472, 5232, 8858, 17044, 367, 1655, 3595, 1808, 1066, 15730, 818, 14, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 1548, 13, 498, 16823, 285, 2, 199, 2502, 26, 298, 42, 14015, 445, 455, 4584, 419, 8593, 74, 1017, 73, 13, 67, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 4005, 675, 1066, 11338, 323, 818, 12, 9329, 1050, 298, 645, 11338, 323, 26, 2549, 2, 370, 2195, 5232, 14, 710, 2536, 199, 3, 790, 15343, 436, 6617, 1536, 402, 314, 11128, 911, 4781, 1806, 12027, 12, 1325, 1006, 3718, 436, 199, 3, 13372, 5445, 911, 506, 406, 5905, 471, 1806, 314, 3066, 2838, 1950, 1808, 19093, 14396, 199, 199, 13, 7057, 26, 4866, 5871, 523, 1066, 11338, 323, 26, 2549, 523, 6527, 26, 489, 446, 1414, 26, 1182, 2647, 15, 1393, 15, 25058, 199, 2344, 199, 199, 646, 1300, 772, 199, 646, 7554, 199, 646, 18354, 199, 646, 2022, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 14374, 199, 646, 4673, 199, 646, 2838, 199, 646, 2702, 199, 646, 984, 199, 646, 22112, 199, 646, 5549, 199, 646, 900, 199, 646, 5190, 199, 199, 646, 17766, 3120, 199, 199, 504, 2197, 492, 2197, 199, 504, 5796, 492, 11086, 12, 15536, 199, 199, 3, 492, 859, 19484, 199, 3, 781, 1471, 492, 642, 2348, 737, 314, 2746, 880, 781, 883, 675, 664, 63, 578, 63, 515, 342, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 16878, 14, 1490, 793, 360, 4853, 3295, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 8964, 199, 199, 3, 314, 3728, 1568, 370, 1586, 436, 3222, 12, 18002, 28270, 24970, 436, 221, 199, 3, 23188, 14726, 367, 1300, 772, 334, 11, 1153, 5, 9, 2644, 436, 1406, 334, 1960, 2783, 9, 199, 3, 841, 627, 334, 28947, 15, 19, 9, 435, 2948, 275, 4329, 383, 221, 199, 3, 1314, 16733, 14726, 367, 314, 13488, 15, 1772, 1406, 199, 20512, 63, 4305, 29, 7727, 16, 199, 199, 3, 7600, 26, 642, 1006, 1077, 506, 12155, 370, 859, 63, 2330, 12, 465, 652, 1159, 221, 199, 3, 263, 7268, 8298, 282, 1331, 687, 314, 13484, 15, 1974, 1233, 199, 5287, 63, 11817, 29, 16, 199, 318, 943, 8, 1328, 12, 4021, 29, 16, 304, 272, 2288, 10990, 63, 11817, 272, 340, 10990, 63, 11817, 2356, 4021, 26, 267, 22112, 14, 16878, 8, 16878, 14, 4947, 63, 4609, 4047, 92, 16878, 14, 4947, 63, 8980, 2769, 615, 12, 1499, 9, 199, 199, 318, 373, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 17, 9, 199, 199, 318, 373, 86, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 18, 9, 199, 199, 318, 373, 8958, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 19, 9, 199 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 1603, 14015, 445, 455, 4584, 419, 665, 74, 15176, 4584, 419, 32, 4853, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1066, 11338, 323, 199, 3612, 63, 1802, 26, 12030, 1066, 15730, 818, 641, 3982, 1031, 199, 1802, 26, 1362, 446, 961, 4621, 10623, 397, 376, 26288, 473, 8, 645, 11338, 323, 9, 11128, 641, 314, 3982, 1031, 1314, 2126, 2622, 883, 675, 370, 26808, 543, 3380, 737, 4721, 8112, 14, 1362, 446, 710, 11128, 1212, 1597, 561, 641, 282, 30241, 1844, 367, 282, 30241, 5982, 402, 900, 14, 1362, 446, 15967, 8571, 818, 365, 19093, 14862, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 2, 199, 1419, 26, 523, 1844, 26, 272, 1369, 26, 489, 446, 13488, 1844, 367, 314, 2838, 1950, 272, 1415, 26, 3055, 272, 849, 26, 5238, 1020, 272, 5481, 26, 942, 523, 2653, 26, 272, 1369, 26, 489, 446, 710, 1329, 402, 4696, 314, 2838, 911, 3618, 367, 666, 14, 982, 7179, 365, 3086, 1380, 314, 2653, 574, 365, 13075, 12, 314, 1950, 911, 506, 6876, 14, 272, 1415, 26, 3055, 272, 849, 26, 9601, 272, 5481, 26, 942, 523, 9395, 26, 272, 1369, 26, 489, 446, 710, 473, 8, 645, 11338, 323, 9, 11647, 11128, 365, 8239, 641, 3380, 436, 911, 25578, 6818, 367, 267, 642, 1329, 402, 9395, 2544, 7485, 316, 6337, 2331, 14, 272, 1415, 26, 3055, 272, 849, 26, 4233, 523, 3278, 22, 26, 272, 1369, 26, 489, 446, 710, 11647, 11128, 641, 314, 3982, 1591, 911, 5398, 370, 314, 3278, 22, 11667, 2838, 267, 340, 642, 2725, 365, 663, 370, 2549, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 523, 3510, 63, 498, 26, 272, 1369, 26, 489, 446, 3979, 5223, 12, 314, 11128, 911, 1551, 282, 2257, 2838, 570, 1314, 883, 506, 1202, 701, 6466, 11128, 2146, 8653, 370, 4960, 5802, 282, 892, 790, 370, 314, 2575, 3879, 11128, 12, 880, 626, 3663, 4390, 883, 4907, 1808, 3365, 2883, 14, 267, 961, 2879, 5139, 5074, 376, 8635, 1950, 465, 314, 1747, 367, 1314, 314, 11128, 365, 5544, 3879, 14, 272, 1415, 26, 3055, 272, 849, 26, 949, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 199, 5983, 26, 272, 446, 1666, 314, 19472, 5232, 8858, 17044, 367, 1655, 3595, 1808, 1066, 15730, 818, 14, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 1548, 13, 498, 16823, 285, 2, 199, 2502, 26, 298, 42, 14015, 445, 455, 4584, 419, 8593, 74, 1017, 73, 13, 67, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 4005, 675, 1066, 11338, 323, 818, 12, 9329, 1050, 298, 645, 11338, 323, 26, 2549, 2, 370, 2195, 5232, 14, 710, 2536, 199, 3, 790, 15343, 436, 6617, 1536, 402, 314, 11128, 911, 4781, 1806, 12027, 12, 1325, 1006, 3718, 436, 199, 3, 13372, 5445, 911, 506, 406, 5905, 471, 1806, 314, 3066, 2838, 1950, 1808, 19093, 14396, 199, 199, 13, 7057, 26, 4866, 5871, 523, 1066, 11338, 323, 26, 2549, 523, 6527, 26, 489, 446, 1414, 26, 1182, 2647, 15, 1393, 15, 25058, 199, 2344, 199, 199, 646, 1300, 772, 199, 646, 7554, 199, 646, 18354, 199, 646, 2022, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 14374, 199, 646, 4673, 199, 646, 2838, 199, 646, 2702, 199, 646, 984, 199, 646, 22112, 199, 646, 5549, 199, 646, 900, 199, 646, 5190, 199, 199, 646, 17766, 3120, 199, 199, 504, 2197, 492, 2197, 199, 504, 5796, 492, 11086, 12, 15536, 199, 199, 3, 492, 859, 19484, 199, 3, 781, 1471, 492, 642, 2348, 737, 314, 2746, 880, 781, 883, 675, 664, 63, 578, 63, 515, 342, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 199, 16878, 14, 1490, 793, 360, 4853, 3295, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 8964, 199, 199, 3, 314, 3728, 1568, 370, 1586, 436, 3222, 12, 18002, 28270, 24970, 436, 221, 199, 3, 23188, 14726, 367, 1300, 772, 334, 11, 1153, 5, 9, 2644, 436, 1406, 334, 1960, 2783, 9, 199, 3, 841, 627, 334, 28947, 15, 19, 9, 435, 2948, 275, 4329, 383, 221, 199, 3, 1314, 16733, 14726, 367, 314, 13488, 15, 1772, 1406, 199, 20512, 63, 4305, 29, 7727, 16, 199, 199, 3, 7600, 26, 642, 1006, 1077, 506, 12155, 370, 859, 63, 2330, 12, 465, 652, 1159, 221, 199, 3, 263, 7268, 8298, 282, 1331, 687, 314, 13484, 15, 1974, 1233, 199, 5287, 63, 11817, 29, 16, 199, 318, 943, 8, 1328, 12, 4021, 29, 16, 304, 272, 2288, 10990, 63, 11817, 272, 340, 10990, 63, 11817, 2356, 4021, 26, 267, 22112, 14, 16878, 8, 16878, 14, 4947, 63, 4609, 4047, 92, 16878, 14, 4947, 63, 8980, 2769, 615, 12, 1499, 9, 199, 199, 318, 373, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 17, 9, 199, 199, 318, 373, 86, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 18, 9, 199, 199, 318, 373, 8958, 8, 1328, 304, 272, 943, 8, 1328, 12, 4021, 29, 19, 9, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jnovinger/django
tests/gis_tests/test_measure.py
325
7363
""" Distance and Area objects to allow for sensible and convenient calculation and conversions. Here are some tests. """ import unittest from django.contrib.gis.measure import A, D, Area, Distance class DistanceTest(unittest.TestCase): "Testing the Distance object" def testInit(self): "Testing initialization from valid units" d = Distance(m=100) self.assertEqual(d.m, 100) d1, d2, d3 = D(m=100), D(meter=100), D(metre=100) for d in (d1, d2, d3): self.assertEqual(d.m, 100) d = D(nm=100) self.assertEqual(d.m, 185200) y1, y2, y3 = D(yd=100), D(yard=100), D(Yard=100) for d in (y1, y2, y3): self.assertEqual(d.yd, 100) mm1, mm2 = D(millimeter=1000), D(MiLLiMeTeR=1000) for d in (mm1, mm2): self.assertEqual(d.m, 1.0) self.assertEqual(d.mm, 1000.0) def testInitInvalid(self): "Testing initialization from invalid units" self.assertRaises(AttributeError, D, banana=100) def testAccess(self): "Testing access in different units" d = D(m=100) self.assertEqual(d.km, 0.1) self.assertAlmostEqual(d.ft, 328.084, 3) def testAccessInvalid(self): "Testing access in invalid units" d = D(m=100) self.assertFalse(hasattr(d, 'banana')) def testAddition(self): "Test addition & subtraction" d1 = D(m=100) d2 = D(m=200) d3 = d1 + d2 self.assertEqual(d3.m, 300) d3 += d1 self.assertEqual(d3.m, 400) d4 = d1 - d2 self.assertEqual(d4.m, -100) d4 -= d1 self.assertEqual(d4.m, -200) with self.assertRaises(TypeError): d1 + 1 with self.assertRaises(TypeError): d1 - 1 with self.assertRaises(TypeError): d1 += 1 with self.assertRaises(TypeError): d1 -= 1 def testMultiplication(self): "Test multiplication & division" d1 = D(m=100) d3 = d1 * 2 self.assertEqual(d3.m, 200) d3 = 2 * d1 self.assertEqual(d3.m, 200) d3 *= 5 self.assertEqual(d3.m, 1000) d4 = d1 / 2 self.assertEqual(d4.m, 50) d4 /= 5 self.assertEqual(d4.m, 10) d5 = d1 / D(m=2) self.assertEqual(d5, 50) a5 = d1 * D(m=10) self.assertIsInstance(a5, Area) self.assertEqual(a5.sq_m, 100 * 10) with self.assertRaises(TypeError): d1 *= D(m=1) with self.assertRaises(TypeError): d1 /= D(m=1) def testUnitConversions(self): "Testing default units during maths" d1 = D(m=100) d2 = D(km=1) d3 = d1 + d2 self.assertEqual(d3._default_unit, 'm') d4 = d2 + d1 self.assertEqual(d4._default_unit, 'km') d5 = d1 * 2 self.assertEqual(d5._default_unit, 'm') d6 = d1 / 2 self.assertEqual(d6._default_unit, 'm') def testComparisons(self): "Testing comparisons" d1 = D(m=100) d2 = D(km=1) d3 = D(km=0) self.assertGreater(d2, d1) self.assertEqual(d1, d1) self.assertLess(d1, d2) self.assertFalse(d3) def testUnitsStr(self): "Testing conversion to strings" d1 = D(m=100) d2 = D(km=3.5) self.assertEqual(str(d1), '100.0 m') self.assertEqual(str(d2), '3.5 km') self.assertEqual(repr(d1), 'Distance(m=100.0)') self.assertEqual(repr(d2), 'Distance(km=3.5)') def testUnitAttName(self): "Testing the `unit_attname` class method" unit_tuple = [('Yard', 'yd'), ('Nautical Mile', 'nm'), ('German legal metre', 'german_m'), ('Indian yard', 'indian_yd'), ('Chain (Sears)', 'chain_sears'), ('Chain', 'chain')] for nm, att in unit_tuple: self.assertEqual(att, D.unit_attname(nm)) class AreaTest(unittest.TestCase): "Testing the Area object" def testInit(self): "Testing initialization from valid units" a = Area(sq_m=100) self.assertEqual(a.sq_m, 100) a = A(sq_m=100) self.assertEqual(a.sq_m, 100) a = A(sq_mi=100) self.assertEqual(a.sq_m, 258998811.0336) def testInitInvaliA(self): "Testing initialization from invalid units" self.assertRaises(AttributeError, A, banana=100) def testAccess(self): "Testing access in different units" a = A(sq_m=100) self.assertEqual(a.sq_km, 0.0001) self.assertAlmostEqual(a.sq_ft, 1076.391, 3) def testAccessInvaliA(self): "Testing access in invalid units" a = A(sq_m=100) self.assertFalse(hasattr(a, 'banana')) def testAddition(self): "Test addition & subtraction" a1 = A(sq_m=100) a2 = A(sq_m=200) a3 = a1 + a2 self.assertEqual(a3.sq_m, 300) a3 += a1 self.assertEqual(a3.sq_m, 400) a4 = a1 - a2 self.assertEqual(a4.sq_m, -100) a4 -= a1 self.assertEqual(a4.sq_m, -200) with self.assertRaises(TypeError): a1 + 1 with self.assertRaises(TypeError): a1 - 1 with self.assertRaises(TypeError): a1 += 1 with self.assertRaises(TypeError): a1 -= 1 def testMultiplication(self): "Test multiplication & division" a1 = A(sq_m=100) a3 = a1 * 2 self.assertEqual(a3.sq_m, 200) a3 = 2 * a1 self.assertEqual(a3.sq_m, 200) a3 *= 5 self.assertEqual(a3.sq_m, 1000) a4 = a1 / 2 self.assertEqual(a4.sq_m, 50) a4 /= 5 self.assertEqual(a4.sq_m, 10) with self.assertRaises(TypeError): a1 * A(sq_m=1) with self.assertRaises(TypeError): a1 *= A(sq_m=1) with self.assertRaises(TypeError): a1 / A(sq_m=1) with self.assertRaises(TypeError): a1 /= A(sq_m=1) def testUnitConversions(self): "Testing default units during maths" a1 = A(sq_m=100) a2 = A(sq_km=1) a3 = a1 + a2 self.assertEqual(a3._default_unit, 'sq_m') a4 = a2 + a1 self.assertEqual(a4._default_unit, 'sq_km') a5 = a1 * 2 self.assertEqual(a5._default_unit, 'sq_m') a6 = a1 / 2 self.assertEqual(a6._default_unit, 'sq_m') def testComparisons(self): "Testing comparisons" a1 = A(sq_m=100) a2 = A(sq_km=1) a3 = A(sq_km=0) self.assertGreater(a2, a1) self.assertEqual(a1, a1) self.assertLess(a1, a2) self.assertFalse(a3) def testUnitsStr(self): "Testing conversion to strings" a1 = A(sq_m=100) a2 = A(sq_km=3.5) self.assertEqual(str(a1), '100.0 sq_m') self.assertEqual(str(a2), '3.5 sq_km') self.assertEqual(repr(a1), 'Area(sq_m=100.0)') self.assertEqual(repr(a2), 'Area(sq_km=3.5)') def suite(): s = unittest.TestSuite() s.addTest(unittest.makeSuite(DistanceTest)) s.addTest(unittest.makeSuite(AreaTest)) return s def run(verbosity=2): unittest.TextTestRunner(verbosity=verbosity).run(suite()) if __name__ == "__main__": run()
bsd-3-clause
[ 624, 199, 10076, 436, 26280, 2251, 370, 2040, 367, 27962, 436, 22700, 15232, 199, 460, 24796, 14, 11842, 787, 2005, 2295, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 437, 12, 577, 12, 26280, 12, 21892, 421, 199, 533, 21892, 774, 8, 2796, 14, 1746, 304, 272, 298, 9029, 314, 21892, 909, 2, 339, 347, 511, 9346, 8, 277, 304, 267, 298, 9029, 11097, 687, 1686, 6204, 2, 267, 366, 275, 21892, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 17, 12, 366, 18, 12, 366, 19, 275, 577, 8, 77, 29, 1960, 395, 577, 8, 10011, 29, 1960, 395, 577, 8, 10207, 264, 29, 1960, 9, 267, 367, 366, 315, 334, 68, 17, 12, 366, 18, 12, 366, 19, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 275, 577, 8, 10756, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 413, 2426, 1840, 9, 398, 612, 17, 12, 612, 18, 12, 612, 19, 275, 577, 8, 24503, 29, 1960, 395, 577, 8, 89, 1005, 29, 1960, 395, 577, 8, 57, 1005, 29, 1960, 9, 267, 367, 366, 315, 334, 89, 17, 12, 612, 18, 12, 612, 19, 304, 288, 291, 14, 629, 8, 68, 14, 24503, 12, 2948, 9, 398, 8562, 17, 12, 8562, 18, 275, 577, 8, 19579, 10011, 29, 5279, 395, 577, 8, 14738, 4464, 73, 1352, 6301, 50, 29, 5279, 9, 267, 367, 366, 315, 334, 596, 17, 12, 8562, 18, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 413, 14, 16, 9, 288, 291, 14, 629, 8, 68, 14, 596, 12, 5198, 14, 16, 9, 339, 347, 511, 9346, 3364, 8, 277, 304, 267, 298, 9029, 11097, 687, 3866, 6204, 2, 267, 291, 14, 1855, 8, 10227, 12, 577, 12, 30354, 6738, 29, 1960, 9, 339, 347, 511, 3946, 8, 277, 304, 267, 298, 9029, 2879, 315, 3365, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 14595, 12, 378, 14, 17, 9, 267, 291, 14, 7904, 8, 68, 14, 856, 12, 650, 1651, 14, 26107, 12, 650, 9, 339, 347, 511, 3946, 3364, 8, 277, 304, 267, 298, 9029, 2879, 315, 3866, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 3334, 8, 11161, 8, 68, 12, 283, 13206, 6738, 1333, 339, 347, 511, 2767, 1671, 8, 277, 304, 267, 298, 774, 10234, 1253, 1007, 26137, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 77, 29, 1840, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 9601, 9, 267, 366, 19, 847, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 8290, 9, 398, 366, 20, 275, 366, 17, 446, 366, 18, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1960, 9, 267, 366, 20, 4862, 366, 17, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1840, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 435, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 446, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 847, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 4862, 413, 339, 347, 511, 25314, 1863, 8, 277, 304, 267, 298, 774, 24638, 1253, 4629, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 398, 366, 19, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 275, 499, 627, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 9000, 959, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 5198, 9, 398, 366, 20, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 5238, 9, 267, 366, 20, 12257, 959, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 1616, 9, 267, 366, 21, 275, 366, 17, 1182, 577, 8, 77, 29, 18, 9, 267, 291, 14, 629, 8, 68, 21, 12, 5238, 9, 398, 282, 21, 275, 366, 17, 627, 577, 8, 77, 29, 709, 9, 267, 291, 14, 6926, 8, 65, 21, 12, 26280, 9, 267, 291, 14, 629, 8, 65, 21, 14, 3526, 63, 77, 12, 2948, 627, 1616, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 9000, 577, 8, 77, 29, 17, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 12257, 577, 8, 77, 29, 17, 9, 339, 347, 511, 5072, 714, 6234, 8, 277, 304, 267, 298, 9029, 849, 6204, 5309, 3473, 83, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 20, 275, 366, 18, 435, 366, 17, 267, 291, 14, 629, 8, 68, 20, 423, 885, 63, 3248, 12, 283, 14595, 358, 267, 366, 21, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 21, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 22, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 22, 423, 885, 63, 3248, 12, 283, 77, 358, 339, 347, 511, 2404, 15864, 8, 277, 304, 267, 298, 9029, 20448, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 267, 366, 19, 275, 577, 8, 14595, 29, 16, 9, 398, 291, 14, 15070, 8, 68, 18, 12, 366, 17, 9, 267, 291, 14, 629, 8, 68, 17, 12, 366, 17, 9, 267, 291, 14, 15625, 8, 68, 17, 12, 366, 18, 9, 267, 291, 14, 3334, 8, 68, 19, 9, 339, 347, 511, 15121, 2848, 8, 277, 304, 267, 298, 9029 ]
[ 199, 10076, 436, 26280, 2251, 370, 2040, 367, 27962, 436, 22700, 15232, 199, 460, 24796, 14, 11842, 787, 2005, 2295, 14, 199, 624, 199, 199, 646, 2882, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 9580, 492, 437, 12, 577, 12, 26280, 12, 21892, 421, 199, 533, 21892, 774, 8, 2796, 14, 1746, 304, 272, 298, 9029, 314, 21892, 909, 2, 339, 347, 511, 9346, 8, 277, 304, 267, 298, 9029, 11097, 687, 1686, 6204, 2, 267, 366, 275, 21892, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 17, 12, 366, 18, 12, 366, 19, 275, 577, 8, 77, 29, 1960, 395, 577, 8, 10011, 29, 1960, 395, 577, 8, 10207, 264, 29, 1960, 9, 267, 367, 366, 315, 334, 68, 17, 12, 366, 18, 12, 366, 19, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 2948, 9, 398, 366, 275, 577, 8, 10756, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 77, 12, 413, 2426, 1840, 9, 398, 612, 17, 12, 612, 18, 12, 612, 19, 275, 577, 8, 24503, 29, 1960, 395, 577, 8, 89, 1005, 29, 1960, 395, 577, 8, 57, 1005, 29, 1960, 9, 267, 367, 366, 315, 334, 89, 17, 12, 612, 18, 12, 612, 19, 304, 288, 291, 14, 629, 8, 68, 14, 24503, 12, 2948, 9, 398, 8562, 17, 12, 8562, 18, 275, 577, 8, 19579, 10011, 29, 5279, 395, 577, 8, 14738, 4464, 73, 1352, 6301, 50, 29, 5279, 9, 267, 367, 366, 315, 334, 596, 17, 12, 8562, 18, 304, 288, 291, 14, 629, 8, 68, 14, 77, 12, 413, 14, 16, 9, 288, 291, 14, 629, 8, 68, 14, 596, 12, 5198, 14, 16, 9, 339, 347, 511, 9346, 3364, 8, 277, 304, 267, 298, 9029, 11097, 687, 3866, 6204, 2, 267, 291, 14, 1855, 8, 10227, 12, 577, 12, 30354, 6738, 29, 1960, 9, 339, 347, 511, 3946, 8, 277, 304, 267, 298, 9029, 2879, 315, 3365, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 629, 8, 68, 14, 14595, 12, 378, 14, 17, 9, 267, 291, 14, 7904, 8, 68, 14, 856, 12, 650, 1651, 14, 26107, 12, 650, 9, 339, 347, 511, 3946, 3364, 8, 277, 304, 267, 298, 9029, 2879, 315, 3866, 6204, 2, 267, 366, 275, 577, 8, 77, 29, 1960, 9, 267, 291, 14, 3334, 8, 11161, 8, 68, 12, 283, 13206, 6738, 1333, 339, 347, 511, 2767, 1671, 8, 277, 304, 267, 298, 774, 10234, 1253, 1007, 26137, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 77, 29, 1840, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 9601, 9, 267, 366, 19, 847, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 8290, 9, 398, 366, 20, 275, 366, 17, 446, 366, 18, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1960, 9, 267, 366, 20, 4862, 366, 17, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 446, 1840, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 435, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 446, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 847, 413, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 4862, 413, 339, 347, 511, 25314, 1863, 8, 277, 304, 267, 298, 774, 24638, 1253, 4629, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 398, 366, 19, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 275, 499, 627, 366, 17, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 1926, 9, 267, 366, 19, 9000, 959, 267, 291, 14, 629, 8, 68, 19, 14, 77, 12, 5198, 9, 398, 366, 20, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 5238, 9, 267, 366, 20, 12257, 959, 267, 291, 14, 629, 8, 68, 20, 14, 77, 12, 1616, 9, 267, 366, 21, 275, 366, 17, 1182, 577, 8, 77, 29, 18, 9, 267, 291, 14, 629, 8, 68, 21, 12, 5238, 9, 398, 282, 21, 275, 366, 17, 627, 577, 8, 77, 29, 709, 9, 267, 291, 14, 6926, 8, 65, 21, 12, 26280, 9, 267, 291, 14, 629, 8, 65, 21, 14, 3526, 63, 77, 12, 2948, 627, 1616, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 9000, 577, 8, 77, 29, 17, 9, 398, 543, 291, 14, 1855, 8, 4333, 304, 288, 366, 17, 12257, 577, 8, 77, 29, 17, 9, 339, 347, 511, 5072, 714, 6234, 8, 277, 304, 267, 298, 9029, 849, 6204, 5309, 3473, 83, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 398, 366, 19, 275, 366, 17, 435, 366, 18, 267, 291, 14, 629, 8, 68, 19, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 20, 275, 366, 18, 435, 366, 17, 267, 291, 14, 629, 8, 68, 20, 423, 885, 63, 3248, 12, 283, 14595, 358, 267, 366, 21, 275, 366, 17, 627, 499, 267, 291, 14, 629, 8, 68, 21, 423, 885, 63, 3248, 12, 283, 77, 358, 267, 366, 22, 275, 366, 17, 1182, 499, 267, 291, 14, 629, 8, 68, 22, 423, 885, 63, 3248, 12, 283, 77, 358, 339, 347, 511, 2404, 15864, 8, 277, 304, 267, 298, 9029, 20448, 2, 267, 366, 17, 275, 577, 8, 77, 29, 1960, 9, 267, 366, 18, 275, 577, 8, 14595, 29, 17, 9, 267, 366, 19, 275, 577, 8, 14595, 29, 16, 9, 398, 291, 14, 15070, 8, 68, 18, 12, 366, 17, 9, 267, 291, 14, 629, 8, 68, 17, 12, 366, 17, 9, 267, 291, 14, 15625, 8, 68, 17, 12, 366, 18, 9, 267, 291, 14, 3334, 8, 68, 19, 9, 339, 347, 511, 15121, 2848, 8, 277, 304, 267, 298, 9029, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Solomoriah/gdmodule
demo/gddemo.py
1
1024
#!/usr/bin/env python import gd, os, cStringIO, urllib2 os.environ["GDFONTPATH"] = "." FONT = "Pacifico" def simple(): im = gd.image((200, 200)) white = im.colorAllocate((255, 255, 255)) black = im.colorAllocate((0, 0, 0)) red = im.colorAllocate((255, 0, 0)) blue = im.colorAllocate((0, 0, 255)) im.colorTransparent(white) im.interlace(1) im.rectangle((0,0),(199,199),black) im.arc((100,100),(195,175),0,360,blue) im.fill((100,100),red) print im.get_bounding_rect(FONT, 12.0, 0.0, (10, 100), "Hello Python") im.string_ttf(FONT, 20.0, 0.0, (10, 100), "Hello Python", black) f=open("xx.png","w") im.writePng(f) f.close() f=open("xx.jpg", "w") im.writeJpeg(f,100) f.close() f=cStringIO.StringIO() im.writePng(f) print "PNG size:", len(f.getvalue()) f.close() f = urllib2.urlopen("http://www.gnu.org/graphics/gnu-head-sm.jpg") im = gd.image(f, "jpg") f.close() print "GNU Image Size:", im.size() simple()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 24714, 12, 747, 12, 15073, 12, 4011, 18, 199, 199, 736, 14, 2314, 905, 39, 3888, 5994, 3243, 937, 275, 14530, 199, 199, 18398, 275, 298, 4232, 559, 329, 331, 2, 199, 199, 318, 3486, 837, 272, 3416, 275, 24714, 14, 1569, 1332, 1840, 12, 1926, 430, 339, 10424, 275, 3416, 14, 2326, 22712, 1332, 2299, 12, 5450, 12, 5450, 430, 272, 12136, 275, 3416, 14, 2326, 22712, 1332, 16, 12, 378, 12, 378, 430, 272, 8992, 275, 3416, 14, 2326, 22712, 1332, 2299, 12, 378, 12, 378, 430, 272, 10030, 275, 3416, 14, 2326, 22712, 1332, 16, 12, 378, 12, 5450, 430, 339, 3416, 14, 2326, 3188, 1708, 8, 7510, 9, 272, 3416, 14, 1058, 1071, 8, 17, 9, 339, 3416, 14, 19954, 1332, 16, 12, 16, 11865, 7155, 12, 7155, 395, 8399, 9, 272, 3416, 14, 9912, 1332, 1960, 12, 1960, 11865, 11874, 12, 10848, 395, 16, 12, 11197, 12, 6304, 9, 272, 3416, 14, 4498, 1332, 1960, 12, 1960, 395, 581, 9, 339, 870, 3416, 14, 362, 63, 24511, 63, 1201, 8, 18398, 12, 3144, 14, 16, 12, 378, 14, 16, 12, 334, 709, 12, 2948, 395, 298, 6257, 2018, 531, 339, 3416, 14, 875, 63, 32264, 8, 18398, 12, 3388, 14, 16, 12, 378, 14, 16, 12, 334, 709, 12, 2948, 395, 298, 6257, 2018, 401, 12136, 9, 339, 289, 29, 1490, 480, 2154, 14, 4524, 2266, 87, 531, 272, 3416, 14, 952, 48, 2753, 8, 70, 9, 272, 289, 14, 1600, 342, 339, 289, 29, 1490, 480, 2154, 14, 8476, 401, 298, 87, 531, 272, 3416, 14, 952, 42, 11997, 8, 70, 12, 1960, 9, 272, 289, 14, 1600, 342, 339, 289, 29, 67, 6424, 14, 6424, 342, 272, 3416, 14, 952, 48, 2753, 8, 70, 9, 272, 870, 298, 24454, 1568, 6783, 822, 8, 70, 14, 7150, 1012, 272, 289, 14, 1600, 342, 2286, 289, 275, 4011, 18, 14, 10890, 480, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 15707, 15, 3689, 13, 2993, 13, 3300, 14, 8476, 531, 272, 3416, 275, 24714, 14, 1569, 8, 70, 12, 298, 8476, 531, 272, 289, 14, 1600, 342, 272, 870, 298, 17732, 6047, 14579, 6783, 3416, 14, 890, 342, 199, 199, 4129, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 24714, 12, 747, 12, 15073, 12, 4011, 18, 199, 199, 736, 14, 2314, 905, 39, 3888, 5994, 3243, 937, 275, 14530, 199, 199, 18398, 275, 298, 4232, 559, 329, 331, 2, 199, 199, 318, 3486, 837, 272, 3416, 275, 24714, 14, 1569, 1332, 1840, 12, 1926, 430, 339, 10424, 275, 3416, 14, 2326, 22712, 1332, 2299, 12, 5450, 12, 5450, 430, 272, 12136, 275, 3416, 14, 2326, 22712, 1332, 16, 12, 378, 12, 378, 430, 272, 8992, 275, 3416, 14, 2326, 22712, 1332, 2299, 12, 378, 12, 378, 430, 272, 10030, 275, 3416, 14, 2326, 22712, 1332, 16, 12, 378, 12, 5450, 430, 339, 3416, 14, 2326, 3188, 1708, 8, 7510, 9, 272, 3416, 14, 1058, 1071, 8, 17, 9, 339, 3416, 14, 19954, 1332, 16, 12, 16, 11865, 7155, 12, 7155, 395, 8399, 9, 272, 3416, 14, 9912, 1332, 1960, 12, 1960, 11865, 11874, 12, 10848, 395, 16, 12, 11197, 12, 6304, 9, 272, 3416, 14, 4498, 1332, 1960, 12, 1960, 395, 581, 9, 339, 870, 3416, 14, 362, 63, 24511, 63, 1201, 8, 18398, 12, 3144, 14, 16, 12, 378, 14, 16, 12, 334, 709, 12, 2948, 395, 298, 6257, 2018, 531, 339, 3416, 14, 875, 63, 32264, 8, 18398, 12, 3388, 14, 16, 12, 378, 14, 16, 12, 334, 709, 12, 2948, 395, 298, 6257, 2018, 401, 12136, 9, 339, 289, 29, 1490, 480, 2154, 14, 4524, 2266, 87, 531, 272, 3416, 14, 952, 48, 2753, 8, 70, 9, 272, 289, 14, 1600, 342, 339, 289, 29, 1490, 480, 2154, 14, 8476, 401, 298, 87, 531, 272, 3416, 14, 952, 42, 11997, 8, 70, 12, 1960, 9, 272, 289, 14, 1600, 342, 339, 289, 29, 67, 6424, 14, 6424, 342, 272, 3416, 14, 952, 48, 2753, 8, 70, 9, 272, 870, 298, 24454, 1568, 6783, 822, 8, 70, 14, 7150, 1012, 272, 289, 14, 1600, 342, 2286, 289, 275, 4011, 18, 14, 10890, 480, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 15707, 15, 3689, 13, 2993, 13, 3300, 14, 8476, 531, 272, 3416, 275, 24714, 14, 1569, 8, 70, 12, 298, 8476, 531, 272, 289, 14, 1600, 342, 272, 870, 298, 17732, 6047, 14579, 6783, 3416, 14, 890, 342, 199, 199, 4129, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mvaled/sentry
src/sentry/integrations/vsts/search.py
3
1484
from __future__ import absolute_import from sentry.api.bases.integration import IntegrationEndpoint from rest_framework.response import Response from sentry.models import Integration class VstsSearchEndpoint(IntegrationEndpoint): def get(self, request, organization, integration_id): try: integration = Integration.objects.get( organizations=organization, id=integration_id, provider="vsts" ) except Integration.DoesNotExist: return Response(status=404) field = request.GET.get("field") query = request.GET.get("query") if field is None: return Response({"detail": "field is a required parameter"}, status=400) if not query: return Response({"detail": "query is a required parameter"}, status=400) installation = integration.get_installation(organization.id) if field == "externalIssue": if not query: return Response([]) resp = installation.get_client().search_issues(integration.name, query) return Response( [ { "label": "(%s) %s" % (i["fields"]["system.id"], i["fields"]["system.title"]), "value": i["fields"]["system.id"], } for i in resp.get("results", []) ] ) return Response(status=400)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 26230, 14, 1246, 14, 12087, 14, 15092, 492, 27561, 11442, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 199, 504, 26230, 14, 992, 492, 27561, 421, 199, 533, 812, 10329, 5278, 11442, 8, 20405, 11442, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 13237, 12, 13150, 63, 344, 304, 267, 862, 26, 288, 13150, 275, 27561, 14, 1462, 14, 362, 8, 355, 20765, 12270, 29, 9071, 12, 1305, 29, 15092, 63, 344, 12, 5022, 628, 86, 10329, 2, 288, 776, 267, 871, 27561, 14, 7400, 26, 288, 372, 7232, 8, 1205, 29, 5188, 9, 398, 901, 275, 1056, 14, 2970, 14, 362, 480, 698, 531, 267, 1827, 275, 1056, 14, 2970, 14, 362, 480, 1131, 531, 267, 340, 901, 365, 488, 26, 288, 372, 7232, 6333, 5506, 582, 298, 698, 365, 282, 1415, 2725, 6018, 2004, 29, 5303, 9, 267, 340, 440, 1827, 26, 288, 372, 7232, 6333, 5506, 582, 298, 1131, 365, 282, 1415, 2725, 6018, 2004, 29, 5303, 9, 398, 12096, 275, 13150, 14, 362, 63, 23048, 8, 9071, 14, 344, 9, 398, 340, 901, 508, 298, 5159, 17106, 582, 288, 340, 440, 1827, 26, 355, 372, 7232, 4157, 953, 3085, 275, 12096, 14, 362, 63, 1258, 1252, 1733, 63, 10115, 8, 15092, 14, 354, 12, 1827, 9, 288, 372, 7232, 8, 355, 359, 490, 469, 717, 298, 1302, 582, 26448, 83, 9, 450, 83, 2, 717, 450, 334, 73, 905, 955, 6611, 2253, 14, 344, 2255, 284, 905, 955, 6611, 2253, 14, 1213, 10252, 717, 298, 585, 582, 284, 905, 955, 6611, 2253, 14, 344, 2255, 490, 789, 490, 367, 284, 315, 3085, 14, 362, 480, 2604, 401, 3073, 355, 1622, 288, 776, 398, 372, 7232, 8, 1205, 29, 5303, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 26230, 14, 1246, 14, 12087, 14, 15092, 492, 27561, 11442, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 199, 504, 26230, 14, 992, 492, 27561, 421, 199, 533, 812, 10329, 5278, 11442, 8, 20405, 11442, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 13237, 12, 13150, 63, 344, 304, 267, 862, 26, 288, 13150, 275, 27561, 14, 1462, 14, 362, 8, 355, 20765, 12270, 29, 9071, 12, 1305, 29, 15092, 63, 344, 12, 5022, 628, 86, 10329, 2, 288, 776, 267, 871, 27561, 14, 7400, 26, 288, 372, 7232, 8, 1205, 29, 5188, 9, 398, 901, 275, 1056, 14, 2970, 14, 362, 480, 698, 531, 267, 1827, 275, 1056, 14, 2970, 14, 362, 480, 1131, 531, 267, 340, 901, 365, 488, 26, 288, 372, 7232, 6333, 5506, 582, 298, 698, 365, 282, 1415, 2725, 6018, 2004, 29, 5303, 9, 267, 340, 440, 1827, 26, 288, 372, 7232, 6333, 5506, 582, 298, 1131, 365, 282, 1415, 2725, 6018, 2004, 29, 5303, 9, 398, 12096, 275, 13150, 14, 362, 63, 23048, 8, 9071, 14, 344, 9, 398, 340, 901, 508, 298, 5159, 17106, 582, 288, 340, 440, 1827, 26, 355, 372, 7232, 4157, 953, 3085, 275, 12096, 14, 362, 63, 1258, 1252, 1733, 63, 10115, 8, 15092, 14, 354, 12, 1827, 9, 288, 372, 7232, 8, 355, 359, 490, 469, 717, 298, 1302, 582, 26448, 83, 9, 450, 83, 2, 717, 450, 334, 73, 905, 955, 6611, 2253, 14, 344, 2255, 284, 905, 955, 6611, 2253, 14, 1213, 10252, 717, 298, 585, 582, 284, 905, 955, 6611, 2253, 14, 344, 2255, 490, 789, 490, 367, 284, 315, 3085, 14, 362, 480, 2604, 401, 3073, 355, 1622, 288, 776, 398, 372, 7232, 8, 1205, 29, 5303, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
janbrohl/SimpleTAL
tests/TALTests/XMLTests/TALRepeatTestCases.py
1
14925
#!/usr/bin/python # -*- coding: iso-8859-1 -*- # Copyright (c) 2016, Jan Brohl <janbrohl@t-online.de> # All rights reserved. # See LICENSE.txt # Copyright (c) 2004 Colin Stewart (http://www.owlfish.com/) # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # If you make any bug fixes or feature enhancements please let me know! """ Unit test cases. """ from __future__ import unicode_literals import unittest import os import io import logging import logging.config from simpletal import simpleTAL, simpleTALES if (os.path.exists("logging.ini")): logging.config.fileConfig("logging.ini") else: logging.basicConfig() class TALRepeatTestCases(unittest.TestCase): def setUp(self): self.context = simpleTALES.Context() self.context.addGlobal('test', 'testing') self.context.addGlobal('one', [1]) self.context.addGlobal('two', ["one", "two"]) self.context.addGlobal('three', [1, "Two", 3]) self.context.addGlobal('bigList', range(1, 100)) self.context.addGlobal('fourList', ["zero", "one", "two", "three"]) self.context.addGlobal('nested', [{ 'title': 'Image 1', 'catList': [1, 2, 3] }, { 'title': 'Image 2', 'catList': [5, 2, 3] }, { 'title': 'Image 3', 'catList': [8, 9, 1] }]) def _runTest_(self, txt, result, errMsg="Error"): template = simpleTAL.compileXMLTemplate(txt) file = io.StringIO() template.expand(self.context, file, outputEncoding="iso-8859-1") realResult = file.getvalue() self.assertEqual( realResult, result, "%s - \npassed in: %s \ngot back %s \nexpected %s\n\nTemplate: %s" % (errMsg, txt, realResult, result, template)) def testInvalidPath(self): self._runTest_( '<html><p tal:repeat="entry wibble">Hello</p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html></html>', "Repeat of non-existant element failed") def testDefaultValue(self): self._runTest_( '<html><p tal:repeat="entry default">Default Only</p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>Default Only</p></html>', 'Default did not keep existing structure intact') def testEmptyList(self): self._runTest_( '<html><p tal:repeat="short emptyList"><b tal:replace="short">Empty</b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html></html>', 'Empty list repeat failed.') def testStringRepeat(self): self._runTest_( '<html><p tal:omit-tag="" tal:repeat="letter test"><b tal:replace="letter"></b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html>testing</html>', 'Itteration over string failed.') def testListRepeat(self): self._runTest_( '<html><p tal:repeat="word two"><b tal:replace="word"></b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>one</p><p>two</p></html>', 'Itteration over list failed.') def testTwoCmndsOneTagListRepeat(self): self._runTest_( '<html><p tal:repeat="word two" tal:content="word"></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>one</p><p>two</p></html>', 'Itteration over list with both content and repeat on same element failed.' ) def testNestedRepeat(self): self._runTest_( '<html><p tal:repeat="image nested"><h2 tal:content="image/title"></h2><b tal:omit-tag="" tal:repeat="category image/catList"><i tal:content="category"></i></b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p><h2>Image 1</h2><i>1</i><i>2</i><i>3</i></p><p><h2>Image 2</h2><i>5</i><i>2</i><i>3</i></p><p><h2>Image 3</h2><i>8</i><i>9</i><i>1</i></p></html>', 'Nested repeat did not create expected outcome.') def testNestedRepeatClasses(self): self._runTest_( '<html><p class="outerClass" tal:repeat="image nested"><div class="innerClass" tal:repeat="category image/catList"><i tal:content="category"></i></div></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p class="outerClass"><div class="innerClass"><i>1</i></div><div class="innerClass"><i>2</i></div><div class="innerClass"><i>3</i></div></p><p class="outerClass"><div class="innerClass"><i>5</i></div><div class="innerClass"><i>2</i></div><div class="innerClass"><i>3</i></div></p><p class="outerClass"><div class="innerClass"><i>8</i></div><div class="innerClass"><i>9</i></div><div class="innerClass"><i>1</i></div></p></html>', 'Nested repeat with classes did not create expected outcome.') def testRepeatVarIndex(self): expectedResult = "<html>" for num in range(0, 99): expectedResult += str(num) expectedResult += "</html>" self._runTest_( '<html><p tal:repeat="var bigList" tal:omit-tag=""><b tal:replace="repeat/var/index">Index</b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n' + expectedResult, "Repeat variable index failed.") def testRepeatVarNumber(self): self._runTest_( '<html><p tal:repeat="var bigList" tal:omit-tag=""><b tal:replace="repeat/var/number">Index</b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899</html>', 'Repeat variable number failed.') def testRepeatVarEvenOdd(self): self._runTest_( '<html><p tal:repeat="var fourList"><i tal:replace="var"></i> - <b tal:condition="repeat/var/odd">Odd</b><b tal:condition="repeat/var/even">Even</b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>zero - <b>Even</b></p><p>one - <b>Odd</b></p><p>two - <b>Even</b></p><p>three - <b>Odd</b></p></html>', 'Repeat variables odd and even failed.') def testRepeatVarStartEnd(self): self._runTest_( '<html><p tal:repeat="var fourList"><b tal:condition="repeat/var/start">Start</b><i tal:replace="var"></i><b tal:condition="repeat/var/end">End</b></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p><b>Start</b>zero</p><p>one</p><p>two</p><p>three<b>End</b></p></html>', 'Repeat variables start and end failed.') def testRepeatVarLength(self): self._runTest_( '<html><p tal:repeat="var fourList"><b tal:condition="repeat/var/start">Len: <i tal:replace="repeat/var/length">length</i></b>Entry: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p><b>Len: 4</b>Entry: zero</p><p>Entry: one</p><p>Entry: two</p><p>Entry: three</p></html>', 'Repeat variable length failed.') def testRepeatVarLowerLetter(self): self._runTest_( '<html><p tal:repeat="var fourList"><i tal:replace="repeat/var/letter">a,b,c,etc</i>: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>a: zero</p><p>b: one</p><p>c: two</p><p>d: three</p></html>', 'Repeat variable letter failed.') def testRepeatVarLowerLetterLarge(self): self._runTest_( '<html><p tal:repeat="var bigList"><i tal:replace="repeat/var/letter">a,b,c,etc</i>: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>a: 1</p><p>b: 2</p><p>c: 3</p><p>d: 4</p><p>e: 5</p><p>f: 6</p><p>g: 7</p><p>h: 8</p><p>i: 9</p><p>j: 10</p><p>k: 11</p><p>l: 12</p><p>m: 13</p><p>n: 14</p><p>o: 15</p><p>p: 16</p><p>q: 17</p><p>r: 18</p><p>s: 19</p><p>t: 20</p><p>u: 21</p><p>v: 22</p><p>w: 23</p><p>x: 24</p><p>y: 25</p><p>z: 26</p><p>ba: 27</p><p>bb: 28</p><p>bc: 29</p><p>bd: 30</p><p>be: 31</p><p>bf: 32</p><p>bg: 33</p><p>bh: 34</p><p>bi: 35</p><p>bj: 36</p><p>bk: 37</p><p>bl: 38</p><p>bm: 39</p><p>bn: 40</p><p>bo: 41</p><p>bp: 42</p><p>bq: 43</p><p>br: 44</p><p>bs: 45</p><p>bt: 46</p><p>bu: 47</p><p>bv: 48</p><p>bw: 49</p><p>bx: 50</p><p>by: 51</p><p>bz: 52</p><p>ca: 53</p><p>cb: 54</p><p>cc: 55</p><p>cd: 56</p><p>ce: 57</p><p>cf: 58</p><p>cg: 59</p><p>ch: 60</p><p>ci: 61</p><p>cj: 62</p><p>ck: 63</p><p>cl: 64</p><p>cm: 65</p><p>cn: 66</p><p>co: 67</p><p>cp: 68</p><p>cq: 69</p><p>cr: 70</p><p>cs: 71</p><p>ct: 72</p><p>cu: 73</p><p>cv: 74</p><p>cw: 75</p><p>cx: 76</p><p>cy: 77</p><p>cz: 78</p><p>da: 79</p><p>db: 80</p><p>dc: 81</p><p>dd: 82</p><p>de: 83</p><p>df: 84</p><p>dg: 85</p><p>dh: 86</p><p>di: 87</p><p>dj: 88</p><p>dk: 89</p><p>dl: 90</p><p>dm: 91</p><p>dn: 92</p><p>do: 93</p><p>dp: 94</p><p>dq: 95</p><p>dr: 96</p><p>ds: 97</p><p>dt: 98</p><p>du: 99</p></html>', 'Repeat variable letter failed on a large list.') def testRepeatVarUpperLetter(self): self._runTest_( '<html><p tal:repeat="var fourList"><i tal:replace="repeat/var/Letter">A,B,C,etc</i>: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>A: zero</p><p>B: one</p><p>C: two</p><p>D: three</p></html>', 'Repeat variable Letter failed.') def testRepeatVarLowerRoman(self): self._runTest_( '<html><p tal:repeat="var bigList"><i tal:replace="repeat/var/roman">i,ii,iii,etc</i>: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>i: 1</p><p>ii: 2</p><p>iii: 3</p><p>iv: 4</p><p>v: 5</p><p>vi: 6</p><p>vii: 7</p><p>viii: 8</p><p>ix: 9</p><p>x: 10</p><p>xi: 11</p><p>xii: 12</p><p>xiii: 13</p><p>xiv: 14</p><p>xv: 15</p><p>xvi: 16</p><p>xvii: 17</p><p>xviii: 18</p><p>xix: 19</p><p>xx: 20</p><p>xxi: 21</p><p>xxii: 22</p><p>xxiii: 23</p><p>xxiv: 24</p><p>xxv: 25</p><p>xxvi: 26</p><p>xxvii: 27</p><p>xxviii: 28</p><p>xxix: 29</p><p>xxx: 30</p><p>xxxi: 31</p><p>xxxii: 32</p><p>xxxiii: 33</p><p>xxxiv: 34</p><p>xxxv: 35</p><p>xxxvi: 36</p><p>xxxvii: 37</p><p>xxxviii: 38</p><p>xxxix: 39</p><p>xl: 40</p><p>xli: 41</p><p>xlii: 42</p><p>xliii: 43</p><p>xliv: 44</p><p>xlv: 45</p><p>xlvi: 46</p><p>xlvii: 47</p><p>xlviii: 48</p><p>xlix: 49</p><p>l: 50</p><p>li: 51</p><p>lii: 52</p><p>liii: 53</p><p>liv: 54</p><p>lv: 55</p><p>lvi: 56</p><p>lvii: 57</p><p>lviii: 58</p><p>lix: 59</p><p>lx: 60</p><p>lxi: 61</p><p>lxii: 62</p><p>lxiii: 63</p><p>lxiv: 64</p><p>lxv: 65</p><p>lxvi: 66</p><p>lxvii: 67</p><p>lxviii: 68</p><p>lxix: 69</p><p>lxx: 70</p><p>lxxi: 71</p><p>lxxii: 72</p><p>lxxiii: 73</p><p>lxxiv: 74</p><p>lxxv: 75</p><p>lxxvi: 76</p><p>lxxvii: 77</p><p>lxxviii: 78</p><p>lxxix: 79</p><p>lxxx: 80</p><p>lxxxi: 81</p><p>lxxxii: 82</p><p>lxxxiii: 83</p><p>lxxxiv: 84</p><p>lxxxv: 85</p><p>lxxxvi: 86</p><p>lxxxvii: 87</p><p>lxxxviii: 88</p><p>lxxxix: 89</p><p>xc: 90</p><p>xci: 91</p><p>xcii: 92</p><p>xciii: 93</p><p>xciv: 94</p><p>xcv: 95</p><p>xcvi: 96</p><p>xcvii: 97</p><p>xcviii: 98</p><p>xcix: 99</p></html>', 'Repeat variable roman failed.') def testRepeatVarUpperRoman(self): self._runTest_( '<html><p tal:repeat="var bigList"><i tal:replace="repeat/var/Roman">I,II,III,etc</i>: <i tal:replace="var"></i></p></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>I: 1</p><p>II: 2</p><p>III: 3</p><p>IV: 4</p><p>V: 5</p><p>VI: 6</p><p>VII: 7</p><p>VIII: 8</p><p>IX: 9</p><p>X: 10</p><p>XI: 11</p><p>XII: 12</p><p>XIII: 13</p><p>XIV: 14</p><p>XV: 15</p><p>XVI: 16</p><p>XVII: 17</p><p>XVIII: 18</p><p>XIX: 19</p><p>XX: 20</p><p>XXI: 21</p><p>XXII: 22</p><p>XXIII: 23</p><p>XXIV: 24</p><p>XXV: 25</p><p>XXVI: 26</p><p>XXVII: 27</p><p>XXVIII: 28</p><p>XXIX: 29</p><p>XXX: 30</p><p>XXXI: 31</p><p>XXXII: 32</p><p>XXXIII: 33</p><p>XXXIV: 34</p><p>XXXV: 35</p><p>XXXVI: 36</p><p>XXXVII: 37</p><p>XXXVIII: 38</p><p>XXXIX: 39</p><p>XL: 40</p><p>XLI: 41</p><p>XLII: 42</p><p>XLIII: 43</p><p>XLIV: 44</p><p>XLV: 45</p><p>XLVI: 46</p><p>XLVII: 47</p><p>XLVIII: 48</p><p>XLIX: 49</p><p>L: 50</p><p>LI: 51</p><p>LII: 52</p><p>LIII: 53</p><p>LIV: 54</p><p>LV: 55</p><p>LVI: 56</p><p>LVII: 57</p><p>LVIII: 58</p><p>LIX: 59</p><p>LX: 60</p><p>LXI: 61</p><p>LXII: 62</p><p>LXIII: 63</p><p>LXIV: 64</p><p>LXV: 65</p><p>LXVI: 66</p><p>LXVII: 67</p><p>LXVIII: 68</p><p>LXIX: 69</p><p>LXX: 70</p><p>LXXI: 71</p><p>LXXII: 72</p><p>LXXIII: 73</p><p>LXXIV: 74</p><p>LXXV: 75</p><p>LXXVI: 76</p><p>LXXVII: 77</p><p>LXXVIII: 78</p><p>LXXIX: 79</p><p>LXXX: 80</p><p>LXXXI: 81</p><p>LXXXII: 82</p><p>LXXXIII: 83</p><p>LXXXIV: 84</p><p>LXXXV: 85</p><p>LXXXVI: 86</p><p>LXXXVII: 87</p><p>LXXXVIII: 88</p><p>LXXXIX: 89</p><p>XC: 90</p><p>XCI: 91</p><p>XCII: 92</p><p>XCIII: 93</p><p>XCIV: 94</p><p>XCV: 95</p><p>XCVI: 96</p><p>XCVII: 97</p><p>XCVIII: 98</p><p>XCIX: 99</p></html>', 'Repeat variable Roman failed.') def testLocalVarScope(self): self._runTest_( '<html><p tal:repeat="var fourList"><b tal:replace="var">bold</b></p><b tal:condition="exists:var">VAR EXISTS</b></html>', '<?xml version="1.0" encoding="iso-8859-1"?>\n<html><p>zero</p><p>one</p><p>two</p><p>three</p></html>', 'Local repeat variable remained accessible out of scope!') if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 199, 3, 259, 1898, 334, 67, 9, 7800, 12, 17474, 699, 293, 15544, 665, 24418, 20670, 15544, 32, 84, 13, 15178, 14, 271, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 1666, 5113, 14, 2424, 199, 199, 3, 259, 1898, 334, 67, 9, 8353, 3626, 262, 17854, 87, 580, 334, 1014, 921, 1544, 14, 583, 276, 2453, 14, 957, 24793, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 259, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 259, 787, 7647, 26, 199, 3, 259, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 259, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 259, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 259, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 199, 3, 259, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 259, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 259, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 259, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 259, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 259, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 259, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 199, 3, 259, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 259, 982, 1265, 1852, 1263, 6519, 25079, 503, 3878, 655, 14666, 1470, 8749, 4691, 562, 5715, 1, 199, 624, 1057, 9068, 198, 5072, 511, 5560, 14, 686, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2882, 199, 646, 747, 199, 646, 5890, 199, 646, 2050, 199, 646, 2050, 14, 888, 199, 199, 504, 3486, 31466, 492, 3486, 52, 748, 12, 3486, 52, 748, 654, 199, 199, 692, 334, 736, 14, 515, 14, 2444, 480, 4806, 14, 2730, 14150, 272, 2050, 14, 888, 14, 493, 2028, 480, 4806, 14, 2730, 531, 199, 2836, 26, 272, 2050, 14, 19602, 342, 421, 199, 533, 377, 748, 27600, 19346, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1100, 275, 3486, 52, 748, 654, 14, 2998, 342, 267, 291, 14, 1100, 14, 525, 7025, 360, 396, 297, 283, 4776, 358, 267, 291, 14, 1100, 14, 525, 7025, 360, 368, 297, 359, 17, 566, 267, 291, 14, 1100, 14, 525, 7025, 360, 5601, 297, 2097, 368, 401, 298, 5601, 3135, 267, 291, 14, 1100, 14, 525, 7025, 360, 10480, 297, 359, 17, 12, 298, 11467, 401, 650, 566, 267, 291, 14, 1100, 14, 525, 7025, 360, 5076, 1296, 297, 1425, 8, 17, 12, 2948, 430, 267, 291, 14, 1100, 14, 525, 7025, 360, 13672, 1296, 297, 2097, 4262, 401, 298, 368, 401, 298, 5601, 401, 298, 10480, 3135, 267, 291, 14, 1100, 14, 525, 7025, 360, 6376, 297, 8910, 288, 283, 1213, 356, 283, 3491, 413, 297, 288, 283, 3385, 1296, 356, 359, 17, 12, 499, 12, 650, 61, 267, 1660, 469, 288, 283, 1213, 356, 283, 3491, 499, 297, 288, 283, 3385, 1296, 356, 359, 21, 12, 499, 12, 650, 61, 267, 1660, 469, 288, 283, 1213, 356, 283, 3491, 650, 297, 288, 283, 3385, 1296, 356, 359, 24, 12, 1749, 12, 413, 61, 267, 789, 566, 339, 347, 485, 27850, 2531, 277, 12, 9444, 12, 754, 12, 2329, 6173, 628, 547, 2349, 267, 1978, 275, 3486, 52, 748, 14, 2014, 4317, 4231, 8, 2424, 9, 267, 570, 275, 5890, 14, 6424, 342, 267, 1978, 14, 4441, 8, 277, 14, 1100, 12, 570, 12, 1072, 7630, 628, 4595, 13, 4830, 13, 17, 531, 267, 3363, 2889, 275, 570, 14, 7150, 342, 267, 291, 14, 629, 8, 288, 3363, 2889, 12, 754, 12, 288, 2071, 83, 446, 971, 1590, 2744, 315, 26, 450, 83, 971, 2753, 357, 1771, 450, 83, 971, 78, 2062, 450, 83, 60, 78, 60, 78, 4231, 26, 450, 83, 2, 288, 450, 334, 1508, 6173, 12, 9444, 12, 3363, 2889, 12, 754, 12, 1978, 430, 339, 347, 511, 3364, 2042, 8, 277, 304, 267, 291, 423, 27850, 2531, 288, 2650, 1360, 2535, 80, 307, 279, 26, 8755, 628, 2373, 336, 30012, 1743, 6257, 1108, 80, 2957, 1360, 4206, 288, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 4595, 13, 4830, 13, 17, 14863, 3072, 78, 28, 1360, 2957, 1360, 4206, 288, 298, 27600, 402, 2222, 13, 4494, 867, 1819, 3405, 531, 339, 347, 511, 2698, 1110, 8, 277, 304, 267, 291, 423, 27850, 2531, 288, 2650, 1360, 2535, 80, 307, 279, 26, 8755, 628, 2373, 849, 1743, 2698, 5972, 1108, 80, 2957, 1360, 4206, 288, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 4595, 13, 4830, 13, 17, 14863, 3072, 78, 28, 1360, 2535, 80, 30, 2698, 5972, 1108, 80, 2957, 1360, 4206, 288, 283, 2698, 8103, 440, 4215, 3411, 5523, 315, 4552, 358, 339, 347, 511, 4699, 1296, 8, 277, 304, 267, 291, 423, 27850, 2531, 288, 2650, 1360, 2535, 80, 307, 279, 26, 8755, 628, 3612, 2701, 1296, 8186, 66, 307, 279, 26, 1814, 628, 3612, 1743, 4699, 1108, 66, 2957, 80, 2957, 1360, 4206, 288, 2650, 31 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 11601, 13, 4830, 13, 17, 1882, 199, 199, 3, 259, 1898, 334, 67, 9, 7800, 12, 17474, 699, 293, 15544, 665, 24418, 20670, 15544, 32, 84, 13, 15178, 14, 271, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 1666, 5113, 14, 2424, 199, 199, 3, 259, 1898, 334, 67, 9, 8353, 3626, 262, 17854, 87, 580, 334, 1014, 921, 1544, 14, 583, 276, 2453, 14, 957, 24793, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 259, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 259, 787, 7647, 26, 199, 3, 259, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 259, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 259, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 199, 3, 259, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 199, 3, 259, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 259, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 259, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 199, 3, 259, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 259, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 259, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 259, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 199, 3, 259, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 259, 982, 1265, 1852, 1263, 6519, 25079, 503, 3878, 655, 14666, 1470, 8749, 4691, 562, 5715, 1, 199, 624, 1057, 9068, 198, 5072, 511, 5560, 14, 686, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2882, 199, 646, 747, 199, 646, 5890, 199, 646, 2050, 199, 646, 2050, 14, 888, 199, 199, 504, 3486, 31466, 492, 3486, 52, 748, 12, 3486, 52, 748, 654, 199, 199, 692, 334, 736, 14, 515, 14, 2444, 480, 4806, 14, 2730, 14150, 272, 2050, 14, 888, 14, 493, 2028, 480, 4806, 14, 2730, 531, 199, 2836, 26, 272, 2050, 14, 19602, 342, 421, 199, 533, 377, 748, 27600, 19346, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1100, 275, 3486, 52, 748, 654, 14, 2998, 342, 267, 291, 14, 1100, 14, 525, 7025, 360, 396, 297, 283, 4776, 358, 267, 291, 14, 1100, 14, 525, 7025, 360, 368, 297, 359, 17, 566, 267, 291, 14, 1100, 14, 525, 7025, 360, 5601, 297, 2097, 368, 401, 298, 5601, 3135, 267, 291, 14, 1100, 14, 525, 7025, 360, 10480, 297, 359, 17, 12, 298, 11467, 401, 650, 566, 267, 291, 14, 1100, 14, 525, 7025, 360, 5076, 1296, 297, 1425, 8, 17, 12, 2948, 430, 267, 291, 14, 1100, 14, 525, 7025, 360, 13672, 1296, 297, 2097, 4262, 401, 298, 368, 401, 298, 5601, 401, 298, 10480, 3135, 267, 291, 14, 1100, 14, 525, 7025, 360, 6376, 297, 8910, 288, 283, 1213, 356, 283, 3491, 413, 297, 288, 283, 3385, 1296, 356, 359, 17, 12, 499, 12, 650, 61, 267, 1660, 469, 288, 283, 1213, 356, 283, 3491, 499, 297, 288, 283, 3385, 1296, 356, 359, 21, 12, 499, 12, 650, 61, 267, 1660, 469, 288, 283, 1213, 356, 283, 3491, 650, 297, 288, 283, 3385, 1296, 356, 359, 24, 12, 1749, 12, 413, 61, 267, 789, 566, 339, 347, 485, 27850, 2531, 277, 12, 9444, 12, 754, 12, 2329, 6173, 628, 547, 2349, 267, 1978, 275, 3486, 52, 748, 14, 2014, 4317, 4231, 8, 2424, 9, 267, 570, 275, 5890, 14, 6424, 342, 267, 1978, 14, 4441, 8, 277, 14, 1100, 12, 570, 12, 1072, 7630, 628, 4595, 13, 4830, 13, 17, 531, 267, 3363, 2889, 275, 570, 14, 7150, 342, 267, 291, 14, 629, 8, 288, 3363, 2889, 12, 754, 12, 288, 2071, 83, 446, 971, 1590, 2744, 315, 26, 450, 83, 971, 2753, 357, 1771, 450, 83, 971, 78, 2062, 450, 83, 60, 78, 60, 78, 4231, 26, 450, 83, 2, 288, 450, 334, 1508, 6173, 12, 9444, 12, 3363, 2889, 12, 754, 12, 1978, 430, 339, 347, 511, 3364, 2042, 8, 277, 304, 267, 291, 423, 27850, 2531, 288, 2650, 1360, 2535, 80, 307, 279, 26, 8755, 628, 2373, 336, 30012, 1743, 6257, 1108, 80, 2957, 1360, 4206, 288, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 4595, 13, 4830, 13, 17, 14863, 3072, 78, 28, 1360, 2957, 1360, 4206, 288, 298, 27600, 402, 2222, 13, 4494, 867, 1819, 3405, 531, 339, 347, 511, 2698, 1110, 8, 277, 304, 267, 291, 423, 27850, 2531, 288, 2650, 1360, 2535, 80, 307, 279, 26, 8755, 628, 2373, 849, 1743, 2698, 5972, 1108, 80, 2957, 1360, 4206, 288, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 4595, 13, 4830, 13, 17, 14863, 3072, 78, 28, 1360, 2535, 80, 30, 2698, 5972, 1108, 80, 2957, 1360, 4206, 288, 283, 2698, 8103, 440, 4215, 3411, 5523, 315, 4552, 358, 339, 347, 511, 4699, 1296, 8, 277, 304, 267, 291, 423, 27850, 2531,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dscorbett/pygments
pygments/lexers/mime.py
4
7975
# -*- coding: utf-8 -*- """ pygments.lexers.mime ~~~~~~~~~~~~~~~~~~~~ Lexer for Multipurpose Internet Mail Extensions (MIME) data. :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import RegexLexer, include from pygments.lexers import get_lexer_for_mimetype from pygments.token import Text, Name, String, Operator, Comment, Other from pygments.util import get_int_opt, ClassNotFound __all__ = ["MIMELexer"] class MIMELexer(RegexLexer): """ Lexer for Multipurpose Internet Mail Extensions (MIME) data. This lexer is designed to process the nested mulitpart data. It assumes that the given data contains both header and body (and is splitted by empty line). If no valid header is found, then the entire data would be treated as body. Additional options accepted: `MIME-max-level` Max recurssion level for nested MIME structure. Any negative number would treated as unlimited. (default: -1) `Content-Type` Treat the data as specific content type. Useful when header is missing, or this lexer would try to parse from header. (default: `text/plain`) `Multipart-Boundary` Set the default multipart boundary delimiter. This option is only used when `Content-Type` is `multipart` and header is missing. This lexer would try to parse from header by default. (default: None) `Content-Transfer-Encoding` Treat the data as specific encoding. Or this lexer would try to parse from header by default. (default: None) .. versionadded:: 2.5 """ name = "MIME" aliases = ["mime"] mimetypes = ["multipart/mixed", "multipart/related", "multipart/alternative"] def __init__(self, **options): super(MIMELexer, self).__init__(**options) self.boundary = options.get("Multipart-Boundary") self.content_transfer_encoding = options.get("Content_Transfer_Encoding") self.content_type = options.get("Content_Type", "text/plain") self.max_nested_level = get_int_opt(options, "MIME-max-level", -1) def analyse_text(text): try: header, body = text.strip().split("\n\n", 1) if not body.strip(): return 0.1 invalid_headers = MIMELexer.tokens["header"].sub("", header) if invalid_headers.strip(): return 0.1 else: return 1 except ValueError: return 0.1 def get_header_tokens(self, match): field = match.group(1) if field.lower() in self.attention_headers: yield match.start(1), Name.Tag, field + ":" yield match.start(2), Text.Whitespace, match.group(2) pos = match.end(2) body = match.group(3) for i, t, v in self.get_tokens_unprocessed(body, ("root", field.lower())): yield pos + i, t, v else: yield match.start(), Comment, match.group() def get_body_tokens(self, match): pos_body_start = match.start() entire_body = match.group() # skip first newline if entire_body[0] == '\n': yield pos_body_start, Text.Whitespace, u'\n' pos_body_start = pos_body_start + 1 entire_body = entire_body[1:] # if it is not a mulitpart if not self.content_type.startswith("multipart") or not self.boundary: for i, t, v in self.get_bodypart_tokens(entire_body): yield pos_body_start + i, t, v return # find boundary bdry_pattern = r"^--%s(--)?\n" % re.escape(self.boundary) bdry_matcher = re.compile(bdry_pattern, re.MULTILINE) # some data has prefix text before first boundary m = bdry_matcher.search(entire_body) if m: pos_part_start = pos_body_start + m.end() pos_iter_start = lpos_end = m.end() yield pos_body_start, Text, entire_body[:m.start()] yield pos_body_start + lpos_end, String.Delimiter, m.group() else: pos_part_start = pos_body_start pos_iter_start = 0 # process tokens of each body part for m in bdry_matcher.finditer(entire_body, pos_iter_start): # bodypart lpos_start = pos_part_start - pos_body_start lpos_end = m.start() part = entire_body[lpos_start:lpos_end] for i, t, v in self.get_bodypart_tokens(part): yield pos_part_start + i, t, v # boundary yield pos_body_start + lpos_end, String.Delimiter, m.group() pos_part_start = pos_body_start + m.end() # some data has suffix text after last boundary lpos_start = pos_part_start - pos_body_start if lpos_start != len(entire_body): yield pos_part_start, Text, entire_body[lpos_start:] def get_bodypart_tokens(self, text): # return if: # * no content # * no content type specific # * content encoding is not readable # * max recurrsion exceed if not text.strip() or not self.content_type: return [(0, Other, text)] cte = self.content_transfer_encoding if cte and cte not in {"8bit", "7bit", "quoted-printable"}: return [(0, Other, text)] if self.max_nested_level == 0: return [(0, Other, text)] # get lexer try: lexer = get_lexer_for_mimetype(self.content_type) except ClassNotFound: return [(0, Other, text)] if isinstance(lexer, type(self)): lexer.max_nested_level = self.max_nested_level - 1 return lexer.get_tokens_unprocessed(text) def store_content_type(self, match): self.content_type = match.group(1) prefix_len = match.start(1) - match.start(0) yield match.start(0), Text.Whitespace, match.group(0)[:prefix_len] yield match.start(1), Name.Label, match.group(2) yield match.end(2), String.Delimiter, u"/" yield match.start(3), Name.Label, match.group(3) def get_content_type_subtokens(self, match): yield match.start(1), Text, match.group(1) yield match.start(2), Text.Whitespace, match.group(2) yield match.start(3), Name.Attribute, match.group(3) yield match.start(4), Operator, match.group(4) yield match.start(5), String, match.group(5) if match.group(3).lower() == "boundary": boundary = match.group(5).strip() if boundary[0] == '"' and boundary[-1] == '"': boundary = boundary[1:-1] self.boundary = boundary def store_content_transfer_encoding(self, match): self.content_transfer_encoding = match.group(0).lower() yield match.start(0), Name.Constant, match.group(0) attention_headers = {"content-type", "content-transfer-encoding"} tokens = { "root": [ (r"^([\w-]+):( *)([\s\S]*?\n)(?![ \t])", get_header_tokens), (r"^$[\s\S]+", get_body_tokens), ], "header": [ # folding (r"\n[ \t]", Text.Whitespace), (r"\n(?![ \t])", Text.Whitespace, "#pop"), ], "content-type": [ include("header"), ( r"^\s*((multipart|application|audio|font|image|model|text|video" r"|message)/([\w-]+))", store_content_type, ), (r'(;)((?:[ \t]|\n[ \t])*)([\w:-]+)(=)([\s\S]*?)(?=;|\n(?![ \t]))', get_content_type_subtokens), (r';[ \t]*\n(?![ \t])', Text, '#pop'), ], "content-transfer-encoding": [ include("header"), (r"([\w-]+)", store_content_transfer_encoding), ], }
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 7626, 272, 18294, 2878, 339, 21125, 367, 603, 2092, 300, 4070, 22026, 18027, 11524, 1356, 334, 17057, 9, 666, 14, 339, 520, 7307, 26, 1898, 8315, 13, 14982, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 2387, 199, 504, 13277, 14, 12245, 492, 664, 63, 11729, 63, 509, 63, 17450, 199, 504, 13277, 14, 1418, 492, 4516, 12, 2812, 12, 2624, 12, 11013, 12, 6819, 12, 5439, 199, 504, 13277, 14, 1974, 492, 664, 63, 442, 63, 2992, 12, 8089, 4667, 199, 199, 363, 452, 363, 275, 2097, 45, 1469, 2901, 5273, 937, 421, 199, 533, 603, 1469, 2901, 5273, 8, 19856, 304, 272, 408, 272, 21125, 367, 603, 2092, 300, 4070, 22026, 18027, 11524, 1356, 334, 17057, 9, 666, 14, 961, 10426, 365, 272, 19829, 370, 2112, 314, 6032, 8504, 1051, 2064, 666, 14, 339, 2779, 15194, 626, 314, 1627, 666, 3509, 3865, 1406, 436, 2396, 334, 460, 365, 272, 30183, 701, 2701, 1004, 680, 982, 949, 1686, 1406, 365, 1911, 12, 2066, 314, 8039, 666, 272, 3955, 506, 10184, 465, 2396, 14, 339, 10961, 1511, 10226, 26, 339, 658, 17057, 13, 988, 13, 1896, 64, 267, 8228, 5344, 83, 438, 2166, 367, 6032, 14735, 5523, 14, 6184, 6946, 1329, 267, 3955, 10184, 465, 625, 14136, 14, 334, 885, 26, 446, 17, 9, 339, 658, 2714, 13, 804, 64, 267, 377, 8319, 314, 666, 465, 2488, 1564, 730, 14, 18491, 1380, 1406, 365, 267, 4124, 12, 503, 642, 10426, 3955, 862, 370, 2198, 687, 1406, 14, 334, 885, 26, 267, 658, 505, 15, 6104, 10522, 339, 658, 27242, 13, 19831, 64, 267, 2494, 314, 849, 15193, 8424, 11172, 14, 961, 945, 365, 1454, 1202, 267, 1380, 658, 2714, 13, 804, 64, 365, 658, 10123, 64, 436, 1406, 365, 4124, 14, 961, 10426, 267, 3955, 862, 370, 2198, 687, 1406, 701, 849, 14, 334, 885, 26, 488, 9, 339, 658, 2714, 13, 11761, 13, 7630, 64, 267, 377, 8319, 314, 666, 465, 2488, 2644, 14, 4236, 642, 10426, 3955, 862, 370, 2198, 267, 687, 1406, 701, 849, 14, 334, 885, 26, 488, 9, 339, 2508, 7445, 447, 499, 14, 21, 272, 408, 339, 536, 275, 298, 17057, 2, 272, 5481, 275, 2097, 7626, 937, 272, 13290, 275, 2097, 10123, 15, 10455, 401, 326, 298, 10123, 15, 2407, 401, 326, 298, 10123, 15, 19389, 937, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 1613, 8, 45, 1469, 2901, 5273, 12, 291, 2843, 826, 14155, 1419, 9, 267, 291, 14, 9891, 275, 1511, 14, 362, 480, 27242, 13, 19831, 531, 267, 291, 14, 1317, 63, 9609, 63, 2991, 275, 1511, 14, 362, 480, 2714, 63, 11761, 63, 7630, 531, 267, 291, 14, 1317, 63, 466, 275, 1511, 14, 362, 480, 2714, 63, 804, 401, 298, 505, 15, 6104, 531, 267, 291, 14, 988, 63, 6376, 63, 1896, 275, 664, 63, 442, 63, 2992, 8, 1419, 12, 298, 17057, 13, 988, 13, 1896, 401, 446, 17, 9, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 862, 26, 288, 1406, 12, 2396, 275, 1318, 14, 1913, 1252, 1294, 4582, 78, 60, 78, 401, 413, 9, 288, 340, 440, 2396, 14, 1913, 837, 355, 372, 378, 14, 17, 953, 3866, 63, 2139, 275, 603, 1469, 2901, 5273, 14, 4504, 905, 1291, 4140, 954, 12398, 1406, 9, 288, 340, 3866, 63, 2139, 14, 1913, 837, 355, 372, 378, 14, 17, 288, 587, 26, 355, 372, 413, 398, 871, 1722, 26, 288, 372, 378, 14, 17, 339, 347, 664, 63, 1291, 63, 4504, 8, 277, 12, 1336, 304, 267, 901, 275, 1336, 14, 923, 8, 17, 9, 398, 340, 901, 14, 2325, 342, 315, 291, 14, 22393, 63, 2139, 26, 288, 1995, 1336, 14, 928, 8, 17, 395, 2812, 14, 1931, 12, 901, 435, 14725, 288, 1995, 1336, 14, 928, 8, 18, 395, 4516, 14, 16552, 12, 1336, 14, 923, 8, 18, 9, 953, 2086, 275, 1336, 14, 500, 8, 18, 9, 288, 2396, 275, 1336, 14, 923, 8, 19, 9, 288, 367, 284, 12, 307, 12, 373, 315, 291, 14, 362, 63, 4504, 63, 24088, 8, 2030, 12, 1689, 1231, 401, 901, 14, 2325, 28256, 355, 1995, 2086, 435, 284, 12, 307, 12, 373, 398, 587, 26, 288, 1995, 1336, 14, 928, 1062, 6819, 12, 1336, 14, 923, 342, 339, 347, 664, 63, 2030, 63, 4504, 8, 277, 12, 1336, 304, 267, 2086, 63, 2030, 63, 928, 275, 1336, 14, 928, 342, 267, 8039, 63, 2030, 275, 1336, 14, 923, 342, 398, 327, 3372, 1642, 8057, 267, 340, 8039, 63, 2030, 59, 16, 61, 508, 1557, 78, 356, 288, 1995, 2086, 63, 2030, 63, 928, 12, 4516, 14, 16552, 12, 399, 1154, 78, 7, 288, 2086, 63, 2030, 63, 928, 275, 2086, 63, 2030, 63, 928, 435, 413, 288, 8039, 63, 2030, 275, 8039, 63, 2030, 59, 17, 2938, 398, 327, 340, 652, 365, 440, 282, 8504, 1051, 2064, 267, 340, 440, 291, 14, 1317, 63, 466, 14, 2460, 480, 10123, 531, 503, 440, 291, 14, 9891, 26, 288, 367, 284, 12, 307, 12, 373, 315, 291, 14, 362, 63, 2030, 2064, 63, 4504, 8, 287, 7261, 63, 2030, 304, 355, 1995, 2086, 63, 2030, 63, 928, 435, 284, 12, 307, 12, 373, 288, 372, 398, 327, 2342, 8424, 267, 330, 10481, 63, 3401, 275, 519, 16136, 306, 5, 83, 8, 306, 5547, 60, 78, 2, 450, 295, 14, 3765, 8, 277, 14, 9891, 9, 267, 330, 10481, 63, 16135, 275, 295, 14, 2014, 8, 3691, 651, 63, 3401, 12, 295, 14, 16661, 9, 398, 327, 2005, 666, 965, 2403, 1318, 2544, 1642, 8424, 267, 333, 275, 330, 10481, 63, 16135, 14, 1733, 8, 287, 7261, 63, 2030, 9, 267, 340, 333, 26, 288, 2086, 63, 2064, 63, 928, 275, 2086, 63, 2030, 63, 928, 435, 333, 14, 500, 342, 288, 2086, 63, 1661, 63, 928, 275, 634, 1712, 63, 500, 275, 333, 14, 500, 342, 288, 1995, 2086, 63, 2030, 63, 928, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 12245, 14, 7626, 272, 18294, 2878, 339, 21125, 367, 603, 2092, 300, 4070, 22026, 18027, 11524, 1356, 334, 17057, 9, 666, 14, 339, 520, 7307, 26, 1898, 8315, 13, 14982, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 646, 295, 199, 199, 504, 13277, 14, 11729, 492, 12939, 5838, 12, 2387, 199, 504, 13277, 14, 12245, 492, 664, 63, 11729, 63, 509, 63, 17450, 199, 504, 13277, 14, 1418, 492, 4516, 12, 2812, 12, 2624, 12, 11013, 12, 6819, 12, 5439, 199, 504, 13277, 14, 1974, 492, 664, 63, 442, 63, 2992, 12, 8089, 4667, 199, 199, 363, 452, 363, 275, 2097, 45, 1469, 2901, 5273, 937, 421, 199, 533, 603, 1469, 2901, 5273, 8, 19856, 304, 272, 408, 272, 21125, 367, 603, 2092, 300, 4070, 22026, 18027, 11524, 1356, 334, 17057, 9, 666, 14, 961, 10426, 365, 272, 19829, 370, 2112, 314, 6032, 8504, 1051, 2064, 666, 14, 339, 2779, 15194, 626, 314, 1627, 666, 3509, 3865, 1406, 436, 2396, 334, 460, 365, 272, 30183, 701, 2701, 1004, 680, 982, 949, 1686, 1406, 365, 1911, 12, 2066, 314, 8039, 666, 272, 3955, 506, 10184, 465, 2396, 14, 339, 10961, 1511, 10226, 26, 339, 658, 17057, 13, 988, 13, 1896, 64, 267, 8228, 5344, 83, 438, 2166, 367, 6032, 14735, 5523, 14, 6184, 6946, 1329, 267, 3955, 10184, 465, 625, 14136, 14, 334, 885, 26, 446, 17, 9, 339, 658, 2714, 13, 804, 64, 267, 377, 8319, 314, 666, 465, 2488, 1564, 730, 14, 18491, 1380, 1406, 365, 267, 4124, 12, 503, 642, 10426, 3955, 862, 370, 2198, 687, 1406, 14, 334, 885, 26, 267, 658, 505, 15, 6104, 10522, 339, 658, 27242, 13, 19831, 64, 267, 2494, 314, 849, 15193, 8424, 11172, 14, 961, 945, 365, 1454, 1202, 267, 1380, 658, 2714, 13, 804, 64, 365, 658, 10123, 64, 436, 1406, 365, 4124, 14, 961, 10426, 267, 3955, 862, 370, 2198, 687, 1406, 701, 849, 14, 334, 885, 26, 488, 9, 339, 658, 2714, 13, 11761, 13, 7630, 64, 267, 377, 8319, 314, 666, 465, 2488, 2644, 14, 4236, 642, 10426, 3955, 862, 370, 2198, 267, 687, 1406, 701, 849, 14, 334, 885, 26, 488, 9, 339, 2508, 7445, 447, 499, 14, 21, 272, 408, 339, 536, 275, 298, 17057, 2, 272, 5481, 275, 2097, 7626, 937, 272, 13290, 275, 2097, 10123, 15, 10455, 401, 326, 298, 10123, 15, 2407, 401, 326, 298, 10123, 15, 19389, 937, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 1613, 8, 45, 1469, 2901, 5273, 12, 291, 2843, 826, 14155, 1419, 9, 267, 291, 14, 9891, 275, 1511, 14, 362, 480, 27242, 13, 19831, 531, 267, 291, 14, 1317, 63, 9609, 63, 2991, 275, 1511, 14, 362, 480, 2714, 63, 11761, 63, 7630, 531, 267, 291, 14, 1317, 63, 466, 275, 1511, 14, 362, 480, 2714, 63, 804, 401, 298, 505, 15, 6104, 531, 267, 291, 14, 988, 63, 6376, 63, 1896, 275, 664, 63, 442, 63, 2992, 8, 1419, 12, 298, 17057, 13, 988, 13, 1896, 401, 446, 17, 9, 339, 347, 21297, 63, 505, 8, 505, 304, 267, 862, 26, 288, 1406, 12, 2396, 275, 1318, 14, 1913, 1252, 1294, 4582, 78, 60, 78, 401, 413, 9, 288, 340, 440, 2396, 14, 1913, 837, 355, 372, 378, 14, 17, 953, 3866, 63, 2139, 275, 603, 1469, 2901, 5273, 14, 4504, 905, 1291, 4140, 954, 12398, 1406, 9, 288, 340, 3866, 63, 2139, 14, 1913, 837, 355, 372, 378, 14, 17, 288, 587, 26, 355, 372, 413, 398, 871, 1722, 26, 288, 372, 378, 14, 17, 339, 347, 664, 63, 1291, 63, 4504, 8, 277, 12, 1336, 304, 267, 901, 275, 1336, 14, 923, 8, 17, 9, 398, 340, 901, 14, 2325, 342, 315, 291, 14, 22393, 63, 2139, 26, 288, 1995, 1336, 14, 928, 8, 17, 395, 2812, 14, 1931, 12, 901, 435, 14725, 288, 1995, 1336, 14, 928, 8, 18, 395, 4516, 14, 16552, 12, 1336, 14, 923, 8, 18, 9, 953, 2086, 275, 1336, 14, 500, 8, 18, 9, 288, 2396, 275, 1336, 14, 923, 8, 19, 9, 288, 367, 284, 12, 307, 12, 373, 315, 291, 14, 362, 63, 4504, 63, 24088, 8, 2030, 12, 1689, 1231, 401, 901, 14, 2325, 28256, 355, 1995, 2086, 435, 284, 12, 307, 12, 373, 398, 587, 26, 288, 1995, 1336, 14, 928, 1062, 6819, 12, 1336, 14, 923, 342, 339, 347, 664, 63, 2030, 63, 4504, 8, 277, 12, 1336, 304, 267, 2086, 63, 2030, 63, 928, 275, 1336, 14, 928, 342, 267, 8039, 63, 2030, 275, 1336, 14, 923, 342, 398, 327, 3372, 1642, 8057, 267, 340, 8039, 63, 2030, 59, 16, 61, 508, 1557, 78, 356, 288, 1995, 2086, 63, 2030, 63, 928, 12, 4516, 14, 16552, 12, 399, 1154, 78, 7, 288, 2086, 63, 2030, 63, 928, 275, 2086, 63, 2030, 63, 928, 435, 413, 288, 8039, 63, 2030, 275, 8039, 63, 2030, 59, 17, 2938, 398, 327, 340, 652, 365, 440, 282, 8504, 1051, 2064, 267, 340, 440, 291, 14, 1317, 63, 466, 14, 2460, 480, 10123, 531, 503, 440, 291, 14, 9891, 26, 288, 367, 284, 12, 307, 12, 373, 315, 291, 14, 362, 63, 2030, 2064, 63, 4504, 8, 287, 7261, 63, 2030, 304, 355, 1995, 2086, 63, 2030, 63, 928, 435, 284, 12, 307, 12, 373, 288, 372, 398, 327, 2342, 8424, 267, 330, 10481, 63, 3401, 275, 519, 16136, 306, 5, 83, 8, 306, 5547, 60, 78, 2, 450, 295, 14, 3765, 8, 277, 14, 9891, 9, 267, 330, 10481, 63, 16135, 275, 295, 14, 2014, 8, 3691, 651, 63, 3401, 12, 295, 14, 16661, 9, 398, 327, 2005, 666, 965, 2403, 1318, 2544, 1642, 8424, 267, 333, 275, 330, 10481, 63, 16135, 14, 1733, 8, 287, 7261, 63, 2030, 9, 267, 340, 333, 26, 288, 2086, 63, 2064, 63, 928, 275, 2086, 63, 2030, 63, 928, 435, 333, 14, 500, 342, 288, 2086, 63, 1661, 63, 928, 275, 634, 1712, 63, 500, 275, 333, 14, 500, 342, 288, 1995, 2086, 63, 2030, 63, 928, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
quentinl-c/network_testing-client
app/editor.py
1
2631
from collaborator import Collaborator import os import random import logging import time logging.basicConfig(filename=__name__ + '.log', level=logging.DEBUG) logger = logging.getLogger(__name__) HOME_DIR = os.getenv('HOME_DIR', '/home/') WRITER_SELECTOR = 'ace_text-input' READER_SELECTOR = 'ace_content' FILTER = '[Tracker]' tempo = 15 # Client will wait 20 secondes befores getting results class Editor(Collaborator): """docstring for Editor""" def __init__(self, controller, target, typing_speed, word_to_type): Collaborator.__init__(self, controller, target) logger.debug("=== Editor is being instanciated ===") self.word_to_type = None self.counter = 0 if len(word_to_type) > 0: selector = WRITER_SELECTOR self.word_to_type = word_to_type else: selector = READER_SELECTOR self.word_to_type = None self.select = None while self.select is None: self._driver.implicitly_wait(20) self.select = self._driver.find_element_by_class_name( selector) def run(self): self.alive = True if self.word_to_type is not None: beg_time = random.uniform(2.0, 6.0) time.sleep(beg_time) while self.alive: if self.word_to_type is not None: w = ''.join((self.word_to_type, ';', str(self.counter).zfill(6))) self.select.send_keys(w) self.counter += 1 time.sleep(2) else: self.select.text self.saveTxt() def getResults(self): time.sleep(tempo) logger.debug("=== Get results from log files ===") tmp = [] self.alive = False time.sleep(tempo) with open(self._log_path, 'r') as content_file: for line in content_file: beg = line.find(FILTER) if beg != -1: rec = line[beg:].split(',')[0].split('"')[0] tmp.append(rec) content = '\n'.join(tmp) self._controller.sendResults(content) def saveTxt(self): if self.word_to_type is not None: self.select = None while self.select is None: self._driver.implicitly_wait(20) self.select = self._driver.find_element_by_class_name( READER_SELECTOR) content = self.select.text file = open(HOME_DIR + str(self._controller.id) + '_content.txt', 'w') file.write(content) file.close()
gpl-3.0
[ 504, 1048, 5561, 10676, 492, 3626, 5561, 10676, 199, 646, 747, 199, 646, 2196, 199, 646, 2050, 199, 646, 900, 199, 199, 4806, 14, 19602, 8, 1501, 18971, 354, 363, 435, 1987, 793, 297, 2166, 29, 4806, 14, 5287, 9, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 9524, 63, 3022, 275, 747, 14, 12959, 360, 9524, 63, 3022, 297, 1994, 4219, 6217, 199, 199, 6524, 11084, 63, 25691, 275, 283, 7984, 63, 505, 13, 1210, 7, 199, 5670, 540, 63, 25691, 275, 283, 7984, 63, 1317, 7, 199, 9905, 275, 6730, 13652, 6616, 199, 808, 79, 275, 4114, 221, 327, 6810, 911, 3618, 3388, 542, 388, 3424, 506, 545, 470, 10232, 2058, 421, 199, 533, 30318, 8, 2001, 5561, 10676, 304, 272, 408, 12485, 367, 30318, 624, 272, 347, 636, 826, 721, 277, 12, 7614, 12, 1347, 12, 14090, 63, 7625, 12, 4349, 63, 475, 63, 466, 304, 267, 3626, 5561, 10676, 855, 826, 721, 277, 12, 7614, 12, 1347, 9, 267, 2512, 14, 1757, 480, 5918, 221, 30318, 365, 3769, 2727, 290, 559, 972, 24768, 531, 267, 291, 14, 1027, 63, 475, 63, 466, 275, 488, 267, 291, 14, 5337, 275, 378, 398, 340, 822, 8, 1027, 63, 475, 63, 466, 9, 690, 378, 26, 288, 9759, 275, 16573, 11084, 63, 25691, 288, 291, 14, 1027, 63, 475, 63, 466, 275, 4349, 63, 475, 63, 466, 267, 587, 26, 288, 9759, 275, 16767, 540, 63, 25691, 288, 291, 14, 1027, 63, 475, 63, 466, 275, 488, 398, 291, 14, 2416, 275, 488, 267, 1830, 291, 14, 2416, 365, 488, 26, 288, 291, 423, 3090, 14, 31120, 63, 2573, 8, 1165, 9, 288, 291, 14, 2416, 275, 291, 423, 3090, 14, 1623, 63, 2108, 63, 991, 63, 533, 63, 354, 8, 355, 9759, 9, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 9631, 275, 715, 398, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 288, 31191, 63, 521, 275, 2196, 14, 8830, 8, 18, 14, 16, 12, 1227, 14, 16, 9, 288, 900, 14, 4532, 8, 26349, 63, 521, 9, 398, 1830, 291, 14, 9631, 26, 288, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 355, 336, 275, 6522, 904, 1332, 277, 14, 1027, 63, 475, 63, 466, 12, 283, 10805, 2490, 620, 8, 277, 14, 5337, 680, 26626, 8, 22, 1724, 355, 291, 14, 2416, 14, 2254, 63, 1612, 8, 87, 9, 355, 291, 14, 5337, 847, 413, 355, 900, 14, 4532, 8, 18, 9, 288, 587, 26, 355, 291, 14, 2416, 14, 505, 267, 291, 14, 2117, 32199, 342, 339, 347, 664, 6579, 8, 277, 304, 267, 900, 14, 4532, 8, 808, 79, 9, 267, 2512, 14, 1757, 480, 5918, 2372, 2058, 687, 943, 1584, 24768, 531, 267, 3529, 275, 942, 267, 291, 14, 9631, 275, 756, 267, 900, 14, 4532, 8, 808, 79, 9, 267, 543, 1551, 8, 277, 423, 793, 63, 515, 12, 283, 82, 358, 465, 1564, 63, 493, 26, 288, 367, 1004, 315, 1564, 63, 493, 26, 355, 31191, 275, 1004, 14, 1623, 8, 9905, 9, 355, 340, 31191, 1137, 446, 17, 26, 490, 6488, 275, 1004, 59, 26349, 11455, 1294, 5102, 5832, 16, 1055, 1294, 14088, 5832, 16, 61, 490, 3529, 14, 740, 8, 2761, 9, 267, 1564, 275, 1557, 78, 1370, 904, 8, 2791, 9, 267, 291, 423, 5538, 14, 2254, 6579, 8, 1317, 9, 339, 347, 3354, 32199, 8, 277, 304, 267, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 288, 291, 14, 2416, 275, 488, 288, 1830, 291, 14, 2416, 365, 488, 26, 355, 291, 423, 3090, 14, 31120, 63, 2573, 8, 1165, 9, 355, 291, 14, 2416, 275, 291, 423, 3090, 14, 1623, 63, 2108, 63, 991, 63, 533, 63, 354, 8, 490, 16767, 540, 63, 25691, 9, 398, 1564, 275, 291, 14, 2416, 14, 505, 267, 570, 275, 1551, 8, 9524, 63, 3022, 435, 620, 8, 277, 423, 5538, 14, 344, 9, 435, 2513, 1317, 14, 2424, 297, 283, 87, 358, 267, 570, 14, 952, 8, 1317, 9, 267, 570, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1048, 5561, 10676, 492, 3626, 5561, 10676, 199, 646, 747, 199, 646, 2196, 199, 646, 2050, 199, 646, 900, 199, 199, 4806, 14, 19602, 8, 1501, 18971, 354, 363, 435, 1987, 793, 297, 2166, 29, 4806, 14, 5287, 9, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 9524, 63, 3022, 275, 747, 14, 12959, 360, 9524, 63, 3022, 297, 1994, 4219, 6217, 199, 199, 6524, 11084, 63, 25691, 275, 283, 7984, 63, 505, 13, 1210, 7, 199, 5670, 540, 63, 25691, 275, 283, 7984, 63, 1317, 7, 199, 9905, 275, 6730, 13652, 6616, 199, 808, 79, 275, 4114, 221, 327, 6810, 911, 3618, 3388, 542, 388, 3424, 506, 545, 470, 10232, 2058, 421, 199, 533, 30318, 8, 2001, 5561, 10676, 304, 272, 408, 12485, 367, 30318, 624, 272, 347, 636, 826, 721, 277, 12, 7614, 12, 1347, 12, 14090, 63, 7625, 12, 4349, 63, 475, 63, 466, 304, 267, 3626, 5561, 10676, 855, 826, 721, 277, 12, 7614, 12, 1347, 9, 267, 2512, 14, 1757, 480, 5918, 221, 30318, 365, 3769, 2727, 290, 559, 972, 24768, 531, 267, 291, 14, 1027, 63, 475, 63, 466, 275, 488, 267, 291, 14, 5337, 275, 378, 398, 340, 822, 8, 1027, 63, 475, 63, 466, 9, 690, 378, 26, 288, 9759, 275, 16573, 11084, 63, 25691, 288, 291, 14, 1027, 63, 475, 63, 466, 275, 4349, 63, 475, 63, 466, 267, 587, 26, 288, 9759, 275, 16767, 540, 63, 25691, 288, 291, 14, 1027, 63, 475, 63, 466, 275, 488, 398, 291, 14, 2416, 275, 488, 267, 1830, 291, 14, 2416, 365, 488, 26, 288, 291, 423, 3090, 14, 31120, 63, 2573, 8, 1165, 9, 288, 291, 14, 2416, 275, 291, 423, 3090, 14, 1623, 63, 2108, 63, 991, 63, 533, 63, 354, 8, 355, 9759, 9, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 9631, 275, 715, 398, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 288, 31191, 63, 521, 275, 2196, 14, 8830, 8, 18, 14, 16, 12, 1227, 14, 16, 9, 288, 900, 14, 4532, 8, 26349, 63, 521, 9, 398, 1830, 291, 14, 9631, 26, 288, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 355, 336, 275, 6522, 904, 1332, 277, 14, 1027, 63, 475, 63, 466, 12, 283, 10805, 2490, 620, 8, 277, 14, 5337, 680, 26626, 8, 22, 1724, 355, 291, 14, 2416, 14, 2254, 63, 1612, 8, 87, 9, 355, 291, 14, 5337, 847, 413, 355, 900, 14, 4532, 8, 18, 9, 288, 587, 26, 355, 291, 14, 2416, 14, 505, 267, 291, 14, 2117, 32199, 342, 339, 347, 664, 6579, 8, 277, 304, 267, 900, 14, 4532, 8, 808, 79, 9, 267, 2512, 14, 1757, 480, 5918, 2372, 2058, 687, 943, 1584, 24768, 531, 267, 3529, 275, 942, 267, 291, 14, 9631, 275, 756, 267, 900, 14, 4532, 8, 808, 79, 9, 267, 543, 1551, 8, 277, 423, 793, 63, 515, 12, 283, 82, 358, 465, 1564, 63, 493, 26, 288, 367, 1004, 315, 1564, 63, 493, 26, 355, 31191, 275, 1004, 14, 1623, 8, 9905, 9, 355, 340, 31191, 1137, 446, 17, 26, 490, 6488, 275, 1004, 59, 26349, 11455, 1294, 5102, 5832, 16, 1055, 1294, 14088, 5832, 16, 61, 490, 3529, 14, 740, 8, 2761, 9, 267, 1564, 275, 1557, 78, 1370, 904, 8, 2791, 9, 267, 291, 423, 5538, 14, 2254, 6579, 8, 1317, 9, 339, 347, 3354, 32199, 8, 277, 304, 267, 340, 291, 14, 1027, 63, 475, 63, 466, 365, 440, 488, 26, 288, 291, 14, 2416, 275, 488, 288, 1830, 291, 14, 2416, 365, 488, 26, 355, 291, 423, 3090, 14, 31120, 63, 2573, 8, 1165, 9, 355, 291, 14, 2416, 275, 291, 423, 3090, 14, 1623, 63, 2108, 63, 991, 63, 533, 63, 354, 8, 490, 16767, 540, 63, 25691, 9, 398, 1564, 275, 291, 14, 2416, 14, 505, 267, 570, 275, 1551, 8, 9524, 63, 3022, 435, 620, 8, 277, 423, 5538, 14, 344, 9, 435, 2513, 1317, 14, 2424, 297, 283, 87, 358, 267, 570, 14, 952, 8, 1317, 9, 267, 570, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bryanbabel/pydokan
src/pydokan/utils.py
4
3926
#coding=utf-8 __author__ = 'Frolov Evgeniy (profisphantom@gmail.com)' __license__ = 'GNU LGPL' __version__ = '0.1' from common.decorator.chain import DecoratorChain from .wrapper import DataWrapper from .struct import FILETIME import time class DateTimeConvertor(object): def __init__(self, dt): self.dt = dt def update(self, dt): self.dt = dt return self def convert(self): value = int((time.mktime(self.dt.timetuple()) + 11644473600) * 10000000) return FILETIME(value >> 32, value & 0xFFFFFFFF) class SizeConvert(object): def __init__(self, size): self.size = size def update(self, size): self.size = size def convert(self): return [self.size >> 32, self.size & 0xFFFFFFFF] def wrap(*proto_args): ''' Декоратор для оборачивания "сырых" параметров callback-функций, которые вызывает драйвер dokan'а, в удобные для работы объекты. ''' def decorator(func): chain = DecoratorChain.get(func) def converter(self, *call_args): if len(proto_args) != len(call_args): e = 'Number of prototypes doesn\'t match number of args' raise Exception(e) call_args = list(call_args) for idx, proto in enumerate(proto_args): if proto is not None: arg = call_args[idx] arg = proto(arg) call_args[idx] = arg return chain.call(self, *call_args) chain.append(converter) return chain.caller return decorator def log(*arg_names): ''' Декоратор для логирования вызовов callback-функций dokan'а. Рассчитан на декорирование методов классов, в которых есть self.app. ''' def decorator(func): chain = DecoratorChain.get(func) padding = 3 def logger(self, *args): if len(arg_names) != len(args): e = 'Number of prototypes doesn\'t match number of args' raise Exception(e) log_lines = ['%s(' % func.__name__] last_arg_idx = len(args) - 1 for idx, arg in enumerate(args): wrapper = isinstance(arg, DataWrapper) lines = arg.debug_repr() if wrapper else \ '\'' + str(arg) + '\'' if isinstance(arg, str) else str(arg) lines = lines.splitlines() log = '%s%s = %s' % (' ' * padding, arg_names[idx], lines[0]) log_lines.append(log) for line in lines[1:]: log_lines.append(' ' * padding + line) if idx != last_arg_idx: log_lines[-1] += ',' log_lines.append(')') # Ставим блокировку на время записи в лог, чтобы сообщения от разных # потоков не перемешивались self.log_lock.acquire() try: log = self.app.log for line in log_lines: log.debug(line) finally: self.log_lock.release() retval = chain.call(self, *args) self.log_lock.acquire() try: log.debug('%s(): %s ' % (func.__name__, retval)) finally: self.log_lock.release() return retval chain.append(logger) return chain.caller return decorator
gpl-3.0
[ 3, 1523, 29, 1624, 13, 24, 199, 199, 363, 2502, 363, 221, 275, 283, 38, 293, 32555, 662, 86, 2268, 31256, 334, 496, 329, 7616, 290, 3151, 32, 6799, 14, 957, 3171, 199, 363, 1682, 363, 275, 283, 17732, 32426, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 7, 199, 199, 504, 2863, 14, 11547, 14, 4429, 492, 30684, 10720, 199, 504, 1275, 5029, 492, 3918, 4590, 199, 504, 1275, 1820, 492, 16444, 10931, 199, 646, 900, 199, 199, 533, 13686, 7306, 269, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 4487, 304, 267, 291, 14, 3583, 275, 4487, 339, 347, 1678, 8, 277, 12, 4487, 304, 267, 291, 14, 3583, 275, 4487, 267, 372, 291, 339, 347, 3957, 8, 277, 304, 267, 574, 275, 1109, 1332, 521, 14, 23456, 8, 277, 14, 3583, 14, 22309, 1012, 435, 4119, 772, 20773, 11035, 9, 627, 413, 9084, 9, 267, 372, 16444, 10931, 8, 585, 4331, 4337, 12, 574, 1253, 378, 32158, 9, 1362, 199, 533, 14579, 7306, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 339, 347, 1678, 8, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 339, 347, 3957, 8, 277, 304, 267, 372, 359, 277, 14, 890, 4331, 4337, 12, 291, 14, 890, 1253, 378, 32158, 61, 199, 199, 318, 4816, 2031, 2625, 63, 589, 304, 272, 1449, 272, 7038, 243, 6286, 11487, 26438, 24219, 26438, 29562, 10356, 14978, 221, 8381, 110, 26438, 5657, 19277, 16863, 111, 21674, 6500, 14978, 298, 8474, 17445, 7753, 17445, 25969, 2, 19820, 27559, 13111, 121, 30160, 7753, 21267, 3233, 13, 31815, 12195, 7592, 11487, 25827, 16863, 118, 12, 31999, 5806, 7413, 26438, 17445, 6286, 5591, 22213, 17445, 31027, 17445, 19630, 5657, 30160, 29562, 7753, 13111, 118, 19630, 21273, 366, 745, 290, 7, 5657, 12, 22213, 221, 12195, 20497, 8381, 110, 7592, 17445, 6286, 29562, 10356, 14978, 221, 7753, 13111, 110, 5806, 7413, 17445, 221, 8381, 110, 142, 233, 6286, 11487, 7413, 17445, 14, 272, 1449, 272, 347, 7531, 8, 1532, 304, 267, 6036, 275, 30684, 10720, 14, 362, 8, 1532, 9, 2728, 347, 11109, 8, 277, 12, 627, 1250, 63, 589, 304, 288, 340, 822, 8, 2625, 63, 589, 9, 1137, 822, 8, 1250, 63, 589, 304, 355, 325, 275, 283, 3259, 402, 19393, 83, 3181, 3985, 84, 1336, 1329, 402, 1249, 7, 355, 746, 2186, 8, 69, 9, 7846, 1240, 63, 589, 275, 769, 8, 1250, 63, 589, 9, 7846, 367, 4280, 12, 4104, 315, 3874, 8, 2625, 63, 589, 304, 355, 340, 4104, 365, 440, 488, 26, 490, 1680, 275, 1240, 63, 589, 59, 2996, 61, 490, 1680, 275, 4104, 8, 1273, 9, 490, 1240, 63, 589, 59, 2996, 61, 275, 1680, 2151, 288, 372, 6036, 14, 1250, 8, 277, 12, 627, 1250, 63, 589, 9, 2728, 6036, 14, 740, 8, 11256, 9, 267, 372, 6036, 14, 11219, 272, 372, 7531, 268, 199, 318, 943, 2031, 1273, 63, 1247, 304, 272, 1449, 272, 7038, 243, 6286, 11487, 26438, 24219, 26438, 29562, 10356, 14978, 7038, 120, 8381, 112, 6500, 7753, 21267, 21674, 6500, 14978, 22213, 17445, 31027, 21267, 21267, 3233, 13, 31815, 12195, 7592, 11487, 25827, 16863, 118, 366, 745, 290, 7, 5657, 14, 7038, 255, 5657, 8474, 8474, 19277, 30019, 21674, 24917, 5657, 5591, 29562, 6286, 11487, 26438, 6500, 7753, 21267, 21674, 6500, 6286, 7038, 121, 30160, 28711, 21267, 31999, 10356, 5657, 8474, 8474, 21267, 12, 22213, 31999, 5806, 7413, 26438, 17445, 25969, 221, 6286, 18261, 16961, 291, 14, 571, 14, 272, 1449, 2286, 347, 7531, 8, 1532, 304, 267, 6036, 275, 30684, 10720, 14, 362, 8, 1532, 9, 267, 6273, 275, 650, 2728, 347, 2512, 8, 277, 12, 627, 589, 304, 288, 340, 822, 8, 1273, 63, 1247, 9, 1137, 822, 8, 589, 304, 355, 325, 275, 283, 3259, 402, 19393, 83, 3181, 3985, 84, 1336, 1329, 402, 1249, 7, 355, 746, 2186, 8, 69, 9, 7846, 943, 63, 1278, 275, 15926, 83, 360, 450, 2562, 855, 354, 22705, 288, 2061, 63, 1273, 63, 2996, 275, 822, 8, 589, 9, 446, 413, 7846, 367, 4280, 12, 1680, 315, 3874, 8, 589, 304, 355, 4975, 275, 1228, 8, 1273, 12, 3918, 4590, 9, 355, 2385, 275, 1680, 14, 1757, 63, 2722, 342, 340, 4975, 587, 971, 490, 1557, 891, 435, 620, 8, 1273, 9, 435, 1557, 891, 340, 1228, 8, 1273, 12, 620, 9, 587, 620, 8, 1273, 9, 355, 2385, 275, 2385, 14, 7644, 342, 14977, 943, 275, 1543, 83, 5, 83, 275, 450, 83, 7, 450, 661, 283, 627, 6273, 12, 1680, 63, 1247, 59, 2996, 467, 2385, 59, 16, 566, 355, 943, 63, 1278, 14, 740, 8, 793, 9, 14977, 367, 1004, 315, 2385, 59, 17, 10688, 490, 943, 63, 1278, 14, 740, 360, 283, 627, 6273, 435, 1004, 9, 2151, 355, 340, 4280, 1137, 2061, 63, 1273, 63, 2996, 26, 490, 943, 63, 1278, 1988, 17, 61, 847, 13647, 24850, 943, 63, 1278, 14, 740, 15938, 358, 7846, 327, 7038, 95, 7413, 13111, 111, 16863, 121, 7038, 110, 10356, 8381, 119, 6500, 7753, 21267, 11487, 12195, 24917, 5657, 22213, 7753, 15578, 121, 14978, 7038, 116, 13111, 124, 6500, 8474, 6500, 22213, 7038, 120, 8381, 112, 12, 221, 19277, 7413, 8381, 110, 17445, 24071, 5806, 8381, 110, 142, 232, 18624, 6500, 14978, 221, 5806, 7413, 221, 7753, 13111, 116, 7592, 17445, 25969, 288, 327, 19820, 5806, 7413, 8381, 119, 21267, 24917, 6286, 19820, 21273, 15578, 121, 6286, 27202, 16863, 111, 30638, 6500, 8474, 16961, 288, 291, 14, 793, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 943, 275, 291, 14, 571, 14, 793, 355, 367, 1004, 315, 943, 63, 1278, 26, 490, 943, 14, 1757, 8, 604, 9, 288, 3753, 26, 355, 291, 14, 793, 63, 831, 14, 3221, 342, 7846, 9151, 275, 6036, 14, 1250, 8, 277, 12, 627, 589, 9, 7846, 291, 14, 793, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 943, 14, 1757, 3508, 83, 837, 450, 83, 283, 450, 334, 1532, 855, 354, 3108, 9151, 430, 288, 3753, 26, 355, 291, 14, 793, 63, 831, 14, 3221, 342, 7846, 372, 9151, 2728, 6036, 14, 740, 8, 2921, 9, 267 ]
[ 1523, 29, 1624, 13, 24, 199, 199, 363, 2502, 363, 221, 275, 283, 38, 293, 32555, 662, 86, 2268, 31256, 334, 496, 329, 7616, 290, 3151, 32, 6799, 14, 957, 3171, 199, 363, 1682, 363, 275, 283, 17732, 32426, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 7, 199, 199, 504, 2863, 14, 11547, 14, 4429, 492, 30684, 10720, 199, 504, 1275, 5029, 492, 3918, 4590, 199, 504, 1275, 1820, 492, 16444, 10931, 199, 646, 900, 199, 199, 533, 13686, 7306, 269, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 4487, 304, 267, 291, 14, 3583, 275, 4487, 339, 347, 1678, 8, 277, 12, 4487, 304, 267, 291, 14, 3583, 275, 4487, 267, 372, 291, 339, 347, 3957, 8, 277, 304, 267, 574, 275, 1109, 1332, 521, 14, 23456, 8, 277, 14, 3583, 14, 22309, 1012, 435, 4119, 772, 20773, 11035, 9, 627, 413, 9084, 9, 267, 372, 16444, 10931, 8, 585, 4331, 4337, 12, 574, 1253, 378, 32158, 9, 1362, 199, 533, 14579, 7306, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 339, 347, 1678, 8, 277, 12, 1568, 304, 267, 291, 14, 890, 275, 1568, 339, 347, 3957, 8, 277, 304, 267, 372, 359, 277, 14, 890, 4331, 4337, 12, 291, 14, 890, 1253, 378, 32158, 61, 199, 199, 318, 4816, 2031, 2625, 63, 589, 304, 272, 1449, 272, 7038, 243, 6286, 11487, 26438, 24219, 26438, 29562, 10356, 14978, 221, 8381, 110, 26438, 5657, 19277, 16863, 111, 21674, 6500, 14978, 298, 8474, 17445, 7753, 17445, 25969, 2, 19820, 27559, 13111, 121, 30160, 7753, 21267, 3233, 13, 31815, 12195, 7592, 11487, 25827, 16863, 118, 12, 31999, 5806, 7413, 26438, 17445, 6286, 5591, 22213, 17445, 31027, 17445, 19630, 5657, 30160, 29562, 7753, 13111, 118, 19630, 21273, 366, 745, 290, 7, 5657, 12, 22213, 221, 12195, 20497, 8381, 110, 7592, 17445, 6286, 29562, 10356, 14978, 221, 7753, 13111, 110, 5806, 7413, 17445, 221, 8381, 110, 142, 233, 6286, 11487, 7413, 17445, 14, 272, 1449, 272, 347, 7531, 8, 1532, 304, 267, 6036, 275, 30684, 10720, 14, 362, 8, 1532, 9, 2728, 347, 11109, 8, 277, 12, 627, 1250, 63, 589, 304, 288, 340, 822, 8, 2625, 63, 589, 9, 1137, 822, 8, 1250, 63, 589, 304, 355, 325, 275, 283, 3259, 402, 19393, 83, 3181, 3985, 84, 1336, 1329, 402, 1249, 7, 355, 746, 2186, 8, 69, 9, 7846, 1240, 63, 589, 275, 769, 8, 1250, 63, 589, 9, 7846, 367, 4280, 12, 4104, 315, 3874, 8, 2625, 63, 589, 304, 355, 340, 4104, 365, 440, 488, 26, 490, 1680, 275, 1240, 63, 589, 59, 2996, 61, 490, 1680, 275, 4104, 8, 1273, 9, 490, 1240, 63, 589, 59, 2996, 61, 275, 1680, 2151, 288, 372, 6036, 14, 1250, 8, 277, 12, 627, 1250, 63, 589, 9, 2728, 6036, 14, 740, 8, 11256, 9, 267, 372, 6036, 14, 11219, 272, 372, 7531, 268, 199, 318, 943, 2031, 1273, 63, 1247, 304, 272, 1449, 272, 7038, 243, 6286, 11487, 26438, 24219, 26438, 29562, 10356, 14978, 7038, 120, 8381, 112, 6500, 7753, 21267, 21674, 6500, 14978, 22213, 17445, 31027, 21267, 21267, 3233, 13, 31815, 12195, 7592, 11487, 25827, 16863, 118, 366, 745, 290, 7, 5657, 14, 7038, 255, 5657, 8474, 8474, 19277, 30019, 21674, 24917, 5657, 5591, 29562, 6286, 11487, 26438, 6500, 7753, 21267, 21674, 6500, 6286, 7038, 121, 30160, 28711, 21267, 31999, 10356, 5657, 8474, 8474, 21267, 12, 22213, 31999, 5806, 7413, 26438, 17445, 25969, 221, 6286, 18261, 16961, 291, 14, 571, 14, 272, 1449, 2286, 347, 7531, 8, 1532, 304, 267, 6036, 275, 30684, 10720, 14, 362, 8, 1532, 9, 267, 6273, 275, 650, 2728, 347, 2512, 8, 277, 12, 627, 589, 304, 288, 340, 822, 8, 1273, 63, 1247, 9, 1137, 822, 8, 589, 304, 355, 325, 275, 283, 3259, 402, 19393, 83, 3181, 3985, 84, 1336, 1329, 402, 1249, 7, 355, 746, 2186, 8, 69, 9, 7846, 943, 63, 1278, 275, 15926, 83, 360, 450, 2562, 855, 354, 22705, 288, 2061, 63, 1273, 63, 2996, 275, 822, 8, 589, 9, 446, 413, 7846, 367, 4280, 12, 1680, 315, 3874, 8, 589, 304, 355, 4975, 275, 1228, 8, 1273, 12, 3918, 4590, 9, 355, 2385, 275, 1680, 14, 1757, 63, 2722, 342, 340, 4975, 587, 971, 490, 1557, 891, 435, 620, 8, 1273, 9, 435, 1557, 891, 340, 1228, 8, 1273, 12, 620, 9, 587, 620, 8, 1273, 9, 355, 2385, 275, 2385, 14, 7644, 342, 14977, 943, 275, 1543, 83, 5, 83, 275, 450, 83, 7, 450, 661, 283, 627, 6273, 12, 1680, 63, 1247, 59, 2996, 467, 2385, 59, 16, 566, 355, 943, 63, 1278, 14, 740, 8, 793, 9, 14977, 367, 1004, 315, 2385, 59, 17, 10688, 490, 943, 63, 1278, 14, 740, 360, 283, 627, 6273, 435, 1004, 9, 2151, 355, 340, 4280, 1137, 2061, 63, 1273, 63, 2996, 26, 490, 943, 63, 1278, 1988, 17, 61, 847, 13647, 24850, 943, 63, 1278, 14, 740, 15938, 358, 7846, 327, 7038, 95, 7413, 13111, 111, 16863, 121, 7038, 110, 10356, 8381, 119, 6500, 7753, 21267, 11487, 12195, 24917, 5657, 22213, 7753, 15578, 121, 14978, 7038, 116, 13111, 124, 6500, 8474, 6500, 22213, 7038, 120, 8381, 112, 12, 221, 19277, 7413, 8381, 110, 17445, 24071, 5806, 8381, 110, 142, 232, 18624, 6500, 14978, 221, 5806, 7413, 221, 7753, 13111, 116, 7592, 17445, 25969, 288, 327, 19820, 5806, 7413, 8381, 119, 21267, 24917, 6286, 19820, 21273, 15578, 121, 6286, 27202, 16863, 111, 30638, 6500, 8474, 16961, 288, 291, 14, 793, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 943, 275, 291, 14, 571, 14, 793, 355, 367, 1004, 315, 943, 63, 1278, 26, 490, 943, 14, 1757, 8, 604, 9, 288, 3753, 26, 355, 291, 14, 793, 63, 831, 14, 3221, 342, 7846, 9151, 275, 6036, 14, 1250, 8, 277, 12, 627, 589, 9, 7846, 291, 14, 793, 63, 831, 14, 8174, 342, 288, 862, 26, 355, 943, 14, 1757, 3508, 83, 837, 450, 83, 283, 450, 334, 1532, 855, 354, 3108, 9151, 430, 288, 3753, 26, 355, 291, 14, 793, 63, 831, 14, 3221, 342, 7846, 372, 9151, 2728, 6036, 14, 740, 8, 2921, 9, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alx-eu/django
django/utils/tree.py
109
5851
""" A class for storing a tree graph. Primarily used for filter constructs in the ORM. """ import copy class Node(object): """ A single internal node in the tree graph. A Node should be viewed as a connection (the root) with the children being either leaf nodes or other Node instances. """ # Standard connector type. Clients usually won't use this at all and # subclasses will usually override the value. default = 'DEFAULT' def __init__(self, children=None, connector=None, negated=False): """ Constructs a new Node. If no connector is given, the default will be used. Warning: You probably don't want to pass in the 'negated' parameter. It is NOT the same as constructing a node and calling negate() on the result. """ self.children = children and children[:] or [] self.connector = connector or self.default self.subtree_parents = [] self.negated = negated # We need this because of django.db.models.query_utils.Q. Q. __init__() is # problematic, but it is a natural Node subclass in all other respects. def _new_instance(cls, children=None, connector=None, negated=False): """ This is called to create a new instance of this class when we need new Nodes (or subclasses) in the internal code in this class. Normally, it just shadows __init__(). However, subclasses with an __init__ signature that is not an extension of Node.__init__ might need to implement this method to allow a Node to create a new instance of them (if they have any extra setting up to do). """ obj = Node(children, connector, negated) obj.__class__ = cls return obj _new_instance = classmethod(_new_instance) def __str__(self): if self.negated: return '(NOT (%s: %s))' % (self.connector, ', '.join([str(c) for c in self.children])) return '(%s: %s)' % (self.connector, ', '.join([str(c) for c in self.children])) def __deepcopy__(self, memodict): """ Utility method used by copy.deepcopy(). """ obj = Node(connector=self.connector, negated=self.negated) obj.__class__ = self.__class__ obj.children = copy.deepcopy(self.children, memodict) obj.subtree_parents = copy.deepcopy(self.subtree_parents, memodict) return obj def __len__(self): """ The size of a node if the number of children it has. """ return len(self.children) def __bool__(self): """ For truth value testing. """ return bool(self.children) def __nonzero__(self): # Python 2 compatibility return type(self).__bool__(self) def __contains__(self, other): """ Returns True is 'other' is a direct child of this instance. """ return other in self.children def add(self, node, conn_type): """ Adds a new node to the tree. If the conn_type is the same as the root's current connector type, the node is added to the first level. Otherwise, the whole tree is pushed down one level and a new root connector is created, connecting the existing tree and the new node. """ if node in self.children and conn_type == self.connector: return if len(self.children) < 2: self.connector = conn_type if self.connector == conn_type: if isinstance(node, Node) and (node.connector == conn_type or len(node) == 1): self.children.extend(node.children) else: self.children.append(node) else: obj = self._new_instance(self.children, self.connector, self.negated) self.connector = conn_type self.children = [obj, node] def negate(self): """ Negate the sense of the root connector. This reorganises the children so that the current node has a single child: a negated node containing all the previous children. This slightly odd construction makes adding new children behave more intuitively. Interpreting the meaning of this negate is up to client code. This method is useful for implementing "not" arrangements. """ self.children = [self._new_instance(self.children, self.connector, not self.negated)] self.connector = self.default def start_subtree(self, conn_type): """ Sets up internal state so that new nodes are added to a subtree of the current node. The conn_type specifies how the sub-tree is joined to the existing children. """ if len(self.children) == 1: self.connector = conn_type elif self.connector != conn_type: self.children = [self._new_instance(self.children, self.connector, self.negated)] self.connector = conn_type self.negated = False self.subtree_parents.append(self.__class__(self.children, self.connector, self.negated)) self.connector = self.default self.negated = False self.children = [] def end_subtree(self): """ Closes off the most recently unmatched start_subtree() call. This puts the current state into a node of the parent tree and returns the current instances state to be the parent. """ obj = self.subtree_parents.pop() node = self.__class__(self.children, self.connector) self.connector = obj.connector self.negated = obj.negated self.children = obj.children self.children.append(node)
bsd-3-clause
[ 624, 199, 33, 1021, 367, 16915, 282, 3123, 3343, 14, 8538, 30468, 1202, 367, 2457, 21638, 315, 314, 199, 8832, 14, 199, 624, 199, 199, 646, 1331, 199, 199, 533, 5013, 8, 785, 304, 272, 408, 272, 437, 2849, 5007, 1031, 315, 314, 3123, 3343, 14, 437, 5013, 1077, 506, 2455, 379, 465, 282, 272, 1950, 334, 1589, 1738, 9, 543, 314, 4978, 3769, 1902, 11747, 3380, 503, 1163, 272, 5013, 4454, 14, 272, 408, 272, 327, 9739, 13252, 730, 14, 6810, 83, 9987, 7859, 1133, 675, 642, 737, 1006, 436, 272, 327, 9180, 911, 9987, 4278, 314, 574, 14, 272, 849, 275, 283, 3472, 7, 339, 347, 636, 826, 721, 277, 12, 4978, 29, 403, 12, 13252, 29, 403, 12, 14158, 972, 29, 797, 304, 267, 408, 267, 9215, 83, 282, 892, 5013, 14, 982, 949, 13252, 365, 1627, 12, 314, 849, 911, 506, 267, 1202, 14, 398, 15902, 26, 2047, 8646, 2793, 1133, 2934, 370, 986, 315, 314, 283, 8705, 972, 7, 2725, 14, 2779, 267, 365, 2845, 314, 2011, 465, 22048, 282, 1031, 436, 6358, 30112, 342, 641, 314, 267, 754, 14, 267, 408, 267, 291, 14, 3223, 275, 4978, 436, 4978, 5873, 503, 942, 267, 291, 14, 11815, 275, 13252, 503, 291, 14, 885, 267, 291, 14, 26043, 63, 8859, 275, 942, 267, 291, 14, 8705, 972, 275, 14158, 972, 339, 327, 2136, 1929, 642, 2952, 402, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 14, 49, 14, 1413, 14, 636, 826, 4533, 365, 272, 327, 557, 31197, 12, 1325, 652, 365, 282, 19981, 5013, 5516, 315, 1006, 1163, 14021, 83, 14, 272, 347, 485, 1222, 63, 842, 8, 1886, 12, 4978, 29, 403, 12, 13252, 29, 403, 12, 14158, 972, 29, 797, 304, 267, 408, 267, 961, 365, 2797, 370, 1218, 282, 892, 1256, 402, 642, 1021, 1380, 781, 1929, 892, 267, 23836, 334, 269, 9180, 9, 315, 314, 5007, 1233, 315, 642, 1021, 14, 24573, 12, 652, 267, 2951, 15084, 83, 636, 826, 31261, 9738, 12, 9180, 543, 376, 636, 826, 363, 4955, 267, 626, 365, 440, 376, 3329, 402, 5013, 855, 826, 363, 5594, 1929, 370, 5669, 642, 267, 1083, 370, 2040, 282, 5013, 370, 1218, 282, 892, 1256, 402, 3062, 334, 692, 2985, 1172, 267, 1263, 2402, 4260, 1536, 370, 886, 680, 267, 408, 267, 1559, 275, 5013, 8, 3223, 12, 13252, 12, 14158, 972, 9, 267, 1559, 855, 533, 363, 275, 843, 267, 372, 1559, 272, 485, 1222, 63, 842, 275, 18990, 1547, 1222, 63, 842, 9, 339, 347, 636, 495, 721, 277, 304, 267, 340, 291, 14, 8705, 972, 26, 288, 372, 8189, 4609, 4366, 83, 26, 450, 83, 23089, 450, 334, 277, 14, 11815, 12, 1656, 1987, 904, 779, 495, 8, 67, 9, 367, 286, 490, 315, 291, 14, 3223, 2459, 267, 372, 25676, 83, 26, 450, 83, 3171, 450, 334, 277, 14, 11815, 12, 1656, 1987, 904, 779, 495, 8, 67, 9, 367, 286, 315, 355, 291, 14, 3223, 2459, 339, 347, 636, 8293, 721, 277, 12, 11955, 807, 304, 267, 408, 267, 20511, 1083, 1202, 701, 1331, 14, 8293, 1252, 267, 408, 267, 1559, 275, 5013, 8, 11815, 29, 277, 14, 11815, 12, 14158, 972, 29, 277, 14, 8705, 972, 9, 267, 1559, 855, 533, 363, 275, 291, 855, 533, 363, 267, 1559, 14, 3223, 275, 1331, 14, 8293, 8, 277, 14, 3223, 12, 11955, 807, 9, 267, 1559, 14, 26043, 63, 8859, 275, 1331, 14, 8293, 8, 277, 14, 26043, 63, 8859, 12, 11955, 807, 9, 267, 372, 1559, 339, 347, 636, 552, 721, 277, 304, 267, 408, 267, 710, 1568, 402, 282, 1031, 340, 314, 1329, 402, 4978, 652, 965, 14, 267, 408, 267, 372, 822, 8, 277, 14, 3223, 9, 339, 347, 636, 2245, 721, 277, 304, 267, 408, 267, 2104, 16865, 574, 5343, 14, 267, 408, 267, 372, 2155, 8, 277, 14, 3223, 9, 339, 347, 636, 10262, 721, 277, 304, 420, 327, 2018, 499, 7163, 267, 372, 730, 8, 277, 2843, 2245, 721, 277, 9, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 408, 267, 1803, 715, 365, 283, 1848, 7, 365, 282, 4125, 1982, 402, 642, 1256, 14, 267, 408, 267, 372, 1163, 315, 291, 14, 3223, 339, 347, 1050, 8, 277, 12, 1031, 12, 2557, 63, 466, 304, 267, 408, 267, 15747, 282, 892, 1031, 370, 314, 3123, 14, 982, 314, 2557, 63, 466, 365, 314, 2011, 465, 314, 1738, 1159, 267, 1453, 13252, 730, 12, 314, 1031, 365, 3483, 370, 314, 1642, 2166, 14, 267, 6630, 12, 314, 8852, 3123, 365, 22319, 3224, 1373, 2166, 436, 282, 892, 1738, 267, 13252, 365, 2737, 12, 18170, 314, 3411, 3123, 436, 314, 892, 1031, 14, 267, 408, 267, 340, 1031, 315, 291, 14, 3223, 436, 2557, 63, 466, 508, 291, 14, 11815, 26, 288, 372, 267, 340, 822, 8, 277, 14, 3223, 9, 665, 499, 26, 288, 291, 14, 11815, 275, 2557, 63, 466, 267, 340, 291, 14, 11815, 508, 2557, 63, 466, 26, 288, 340, 1228, 8, 932, 12, 5013, 9, 436, 334, 932, 14, 11815, 508, 2557, 63, 466, 503, 490, 822, 8, 932, 9, 508, 413, 304, 355, 291, 14, 3223, 14, 2880, 8, 932, 14, 3223, 9, 288, 587, 26, 355, 291, 14, 3223, 14, 740, 8, 932, 9, 267, 587, 26, 288, 1559, 275, 291, 423, 1222, 63, 842, 8, 277, 14, 3223, 12, 291, 14, 11815, 12, 490, 291, 14, 8705, 972, 9, 288, 291, 14, 11815, 275, 2557, 63, 466, 288, 291, 14, 3223, 275, 359, 1113, 12, 1031, 61, 339, 347, 30112, 8, 277, 304, 267, 408, 267, 5612, 3237, 314, 12249, 402, 314, 1738, 13252, 14, 961, 295, 19916, 1388, 314, 4978, 267, 880, 626, 314, 1453, 1031, 965, 282, 2849, 1982, 26, 282, 14158, 972, 1031, 3035, 267, 1006, 314, 4136, 4978, 14, 961, 18023, 16699, 14538, 7704, 7791, 267, 892, 4978, 24062, 1655, 1109, 1907, 9462, 14, 398, 6551, 657, 1337, 314, 11150, 402, 642, 30112, 365, 1536, 370, 1890, 1233, 14, 961, 267, 1083, 365, 2997, 367, 18234, 298, 1397, 2, 601, 1842, 1470, 14, 267, 408, 267, 291, 14, 3223, 275, 359, 277, 423, 1222, 63, 842, 8, 277 ]
[ 199, 33, 1021, 367, 16915, 282, 3123, 3343, 14, 8538, 30468, 1202, 367, 2457, 21638, 315, 314, 199, 8832, 14, 199, 624, 199, 199, 646, 1331, 199, 199, 533, 5013, 8, 785, 304, 272, 408, 272, 437, 2849, 5007, 1031, 315, 314, 3123, 3343, 14, 437, 5013, 1077, 506, 2455, 379, 465, 282, 272, 1950, 334, 1589, 1738, 9, 543, 314, 4978, 3769, 1902, 11747, 3380, 503, 1163, 272, 5013, 4454, 14, 272, 408, 272, 327, 9739, 13252, 730, 14, 6810, 83, 9987, 7859, 1133, 675, 642, 737, 1006, 436, 272, 327, 9180, 911, 9987, 4278, 314, 574, 14, 272, 849, 275, 283, 3472, 7, 339, 347, 636, 826, 721, 277, 12, 4978, 29, 403, 12, 13252, 29, 403, 12, 14158, 972, 29, 797, 304, 267, 408, 267, 9215, 83, 282, 892, 5013, 14, 982, 949, 13252, 365, 1627, 12, 314, 849, 911, 506, 267, 1202, 14, 398, 15902, 26, 2047, 8646, 2793, 1133, 2934, 370, 986, 315, 314, 283, 8705, 972, 7, 2725, 14, 2779, 267, 365, 2845, 314, 2011, 465, 22048, 282, 1031, 436, 6358, 30112, 342, 641, 314, 267, 754, 14, 267, 408, 267, 291, 14, 3223, 275, 4978, 436, 4978, 5873, 503, 942, 267, 291, 14, 11815, 275, 13252, 503, 291, 14, 885, 267, 291, 14, 26043, 63, 8859, 275, 942, 267, 291, 14, 8705, 972, 275, 14158, 972, 339, 327, 2136, 1929, 642, 2952, 402, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 14, 49, 14, 1413, 14, 636, 826, 4533, 365, 272, 327, 557, 31197, 12, 1325, 652, 365, 282, 19981, 5013, 5516, 315, 1006, 1163, 14021, 83, 14, 272, 347, 485, 1222, 63, 842, 8, 1886, 12, 4978, 29, 403, 12, 13252, 29, 403, 12, 14158, 972, 29, 797, 304, 267, 408, 267, 961, 365, 2797, 370, 1218, 282, 892, 1256, 402, 642, 1021, 1380, 781, 1929, 892, 267, 23836, 334, 269, 9180, 9, 315, 314, 5007, 1233, 315, 642, 1021, 14, 24573, 12, 652, 267, 2951, 15084, 83, 636, 826, 31261, 9738, 12, 9180, 543, 376, 636, 826, 363, 4955, 267, 626, 365, 440, 376, 3329, 402, 5013, 855, 826, 363, 5594, 1929, 370, 5669, 642, 267, 1083, 370, 2040, 282, 5013, 370, 1218, 282, 892, 1256, 402, 3062, 334, 692, 2985, 1172, 267, 1263, 2402, 4260, 1536, 370, 886, 680, 267, 408, 267, 1559, 275, 5013, 8, 3223, 12, 13252, 12, 14158, 972, 9, 267, 1559, 855, 533, 363, 275, 843, 267, 372, 1559, 272, 485, 1222, 63, 842, 275, 18990, 1547, 1222, 63, 842, 9, 339, 347, 636, 495, 721, 277, 304, 267, 340, 291, 14, 8705, 972, 26, 288, 372, 8189, 4609, 4366, 83, 26, 450, 83, 23089, 450, 334, 277, 14, 11815, 12, 1656, 1987, 904, 779, 495, 8, 67, 9, 367, 286, 490, 315, 291, 14, 3223, 2459, 267, 372, 25676, 83, 26, 450, 83, 3171, 450, 334, 277, 14, 11815, 12, 1656, 1987, 904, 779, 495, 8, 67, 9, 367, 286, 315, 355, 291, 14, 3223, 2459, 339, 347, 636, 8293, 721, 277, 12, 11955, 807, 304, 267, 408, 267, 20511, 1083, 1202, 701, 1331, 14, 8293, 1252, 267, 408, 267, 1559, 275, 5013, 8, 11815, 29, 277, 14, 11815, 12, 14158, 972, 29, 277, 14, 8705, 972, 9, 267, 1559, 855, 533, 363, 275, 291, 855, 533, 363, 267, 1559, 14, 3223, 275, 1331, 14, 8293, 8, 277, 14, 3223, 12, 11955, 807, 9, 267, 1559, 14, 26043, 63, 8859, 275, 1331, 14, 8293, 8, 277, 14, 26043, 63, 8859, 12, 11955, 807, 9, 267, 372, 1559, 339, 347, 636, 552, 721, 277, 304, 267, 408, 267, 710, 1568, 402, 282, 1031, 340, 314, 1329, 402, 4978, 652, 965, 14, 267, 408, 267, 372, 822, 8, 277, 14, 3223, 9, 339, 347, 636, 2245, 721, 277, 304, 267, 408, 267, 2104, 16865, 574, 5343, 14, 267, 408, 267, 372, 2155, 8, 277, 14, 3223, 9, 339, 347, 636, 10262, 721, 277, 304, 420, 327, 2018, 499, 7163, 267, 372, 730, 8, 277, 2843, 2245, 721, 277, 9, 339, 347, 636, 6134, 721, 277, 12, 1163, 304, 267, 408, 267, 1803, 715, 365, 283, 1848, 7, 365, 282, 4125, 1982, 402, 642, 1256, 14, 267, 408, 267, 372, 1163, 315, 291, 14, 3223, 339, 347, 1050, 8, 277, 12, 1031, 12, 2557, 63, 466, 304, 267, 408, 267, 15747, 282, 892, 1031, 370, 314, 3123, 14, 982, 314, 2557, 63, 466, 365, 314, 2011, 465, 314, 1738, 1159, 267, 1453, 13252, 730, 12, 314, 1031, 365, 3483, 370, 314, 1642, 2166, 14, 267, 6630, 12, 314, 8852, 3123, 365, 22319, 3224, 1373, 2166, 436, 282, 892, 1738, 267, 13252, 365, 2737, 12, 18170, 314, 3411, 3123, 436, 314, 892, 1031, 14, 267, 408, 267, 340, 1031, 315, 291, 14, 3223, 436, 2557, 63, 466, 508, 291, 14, 11815, 26, 288, 372, 267, 340, 822, 8, 277, 14, 3223, 9, 665, 499, 26, 288, 291, 14, 11815, 275, 2557, 63, 466, 267, 340, 291, 14, 11815, 508, 2557, 63, 466, 26, 288, 340, 1228, 8, 932, 12, 5013, 9, 436, 334, 932, 14, 11815, 508, 2557, 63, 466, 503, 490, 822, 8, 932, 9, 508, 413, 304, 355, 291, 14, 3223, 14, 2880, 8, 932, 14, 3223, 9, 288, 587, 26, 355, 291, 14, 3223, 14, 740, 8, 932, 9, 267, 587, 26, 288, 1559, 275, 291, 423, 1222, 63, 842, 8, 277, 14, 3223, 12, 291, 14, 11815, 12, 490, 291, 14, 8705, 972, 9, 288, 291, 14, 11815, 275, 2557, 63, 466, 288, 291, 14, 3223, 275, 359, 1113, 12, 1031, 61, 339, 347, 30112, 8, 277, 304, 267, 408, 267, 5612, 3237, 314, 12249, 402, 314, 1738, 13252, 14, 961, 295, 19916, 1388, 314, 4978, 267, 880, 626, 314, 1453, 1031, 965, 282, 2849, 1982, 26, 282, 14158, 972, 1031, 3035, 267, 1006, 314, 4136, 4978, 14, 961, 18023, 16699, 14538, 7704, 7791, 267, 892, 4978, 24062, 1655, 1109, 1907, 9462, 14, 398, 6551, 657, 1337, 314, 11150, 402, 642, 30112, 365, 1536, 370, 1890, 1233, 14, 961, 267, 1083, 365, 2997, 367, 18234, 298, 1397, 2, 601, 1842, 1470, 14, 267, 408, 267, 291, 14, 3223, 275, 359, 277, 423, 1222, 63, 842, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
amarjeetkapoor1/CivilOctave
sage/civilsage/views.py
2
9013
## # @package civilsage.views # This module contain functions to controls veiws of django. # It include following functions -: # index() # matrix() # last() # file() # pdfemail() # first_write() # ... # @author amarjeet kapoor # @code importing modules import os,threading from django.http import HttpResponse from django.shortcuts import render import csv,datetime from django.core.mail import EmailMessage ## # first veiw created by rendering html page # from templete # @param request request from civilsage.urls() # @return request and path to index.html # def index(request): return render(request, 'civilsage/index.html') ## # This function display matrix for input from user and take # response from index veiw and write input taken through index.html # and write in input.sage file # @param request request from index.html # @return request and path to matrix.html and number of storeys and # input taken from index.html # @exception return message and request to index.html def matrix(request): try: #dictionary of all input tags lists = {'Soil_type':'','Number_of_storeys':'' ,'Importance_factor':'','Response_reduction_factor':'' ,'Zone_factor':'','Gravity_acceleration':'' ,'Modes_considered':'','email_get':''} name = '' #getting input using tags and sending it as response for var in lists.keys(): request.session[var] = request.POST.get(var) #creating directory from base directory lists['Number_of_storeys'] = request.POST.get('Number_of_storeys') #making list for iteratation in templete number_of_storeys = list() #name of directory of specific user for a in range(int(lists['Number_of_storeys'])): number_of_storeys.append('a') #calling differnet veiws based on option whether #manually if(request.POST.get('through_file')=='Y'): return render( request,'civilsage/file.html' ,{'number_of_storeys': number_of_storeys, 'email_get': request.POST.get('email_get')}) else: #user want to upload matrix value through file or return render( request,'civilsage/matrix.html' ,{'number_of_storeys': number_of_storeys, 'email_get': request.POST.get('email_get') }) except: return render(request, 'civilsage/index.html' ,{'message':'please fill again'}) ## # This function gets request from matix.html and # gives pdf as output to user it call civil.sh to process inputs and get output # @param request request from matrix.html # @return request and message to index.html # @return pdf as response # @exception return message and request to index.html def last(request): message='error occured please fill again' try: #calling function to writte basic input name,message=first_write(request) #getting numbers of storeys num = request.session.get('Number_of_storeys') #opening input.sage to append remaining inputs command=name+'/input.sage' file=open(command,'a') #list of basic tags var = ['mass','Height_storey','Stiffness_storey'] #writing matix into sage file for j in var: file.write(j) file.write('=matrix([') #writing elements of matix for i in range(int(num)): #creating input tags temp = j+str(i) file.write('[') #getting input from tags d=request.POST.get(temp) file.write(d) file.write(']') #condition to check last element if( i!=int(num)-1): file.write(',') file.write('])\n') file.close() if(request.POST.get('email_id')): #calling funcion to send pdf and run that as background process thread = threading.Thread(target=pdfemail,args=(request,name)) thread.daemon = True thread.start() message="PDF send to "+request.POST.get('email_id') return render(request, "civilsage/index.html", {'message':message}) else: #calling sh file for background processing command='sh civil.sh '+name os.system(command) #opening creted pdf to display to user command=name+'/civil.pdf' f=open(command) #sending pdf as response response = HttpResponse(f,content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="civil.pdf"' #deleting temperary files command='rm -rf '+name os.system(command) return response except: return render(request, "civilsage/index.html", {'message':message,'email_get':request.session.get('email_get')}) ## # This veiw take input data from file uploaded by user and processes # to give output in form of response. # It call civil.sh to process # @param request request from matrix.html # @return render() request and message to index.html # @return response pdf as response # @exception return message and request to file.html def file(request): message='please fill again' try: name,message=first_write(request) #getting file uploaded by user f=request.FILES["input_file"] if(f.content_type != 'text/csv'): return render( request,'civilsage/file.html', {'email_get': request.session.get('email_get'), 'message':'File Not in CSV FORMAT '}) data = [row for row in csv.reader(f)] #getting numbers of storeys num = request.session.get('Number_of_storeys') #opening input.sage to append remaining inputs command=name+'/input.sage' file=open(command,'a') #list of basic tags var = ['mass','Height_storey','Stiffness_storey'] jar=0 #writing matix into sage file for j in var: message="Less no. of rows in csv file" file.write(j) file.write('=matrix([') #writing elements of matix for i in range(int(num)): file.write('[') #getting input from tags message="Less no. of elements in row "+str(j) if(not data[jar][i].isdigit()): ii=i+1 else: ii=i d=data[jar][ii] file.write(str(d)) file.write(']') #condition to check last element if( i!=int(num)-1): file.write(',') jar=jar+1 file.write('])\n') file.close() if(request.POST.get('email_id')): #calling funcion to send pdf and run that as background proces thread = threading.Thread(target=pdfemail,args=(request,name)) thread.daemon = True thread.start() message="PDF will be send to "+request.POST.get('email_id') return render(request, "civilsage/index.html", {'message':message}) else: command='sh civil.sh '+name os.system(command) #opening creted pdf to display to user command=name+'/civil.pdf' f=open(command) #sending pdf as response response = HttpResponse(f,content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="civil.pdf"' #deleting temperary files command='rm -rf '+name os.system(command) return response except: command='rm -rf '+name os.system(command) return render(request, "civilsage/file.html", {'message':message,'email_get':request.session.get('email_get')}) ## # A function that run as background process to send pdf as emails and called # by last() and file() when email option is chossen # @param request request from calling function # @param name name of directory to becreated for user # @exception send error message through email def pdfemail(request,name): message='unable to send it will be send after sometime' try: #creating and writing sh file for background processing email_id=request.POST.get('email_id') command=name+'/email.txt' f=open(command,'w') f.write(email_id) f.close() command='sh civil.sh '+name os.system(command) command=name+'/civil.pdf' email_id=request.POST.get('email_id') user_email = EmailMessage('Dynamics of structure', 'You have is ready', to=[email_id]) user_email.attach_file(command) message='wrong email id' user_email.send() command='rm -rf '+name os.system(command) except: command='rm -rf '+name if(message=='wrong email id'): os.system(command) email_id=request.POST.get('email_id') user_email = EmailMessage('Dynamics of structure', message, to=[email_id]) ## # This function that write basic input same for all veiws and called # by last() and file() when email option is chossen # @param request request from calling function # @return name,message name of directory and Error message def first_write(request): message='error occured please fill again' #dictionary of all input tags lists = {'Soil_type':'','Number_of_storeys':'' ,'Importance_factor':'','Response_reduction_factor':'' ,'Zone_factor':'','Gravity_acceleration':'' ,'Modes_considered':''} #name of directory of specific user name='Temp'+request.session.session_key+str(datetime.datetime.now()) name=name.replace(" ", "") #getting input using tags for var in lists.keys(): lists[var]=request.session.get(var) name=name+str(lists[var]) command='cp -r sagemath '+name os.popen(command) #opening file for writing command=name+'/input.sage' file = open(command, 'w') #writing variables in input.sage file with syntax of sage for var in lists.keys(): file.write(var) file.write('=') file.write(lists[var]) file.write('\n') file.close() return name,message
mit
[ 309, 199, 3, 768, 2491, 286, 1003, 382, 5648, 14, 4196, 199, 3, 961, 859, 1395, 3423, 370, 13467, 11199, 73, 3569, 402, 1639, 14, 199, 3, 2779, 2387, 2569, 3423, 446, 26, 199, 3, 1478, 342, 199, 3, 3634, 342, 221, 199, 3, 2061, 342, 199, 3, 570, 342, 221, 199, 3, 6454, 771, 1198, 342, 199, 3, 1642, 63, 952, 342, 199, 3, 2263, 199, 3, 768, 2502, 282, 4584, 6532, 386, 1022, 439, 79, 269, 199, 199, 3, 768, 600, 16306, 4621, 199, 646, 747, 12, 12562, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 199, 646, 7392, 12, 2083, 199, 504, 1639, 14, 1018, 14, 1198, 492, 11426, 2209, 199, 199, 309, 199, 3, 1642, 11199, 73, 87, 2737, 701, 14066, 3517, 2034, 199, 3, 687, 1565, 575, 266, 199, 3, 768, 635, 1056, 1056, 687, 286, 1003, 382, 5648, 14, 3603, 342, 199, 3, 768, 1107, 1056, 436, 931, 370, 1478, 14, 1360, 199, 3, 199, 318, 1478, 8, 1069, 304, 199, 198, 1107, 3795, 8, 1069, 12, 283, 559, 29792, 5648, 15, 1080, 14, 1360, 358, 199, 199, 309, 199, 3, 961, 805, 2929, 3634, 367, 1324, 687, 922, 436, 5452, 221, 199, 3, 1177, 687, 1478, 11199, 73, 87, 436, 2218, 1324, 9394, 4012, 1478, 14, 1360, 199, 3, 436, 2218, 315, 1324, 14, 5648, 570, 199, 3, 768, 635, 1056, 1056, 687, 1478, 14, 1360, 199, 3, 768, 1107, 1056, 436, 931, 370, 3634, 14, 1360, 436, 1329, 402, 3877, 588, 436, 221, 199, 3, 1324, 9394, 687, 1478, 14, 1360, 199, 3, 768, 1971, 372, 1245, 436, 1056, 370, 1478, 14, 1360, 199, 199, 318, 3634, 8, 1069, 304, 421, 198, 893, 26, 507, 198, 3, 9086, 402, 1006, 1324, 3762, 9068, 198, 6717, 275, 791, 5158, 382, 63, 466, 5242, 1673, 3259, 63, 1618, 63, 1617, 588, 356, 891, 507, 198, 2584, 6295, 554, 63, 4778, 5242, 1673, 2364, 63, 22508, 63, 4778, 356, 891, 507, 198, 2584, 11860, 63, 4778, 5242, 1673, 5761, 18936, 63, 645, 29765, 356, 891, 507, 198, 2584, 19578, 63, 388, 2441, 581, 5242, 1673, 2123, 63, 362, 356, 891, 93, 2742, 198, 354, 275, 2125, 2742, 198, 3, 362, 1337, 1324, 1808, 3762, 436, 10209, 652, 465, 1177, 9068, 198, 509, 2729, 315, 5548, 14, 1612, 837, 686, 198, 1069, 14, 1730, 59, 1391, 61, 275, 1056, 14, 4030, 14, 362, 8, 1391, 9, 2742, 198, 3, 20358, 2082, 687, 1300, 2082, 9068, 198, 6717, 459, 3259, 63, 1618, 63, 1617, 588, 418, 275, 1056, 14, 4030, 14, 362, 360, 3259, 63, 1618, 63, 1617, 588, 358, 2742, 198, 3, 391, 17443, 769, 367, 2740, 419, 296, 315, 1565, 575, 266, 9068, 198, 1955, 63, 1618, 63, 1617, 588, 275, 769, 342, 9068, 198, 3, 354, 402, 2082, 402, 2488, 922, 9068, 198, 509, 282, 315, 1425, 8, 442, 8, 6717, 459, 3259, 63, 1618, 63, 1617, 588, 26536, 686, 198, 1955, 63, 1618, 63, 1617, 588, 14, 740, 360, 65, 358, 2742, 198, 3, 25566, 14460, 846, 11199, 73, 3569, 4079, 641, 945, 3775, 507, 198, 3, 1237, 3163, 2742, 198, 692, 8, 1069, 14, 4030, 14, 362, 360, 8304, 63, 493, 358, 6803, 57, 735, 686, 198, 1107, 3795, 8, 1056, 2584, 559, 29792, 5648, 15, 493, 14, 1360, 7, 686, 198, 12, 1445, 1955, 63, 1618, 63, 1617, 588, 356, 1329, 63, 1618, 63, 1617, 588, 12, 686, 198, 7, 2123, 63, 362, 356, 1056, 14, 4030, 14, 362, 360, 2123, 63, 362, 22220, 507, 198, 2836, 26, 507, 198, 3, 751, 2934, 370, 5802, 3634, 574, 4012, 570, 503, 686, 686, 198, 1107, 3795, 8, 1056, 2584, 559, 29792, 5648, 15, 3642, 14, 1360, 7, 686, 198, 12, 1445, 1955, 63, 1618, 63, 1617, 588, 356, 1329, 63, 1618, 63, 1617, 588, 12, 686, 198, 7, 2123, 63, 362, 356, 1056, 14, 4030, 14, 362, 360, 2123, 63, 362, 358, 3828, 199, 198, 2590, 26, 507, 198, 1107, 3795, 8, 1069, 12, 283, 559, 29792, 5648, 15, 1080, 14, 1360, 7, 507, 198, 12, 1445, 1188, 5242, 27567, 5554, 4020, 3071, 421, 199, 309, 199, 3, 961, 805, 7545, 1056, 687, 610, 31625, 14, 1360, 436, 199, 3, 10557, 11249, 465, 1072, 370, 922, 652, 1240, 286, 1003, 382, 14, 609, 370, 2112, 4153, 436, 664, 1072, 199, 3, 768, 635, 1056, 1056, 687, 3634, 14, 1360, 199, 3, 768, 1107, 1056, 436, 1245, 370, 1478, 14, 1360, 221, 199, 3, 768, 1107, 11249, 465, 1177, 221, 199, 3, 768, 1971, 372, 1245, 436, 1056, 370, 1478, 14, 1360, 199, 199, 318, 2061, 8, 1069, 304, 421, 198, 1188, 534, 705, 28408, 8749, 5554, 4020, 7, 199, 198, 893, 26, 507, 198, 3, 25566, 805, 370, 2211, 14586, 5678, 1324, 507, 198, 354, 12, 1188, 29, 2246, 63, 952, 8, 1069, 9, 507, 198, 3, 362, 1337, 5579, 402, 3877, 588, 507, 198, 1507, 275, 1056, 14, 1730, 14, 362, 360, 3259, 63, 1618, 63, 1617, 588, 358, 2742, 198, 3, 21849, 1324, 14, 5648, 370, 5666, 7971, 4153, 507, 198, 1531, 29, 354, 23164, 1210, 14, 5648, 7, 507, 198, 493, 29, 1490, 8, 1531, 2584, 65, 358, 2742, 198, 3, 513, 402, 5678, 3762, 507, 198, 1391, 275, 788, 11535, 1673, 8436, 63, 1617, 89, 1673, 51, 29119, 4171, 63, 1617, 89, 418, 2742, 198, 3, 14827, 610, 31625, 1901, 28510, 570, 507, 198, 509, 1335, 315, 2729, 26, 686, 198, 493, 14, 952, 8, 74, 9, 686, 198, 493, 14, 952, 26800, 3642, 779, 358, 6319, 198, 3, 14827, 4008, 402, 610, 31625, 686, 198, 509, 284, 315, 1425, 8, 442, 8, 1507, 2298, 16737, 198, 3, 20358, 1324, 3762, 1585, 198, 808, 275, 1335, 11, 495, 8, 73, 9, 1585, 198, 493, 14, 952, 11894, 358, 16737, 198, 3, 362, 1337, 1324, 687, 3762, 1585, 198, 68, 29, 1069, 14, 4030, 14, 362, 8, 808, 9, 1585, 198, 493, 14, 952, 8, 68, 9, 1585, 198, 493, 14, 952, 360, 10374, 16737, 198, 3, 5394, 370, 1104, 2061, 1819, 1585, 198, 692, 8, 284, 1111, 442, 8, 1507, 7216, 17, 304, 1871, 198, 493 ]
[ 199, 3, 768, 2491, 286, 1003, 382, 5648, 14, 4196, 199, 3, 961, 859, 1395, 3423, 370, 13467, 11199, 73, 3569, 402, 1639, 14, 199, 3, 2779, 2387, 2569, 3423, 446, 26, 199, 3, 1478, 342, 199, 3, 3634, 342, 221, 199, 3, 2061, 342, 199, 3, 570, 342, 221, 199, 3, 6454, 771, 1198, 342, 199, 3, 1642, 63, 952, 342, 199, 3, 2263, 199, 3, 768, 2502, 282, 4584, 6532, 386, 1022, 439, 79, 269, 199, 199, 3, 768, 600, 16306, 4621, 199, 646, 747, 12, 12562, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 199, 646, 7392, 12, 2083, 199, 504, 1639, 14, 1018, 14, 1198, 492, 11426, 2209, 199, 199, 309, 199, 3, 1642, 11199, 73, 87, 2737, 701, 14066, 3517, 2034, 199, 3, 687, 1565, 575, 266, 199, 3, 768, 635, 1056, 1056, 687, 286, 1003, 382, 5648, 14, 3603, 342, 199, 3, 768, 1107, 1056, 436, 931, 370, 1478, 14, 1360, 199, 3, 199, 318, 1478, 8, 1069, 304, 199, 198, 1107, 3795, 8, 1069, 12, 283, 559, 29792, 5648, 15, 1080, 14, 1360, 358, 199, 199, 309, 199, 3, 961, 805, 2929, 3634, 367, 1324, 687, 922, 436, 5452, 221, 199, 3, 1177, 687, 1478, 11199, 73, 87, 436, 2218, 1324, 9394, 4012, 1478, 14, 1360, 199, 3, 436, 2218, 315, 1324, 14, 5648, 570, 199, 3, 768, 635, 1056, 1056, 687, 1478, 14, 1360, 199, 3, 768, 1107, 1056, 436, 931, 370, 3634, 14, 1360, 436, 1329, 402, 3877, 588, 436, 221, 199, 3, 1324, 9394, 687, 1478, 14, 1360, 199, 3, 768, 1971, 372, 1245, 436, 1056, 370, 1478, 14, 1360, 199, 199, 318, 3634, 8, 1069, 304, 421, 198, 893, 26, 507, 198, 3, 9086, 402, 1006, 1324, 3762, 9068, 198, 6717, 275, 791, 5158, 382, 63, 466, 5242, 1673, 3259, 63, 1618, 63, 1617, 588, 356, 891, 507, 198, 2584, 6295, 554, 63, 4778, 5242, 1673, 2364, 63, 22508, 63, 4778, 356, 891, 507, 198, 2584, 11860, 63, 4778, 5242, 1673, 5761, 18936, 63, 645, 29765, 356, 891, 507, 198, 2584, 19578, 63, 388, 2441, 581, 5242, 1673, 2123, 63, 362, 356, 891, 93, 2742, 198, 354, 275, 2125, 2742, 198, 3, 362, 1337, 1324, 1808, 3762, 436, 10209, 652, 465, 1177, 9068, 198, 509, 2729, 315, 5548, 14, 1612, 837, 686, 198, 1069, 14, 1730, 59, 1391, 61, 275, 1056, 14, 4030, 14, 362, 8, 1391, 9, 2742, 198, 3, 20358, 2082, 687, 1300, 2082, 9068, 198, 6717, 459, 3259, 63, 1618, 63, 1617, 588, 418, 275, 1056, 14, 4030, 14, 362, 360, 3259, 63, 1618, 63, 1617, 588, 358, 2742, 198, 3, 391, 17443, 769, 367, 2740, 419, 296, 315, 1565, 575, 266, 9068, 198, 1955, 63, 1618, 63, 1617, 588, 275, 769, 342, 9068, 198, 3, 354, 402, 2082, 402, 2488, 922, 9068, 198, 509, 282, 315, 1425, 8, 442, 8, 6717, 459, 3259, 63, 1618, 63, 1617, 588, 26536, 686, 198, 1955, 63, 1618, 63, 1617, 588, 14, 740, 360, 65, 358, 2742, 198, 3, 25566, 14460, 846, 11199, 73, 3569, 4079, 641, 945, 3775, 507, 198, 3, 1237, 3163, 2742, 198, 692, 8, 1069, 14, 4030, 14, 362, 360, 8304, 63, 493, 358, 6803, 57, 735, 686, 198, 1107, 3795, 8, 1056, 2584, 559, 29792, 5648, 15, 493, 14, 1360, 7, 686, 198, 12, 1445, 1955, 63, 1618, 63, 1617, 588, 356, 1329, 63, 1618, 63, 1617, 588, 12, 686, 198, 7, 2123, 63, 362, 356, 1056, 14, 4030, 14, 362, 360, 2123, 63, 362, 22220, 507, 198, 2836, 26, 507, 198, 3, 751, 2934, 370, 5802, 3634, 574, 4012, 570, 503, 686, 686, 198, 1107, 3795, 8, 1056, 2584, 559, 29792, 5648, 15, 3642, 14, 1360, 7, 686, 198, 12, 1445, 1955, 63, 1618, 63, 1617, 588, 356, 1329, 63, 1618, 63, 1617, 588, 12, 686, 198, 7, 2123, 63, 362, 356, 1056, 14, 4030, 14, 362, 360, 2123, 63, 362, 358, 3828, 199, 198, 2590, 26, 507, 198, 1107, 3795, 8, 1069, 12, 283, 559, 29792, 5648, 15, 1080, 14, 1360, 7, 507, 198, 12, 1445, 1188, 5242, 27567, 5554, 4020, 3071, 421, 199, 309, 199, 3, 961, 805, 7545, 1056, 687, 610, 31625, 14, 1360, 436, 199, 3, 10557, 11249, 465, 1072, 370, 922, 652, 1240, 286, 1003, 382, 14, 609, 370, 2112, 4153, 436, 664, 1072, 199, 3, 768, 635, 1056, 1056, 687, 3634, 14, 1360, 199, 3, 768, 1107, 1056, 436, 1245, 370, 1478, 14, 1360, 221, 199, 3, 768, 1107, 11249, 465, 1177, 221, 199, 3, 768, 1971, 372, 1245, 436, 1056, 370, 1478, 14, 1360, 199, 199, 318, 2061, 8, 1069, 304, 421, 198, 1188, 534, 705, 28408, 8749, 5554, 4020, 7, 199, 198, 893, 26, 507, 198, 3, 25566, 805, 370, 2211, 14586, 5678, 1324, 507, 198, 354, 12, 1188, 29, 2246, 63, 952, 8, 1069, 9, 507, 198, 3, 362, 1337, 5579, 402, 3877, 588, 507, 198, 1507, 275, 1056, 14, 1730, 14, 362, 360, 3259, 63, 1618, 63, 1617, 588, 358, 2742, 198, 3, 21849, 1324, 14, 5648, 370, 5666, 7971, 4153, 507, 198, 1531, 29, 354, 23164, 1210, 14, 5648, 7, 507, 198, 493, 29, 1490, 8, 1531, 2584, 65, 358, 2742, 198, 3, 513, 402, 5678, 3762, 507, 198, 1391, 275, 788, 11535, 1673, 8436, 63, 1617, 89, 1673, 51, 29119, 4171, 63, 1617, 89, 418, 2742, 198, 3, 14827, 610, 31625, 1901, 28510, 570, 507, 198, 509, 1335, 315, 2729, 26, 686, 198, 493, 14, 952, 8, 74, 9, 686, 198, 493, 14, 952, 26800, 3642, 779, 358, 6319, 198, 3, 14827, 4008, 402, 610, 31625, 686, 198, 509, 284, 315, 1425, 8, 442, 8, 1507, 2298, 16737, 198, 3, 20358, 1324, 3762, 1585, 198, 808, 275, 1335, 11, 495, 8, 73, 9, 1585, 198, 493, 14, 952, 11894, 358, 16737, 198, 3, 362, 1337, 1324, 687, 3762, 1585, 198, 68, 29, 1069, 14, 4030, 14, 362, 8, 808, 9, 1585, 198, 493, 14, 952, 8, 68, 9, 1585, 198, 493, 14, 952, 360, 10374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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jcalbert/TextBlob
textblob/decorators.py
17
1085
# -*- coding: utf-8 -*- """Custom decorators.""" from __future__ import absolute_import from functools import wraps from textblob.exceptions import MissingCorpusError class cached_property(object): """A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Credit to Marcel Hellkamp, author of bottle.py. """ def __init__(self, func): self.__doc__ = getattr(func, '__doc__') self.func = func def __get__(self, obj, cls): if obj is None: return self value = obj.__dict__[self.func.__name__] = self.func(obj) return value def requires_nltk_corpus(func): """Wraps a function that requires an NLTK corpus. If the corpus isn't found, raise a :exc:`MissingCorpusError`. """ @wraps(func) def decorated(*args, **kwargs): try: return func(*args, **kwargs) except LookupError as err: print(err) raise MissingCorpusError() return decorated
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 7223, 20419, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 9143, 492, 14018, 199, 504, 1318, 6582, 14, 3924, 492, 15626, 26424, 547, 421, 199, 533, 6328, 63, 1829, 8, 785, 304, 272, 408, 33, 3324, 626, 365, 1454, 9235, 5403, 1126, 1256, 436, 2066, 19058, 272, 6337, 543, 376, 24801, 2225, 14, 15920, 314, 2225, 295, 2193, 314, 272, 3324, 14, 339, 30473, 370, 16794, 6067, 869, 1697, 75, 5282, 12, 4132, 402, 5888, 1118, 14, 647, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2562, 304, 267, 291, 855, 1301, 363, 275, 2519, 8, 1532, 12, 2560, 1301, 13766, 267, 291, 14, 1532, 275, 2562, 339, 347, 636, 362, 721, 277, 12, 1559, 12, 843, 304, 267, 340, 1559, 365, 488, 26, 288, 372, 291, 267, 574, 275, 1559, 855, 807, 12298, 277, 14, 1532, 855, 354, 22705, 275, 291, 14, 1532, 8, 1113, 9, 267, 372, 574, 421, 199, 318, 5074, 63, 7530, 2663, 63, 16780, 8, 1532, 304, 272, 408, 55, 8146, 282, 805, 626, 5074, 376, 24719, 15263, 16831, 14, 982, 314, 16831, 5712, 1133, 1911, 12, 272, 746, 282, 520, 2804, 1705, 7718, 26424, 547, 2313, 272, 408, 272, 768, 13582, 8, 1532, 9, 272, 347, 16225, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 2562, 2031, 589, 12, 1011, 958, 9, 267, 871, 19021, 465, 2329, 26, 288, 870, 8, 1508, 9, 288, 746, 15626, 26424, 547, 342, 272, 372, 16225, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 7223, 20419, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 9143, 492, 14018, 199, 504, 1318, 6582, 14, 3924, 492, 15626, 26424, 547, 421, 199, 533, 6328, 63, 1829, 8, 785, 304, 272, 408, 33, 3324, 626, 365, 1454, 9235, 5403, 1126, 1256, 436, 2066, 19058, 272, 6337, 543, 376, 24801, 2225, 14, 15920, 314, 2225, 295, 2193, 314, 272, 3324, 14, 339, 30473, 370, 16794, 6067, 869, 1697, 75, 5282, 12, 4132, 402, 5888, 1118, 14, 647, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2562, 304, 267, 291, 855, 1301, 363, 275, 2519, 8, 1532, 12, 2560, 1301, 13766, 267, 291, 14, 1532, 275, 2562, 339, 347, 636, 362, 721, 277, 12, 1559, 12, 843, 304, 267, 340, 1559, 365, 488, 26, 288, 372, 291, 267, 574, 275, 1559, 855, 807, 12298, 277, 14, 1532, 855, 354, 22705, 275, 291, 14, 1532, 8, 1113, 9, 267, 372, 574, 421, 199, 318, 5074, 63, 7530, 2663, 63, 16780, 8, 1532, 304, 272, 408, 55, 8146, 282, 805, 626, 5074, 376, 24719, 15263, 16831, 14, 982, 314, 16831, 5712, 1133, 1911, 12, 272, 746, 282, 520, 2804, 1705, 7718, 26424, 547, 2313, 272, 408, 272, 768, 13582, 8, 1532, 9, 272, 347, 16225, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 2562, 2031, 589, 12, 1011, 958, 9, 267, 871, 19021, 465, 2329, 26, 288, 870, 8, 1508, 9, 288, 746, 15626, 26424, 547, 342, 272, 372, 16225, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kerr-huang/SL4A
python/src/Lib/test/test_doctest.py
52
76371
""" Test script for doctest. """ from test import test_support import doctest import warnings # NOTE: There are some additional tests relating to interaction with # zipimport in the test_zipimport_support test module. ###################################################################### ## Sample Objects (used by test cases) ###################################################################### def sample_func(v): """ Blah blah >>> print sample_func(22) 44 Yee ha! """ return v+v class SampleClass: """ >>> print 1 1 >>> # comments get ignored. so are empty PS1 and PS2 prompts: >>> ... Multiline example: >>> sc = SampleClass(3) >>> for i in range(10): ... sc = sc.double() ... print sc.get(), 6 12 24 48 96 192 384 768 1536 3072 """ def __init__(self, val): """ >>> print SampleClass(12).get() 12 """ self.val = val def double(self): """ >>> print SampleClass(12).double().get() 24 """ return SampleClass(self.val + self.val) def get(self): """ >>> print SampleClass(-5).get() -5 """ return self.val def a_staticmethod(v): """ >>> print SampleClass.a_staticmethod(10) 11 """ return v+1 a_staticmethod = staticmethod(a_staticmethod) def a_classmethod(cls, v): """ >>> print SampleClass.a_classmethod(10) 12 >>> print SampleClass(0).a_classmethod(10) 12 """ return v+2 a_classmethod = classmethod(a_classmethod) a_property = property(get, doc=""" >>> print SampleClass(22).a_property 22 """) class NestedClass: """ >>> x = SampleClass.NestedClass(5) >>> y = x.square() >>> print y.get() 25 """ def __init__(self, val=0): """ >>> print SampleClass.NestedClass().get() 0 """ self.val = val def square(self): return SampleClass.NestedClass(self.val*self.val) def get(self): return self.val class SampleNewStyleClass(object): r""" >>> print '1\n2\n3' 1 2 3 """ def __init__(self, val): """ >>> print SampleNewStyleClass(12).get() 12 """ self.val = val def double(self): """ >>> print SampleNewStyleClass(12).double().get() 24 """ return SampleNewStyleClass(self.val + self.val) def get(self): """ >>> print SampleNewStyleClass(-5).get() -5 """ return self.val ###################################################################### ## Fake stdin (for testing interactive debugging) ###################################################################### class _FakeInput: """ A fake input stream for pdb's interactive debugger. Whenever a line is read, print it (to simulate the user typing it), and then return it. The set of lines to return is specified in the constructor; they should not have trailing newlines. """ def __init__(self, lines): self.lines = lines def readline(self): line = self.lines.pop(0) print line return line+'\n' ###################################################################### ## Test Cases ###################################################################### def test_Example(): r""" Unit tests for the `Example` class. Example is a simple container class that holds: - `source`: A source string. - `want`: An expected output string. - `exc_msg`: An expected exception message string (or None if no exception is expected). - `lineno`: A line number (within the docstring). - `indent`: The example's indentation in the input string. - `options`: An option dictionary, mapping option flags to True or False. These attributes are set by the constructor. `source` and `want` are required; the other attributes all have default values: >>> example = doctest.Example('print 1', '1\n') >>> (example.source, example.want, example.exc_msg, ... example.lineno, example.indent, example.options) ('print 1\n', '1\n', None, 0, 0, {}) The first three attributes (`source`, `want`, and `exc_msg`) may be specified positionally; the remaining arguments should be specified as keyword arguments: >>> exc_msg = 'IndexError: pop from an empty list' >>> example = doctest.Example('[].pop()', '', exc_msg, ... lineno=5, indent=4, ... options={doctest.ELLIPSIS: True}) >>> (example.source, example.want, example.exc_msg, ... example.lineno, example.indent, example.options) ('[].pop()\n', '', 'IndexError: pop from an empty list\n', 5, 4, {8: True}) The constructor normalizes the `source` string to end in a newline: Source spans a single line: no terminating newline. >>> e = doctest.Example('print 1', '1\n') >>> e.source, e.want ('print 1\n', '1\n') >>> e = doctest.Example('print 1\n', '1\n') >>> e.source, e.want ('print 1\n', '1\n') Source spans multiple lines: require terminating newline. >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n') >>> e.source, e.want ('print 1;\nprint 2\n', '1\n2\n') >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n') >>> e.source, e.want ('print 1;\nprint 2\n', '1\n2\n') Empty source string (which should never appear in real examples) >>> e = doctest.Example('', '') >>> e.source, e.want ('\n', '') The constructor normalizes the `want` string to end in a newline, unless it's the empty string: >>> e = doctest.Example('print 1', '1\n') >>> e.source, e.want ('print 1\n', '1\n') >>> e = doctest.Example('print 1', '1') >>> e.source, e.want ('print 1\n', '1\n') >>> e = doctest.Example('print', '') >>> e.source, e.want ('print\n', '') The constructor normalizes the `exc_msg` string to end in a newline, unless it's `None`: Message spans one line >>> exc_msg = 'IndexError: pop from an empty list' >>> e = doctest.Example('[].pop()', '', exc_msg) >>> e.exc_msg 'IndexError: pop from an empty list\n' >>> exc_msg = 'IndexError: pop from an empty list\n' >>> e = doctest.Example('[].pop()', '', exc_msg) >>> e.exc_msg 'IndexError: pop from an empty list\n' Message spans multiple lines >>> exc_msg = 'ValueError: 1\n 2' >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) >>> e.exc_msg 'ValueError: 1\n 2\n' >>> exc_msg = 'ValueError: 1\n 2\n' >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) >>> e.exc_msg 'ValueError: 1\n 2\n' Empty (but non-None) exception message (which should never appear in real examples) >>> exc_msg = '' >>> e = doctest.Example('raise X()', '', exc_msg) >>> e.exc_msg '\n' """ def test_DocTest(): r""" Unit tests for the `DocTest` class. DocTest is a collection of examples, extracted from a docstring, along with information about where the docstring comes from (a name, filename, and line number). The docstring is parsed by the `DocTest` constructor: >>> docstring = ''' ... >>> print 12 ... 12 ... ... Non-example text. ... ... >>> print 'another\example' ... another ... example ... ''' >>> globs = {} # globals to run the test in. >>> parser = doctest.DocTestParser() >>> test = parser.get_doctest(docstring, globs, 'some_test', ... 'some_file', 20) >>> print test <DocTest some_test from some_file:20 (2 examples)> >>> len(test.examples) 2 >>> e1, e2 = test.examples >>> (e1.source, e1.want, e1.lineno) ('print 12\n', '12\n', 1) >>> (e2.source, e2.want, e2.lineno) ("print 'another\\example'\n", 'another\nexample\n', 6) Source information (name, filename, and line number) is available as attributes on the doctest object: >>> (test.name, test.filename, test.lineno) ('some_test', 'some_file', 20) The line number of an example within its containing file is found by adding the line number of the example and the line number of its containing test: >>> test.lineno + e1.lineno 21 >>> test.lineno + e2.lineno 26 If the docstring contains inconsistant leading whitespace in the expected output of an example, then `DocTest` will raise a ValueError: >>> docstring = r''' ... >>> print 'bad\nindentation' ... bad ... indentation ... ''' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: 'indentation' If the docstring contains inconsistent leading whitespace on continuation lines, then `DocTest` will raise a ValueError: >>> docstring = r''' ... >>> print ('bad indentation', ... ... 2) ... ('bad', 'indentation') ... ''' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2)' If there's no blank space after a PS1 prompt ('>>>'), then `DocTest` will raise a ValueError: >>> docstring = '>>>print 1\n1' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' If there's no blank space after a PS2 prompt ('...'), then `DocTest` will raise a ValueError: >>> docstring = '>>> if 1:\n...print 1\n1' >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) Traceback (most recent call last): ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' """ def test_DocTestFinder(): r""" Unit tests for the `DocTestFinder` class. DocTestFinder is used to extract DocTests from an object's docstring and the docstrings of its contained objects. It can be used with modules, functions, classes, methods, staticmethods, classmethods, and properties. Finding Tests in Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~ For a function whose docstring contains examples, DocTestFinder.find() will return a single test (for that function's docstring): >>> finder = doctest.DocTestFinder() We'll simulate a __file__ attr that ends in pyc: >>> import test.test_doctest >>> old = test.test_doctest.__file__ >>> test.test_doctest.__file__ = 'test_doctest.pyc' >>> tests = finder.find(sample_func) >>> print tests # doctest: +ELLIPSIS [<DocTest sample_func from ...:16 (1 example)>] The exact name depends on how test_doctest was invoked, so allow for leading path components. >>> tests[0].filename # doctest: +ELLIPSIS '...test_doctest.py' >>> test.test_doctest.__file__ = old >>> e = tests[0].examples[0] >>> (e.source, e.want, e.lineno) ('print sample_func(22)\n', '44\n', 3) By default, tests are created for objects with no docstring: >>> def no_docstring(v): ... pass >>> finder.find(no_docstring) [] However, the optional argument `exclude_empty` to the DocTestFinder constructor can be used to exclude tests for objects with empty docstrings: >>> def no_docstring(v): ... pass >>> excl_empty_finder = doctest.DocTestFinder(exclude_empty=True) >>> excl_empty_finder.find(no_docstring) [] If the function has a docstring with no examples, then a test with no examples is returned. (This lets `DocTestRunner` collect statistics about which functions have no tests -- but is that useful? And should an empty test also be created when there's no docstring?) >>> def no_examples(v): ... ''' no doctest examples ''' >>> finder.find(no_examples) # doctest: +ELLIPSIS [<DocTest no_examples from ...:1 (no examples)>] Finding Tests in Classes ~~~~~~~~~~~~~~~~~~~~~~~~ For a class, DocTestFinder will create a test for the class's docstring, and will recursively explore its contents, including methods, classmethods, staticmethods, properties, and nested classes. >>> finder = doctest.DocTestFinder() >>> tests = finder.find(SampleClass) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get New-style classes are also supported: >>> tests = finder.find(SampleNewStyleClass) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 1 SampleNewStyleClass 1 SampleNewStyleClass.__init__ 1 SampleNewStyleClass.double 1 SampleNewStyleClass.get Finding Tests in Modules ~~~~~~~~~~~~~~~~~~~~~~~~ For a module, DocTestFinder will create a test for the class's docstring, and will recursively explore its contents, including functions, classes, and the `__test__` dictionary, if it exists: >>> # A module >>> import types >>> m = types.ModuleType('some_module') >>> def triple(val): ... ''' ... >>> print triple(11) ... 33 ... ''' ... return val*3 >>> m.__dict__.update({ ... 'sample_func': sample_func, ... 'SampleClass': SampleClass, ... '__doc__': ''' ... Module docstring. ... >>> print 'module' ... module ... ''', ... '__test__': { ... 'd': '>>> print 6\n6\n>>> print 7\n7\n', ... 'c': triple}}) >>> finder = doctest.DocTestFinder() >>> # Use module=test.test_doctest, to prevent doctest from >>> # ignoring the objects since they weren't defined in m. >>> import test.test_doctest >>> tests = finder.find(m, module=test.test_doctest) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 1 some_module 3 some_module.SampleClass 3 some_module.SampleClass.NestedClass 1 some_module.SampleClass.NestedClass.__init__ 1 some_module.SampleClass.__init__ 2 some_module.SampleClass.a_classmethod 1 some_module.SampleClass.a_property 1 some_module.SampleClass.a_staticmethod 1 some_module.SampleClass.double 1 some_module.SampleClass.get 1 some_module.__test__.c 2 some_module.__test__.d 1 some_module.sample_func Duplicate Removal ~~~~~~~~~~~~~~~~~ If a single object is listed twice (under different names), then tests will only be generated for it once: >>> from test import doctest_aliases >>> tests = excl_empty_finder.find(doctest_aliases) >>> print len(tests) 2 >>> print tests[0].name test.doctest_aliases.TwoNames TwoNames.f and TwoNames.g are bound to the same object. We can't guess which will be found in doctest's traversal of TwoNames.__dict__ first, so we have to allow for either. >>> tests[1].name.split('.')[-1] in ['f', 'g'] True Empty Tests ~~~~~~~~~~~ By default, an object with no doctests doesn't create any tests: >>> tests = doctest.DocTestFinder().find(SampleClass) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get By default, that excluded objects with no doctests. exclude_empty=False tells it to include (empty) tests for objects with no doctests. This feature is really to support backward compatibility in what doctest.master.summarize() displays. >>> tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 3 SampleClass 3 SampleClass.NestedClass 1 SampleClass.NestedClass.__init__ 0 SampleClass.NestedClass.get 0 SampleClass.NestedClass.square 1 SampleClass.__init__ 2 SampleClass.a_classmethod 1 SampleClass.a_property 1 SampleClass.a_staticmethod 1 SampleClass.double 1 SampleClass.get Turning off Recursion ~~~~~~~~~~~~~~~~~~~~~ DocTestFinder can be told not to look for tests in contained objects using the `recurse` flag: >>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass) >>> for t in tests: ... print '%2s %s' % (len(t.examples), t.name) 3 SampleClass Line numbers ~~~~~~~~~~~~ DocTestFinder finds the line number of each example: >>> def f(x): ... ''' ... >>> x = 12 ... ... some text ... ... >>> # examples are not created for comments & bare prompts. ... >>> ... ... ... ... >>> for x in range(10): ... ... print x, ... 0 1 2 3 4 5 6 7 8 9 ... >>> x//2 ... 6 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> [e.lineno for e in test.examples] [1, 9, 12] """ def test_DocTestParser(): r""" Unit tests for the `DocTestParser` class. DocTestParser is used to parse docstrings containing doctest examples. The `parse` method divides a docstring into examples and intervening text: >>> s = ''' ... >>> x, y = 2, 3 # no output expected ... >>> if 1: ... ... print x ... ... print y ... 2 ... 3 ... ... Some text. ... >>> x+y ... 5 ... ''' >>> parser = doctest.DocTestParser() >>> for piece in parser.parse(s): ... if isinstance(piece, doctest.Example): ... print 'Example:', (piece.source, piece.want, piece.lineno) ... else: ... print ' Text:', `piece` Text: '\n' Example: ('x, y = 2, 3 # no output expected\n', '', 1) Text: '' Example: ('if 1:\n print x\n print y\n', '2\n3\n', 2) Text: '\nSome text.\n' Example: ('x+y\n', '5\n', 9) Text: '' The `get_examples` method returns just the examples: >>> for piece in parser.get_examples(s): ... print (piece.source, piece.want, piece.lineno) ('x, y = 2, 3 # no output expected\n', '', 1) ('if 1:\n print x\n print y\n', '2\n3\n', 2) ('x+y\n', '5\n', 9) The `get_doctest` method creates a Test from the examples, along with the given arguments: >>> test = parser.get_doctest(s, {}, 'name', 'filename', lineno=5) >>> (test.name, test.filename, test.lineno) ('name', 'filename', 5) >>> for piece in test.examples: ... print (piece.source, piece.want, piece.lineno) ('x, y = 2, 3 # no output expected\n', '', 1) ('if 1:\n print x\n print y\n', '2\n3\n', 2) ('x+y\n', '5\n', 9) """ class test_DocTestRunner: def basics(): r""" Unit tests for the `DocTestRunner` class. DocTestRunner is used to run DocTest test cases, and to accumulate statistics. Here's a simple DocTest case we can use: >>> def f(x): ... ''' ... >>> x = 12 ... >>> print x ... 12 ... >>> x//2 ... 6 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] The main DocTestRunner interface is the `run` method, which runs a given DocTest case in a given namespace (globs). It returns a tuple `(f,t)`, where `f` is the number of failed tests and `t` is the number of tried tests. >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=3) If any example produces incorrect output, then the test runner reports the failure and proceeds to the next example: >>> def f(x): ... ''' ... >>> x = 12 ... >>> print x ... 14 ... >>> x//2 ... 6 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=True).run(test) ... # doctest: +ELLIPSIS Trying: x = 12 Expecting nothing ok Trying: print x Expecting: 14 ********************************************************************** File ..., line 4, in f Failed example: print x Expected: 14 Got: 12 Trying: x//2 Expecting: 6 ok TestResults(failed=1, attempted=3) """ def verbose_flag(): r""" The `verbose` flag makes the test runner generate more detailed output: >>> def f(x): ... ''' ... >>> x = 12 ... >>> print x ... 12 ... >>> x//2 ... 6 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=True).run(test) Trying: x = 12 Expecting nothing ok Trying: print x Expecting: 12 ok Trying: x//2 Expecting: 6 ok TestResults(failed=0, attempted=3) If the `verbose` flag is unspecified, then the output will be verbose iff `-v` appears in sys.argv: >>> # Save the real sys.argv list. >>> old_argv = sys.argv >>> # If -v does not appear in sys.argv, then output isn't verbose. >>> sys.argv = ['test'] >>> doctest.DocTestRunner().run(test) TestResults(failed=0, attempted=3) >>> # If -v does appear in sys.argv, then output is verbose. >>> sys.argv = ['test', '-v'] >>> doctest.DocTestRunner().run(test) Trying: x = 12 Expecting nothing ok Trying: print x Expecting: 12 ok Trying: x//2 Expecting: 6 ok TestResults(failed=0, attempted=3) >>> # Restore sys.argv >>> sys.argv = old_argv In the remaining examples, the test runner's verbosity will be explicitly set, to ensure that the test behavior is consistent. """ def exceptions(): r""" Tests of `DocTestRunner`'s exception handling. An expected exception is specified with a traceback message. The lines between the first line and the type/value may be omitted or replaced with any other string: >>> def f(x): ... ''' ... >>> x = 12 ... >>> print x//0 ... Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=2) An example may not generate output before it raises an exception; if it does, then the traceback message will not be recognized as signaling an expected exception, so the example will be reported as an unexpected exception: >>> def f(x): ... ''' ... >>> x = 12 ... >>> print 'pre-exception output', x//0 ... pre-exception output ... Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 4, in f Failed example: print 'pre-exception output', x//0 Exception raised: ... ZeroDivisionError: integer division or modulo by zero TestResults(failed=1, attempted=2) Exception messages may contain newlines: >>> def f(x): ... r''' ... >>> raise ValueError, 'multi\nline\nmessage' ... Traceback (most recent call last): ... ValueError: multi ... line ... message ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) If an exception is expected, but an exception with the wrong type or message is raised, then it is reported as a failure: >>> def f(x): ... r''' ... >>> raise ValueError, 'message' ... Traceback (most recent call last): ... ValueError: wrong message ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: raise ValueError, 'message' Expected: Traceback (most recent call last): ValueError: wrong message Got: Traceback (most recent call last): ... ValueError: message TestResults(failed=1, attempted=1) However, IGNORE_EXCEPTION_DETAIL can be used to allow a mismatch in the detail: >>> def f(x): ... r''' ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL ... Traceback (most recent call last): ... ValueError: wrong message ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type: >>> def f(x): ... r''' ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL ... Traceback (most recent call last): ... TypeError: wrong type ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL Expected: Traceback (most recent call last): TypeError: wrong type Got: Traceback (most recent call last): ... ValueError: message TestResults(failed=1, attempted=1) If an exception is raised but not expected, then it is reported as an unexpected exception: >>> def f(x): ... r''' ... >>> 1//0 ... 0 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: 1//0 Exception raised: Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero TestResults(failed=1, attempted=1) """ def optionflags(): r""" Tests of `DocTestRunner`'s option flag handling. Several option flags can be used to customize the behavior of the test runner. These are defined as module constants in doctest, and passed to the DocTestRunner constructor (multiple constants should be ORed together). The DONT_ACCEPT_TRUE_FOR_1 flag disables matches between True/False and 1/0: >>> def f(x): ... '>>> True\n1\n' >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: True Expected: 1 Got: True TestResults(failed=1, attempted=1) The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines and the '<BLANKLINE>' marker: >>> def f(x): ... '>>> print "a\\n\\nb"\na\n<BLANKLINE>\nb\n' >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.DONT_ACCEPT_BLANKLINE >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print "a\n\nb" Expected: a <BLANKLINE> b Got: a <BLANKLINE> b TestResults(failed=1, attempted=1) The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be treated as equal: >>> def f(x): ... '>>> print 1, 2, 3\n 1 2\n 3' >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print 1, 2, 3 Expected: 1 2 3 Got: 1 2 3 TestResults(failed=1, attempted=1) >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.NORMALIZE_WHITESPACE >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) TestResults(failed=0, attempted=1) An example from the docs: >>> print range(20) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] The ELLIPSIS flag causes ellipsis marker ("...") in the expected output to match any substring in the actual output: >>> def f(x): ... '>>> print range(15)\n[0, 1, 2, ..., 14]\n' >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(15) Expected: [0, 1, 2, ..., 14] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] TestResults(failed=1, attempted=1) >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.ELLIPSIS >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) TestResults(failed=0, attempted=1) ... also matches nothing: >>> for i in range(100): ... print i**2, #doctest: +ELLIPSIS 0 1...4...9 16 ... 36 49 64 ... 9801 ... can be surprising; e.g., this test passes: >>> for i in range(21): #doctest: +ELLIPSIS ... print i, 0 1 2 ...1...2...0 Examples from the docs: >>> print range(20) # doctest:+ELLIPSIS [0, 1, ..., 18, 19] >>> print range(20) # doctest: +ELLIPSIS ... # doctest: +NORMALIZE_WHITESPACE [0, 1, ..., 18, 19] The SKIP flag causes an example to be skipped entirely. I.e., the example is not run. It can be useful in contexts where doctest examples serve as both documentation and test cases, and an example should be included for documentation purposes, but should not be checked (e.g., because its output is random, or depends on resources which would be unavailable.) The SKIP flag can also be used for 'commenting out' broken examples. >>> import unavailable_resource # doctest: +SKIP >>> unavailable_resource.do_something() # doctest: +SKIP >>> unavailable_resource.blow_up() # doctest: +SKIP Traceback (most recent call last): ... UncheckedBlowUpError: Nobody checks me. >>> import random >>> print random.random() # doctest: +SKIP 0.721216923889 The REPORT_UDIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a unified diff: >>> def f(x): ... r''' ... >>> print '\n'.join('abcdefg') ... a ... B ... c ... d ... f ... g ... h ... ''' >>> # Without the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: print '\n'.join('abcdefg') Expected: a B c d f g h Got: a b c d e f g TestResults(failed=1, attempted=1) >>> # With the flag: >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.REPORT_UDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: print '\n'.join('abcdefg') Differences (unified diff with -expected +actual): @@ -1,7 +1,7 @@ a -B +b c d +e f g -h TestResults(failed=1, attempted=1) The REPORT_CDIFF flag causes failures that involve multi-line expected and actual outputs to be displayed using a context diff: >>> # Reuse f() from the REPORT_UDIFF example, above. >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.REPORT_CDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: print '\n'.join('abcdefg') Differences (context diff with expected followed by actual): *************** *** 1,7 **** a ! B c d f g - h --- 1,7 ---- a ! b c d + e f g TestResults(failed=1, attempted=1) The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm used by the popular ndiff.py utility. This does intraline difference marking, as well as interline differences. >>> def f(x): ... r''' ... >>> print "a b c d e f g h i j k l m" ... a b c d e f g h i j k 1 m ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.REPORT_NDIFF >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 3, in f Failed example: print "a b c d e f g h i j k l m" Differences (ndiff with -expected +actual): - a b c d e f g h i j k 1 m ? ^ + a b c d e f g h i j k l m ? + ++ ^ TestResults(failed=1, attempted=1) The REPORT_ONLY_FIRST_FAILURE supresses result output after the first failing example: >>> def f(x): ... r''' ... >>> print 1 # first success ... 1 ... >>> print 2 # first failure ... 200 ... >>> print 3 # second failure ... 300 ... >>> print 4 # second success ... 4 ... >>> print 5 # third failure ... 500 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 5, in f Failed example: print 2 # first failure Expected: 200 Got: 2 TestResults(failed=3, attempted=5) However, output from `report_start` is not supressed: >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) ... # doctest: +ELLIPSIS Trying: print 1 # first success Expecting: 1 ok Trying: print 2 # first failure Expecting: 200 ********************************************************************** File ..., line 5, in f Failed example: print 2 # first failure Expected: 200 Got: 2 TestResults(failed=3, attempted=5) For the purposes of REPORT_ONLY_FIRST_FAILURE, unexpected exceptions count as failures: >>> def f(x): ... r''' ... >>> print 1 # first success ... 1 ... >>> raise ValueError(2) # first failure ... 200 ... >>> print 3 # second failure ... 300 ... >>> print 4 # second success ... 4 ... >>> print 5 # third failure ... 500 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 5, in f Failed example: raise ValueError(2) # first failure Exception raised: ... ValueError: 2 TestResults(failed=3, attempted=5) New option flags can also be registered, via register_optionflag(). Here we reach into doctest's internals a bit. >>> unlikely = "UNLIKELY_OPTION_NAME" >>> unlikely in doctest.OPTIONFLAGS_BY_NAME False >>> new_flag_value = doctest.register_optionflag(unlikely) >>> unlikely in doctest.OPTIONFLAGS_BY_NAME True Before 2.4.4/2.5, registering a name more than once erroneously created more than one flag value. Here we verify that's fixed: >>> redundant_flag_value = doctest.register_optionflag(unlikely) >>> redundant_flag_value == new_flag_value True Clean up. >>> del doctest.OPTIONFLAGS_BY_NAME[unlikely] """ def option_directives(): r""" Tests of `DocTestRunner`'s option directive mechanism. Option directives can be used to turn option flags on or off for a single example. To turn an option on for an example, follow that example with a comment of the form ``# doctest: +OPTION``: >>> def f(x): r''' ... >>> print range(10) # should fail: no ellipsis ... [0, 1, ..., 9] ... ... >>> print range(10) # doctest: +ELLIPSIS ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(10) # should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) To turn an option off for an example, follow that example with a comment of the form ``# doctest: -OPTION``: >>> def f(x): r''' ... >>> print range(10) ... [0, 1, ..., 9] ... ... >>> # should fail: no ellipsis ... >>> print range(10) # doctest: -ELLIPSIS ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False, ... optionflags=doctest.ELLIPSIS).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 6, in f Failed example: print range(10) # doctest: -ELLIPSIS Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) Option directives affect only the example that they appear with; they do not change the options for surrounding examples: >>> def f(x): r''' ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] ... ... >>> print range(10) # doctest: +ELLIPSIS ... [0, 1, ..., 9] ... ... >>> print range(10) # Should fail: no ellipsis ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(10) # Should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ********************************************************************** File ..., line 8, in f Failed example: print range(10) # Should fail: no ellipsis Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=2, attempted=3) Multiple options may be modified by a single option directive. They may be separated by whitespace, commas, or both: >>> def f(x): r''' ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ... >>> print range(10) # Should succeed ... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(10) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) >>> def f(x): r''' ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ... >>> print range(10) # Should succeed ... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(10) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) >>> def f(x): r''' ... >>> print range(10) # Should fail ... [0, 1, ..., 9] ... >>> print range(10) # Should succeed ... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) ... # doctest: +ELLIPSIS ********************************************************************** File ..., line 2, in f Failed example: print range(10) # Should fail Expected: [0, 1, ..., 9] Got: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TestResults(failed=1, attempted=2) The option directive may be put on the line following the source, as long as a continuation prompt is used: >>> def f(x): r''' ... >>> print range(10) ... ... # doctest: +ELLIPSIS ... [0, 1, ..., 9] ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) For examples with multi-line source, the option directive may appear at the end of any line: >>> def f(x): r''' ... >>> for x in range(10): # doctest: +ELLIPSIS ... ... print x, ... 0 1 2 ... 9 ... ... >>> for x in range(10): ... ... print x, # doctest: +ELLIPSIS ... 0 1 2 ... 9 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=2) If more than one line of an example with multi-line source has an option directive, then they are combined: >>> def f(x): r''' ... Should fail (option directive not on the last line): ... >>> for x in range(10): # doctest: +ELLIPSIS ... ... print x, # doctest: +NORMALIZE_WHITESPACE ... 0 1 2...9 ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) TestResults(failed=0, attempted=1) It is an error to have a comment of the form ``# doctest:`` that is *not* followed by words of the form ``+OPTION`` or ``-OPTION``, where ``OPTION`` is an option that has been registered with `register_option`: >>> # Error: Option not registered >>> s = '>>> print 12 #doctest: +BADOPTION' >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Traceback (most recent call last): ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION' >>> # Error: No + or - prefix >>> s = '>>> print 12 #doctest: ELLIPSIS' >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Traceback (most recent call last): ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS' It is an error to use an option directive on a line that contains no source: >>> s = '>>> # doctest: +ELLIPSIS' >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) Traceback (most recent call last): ValueError: line 0 of the doctest for s has an option directive on a line with no example: '# doctest: +ELLIPSIS' """ def test_testsource(): r""" Unit tests for `testsource()`. The testsource() function takes a module and a name, finds the (first) test with that name in that module, and converts it to a script. The example code is converted to regular Python code. The surrounding words and expected output are converted to comments: >>> import test.test_doctest >>> name = 'test.test_doctest.sample_func' >>> print doctest.testsource(test.test_doctest, name) # Blah blah # print sample_func(22) # Expected: ## 44 # # Yee ha! <BLANKLINE> >>> name = 'test.test_doctest.SampleNewStyleClass' >>> print doctest.testsource(test.test_doctest, name) print '1\n2\n3' # Expected: ## 1 ## 2 ## 3 <BLANKLINE> >>> name = 'test.test_doctest.SampleClass.a_classmethod' >>> print doctest.testsource(test.test_doctest, name) print SampleClass.a_classmethod(10) # Expected: ## 12 print SampleClass(0).a_classmethod(10) # Expected: ## 12 <BLANKLINE> """ def test_debug(): r""" Create a docstring that we want to debug: >>> s = ''' ... >>> x = 12 ... >>> print x ... 12 ... ''' Create some fake stdin input, to feed to the debugger: >>> import tempfile >>> real_stdin = sys.stdin >>> sys.stdin = _FakeInput(['next', 'print x', 'continue']) Run the debugger on the docstring, and then restore sys.stdin. >>> try: doctest.debug_src(s) ... finally: sys.stdin = real_stdin > <string>(1)<module>() (Pdb) next 12 --Return-- > <string>(1)<module>()->None (Pdb) print x 12 (Pdb) continue """ def test_pdb_set_trace(): """Using pdb.set_trace from a doctest. You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time you use it. The doctest module changes sys.stdout so that it can capture program output. It also temporarily replaces pdb.set_trace with a version that restores stdout. This is necessary for you to see debugger output. >>> doc = ''' ... >>> x = 42 ... >>> import pdb; pdb.set_trace() ... ''' >>> parser = doctest.DocTestParser() >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0) >>> runner = doctest.DocTestRunner(verbose=False) To demonstrate this, we'll create a fake standard input that captures our debugger input: >>> import tempfile >>> real_stdin = sys.stdin >>> sys.stdin = _FakeInput([ ... 'print x', # print data defined by the example ... 'continue', # stop debugging ... '']) >>> try: runner.run(test) ... finally: sys.stdin = real_stdin --Return-- > <doctest foo[1]>(1)<module>()->None -> import pdb; pdb.set_trace() (Pdb) print x 42 (Pdb) continue TestResults(failed=0, attempted=2) You can also put pdb.set_trace in a function called from a test: >>> def calls_set_trace(): ... y=2 ... import pdb; pdb.set_trace() >>> doc = ''' ... >>> x=1 ... >>> calls_set_trace() ... ''' >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> real_stdin = sys.stdin >>> sys.stdin = _FakeInput([ ... 'print y', # print data defined in the function ... 'up', # out of function ... 'print x', # print data defined by the example ... 'continue', # stop debugging ... '']) >>> try: ... runner.run(test) ... finally: ... sys.stdin = real_stdin --Return-- > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None -> import pdb; pdb.set_trace() (Pdb) print y 2 (Pdb) up > <doctest foo[1]>(1)<module>() -> calls_set_trace() (Pdb) print x 1 (Pdb) continue TestResults(failed=0, attempted=2) During interactive debugging, source code is shown, even for doctest examples: >>> doc = ''' ... >>> def f(x): ... ... g(x*2) ... >>> def g(x): ... ... print x+3 ... ... import pdb; pdb.set_trace() ... >>> f(3) ... ''' >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> real_stdin = sys.stdin >>> sys.stdin = _FakeInput([ ... 'list', # list source from example 2 ... 'next', # return from g() ... 'list', # list source from example 1 ... 'next', # return from f() ... 'list', # list source from example 3 ... 'continue', # stop debugging ... '']) >>> try: runner.run(test) ... finally: sys.stdin = real_stdin ... # doctest: +NORMALIZE_WHITESPACE --Return-- > <doctest foo[1]>(3)g()->None -> import pdb; pdb.set_trace() (Pdb) list 1 def g(x): 2 print x+3 3 -> import pdb; pdb.set_trace() [EOF] (Pdb) next --Return-- > <doctest foo[0]>(2)f()->None -> g(x*2) (Pdb) list 1 def f(x): 2 -> g(x*2) [EOF] (Pdb) next --Return-- > <doctest foo[2]>(1)<module>()->None -> f(3) (Pdb) list 1 -> f(3) [EOF] (Pdb) continue ********************************************************************** File "foo.py", line 7, in foo Failed example: f(3) Expected nothing Got: 9 TestResults(failed=1, attempted=3) """ def test_pdb_set_trace_nested(): """This illustrates more-demanding use of set_trace with nested functions. >>> class C(object): ... def calls_set_trace(self): ... y = 1 ... import pdb; pdb.set_trace() ... self.f1() ... y = 2 ... def f1(self): ... x = 1 ... self.f2() ... x = 2 ... def f2(self): ... z = 1 ... z = 2 >>> calls_set_trace = C().calls_set_trace >>> doc = ''' ... >>> a = 1 ... >>> calls_set_trace() ... ''' >>> parser = doctest.DocTestParser() >>> runner = doctest.DocTestRunner(verbose=False) >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> real_stdin = sys.stdin >>> sys.stdin = _FakeInput([ ... 'print y', # print data defined in the function ... 'step', 'step', 'step', 'step', 'step', 'step', 'print z', ... 'up', 'print x', ... 'up', 'print y', ... 'up', 'print foo', ... 'continue', # stop debugging ... '']) >>> try: ... runner.run(test) ... finally: ... sys.stdin = real_stdin > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() -> self.f1() (Pdb) print y 1 (Pdb) step --Call-- > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(7)f1() -> def f1(self): (Pdb) step > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(8)f1() -> x = 1 (Pdb) step > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1() -> self.f2() (Pdb) step --Call-- > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(11)f2() -> def f2(self): (Pdb) step > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(12)f2() -> z = 1 (Pdb) step > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2() -> z = 2 (Pdb) print z 1 (Pdb) up > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1() -> self.f2() (Pdb) print x 1 (Pdb) up > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() -> self.f1() (Pdb) print y 1 (Pdb) up > <doctest foo[1]>(1)<module>() -> calls_set_trace() (Pdb) print foo *** NameError: name 'foo' is not defined (Pdb) continue TestResults(failed=0, attempted=2) """ def test_DocTestSuite(): """DocTestSuite creates a unittest test suite from a doctest. We create a Suite by providing a module. A module can be provided by passing a module object: >>> import unittest >>> import test.sample_doctest >>> suite = doctest.DocTestSuite(test.sample_doctest) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=4> We can also supply the module by name: >>> suite = doctest.DocTestSuite('test.sample_doctest') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=4> We can use the current module: >>> suite = test.sample_doctest.test_suite() >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=4> We can supply global variables. If we pass globs, they will be used instead of the module globals. Here we'll pass an empty globals, triggering an extra error: >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=5> Alternatively, we can provide extra globals. Here we'll make an error go away by providing an extra global variable: >>> suite = doctest.DocTestSuite('test.sample_doctest', ... extraglobs={'y': 1}) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=3> You can pass option flags. Here we'll cause an extra error by disabling the blank-line feature: >>> suite = doctest.DocTestSuite('test.sample_doctest', ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=5> You can supply setUp and tearDown functions: >>> def setUp(t): ... import test.test_doctest ... test.test_doctest.sillySetup = True >>> def tearDown(t): ... import test.test_doctest ... del test.test_doctest.sillySetup Here, we installed a silly variable that the test expects: >>> suite = doctest.DocTestSuite('test.sample_doctest', ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=3> But the tearDown restores sanity: >>> import test.test_doctest >>> test.test_doctest.sillySetup Traceback (most recent call last): ... AttributeError: 'module' object has no attribute 'sillySetup' The setUp and tearDown funtions are passed test objects. Here we'll use the setUp function to supply the missing variable y: >>> def setUp(test): ... test.globs['y'] = 1 >>> suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=9 errors=0 failures=3> Here, we didn't need to use a tearDown function because we modified the test globals, which are a copy of the sample_doctest module dictionary. The test globals are automatically cleared for us after a test. """ def test_DocFileSuite(): """We can test tests found in text files using a DocFileSuite. We create a suite by providing the names of one or more text files that include examples: >>> import unittest >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=3> The test files are looked for in the directory containing the calling module. A package keyword argument can be provided to specify a different relative location. >>> import unittest >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... package='test') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=3> Support for using a package's __loader__.get_data() is also provided. >>> import unittest, pkgutil, test >>> added_loader = False >>> if not hasattr(test, '__loader__'): ... test.__loader__ = pkgutil.get_loader(test) ... added_loader = True >>> try: ... suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... package='test') ... suite.run(unittest.TestResult()) ... finally: ... if added_loader: ... del test.__loader__ <unittest.TestResult run=3 errors=0 failures=3> '/' should be used as a path separator. It will be converted to a native separator at run time: >>> suite = doctest.DocFileSuite('../test/test_doctest.txt') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=1 errors=0 failures=1> If DocFileSuite is used from an interactive session, then files are resolved relative to the directory of sys.argv[0]: >>> import types, os.path, test.test_doctest >>> save_argv = sys.argv >>> sys.argv = [test.test_doctest.__file__] >>> suite = doctest.DocFileSuite('test_doctest.txt', ... package=types.ModuleType('__main__')) >>> sys.argv = save_argv By setting `module_relative=False`, os-specific paths may be used (including absolute paths and paths relative to the working directory): >>> # Get the absolute path of the test package. >>> test_doctest_path = os.path.abspath(test.test_doctest.__file__) >>> test_pkg_path = os.path.split(test_doctest_path)[0] >>> # Use it to find the absolute path of test_doctest.txt. >>> test_file = os.path.join(test_pkg_path, 'test_doctest.txt') >>> suite = doctest.DocFileSuite(test_file, module_relative=False) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=1 errors=0 failures=1> It is an error to specify `package` when `module_relative=False`: >>> suite = doctest.DocFileSuite(test_file, module_relative=False, ... package='test') Traceback (most recent call last): ValueError: Package may only be specified for module-relative paths. You can specify initial global variables: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=2> In this case, we supplied a missing favorite color. You can provide doctest options: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... optionflags=doctest.DONT_ACCEPT_BLANKLINE, ... globs={'favorite_color': 'blue'}) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=3> And, you can provide setUp and tearDown functions: >>> def setUp(t): ... import test.test_doctest ... test.test_doctest.sillySetup = True >>> def tearDown(t): ... import test.test_doctest ... del test.test_doctest.sillySetup Here, we installed a silly variable that the test expects: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... setUp=setUp, tearDown=tearDown) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=2> But the tearDown restores sanity: >>> import test.test_doctest >>> test.test_doctest.sillySetup Traceback (most recent call last): ... AttributeError: 'module' object has no attribute 'sillySetup' The setUp and tearDown funtions are passed test objects. Here, we'll use a setUp function to set the favorite color in test_doctest.txt: >>> def setUp(test): ... test.globs['favorite_color'] = 'blue' >>> suite = doctest.DocFileSuite('test_doctest.txt', setUp=setUp) >>> suite.run(unittest.TestResult()) <unittest.TestResult run=1 errors=0 failures=0> Here, we didn't need to use a tearDown function because we modified the test globals. The test globals are automatically cleared for us after a test. Tests in a file run using `DocFileSuite` can also access the `__file__` global, which is set to the name of the file containing the tests: >>> suite = doctest.DocFileSuite('test_doctest3.txt') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=1 errors=0 failures=0> If the tests contain non-ASCII characters, we have to specify which encoding the file is encoded with. We do so by using the `encoding` parameter: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... 'test_doctest2.txt', ... 'test_doctest4.txt', ... encoding='utf-8') >>> suite.run(unittest.TestResult()) <unittest.TestResult run=3 errors=0 failures=2> """ def test_trailing_space_in_test(): """ Trailing spaces in expected output are significant: >>> x, y = 'foo', '' >>> print x, y foo \n """ def test_unittest_reportflags(): """Default unittest reporting flags can be set to control reporting Here, we'll set the REPORT_ONLY_FIRST_FAILURE option so we see only the first failure of each test. First, we'll look at the output without the flag. The file test_doctest.txt file has two tests. They both fail if blank lines are disabled: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) >>> import unittest >>> result = suite.run(unittest.TestResult()) >>> print result.failures[0][1] # doctest: +ELLIPSIS Traceback ... Failed example: favorite_color ... Failed example: if 1: ... Note that we see both failures displayed. >>> old = doctest.set_unittest_reportflags( ... doctest.REPORT_ONLY_FIRST_FAILURE) Now, when we run the test: >>> result = suite.run(unittest.TestResult()) >>> print result.failures[0][1] # doctest: +ELLIPSIS Traceback ... Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined <BLANKLINE> <BLANKLINE> We get only the first failure. If we give any reporting options when we set up the tests, however: >>> suite = doctest.DocFileSuite('test_doctest.txt', ... optionflags=doctest.DONT_ACCEPT_BLANKLINE | doctest.REPORT_NDIFF) Then the default eporting options are ignored: >>> result = suite.run(unittest.TestResult()) >>> print result.failures[0][1] # doctest: +ELLIPSIS Traceback ... Failed example: favorite_color ... Failed example: if 1: print 'a' print print 'b' Differences (ndiff with -expected +actual): a - <BLANKLINE> + b <BLANKLINE> <BLANKLINE> Test runners can restore the formatting flags after they run: >>> ignored = doctest.set_unittest_reportflags(old) """ def test_testfile(): r""" Tests for the `testfile()` function. This function runs all the doctest examples in a given file. In its simple invokation, it is called with the name of a file, which is taken to be relative to the calling module. The return value is (#failures, #tests). >>> doctest.testfile('test_doctest.txt') # doctest: +ELLIPSIS ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) >>> doctest.master = None # Reset master. (Note: we'll be clearing doctest.master after each call to `doctest.testfile`, to supress warnings about multiple tests with the same name.) Globals may be specified with the `globs` and `extraglobs` parameters: >>> globs = {'favorite_color': 'blue'} >>> doctest.testfile('test_doctest.txt', globs=globs) TestResults(failed=0, attempted=2) >>> doctest.master = None # Reset master. >>> extraglobs = {'favorite_color': 'red'} >>> doctest.testfile('test_doctest.txt', globs=globs, ... extraglobs=extraglobs) # doctest: +ELLIPSIS ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Expected: 'blue' Got: 'red' ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt ***Test Failed*** 1 failures. TestResults(failed=1, attempted=2) >>> doctest.master = None # Reset master. The file may be made relative to a given module or package, using the optional `module_relative` parameter: >>> doctest.testfile('test_doctest.txt', globs=globs, ... module_relative='test') TestResults(failed=0, attempted=2) >>> doctest.master = None # Reset master. Verbosity can be increased with the optional `verbose` paremter: >>> doctest.testfile('test_doctest.txt', globs=globs, verbose=True) Trying: favorite_color Expecting: 'blue' ok Trying: if 1: print 'a' print print 'b' Expecting: a <BLANKLINE> b ok 1 items passed all tests: 2 tests in test_doctest.txt 2 tests in 1 items. 2 passed and 0 failed. Test passed. TestResults(failed=0, attempted=2) >>> doctest.master = None # Reset master. The name of the test may be specified with the optional `name` parameter: >>> doctest.testfile('test_doctest.txt', name='newname') ... # doctest: +ELLIPSIS ********************************************************************** File "...", line 6, in newname ... TestResults(failed=1, attempted=2) >>> doctest.master = None # Reset master. The summary report may be supressed with the optional `report` parameter: >>> doctest.testfile('test_doctest.txt', report=False) ... # doctest: +ELLIPSIS ********************************************************************** File "...", line 6, in test_doctest.txt Failed example: favorite_color Exception raised: ... NameError: name 'favorite_color' is not defined TestResults(failed=1, attempted=2) >>> doctest.master = None # Reset master. The optional keyword argument `raise_on_error` can be used to raise an exception on the first error (which may be useful for postmortem debugging): >>> doctest.testfile('test_doctest.txt', raise_on_error=True) ... # doctest: +ELLIPSIS Traceback (most recent call last): UnexpectedException: ... >>> doctest.master = None # Reset master. If the tests contain non-ASCII characters, the tests might fail, since it's unknown which encoding is used. The encoding can be specified using the optional keyword argument `encoding`: >>> doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS ********************************************************************** File "...", line 7, in test_doctest4.txt Failed example: u'...' Expected: u'f\xf6\xf6' Got: u'f\xc3\xb6\xc3\xb6' ********************************************************************** ... ********************************************************************** 1 items had failures: 2 of 4 in test_doctest4.txt ***Test Failed*** 2 failures. TestResults(failed=2, attempted=4) >>> doctest.master = None # Reset master. >>> doctest.testfile('test_doctest4.txt', encoding='utf-8') TestResults(failed=0, attempted=4) >>> doctest.master = None # Reset master. """ # old_test1, ... used to live in doctest.py, but cluttered it. Note # that these use the deprecated doctest.Tester, so should go away (or # be rewritten) someday. # Ignore all warnings about the use of class Tester in this module. # Note that the name of this module may differ depending on how it's # imported, so the use of __name__ is important. warnings.filterwarnings("ignore", "class Tester", DeprecationWarning, __name__, 0) def old_test1(): r""" >>> from doctest import Tester >>> t = Tester(globs={'x': 42}, verbose=0) >>> t.runstring(r''' ... >>> x = x * 2 ... >>> print x ... 42 ... ''', 'XYZ') ********************************************************************** Line 3, in XYZ Failed example: print x Expected: 42 Got: 84 TestResults(failed=1, attempted=2) >>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2') TestResults(failed=0, attempted=2) >>> t.summarize() ********************************************************************** 1 items had failures: 1 of 2 in XYZ ***Test Failed*** 1 failures. TestResults(failed=1, attempted=4) >>> t.summarize(verbose=1) 1 items passed all tests: 2 tests in example2 ********************************************************************** 1 items had failures: 1 of 2 in XYZ 4 tests in 2 items. 3 passed and 1 failed. ***Test Failed*** 1 failures. TestResults(failed=1, attempted=4) """ def old_test2(): r""" >>> from doctest import Tester >>> t = Tester(globs={}, verbose=1) >>> test = r''' ... # just an example ... >>> x = 1 + 2 ... >>> x ... 3 ... ''' >>> t.runstring(test, "Example") Running string Example Trying: x = 1 + 2 Expecting nothing ok Trying: x Expecting: 3 ok 0 of 2 examples failed in string Example TestResults(failed=0, attempted=2) """ def old_test3(): r""" >>> from doctest import Tester >>> t = Tester(globs={}, verbose=0) >>> def _f(): ... '''Trivial docstring example. ... >>> assert 2 == 2 ... ''' ... return 32 ... >>> t.rundoc(_f) # expect 0 failures in 1 example TestResults(failed=0, attempted=1) """ def old_test4(): """ >>> import types >>> m1 = types.ModuleType('_m1') >>> m2 = types.ModuleType('_m2') >>> test_data = \""" ... def _f(): ... '''>>> assert 1 == 1 ... ''' ... def g(): ... '''>>> assert 2 != 1 ... ''' ... class H: ... '''>>> assert 2 > 1 ... ''' ... def bar(self): ... '''>>> assert 1 < 2 ... ''' ... \""" >>> exec test_data in m1.__dict__ >>> exec test_data in m2.__dict__ >>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H}) Tests that objects outside m1 are excluded: >>> from doctest import Tester >>> t = Tester(globs={}, verbose=0) >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped TestResults(failed=0, attempted=4) Once more, not excluding stuff outside m1: >>> t = Tester(globs={}, verbose=0) >>> t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped. TestResults(failed=0, attempted=8) The exclusion of objects from outside the designated module is meant to be invoked automagically by testmod. >>> doctest.testmod(m1, verbose=False) TestResults(failed=0, attempted=4) """ ###################################################################### ## Main ###################################################################### def test_main(): # Check the doctest cases in doctest itself: test_support.run_doctest(doctest, verbosity=True) # Check the doctest cases defined here: from test import test_doctest test_support.run_doctest(test_doctest, verbosity=True) import trace, sys def test_coverage(coverdir): tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0, count=1) tracer.run('reload(doctest); test_main()') r = tracer.results() print 'Writing coverage results...' r.write_results(show_missing=True, summary=True, coverdir=coverdir) if __name__ == '__main__': if '-c' in sys.argv: test_coverage('/tmp/doctest.cover') else: test_main()
apache-2.0
[ 624, 199, 774, 2884, 367, 8868, 14, 199, 624, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 646, 8868, 199, 646, 3598, 199, 199, 3, 6944, 26, 6006, 787, 2005, 4722, 2295, 4668, 1958, 370, 18752, 543, 199, 3, 755, 3482, 646, 315, 314, 511, 63, 3065, 646, 63, 4058, 511, 859, 14, 199, 199, 18022, 199, 309, 15227, 26794, 334, 2972, 701, 511, 5560, 9, 199, 18022, 199, 199, 318, 2690, 63, 1532, 8, 86, 304, 272, 408, 272, 699, 8093, 14359, 339, 1306, 870, 2690, 63, 1532, 8, 1081, 9, 272, 10868, 339, 1488, 1024, 18251, 1, 272, 408, 272, 372, 373, 11, 86, 199, 199, 533, 15227, 2543, 26, 272, 408, 272, 1306, 870, 413, 272, 413, 339, 1306, 327, 6786, 664, 5525, 14, 221, 880, 787, 2701, 30382, 17, 436, 30382, 18, 29951, 26, 272, 1306, 272, 2263, 339, 6879, 604, 2893, 26, 272, 1306, 4061, 275, 15227, 2543, 8, 19, 9, 272, 1306, 367, 284, 315, 1425, 8, 709, 304, 272, 2263, 258, 4061, 275, 4061, 14, 3157, 342, 272, 2263, 258, 870, 4061, 14, 362, 1062, 272, 1227, 3144, 5504, 9615, 15580, 13567, 29772, 32404, 4114, 1344, 650, 20281, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 408, 267, 1306, 870, 15227, 2543, 8, 713, 680, 362, 342, 267, 3144, 267, 408, 267, 291, 14, 637, 275, 1139, 339, 347, 4270, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 2543, 8, 713, 680, 3157, 1252, 362, 342, 267, 5504, 267, 408, 267, 372, 15227, 2543, 8, 277, 14, 637, 435, 291, 14, 637, 9, 339, 347, 664, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 2543, 2801, 21, 680, 362, 342, 267, 446, 21, 267, 408, 267, 372, 291, 14, 637, 339, 347, 282, 63, 4639, 8, 86, 304, 267, 408, 267, 1306, 870, 15227, 2543, 14, 65, 63, 4639, 8, 709, 9, 267, 4119, 267, 408, 267, 372, 373, 11, 17, 272, 282, 63, 4639, 275, 12822, 8, 65, 63, 4639, 9, 339, 347, 282, 63, 3744, 8, 1886, 12, 373, 304, 267, 408, 267, 1306, 870, 15227, 2543, 14, 65, 63, 3744, 8, 709, 9, 267, 3144, 267, 1306, 870, 15227, 2543, 8, 16, 680, 65, 63, 3744, 8, 709, 9, 267, 3144, 267, 408, 267, 372, 373, 11, 18, 272, 282, 63, 3744, 275, 18990, 8, 65, 63, 3744, 9, 339, 282, 63, 1829, 275, 3324, 8, 362, 12, 1382, 11916, 267, 1306, 870, 15227, 2543, 8, 1081, 680, 65, 63, 1829, 267, 6928, 267, 7857, 339, 1021, 23137, 2543, 26, 267, 408, 267, 1306, 671, 275, 15227, 2543, 14, 13029, 2543, 8, 21, 9, 267, 1306, 612, 275, 671, 14, 9646, 342, 267, 1306, 870, 612, 14, 362, 342, 267, 5661, 267, 408, 267, 347, 636, 826, 721, 277, 12, 1139, 29, 16, 304, 288, 408, 288, 1306, 870, 15227, 2543, 14, 13029, 2543, 1252, 362, 342, 288, 378, 288, 408, 288, 291, 14, 637, 275, 1139, 267, 347, 12386, 8, 277, 304, 288, 372, 15227, 2543, 14, 13029, 2543, 8, 277, 14, 637, 10, 277, 14, 637, 9, 267, 347, 664, 8, 277, 304, 288, 372, 291, 14, 637, 199, 199, 533, 15227, 4665, 6609, 2543, 8, 785, 304, 272, 519, 624, 272, 1306, 870, 283, 17, 60, 78, 18, 60, 78, 19, 7, 272, 413, 272, 499, 272, 650, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 8, 713, 680, 362, 342, 267, 3144, 267, 408, 267, 291, 14, 637, 275, 1139, 339, 347, 4270, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 8, 713, 680, 3157, 1252, 362, 342, 267, 5504, 267, 408, 267, 372, 15227, 4665, 6609, 2543, 8, 277, 14, 637, 435, 291, 14, 637, 9, 339, 347, 664, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 2801, 21, 680, 362, 342, 267, 446, 21, 267, 408, 267, 372, 291, 14, 637, 199, 199, 18022, 199, 309, 7777, 9009, 334, 509, 5343, 12777, 10201, 9, 199, 18022, 199, 199, 533, 485, 8249, 3205, 26, 272, 408, 272, 437, 4026, 1324, 2547, 367, 10543, 1159, 12777, 14958, 14, 221, 3979, 5907, 282, 272, 1004, 365, 1586, 12, 870, 652, 334, 475, 20577, 314, 922, 14090, 652, 395, 436, 2066, 272, 372, 652, 14, 221, 710, 663, 402, 2385, 370, 372, 365, 2013, 315, 314, 272, 3787, 27, 2985, 1077, 440, 1172, 8520, 14930, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2385, 304, 267, 291, 14, 1278, 275, 2385, 339, 347, 14441, 8, 277, 304, 267, 1004, 275, 291, 14, 1278, 14, 1935, 8, 16, 9, 267, 870, 1004, 267, 372, 1004, 19192, 78, 7, 199, 199, 18022, 199, 309, 1379, 445, 3274, 199, 18022, 199, 199, 318, 511, 63, 9846, 837, 519, 624, 199, 5072, 2295, 367, 314, 658, 9846, 64, 1021, 14, 199, 199, 9846, 365, 282, 3486, 3970, 1021, 626, 15164, 26, 523, 446, 658, 1365, 8340, 437, 1350, 1059, 14, 523, 446, 658, 7051, 8340, 1626, 1420, 1072, 1059, 14, 523, 446, 658, 2804, 63, 1328, 8340, 1626, 1420, 1919, 1245, 1059, 334, 269, 488, 340, 949, 272, 1919, 365, 1420, 680, 523, 446, 658, 3469, 8340, 437, 1004, 1329, 334, 12541, 314, 9214, 680, 523, 446, 658, 3724, 8340, 710, 2893, 1159, 14311, 315, 314, 1324, 1059, 14, 523, 446, 658, 1419, 8340, 1626, 945, 2600, 12, 4412, 945, 3285, 370, 715, 503, 272, 756, 14, 199, 199, 20676, 3004, 787, 663, 701, 314, 3787, 14, 221, 658, 1365, 64, 436, 658, 7051, 64, 787, 199, 2427, 27, 314, 1163, 3004, 1006, 1172, 849, 1338, 26, 339, 1306, 2893, 275, 8868, 14, 9846, 360, 1361, 413, 297, 283, 17, 60, 78, 358, 272, 1306, 334, 2694, 14, 1365, 12, 2893, 14, 7051, 12, 2893, 14, 2804, 63, 1328, 12, 272, 2263, 221, 2893, 14, 3469, 12, 2893, 14, 3724, 12, 2893, 14, 1419, 9, 272, 661, 1361, 413, 60, 78, 297, 283, 17, 60, 78, 297, 488, 12, 378, 12, 378, 12, 5009, 199, 199, 1918, 1642, 7795, 3004, 13493, 1365, 3559, 658, 7051, 3559, 436 ]
[ 199, 774, 2884, 367, 8868, 14, 199, 624, 199, 199, 504, 511, 492, 511, 63, 4058, 199, 646, 8868, 199, 646, 3598, 199, 199, 3, 6944, 26, 6006, 787, 2005, 4722, 2295, 4668, 1958, 370, 18752, 543, 199, 3, 755, 3482, 646, 315, 314, 511, 63, 3065, 646, 63, 4058, 511, 859, 14, 199, 199, 18022, 199, 309, 15227, 26794, 334, 2972, 701, 511, 5560, 9, 199, 18022, 199, 199, 318, 2690, 63, 1532, 8, 86, 304, 272, 408, 272, 699, 8093, 14359, 339, 1306, 870, 2690, 63, 1532, 8, 1081, 9, 272, 10868, 339, 1488, 1024, 18251, 1, 272, 408, 272, 372, 373, 11, 86, 199, 199, 533, 15227, 2543, 26, 272, 408, 272, 1306, 870, 413, 272, 413, 339, 1306, 327, 6786, 664, 5525, 14, 221, 880, 787, 2701, 30382, 17, 436, 30382, 18, 29951, 26, 272, 1306, 272, 2263, 339, 6879, 604, 2893, 26, 272, 1306, 4061, 275, 15227, 2543, 8, 19, 9, 272, 1306, 367, 284, 315, 1425, 8, 709, 304, 272, 2263, 258, 4061, 275, 4061, 14, 3157, 342, 272, 2263, 258, 870, 4061, 14, 362, 1062, 272, 1227, 3144, 5504, 9615, 15580, 13567, 29772, 32404, 4114, 1344, 650, 20281, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 408, 267, 1306, 870, 15227, 2543, 8, 713, 680, 362, 342, 267, 3144, 267, 408, 267, 291, 14, 637, 275, 1139, 339, 347, 4270, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 2543, 8, 713, 680, 3157, 1252, 362, 342, 267, 5504, 267, 408, 267, 372, 15227, 2543, 8, 277, 14, 637, 435, 291, 14, 637, 9, 339, 347, 664, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 2543, 2801, 21, 680, 362, 342, 267, 446, 21, 267, 408, 267, 372, 291, 14, 637, 339, 347, 282, 63, 4639, 8, 86, 304, 267, 408, 267, 1306, 870, 15227, 2543, 14, 65, 63, 4639, 8, 709, 9, 267, 4119, 267, 408, 267, 372, 373, 11, 17, 272, 282, 63, 4639, 275, 12822, 8, 65, 63, 4639, 9, 339, 347, 282, 63, 3744, 8, 1886, 12, 373, 304, 267, 408, 267, 1306, 870, 15227, 2543, 14, 65, 63, 3744, 8, 709, 9, 267, 3144, 267, 1306, 870, 15227, 2543, 8, 16, 680, 65, 63, 3744, 8, 709, 9, 267, 3144, 267, 408, 267, 372, 373, 11, 18, 272, 282, 63, 3744, 275, 18990, 8, 65, 63, 3744, 9, 339, 282, 63, 1829, 275, 3324, 8, 362, 12, 1382, 11916, 267, 1306, 870, 15227, 2543, 8, 1081, 680, 65, 63, 1829, 267, 6928, 267, 7857, 339, 1021, 23137, 2543, 26, 267, 408, 267, 1306, 671, 275, 15227, 2543, 14, 13029, 2543, 8, 21, 9, 267, 1306, 612, 275, 671, 14, 9646, 342, 267, 1306, 870, 612, 14, 362, 342, 267, 5661, 267, 408, 267, 347, 636, 826, 721, 277, 12, 1139, 29, 16, 304, 288, 408, 288, 1306, 870, 15227, 2543, 14, 13029, 2543, 1252, 362, 342, 288, 378, 288, 408, 288, 291, 14, 637, 275, 1139, 267, 347, 12386, 8, 277, 304, 288, 372, 15227, 2543, 14, 13029, 2543, 8, 277, 14, 637, 10, 277, 14, 637, 9, 267, 347, 664, 8, 277, 304, 288, 372, 291, 14, 637, 199, 199, 533, 15227, 4665, 6609, 2543, 8, 785, 304, 272, 519, 624, 272, 1306, 870, 283, 17, 60, 78, 18, 60, 78, 19, 7, 272, 413, 272, 499, 272, 650, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1139, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 8, 713, 680, 362, 342, 267, 3144, 267, 408, 267, 291, 14, 637, 275, 1139, 339, 347, 4270, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 8, 713, 680, 3157, 1252, 362, 342, 267, 5504, 267, 408, 267, 372, 15227, 4665, 6609, 2543, 8, 277, 14, 637, 435, 291, 14, 637, 9, 339, 347, 664, 8, 277, 304, 267, 408, 267, 1306, 870, 15227, 4665, 6609, 2543, 2801, 21, 680, 362, 342, 267, 446, 21, 267, 408, 267, 372, 291, 14, 637, 199, 199, 18022, 199, 309, 7777, 9009, 334, 509, 5343, 12777, 10201, 9, 199, 18022, 199, 199, 533, 485, 8249, 3205, 26, 272, 408, 272, 437, 4026, 1324, 2547, 367, 10543, 1159, 12777, 14958, 14, 221, 3979, 5907, 282, 272, 1004, 365, 1586, 12, 870, 652, 334, 475, 20577, 314, 922, 14090, 652, 395, 436, 2066, 272, 372, 652, 14, 221, 710, 663, 402, 2385, 370, 372, 365, 2013, 315, 314, 272, 3787, 27, 2985, 1077, 440, 1172, 8520, 14930, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2385, 304, 267, 291, 14, 1278, 275, 2385, 339, 347, 14441, 8, 277, 304, 267, 1004, 275, 291, 14, 1278, 14, 1935, 8, 16, 9, 267, 870, 1004, 267, 372, 1004, 19192, 78, 7, 199, 199, 18022, 199, 309, 1379, 445, 3274, 199, 18022, 199, 199, 318, 511, 63, 9846, 837, 519, 624, 199, 5072, 2295, 367, 314, 658, 9846, 64, 1021, 14, 199, 199, 9846, 365, 282, 3486, 3970, 1021, 626, 15164, 26, 523, 446, 658, 1365, 8340, 437, 1350, 1059, 14, 523, 446, 658, 7051, 8340, 1626, 1420, 1072, 1059, 14, 523, 446, 658, 2804, 63, 1328, 8340, 1626, 1420, 1919, 1245, 1059, 334, 269, 488, 340, 949, 272, 1919, 365, 1420, 680, 523, 446, 658, 3469, 8340, 437, 1004, 1329, 334, 12541, 314, 9214, 680, 523, 446, 658, 3724, 8340, 710, 2893, 1159, 14311, 315, 314, 1324, 1059, 14, 523, 446, 658, 1419, 8340, 1626, 945, 2600, 12, 4412, 945, 3285, 370, 715, 503, 272, 756, 14, 199, 199, 20676, 3004, 787, 663, 701, 314, 3787, 14, 221, 658, 1365, 64, 436, 658, 7051, 64, 787, 199, 2427, 27, 314, 1163, 3004, 1006, 1172, 849, 1338, 26, 339, 1306, 2893, 275, 8868, 14, 9846, 360, 1361, 413, 297, 283, 17, 60, 78, 358, 272, 1306, 334, 2694, 14, 1365, 12, 2893, 14, 7051, 12, 2893, 14, 2804, 63, 1328, 12, 272, 2263, 221, 2893, 14, 3469, 12, 2893, 14, 3724, 12, 2893, 14, 1419, 9, 272, 661, 1361, 413, 60, 78, 297, 283, 17, 60, 78, 297, 488, 12, 378, 12, 378, 12, 5009, 199, 199, 1918, 1642, 7795, 3004, 13493, 1365, 3559, 658, 7051, 3559, 436, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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