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
blueboxgroup/cinder
cinder/scheduler/driver.py
4
4199
# Copyright (c) 2010 OpenStack Foundation # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # 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. """ Scheduler base class that all Schedulers should inherit from """ from oslo_config import cfg from oslo_utils import importutils from oslo_utils import timeutils from cinder import db from cinder.i18n import _ from cinder.volume import rpcapi as volume_rpcapi scheduler_driver_opts = [ cfg.StrOpt('scheduler_host_manager', default='cinder.scheduler.host_manager.HostManager', help='The scheduler host manager class to use'), cfg.IntOpt('scheduler_max_attempts', default=3, help='Maximum number of attempts to schedule an volume'), ] CONF = cfg.CONF CONF.register_opts(scheduler_driver_opts) def volume_update_db(context, volume_id, host): '''Set the host and set the scheduled_at field of a volume. :returns: A Volume with the updated fields set properly. ''' now = timeutils.utcnow() values = {'host': host, 'scheduled_at': now} return db.volume_update(context, volume_id, values) def group_update_db(context, group_id, host): """Set the host and the scheduled_at field of a consistencygroup. :returns: A Consistencygroup with the updated fields set properly. """ now = timeutils.utcnow() values = {'host': host, 'updated_at': now} return db.consistencygroup_update(context, group_id, values) class Scheduler(object): """The base class that all Scheduler classes should inherit from.""" def __init__(self): self.host_manager = importutils.import_object( CONF.scheduler_host_manager) self.volume_rpcapi = volume_rpcapi.VolumeAPI() def update_service_capabilities(self, service_name, host, capabilities): """Process a capability update from a service node.""" self.host_manager.update_service_capabilities(service_name, host, capabilities) def host_passes_filters(self, context, volume_id, host, filter_properties): """Check if the specified host passes the filters.""" raise NotImplementedError(_("Must implement host_passes_filters")) def find_retype_host(self, context, request_spec, filter_properties=None, migration_policy='never'): """Find a host that can accept the volume with its new type.""" raise NotImplementedError(_("Must implement find_retype_host")) def schedule(self, context, topic, method, *_args, **_kwargs): """Must override schedule method for scheduler to work.""" raise NotImplementedError(_("Must implement a fallback schedule")) def schedule_create_volume(self, context, request_spec, filter_properties): """Must override schedule method for scheduler to work.""" raise NotImplementedError(_("Must implement schedule_create_volume")) def schedule_create_consistencygroup(self, context, group_id, request_spec_list, filter_properties_list): """Must override schedule method for scheduler to work.""" raise NotImplementedError(_( "Must implement schedule_create_consistencygroup")) def get_pools(self, context, filters): """Must override schedule method for scheduler to work.""" raise NotImplementedError(_( "Must implement schedule_get_pools"))
apache-2.0
[ 3, 1898, 334, 67, 9, 7129, 14260, 2752, 199, 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 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, 199, 624, 199, 11251, 1300, 1021, 626, 1006, 24317, 2393, 1077, 8287, 687, 199, 624, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 199, 504, 13069, 492, 1592, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 14, 2405, 492, 8985, 1246, 465, 3301, 63, 20776, 421, 199, 8874, 63, 3090, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 8874, 63, 1102, 63, 2609, 297, 2049, 849, 534, 12372, 14, 8874, 14, 1102, 63, 2609, 14, 4965, 2988, 297, 2049, 1720, 534, 1918, 11899, 1591, 5256, 1021, 370, 675, 659, 272, 4810, 14, 3241, 9985, 360, 8874, 63, 988, 63, 13143, 297, 2049, 849, 29, 19, 12, 2049, 1720, 534, 10915, 1329, 402, 12454, 370, 8732, 376, 3301, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 8874, 63, 3090, 63, 3291, 9, 421, 199, 318, 3301, 63, 873, 63, 697, 8, 1100, 12, 3301, 63, 344, 12, 1591, 304, 272, 1449, 1084, 314, 1591, 436, 663, 314, 18416, 63, 292, 901, 402, 282, 3301, 14, 339, 520, 5808, 26, 437, 15018, 543, 314, 4588, 1504, 663, 7684, 14, 272, 1449, 272, 3063, 275, 23011, 14, 10779, 342, 272, 1338, 275, 791, 1102, 356, 1591, 12, 283, 19274, 63, 292, 356, 3063, 93, 272, 372, 1592, 14, 2405, 63, 873, 8, 1100, 12, 3301, 63, 344, 12, 1338, 9, 421, 199, 318, 1572, 63, 873, 63, 697, 8, 1100, 12, 1572, 63, 344, 12, 1591, 304, 272, 408, 1084, 314, 1591, 436, 314, 18416, 63, 292, 901, 402, 282, 17754, 923, 14, 339, 520, 5808, 26, 437, 1448, 10398, 923, 543, 314, 4588, 1504, 663, 7684, 14, 272, 408, 272, 3063, 275, 23011, 14, 10779, 342, 272, 1338, 275, 791, 1102, 356, 1591, 12, 283, 5334, 63, 292, 356, 3063, 93, 272, 372, 1592, 14, 20249, 923, 63, 873, 8, 1100, 12, 1572, 63, 344, 12, 1338, 9, 421, 199, 533, 32051, 8, 785, 304, 272, 408, 1918, 1300, 1021, 626, 1006, 32051, 3992, 1077, 8287, 687, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1102, 63, 2609, 275, 492, 1208, 14, 646, 63, 785, 8, 288, 6392, 14, 8874, 63, 1102, 63, 2609, 9, 267, 291, 14, 2405, 63, 20776, 275, 3301, 63, 20776, 14, 6464, 3735, 342, 339, 347, 1678, 63, 1364, 63, 10732, 8, 277, 12, 2435, 63, 354, 12, 1591, 12, 14918, 304, 267, 408, 3498, 282, 19854, 1678, 687, 282, 2435, 1031, 1041, 267, 291, 14, 1102, 63, 2609, 14, 873, 63, 1364, 63, 10732, 8, 1364, 63, 354, 12, 10028, 1591, 12, 10028, 14918, 9, 339, 347, 1591, 63, 16027, 63, 4273, 8, 277, 12, 1067, 12, 3301, 63, 344, 12, 1591, 12, 2457, 63, 3282, 304, 267, 408, 1799, 340, 314, 2013, 1591, 14933, 314, 4766, 1041, 267, 746, 4279, 6115, 13757, 5669, 1591, 63, 16027, 63, 4273, 2237, 339, 347, 2342, 63, 264, 466, 63, 1102, 8, 277, 12, 1067, 12, 1056, 63, 1650, 12, 2457, 63, 3282, 29, 403, 12, 586, 8367, 63, 3185, 534, 18178, 735, 267, 408, 6591, 282, 1591, 626, 883, 4729, 314, 3301, 543, 2399, 892, 730, 1041, 267, 746, 4279, 6115, 13757, 5669, 2342, 63, 264, 466, 63, 1102, 2237, 339, 347, 8732, 8, 277, 12, 1067, 12, 7482, 12, 1083, 12, 20841, 589, 12, 29666, 958, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 6115, 13757, 5669, 282, 9567, 8732, 2237, 339, 347, 8732, 63, 981, 63, 2405, 8, 277, 12, 1067, 12, 1056, 63, 1650, 12, 2457, 63, 3282, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 6115, 13757, 5669, 8732, 63, 981, 63, 2405, 2237, 339, 347, 8732, 63, 981, 63, 20249, 923, 8, 277, 12, 1067, 12, 1572, 63, 344, 12, 1460, 1056, 63, 1650, 63, 513, 12, 1460, 2457, 63, 3282, 63, 513, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 27594, 288, 298, 13757, 5669, 8732, 63, 981, 63, 20249, 923, 2237, 339, 347, 664, 63, 12406, 8, 277, 12, 1067, 12, 4766, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 27594, 288, 298, 13757, 5669, 8732, 63, 362, 63, 12406, 2237, 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 ]
[ 1898, 334, 67, 9, 7129, 14260, 2752, 199, 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 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, 199, 624, 199, 11251, 1300, 1021, 626, 1006, 24317, 2393, 1077, 8287, 687, 199, 624, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 504, 11258, 63, 1208, 492, 23011, 199, 199, 504, 13069, 492, 1592, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 14, 2405, 492, 8985, 1246, 465, 3301, 63, 20776, 421, 199, 8874, 63, 3090, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 8874, 63, 1102, 63, 2609, 297, 2049, 849, 534, 12372, 14, 8874, 14, 1102, 63, 2609, 14, 4965, 2988, 297, 2049, 1720, 534, 1918, 11899, 1591, 5256, 1021, 370, 675, 659, 272, 4810, 14, 3241, 9985, 360, 8874, 63, 988, 63, 13143, 297, 2049, 849, 29, 19, 12, 2049, 1720, 534, 10915, 1329, 402, 12454, 370, 8732, 376, 3301, 659, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 8874, 63, 3090, 63, 3291, 9, 421, 199, 318, 3301, 63, 873, 63, 697, 8, 1100, 12, 3301, 63, 344, 12, 1591, 304, 272, 1449, 1084, 314, 1591, 436, 663, 314, 18416, 63, 292, 901, 402, 282, 3301, 14, 339, 520, 5808, 26, 437, 15018, 543, 314, 4588, 1504, 663, 7684, 14, 272, 1449, 272, 3063, 275, 23011, 14, 10779, 342, 272, 1338, 275, 791, 1102, 356, 1591, 12, 283, 19274, 63, 292, 356, 3063, 93, 272, 372, 1592, 14, 2405, 63, 873, 8, 1100, 12, 3301, 63, 344, 12, 1338, 9, 421, 199, 318, 1572, 63, 873, 63, 697, 8, 1100, 12, 1572, 63, 344, 12, 1591, 304, 272, 408, 1084, 314, 1591, 436, 314, 18416, 63, 292, 901, 402, 282, 17754, 923, 14, 339, 520, 5808, 26, 437, 1448, 10398, 923, 543, 314, 4588, 1504, 663, 7684, 14, 272, 408, 272, 3063, 275, 23011, 14, 10779, 342, 272, 1338, 275, 791, 1102, 356, 1591, 12, 283, 5334, 63, 292, 356, 3063, 93, 272, 372, 1592, 14, 20249, 923, 63, 873, 8, 1100, 12, 1572, 63, 344, 12, 1338, 9, 421, 199, 533, 32051, 8, 785, 304, 272, 408, 1918, 1300, 1021, 626, 1006, 32051, 3992, 1077, 8287, 687, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1102, 63, 2609, 275, 492, 1208, 14, 646, 63, 785, 8, 288, 6392, 14, 8874, 63, 1102, 63, 2609, 9, 267, 291, 14, 2405, 63, 20776, 275, 3301, 63, 20776, 14, 6464, 3735, 342, 339, 347, 1678, 63, 1364, 63, 10732, 8, 277, 12, 2435, 63, 354, 12, 1591, 12, 14918, 304, 267, 408, 3498, 282, 19854, 1678, 687, 282, 2435, 1031, 1041, 267, 291, 14, 1102, 63, 2609, 14, 873, 63, 1364, 63, 10732, 8, 1364, 63, 354, 12, 10028, 1591, 12, 10028, 14918, 9, 339, 347, 1591, 63, 16027, 63, 4273, 8, 277, 12, 1067, 12, 3301, 63, 344, 12, 1591, 12, 2457, 63, 3282, 304, 267, 408, 1799, 340, 314, 2013, 1591, 14933, 314, 4766, 1041, 267, 746, 4279, 6115, 13757, 5669, 1591, 63, 16027, 63, 4273, 2237, 339, 347, 2342, 63, 264, 466, 63, 1102, 8, 277, 12, 1067, 12, 1056, 63, 1650, 12, 2457, 63, 3282, 29, 403, 12, 586, 8367, 63, 3185, 534, 18178, 735, 267, 408, 6591, 282, 1591, 626, 883, 4729, 314, 3301, 543, 2399, 892, 730, 1041, 267, 746, 4279, 6115, 13757, 5669, 2342, 63, 264, 466, 63, 1102, 2237, 339, 347, 8732, 8, 277, 12, 1067, 12, 7482, 12, 1083, 12, 20841, 589, 12, 29666, 958, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 6115, 13757, 5669, 282, 9567, 8732, 2237, 339, 347, 8732, 63, 981, 63, 2405, 8, 277, 12, 1067, 12, 1056, 63, 1650, 12, 2457, 63, 3282, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 6115, 13757, 5669, 8732, 63, 981, 63, 2405, 2237, 339, 347, 8732, 63, 981, 63, 20249, 923, 8, 277, 12, 1067, 12, 1572, 63, 344, 12, 1460, 1056, 63, 1650, 63, 513, 12, 1460, 2457, 63, 3282, 63, 513, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 27594, 288, 298, 13757, 5669, 8732, 63, 981, 63, 20249, 923, 2237, 339, 347, 664, 63, 12406, 8, 277, 12, 1067, 12, 4766, 304, 267, 408, 13757, 4278, 8732, 1083, 367, 11899, 370, 1736, 1041, 267, 746, 4279, 27594, 288, 298, 13757, 5669, 8732, 63, 362, 63, 12406, 2237, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nmayorov/scipy
scipy/sparse/linalg/tests/test_norm.py
9
5361
"""Test functions for the sparse.linalg.norm module """ import numpy as np from numpy.linalg import norm as npnorm from numpy.testing import assert_allclose from pytest import raises as assert_raises import scipy.sparse from scipy.sparse.linalg import norm as spnorm class TestNorm(object): def setup_method(self): a = np.arange(9) - 4 b = a.reshape((3, 3)) self.b = scipy.sparse.csr_matrix(b) def test_matrix_norm(self): # Frobenius norm is the default assert_allclose(spnorm(self.b), 7.745966692414834) assert_allclose(spnorm(self.b, 'fro'), 7.745966692414834) assert_allclose(spnorm(self.b, np.inf), 9) assert_allclose(spnorm(self.b, -np.inf), 2) assert_allclose(spnorm(self.b, 1), 7) assert_allclose(spnorm(self.b, -1), 6) # _multi_svd_norm is not implemented for sparse matrix assert_raises(NotImplementedError, spnorm, self.b, 2) assert_raises(NotImplementedError, spnorm, self.b, -2) def test_matrix_norm_axis(self): for m, axis in ((self.b, None), (self.b, (0, 1)), (self.b.T, (1, 0))): assert_allclose(spnorm(m, axis=axis), 7.745966692414834) assert_allclose(spnorm(m, 'fro', axis=axis), 7.745966692414834) assert_allclose(spnorm(m, np.inf, axis=axis), 9) assert_allclose(spnorm(m, -np.inf, axis=axis), 2) assert_allclose(spnorm(m, 1, axis=axis), 7) assert_allclose(spnorm(m, -1, axis=axis), 6) def test_vector_norm(self): v = [4.5825756949558398, 4.2426406871192848, 4.5825756949558398] for m, a in (self.b, 0), (self.b.T, 1): for axis in a, (a, ), a-2, (a-2, ): assert_allclose(spnorm(m, 1, axis=axis), [7, 6, 7]) assert_allclose(spnorm(m, np.inf, axis=axis), [4, 3, 4]) assert_allclose(spnorm(m, axis=axis), v) assert_allclose(spnorm(m, ord=2, axis=axis), v) assert_allclose(spnorm(m, ord=None, axis=axis), v) def test_norm_exceptions(self): m = self.b assert_raises(TypeError, spnorm, m, None, 1.5) assert_raises(TypeError, spnorm, m, None, [2]) assert_raises(ValueError, spnorm, m, None, ()) assert_raises(ValueError, spnorm, m, None, (0, 1, 2)) assert_raises(ValueError, spnorm, m, None, (0, 0)) assert_raises(ValueError, spnorm, m, None, (0, 2)) assert_raises(ValueError, spnorm, m, None, (-3, 0)) assert_raises(ValueError, spnorm, m, None, 2) assert_raises(ValueError, spnorm, m, None, -3) assert_raises(ValueError, spnorm, m, 'plate_of_shrimp', 0) assert_raises(ValueError, spnorm, m, 'plate_of_shrimp', (0, 1)) class TestVsNumpyNorm(object): _sparse_types = ( scipy.sparse.bsr_matrix, scipy.sparse.coo_matrix, scipy.sparse.csc_matrix, scipy.sparse.csr_matrix, scipy.sparse.dia_matrix, scipy.sparse.dok_matrix, scipy.sparse.lil_matrix, ) _test_matrices = ( (np.arange(9) - 4).reshape((3, 3)), [ [1, 2, 3], [-1, 1, 4]], [ [1, 0, 3], [-1, 1, 4j]], ) def test_sparse_matrix_norms(self): for sparse_type in self._sparse_types: for M in self._test_matrices: S = sparse_type(M) assert_allclose(spnorm(S), npnorm(M)) assert_allclose(spnorm(S, 'fro'), npnorm(M, 'fro')) assert_allclose(spnorm(S, np.inf), npnorm(M, np.inf)) assert_allclose(spnorm(S, -np.inf), npnorm(M, -np.inf)) assert_allclose(spnorm(S, 1), npnorm(M, 1)) assert_allclose(spnorm(S, -1), npnorm(M, -1)) def test_sparse_matrix_norms_with_axis(self): for sparse_type in self._sparse_types: for M in self._test_matrices: S = sparse_type(M) for axis in None, (0, 1), (1, 0): assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis)) for ord in 'fro', np.inf, -np.inf, 1, -1: assert_allclose(spnorm(S, ord, axis=axis), npnorm(M, ord, axis=axis)) # Some numpy matrix norms are allergic to negative axes. for axis in (-2, -1), (-1, -2), (1, -2): assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis)) assert_allclose(spnorm(S, 'f', axis=axis), npnorm(M, 'f', axis=axis)) assert_allclose(spnorm(S, 'fro', axis=axis), npnorm(M, 'fro', axis=axis)) def test_sparse_vector_norms(self): for sparse_type in self._sparse_types: for M in self._test_matrices: S = sparse_type(M) for axis in (0, 1, -1, -2, (0, ), (1, ), (-1, ), (-2, )): assert_allclose(spnorm(S, axis=axis), npnorm(M, axis=axis)) for ord in None, 2, np.inf, -np.inf, 1, 0.5, 0.42: assert_allclose(spnorm(S, ord, axis=axis), npnorm(M, ord, axis=axis))
bsd-3-clause
[ 624, 774, 3423, 367, 314, 5178, 14, 10096, 14, 4791, 859, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 10096, 492, 6316, 465, 980, 4791, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 199, 504, 4613, 492, 6534, 465, 702, 63, 3536, 199, 199, 646, 7026, 14, 4421, 199, 504, 7026, 14, 4421, 14, 10096, 492, 6316, 465, 2249, 4791, 421, 199, 533, 1379, 15548, 8, 785, 304, 272, 347, 3272, 63, 765, 8, 277, 304, 267, 282, 275, 980, 14, 5605, 8, 25, 9, 446, 841, 267, 330, 275, 282, 14, 5217, 1332, 19, 12, 650, 430, 267, 291, 14, 66, 275, 7026, 14, 4421, 14, 10101, 63, 3642, 8, 66, 9, 339, 347, 511, 63, 3642, 63, 4791, 8, 277, 304, 398, 327, 481, 293, 18486, 73, 527, 6316, 365, 314, 849, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 18418, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 283, 21775, 659, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 398, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 980, 14, 4904, 395, 1749, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 446, 1590, 14, 4904, 395, 499, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 413, 395, 1520, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 446, 17, 395, 1227, 9, 398, 327, 485, 3029, 63, 18675, 63, 4791, 365, 440, 6366, 367, 5178, 3634, 267, 702, 63, 3536, 8, 18097, 12, 2249, 4791, 12, 291, 14, 66, 12, 499, 9, 267, 702, 63, 3536, 8, 18097, 12, 2249, 4791, 12, 291, 14, 66, 12, 446, 18, 9, 339, 347, 511, 63, 3642, 63, 4791, 63, 3127, 8, 277, 304, 267, 367, 333, 12, 3114, 315, 3666, 277, 14, 66, 12, 488, 395, 334, 277, 14, 66, 12, 334, 16, 12, 413, 1826, 334, 277, 14, 66, 14, 52, 12, 334, 17, 12, 378, 15206, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 3114, 29, 3127, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 260, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 283, 21775, 297, 3114, 29, 3127, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 980, 14, 4904, 12, 3114, 29, 3127, 395, 1749, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 446, 1590, 14, 4904, 12, 3114, 29, 3127, 395, 499, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 413, 12, 3114, 29, 3127, 395, 1520, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 446, 17, 12, 3114, 29, 3127, 395, 1227, 9, 339, 347, 511, 63, 4106, 63, 4791, 8, 277, 304, 267, 373, 275, 359, 20, 14, 2010, 11551, 15143, 1887, 17686, 13944, 12, 841, 14, 1194, 9408, 1690, 1555, 845, 2942, 15186, 12, 841, 14, 2010, 11551, 15143, 1887, 17686, 13944, 61, 267, 367, 333, 12, 282, 315, 334, 277, 14, 66, 12, 378, 395, 334, 277, 14, 66, 14, 52, 12, 413, 304, 288, 367, 3114, 315, 282, 12, 334, 65, 12, 2318, 282, 13, 18, 12, 334, 65, 13, 18, 12, 3461, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 413, 12, 3114, 29, 3127, 395, 359, 23, 12, 1227, 12, 1520, 566, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 980, 14, 4904, 12, 3114, 29, 3127, 395, 359, 20, 12, 650, 12, 841, 566, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 3114, 29, 3127, 395, 373, 9, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 6206, 29, 18, 12, 3114, 29, 3127, 395, 373, 9, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 6206, 29, 403, 12, 3114, 29, 3127, 395, 373, 9, 339, 347, 511, 63, 4791, 63, 3924, 8, 277, 304, 267, 333, 275, 291, 14, 66, 267, 702, 63, 3536, 8, 4333, 12, 2249, 4791, 12, 333, 12, 488, 12, 413, 14, 21, 9, 267, 702, 63, 3536, 8, 4333, 12, 2249, 4791, 12, 333, 12, 488, 12, 359, 18, 566, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 14515, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 413, 12, 499, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 378, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 499, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 5868, 19, 12, 378, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 499, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 446, 19, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 283, 17673, 63, 1618, 63, 609, 322, 311, 297, 378, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 283, 17673, 63, 1618, 63, 609, 322, 311, 297, 334, 16, 12, 413, 430, 421, 199, 533, 1379, 20343, 25218, 15548, 8, 785, 304, 272, 485, 4421, 63, 1313, 275, 334, 288, 7026, 14, 4421, 14, 1533, 82, 63, 3642, 12, 288, 7026, 14, 4421, 14, 22684, 63, 3642, 12, 288, 7026, 14, 4421, 14, 17000, 63, 3642, 12, 288, 7026, 14, 4421, 14, 10101, 63, 3642, 12, 288, 7026, 14, 4421, 14, 2391, 63, 3642, 12, 288, 7026, 14, 4421, 14, 68, 745, 63, 3642, 12, 288, 7026, 14, 4421, 14, 317, 76, 63, 3642, 12, 288, 776, 272, 485, 396, 63, 19032, 275, 334, 288, 334, 1590, 14, 5605, 8, 25, 9, 446, 841, 680, 5217, 1332, 19, 12, 650, 1826, 288, 359, 355, 359, 17, 12, 499, 12, 650, 467, 355, 5243, 17, 12, 413, 12, 841, 2365, 288, 359, 355 ]
[ 774, 3423, 367, 314, 5178, 14, 10096, 14, 4791, 859, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 10096, 492, 6316, 465, 980, 4791, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 199, 504, 4613, 492, 6534, 465, 702, 63, 3536, 199, 199, 646, 7026, 14, 4421, 199, 504, 7026, 14, 4421, 14, 10096, 492, 6316, 465, 2249, 4791, 421, 199, 533, 1379, 15548, 8, 785, 304, 272, 347, 3272, 63, 765, 8, 277, 304, 267, 282, 275, 980, 14, 5605, 8, 25, 9, 446, 841, 267, 330, 275, 282, 14, 5217, 1332, 19, 12, 650, 430, 267, 291, 14, 66, 275, 7026, 14, 4421, 14, 10101, 63, 3642, 8, 66, 9, 339, 347, 511, 63, 3642, 63, 4791, 8, 277, 304, 398, 327, 481, 293, 18486, 73, 527, 6316, 365, 314, 849, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 18418, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 283, 21775, 659, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 398, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 980, 14, 4904, 395, 1749, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 446, 1590, 14, 4904, 395, 499, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 413, 395, 1520, 9, 267, 702, 63, 7520, 8, 681, 4791, 8, 277, 14, 66, 12, 446, 17, 395, 1227, 9, 398, 327, 485, 3029, 63, 18675, 63, 4791, 365, 440, 6366, 367, 5178, 3634, 267, 702, 63, 3536, 8, 18097, 12, 2249, 4791, 12, 291, 14, 66, 12, 499, 9, 267, 702, 63, 3536, 8, 18097, 12, 2249, 4791, 12, 291, 14, 66, 12, 446, 18, 9, 339, 347, 511, 63, 3642, 63, 4791, 63, 3127, 8, 277, 304, 267, 367, 333, 12, 3114, 315, 3666, 277, 14, 66, 12, 488, 395, 334, 277, 14, 66, 12, 334, 16, 12, 413, 1826, 334, 277, 14, 66, 14, 52, 12, 334, 17, 12, 378, 15206, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 3114, 29, 3127, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 260, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 283, 21775, 297, 3114, 29, 3127, 395, 1520, 14, 1342, 1427, 1272, 1876, 1194, 10834, 1082, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 980, 14, 4904, 12, 3114, 29, 3127, 395, 1749, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 446, 1590, 14, 4904, 12, 3114, 29, 3127, 395, 499, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 413, 12, 3114, 29, 3127, 395, 1520, 9, 288, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 446, 17, 12, 3114, 29, 3127, 395, 1227, 9, 339, 347, 511, 63, 4106, 63, 4791, 8, 277, 304, 267, 373, 275, 359, 20, 14, 2010, 11551, 15143, 1887, 17686, 13944, 12, 841, 14, 1194, 9408, 1690, 1555, 845, 2942, 15186, 12, 841, 14, 2010, 11551, 15143, 1887, 17686, 13944, 61, 267, 367, 333, 12, 282, 315, 334, 277, 14, 66, 12, 378, 395, 334, 277, 14, 66, 14, 52, 12, 413, 304, 288, 367, 3114, 315, 282, 12, 334, 65, 12, 2318, 282, 13, 18, 12, 334, 65, 13, 18, 12, 3461, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 413, 12, 3114, 29, 3127, 395, 359, 23, 12, 1227, 12, 1520, 566, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 980, 14, 4904, 12, 3114, 29, 3127, 395, 359, 20, 12, 650, 12, 841, 566, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 3114, 29, 3127, 395, 373, 9, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 6206, 29, 18, 12, 3114, 29, 3127, 395, 373, 9, 355, 702, 63, 7520, 8, 681, 4791, 8, 77, 12, 6206, 29, 403, 12, 3114, 29, 3127, 395, 373, 9, 339, 347, 511, 63, 4791, 63, 3924, 8, 277, 304, 267, 333, 275, 291, 14, 66, 267, 702, 63, 3536, 8, 4333, 12, 2249, 4791, 12, 333, 12, 488, 12, 413, 14, 21, 9, 267, 702, 63, 3536, 8, 4333, 12, 2249, 4791, 12, 333, 12, 488, 12, 359, 18, 566, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 14515, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 413, 12, 499, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 378, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 334, 16, 12, 499, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 5868, 19, 12, 378, 430, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 499, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 488, 12, 446, 19, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 283, 17673, 63, 1618, 63, 609, 322, 311, 297, 378, 9, 267, 702, 63, 3536, 8, 3393, 12, 2249, 4791, 12, 333, 12, 283, 17673, 63, 1618, 63, 609, 322, 311, 297, 334, 16, 12, 413, 430, 421, 199, 533, 1379, 20343, 25218, 15548, 8, 785, 304, 272, 485, 4421, 63, 1313, 275, 334, 288, 7026, 14, 4421, 14, 1533, 82, 63, 3642, 12, 288, 7026, 14, 4421, 14, 22684, 63, 3642, 12, 288, 7026, 14, 4421, 14, 17000, 63, 3642, 12, 288, 7026, 14, 4421, 14, 10101, 63, 3642, 12, 288, 7026, 14, 4421, 14, 2391, 63, 3642, 12, 288, 7026, 14, 4421, 14, 68, 745, 63, 3642, 12, 288, 7026, 14, 4421, 14, 317, 76, 63, 3642, 12, 288, 776, 272, 485, 396, 63, 19032, 275, 334, 288, 334, 1590, 14, 5605, 8, 25, 9, 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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 ]
verloop/rasa_nlu
rasa_nlu/server.py
1
4816
from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import import argparse import logging import os from functools import wraps from flask import Flask from flask import current_app from flask import jsonify from flask import request from gevent.wsgi import WSGIServer from rasa_nlu.config import RasaNLUConfig from rasa_nlu.data_router import DataRouter, InvalidModelError from rasa_nlu.version import __version__ def create_argparser(): parser = argparse.ArgumentParser(description='parse incoming text') parser.add_argument('-c', '--config', help="config file, all the command line options can also be passed via a (json-formatted) " + "config file. NB command line args take precedence") parser.add_argument('-d', '--server_model_dirs', help='directory containing model to for parser to use') parser.add_argument('-e', '--emulate', choices=['wit', 'luis', 'api'], help='which service to emulate (default: None i.e. use simple built in format)') parser.add_argument('-l', '--language', choices=['de', 'en'], help="model and data language") parser.add_argument('-m', '--mitie_file', help='file with mitie total_word_feature_extractor') parser.add_argument('-p', '--path', help="path where model files will be saved") parser.add_argument('--pipeline', help="The pipeline to use. Either a pipeline template name or a list of " + "components separated by comma") parser.add_argument('-P', '--port', type=int, help='port on which to run server') parser.add_argument('-t', '--token', help="auth token. If set, reject requests which don't provide this token as a query parameter") parser.add_argument('-w', '--write', help='file where logs will be saved') return parser def requires_auth(f): """Wraps a request handler with token authentication.""" @wraps(f) def decorated(*args, **kwargs): token = request.args.get('token', '') if current_app.data_router.token is None or token == current_app.data_router.token: return f(*args, **kwargs) return "unauthorized", 401 return decorated def create_app(config, component_builder=None): rasa_nlu_app = Flask(__name__) @rasa_nlu_app.route("/parse", methods=['GET', 'POST']) @requires_auth def parse_get(): if request.method == 'GET': request_params = request.args else: request_params = request.get_json(force=True) if 'q' not in request_params: return jsonify(error="Invalid parse parameter specified"), 404 else: try: data = current_app.data_router.extract(request_params) response = current_app.data_router.parse(data) return jsonify(response) except InvalidModelError as e: return jsonify({"error": "{}".format(e)}), 404 @rasa_nlu_app.route("/version", methods=['GET']) @requires_auth def version(): return jsonify({'version': __version__}) @rasa_nlu_app.route("/config", methods=['GET']) @requires_auth def rasaconfig(): return jsonify(config.as_dict()) @rasa_nlu_app.route("/status", methods=['GET']) @requires_auth def status(): return jsonify(current_app.data_router.get_status()) @rasa_nlu_app.route("/", methods=['GET']) def hello(): return "hello from Rasa NLU: " + __version__ @rasa_nlu_app.route("/train", methods=['POST']) @requires_auth def train(): data_string = request.get_data(as_text=True) current_app.data_router.start_train_process(data_string, request.args) return jsonify(info="training started.", training_process_ids=current_app.data_router.train_proc_ids()) logging.basicConfig(filename=config['log_file'], level=config['log_level']) logging.captureWarnings(True) logging.info("Configuration: " + config.view()) logging.debug("Creating a new data router") rasa_nlu_app.data_router = DataRouter(config, component_builder) return rasa_nlu_app if __name__ == '__main__': # Running as standalone python application arg_parser = create_argparser() cmdline_args = {key: val for key, val in list(vars(arg_parser.parse_args()).items()) if val is not None} rasa_nlu_config = RasaNLUConfig(cmdline_args.get("config"), os.environ, cmdline_args) app = WSGIServer(('0.0.0.0', rasa_nlu_config['port']), create_app(rasa_nlu_config)) logging.info('Started http server on port %s' % rasa_nlu_config['port']) app.serve_forever()
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 7534, 199, 646, 2050, 199, 646, 747, 199, 504, 9143, 492, 14018, 199, 199, 504, 7209, 492, 16704, 199, 504, 7209, 492, 1453, 63, 571, 199, 504, 7209, 492, 23819, 199, 504, 7209, 492, 1056, 199, 504, 23386, 14, 6508, 492, 644, 28732, 199, 199, 504, 519, 30253, 63, 7530, 85, 14, 888, 492, 820, 30253, 14176, 53, 2028, 199, 504, 519, 30253, 63, 7530, 85, 14, 576, 63, 4995, 492, 3918, 11691, 12, 6378, 1685, 547, 199, 504, 519, 30253, 63, 7530, 85, 14, 1023, 492, 636, 1023, 363, 421, 199, 318, 1218, 63, 1273, 2087, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 1122, 12467, 1318, 358, 272, 1798, 14, 525, 63, 2094, 3654, 67, 297, 2850, 888, 297, 717, 1720, 628, 888, 570, 12, 1006, 314, 1414, 1004, 1511, 883, 2597, 506, 3032, 4799, 282, 334, 1001, 13, 15317, 9, 298, 435, 2490, 298, 888, 570, 14, 25377, 1414, 1004, 1249, 5452, 13823, 531, 272, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 1000, 63, 1238, 63, 3220, 297, 717, 1720, 534, 3619, 3035, 1402, 370, 367, 1798, 370, 675, 358, 272, 1798, 14, 525, 63, 2094, 3654, 69, 297, 2850, 29809, 323, 297, 3415, 2968, 2503, 297, 283, 10836, 374, 297, 283, 1246, 995, 717, 1720, 534, 6777, 2435, 370, 31102, 334, 885, 26, 488, 284, 14, 69, 14, 675, 3486, 6137, 315, 1475, 5942, 272, 1798, 14, 525, 63, 2094, 3654, 76, 297, 2850, 3671, 297, 3415, 2968, 271, 297, 283, 287, 995, 1720, 628, 1238, 436, 666, 2637, 531, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 2664, 23958, 63, 493, 297, 717, 1720, 534, 493, 543, 333, 5277, 69, 3141, 63, 1027, 63, 4445, 63, 22677, 358, 272, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 515, 297, 1720, 628, 515, 2382, 1402, 1584, 911, 506, 6290, 531, 272, 1798, 14, 525, 63, 2094, 4517, 7379, 297, 1720, 628, 1918, 7679, 370, 675, 14, 13083, 282, 7679, 1978, 536, 503, 282, 769, 402, 298, 435, 5644, 298, 4608, 11673, 701, 10029, 531, 272, 1798, 14, 525, 63, 2094, 3654, 48, 297, 2850, 719, 297, 730, 29, 442, 12, 1720, 534, 719, 641, 1314, 370, 1255, 1654, 358, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1418, 297, 717, 1720, 628, 1178, 1526, 14, 982, 663, 12, 17100, 4145, 1314, 2793, 1133, 5647, 642, 1526, 465, 282, 1827, 2725, 531, 272, 1798, 14, 525, 63, 2094, 3654, 87, 297, 2850, 952, 297, 1720, 534, 493, 2382, 9610, 911, 506, 6290, 358, 339, 372, 1798, 421, 199, 318, 5074, 63, 1178, 8, 70, 304, 272, 408, 55, 8146, 282, 1056, 3016, 543, 1526, 6299, 1041, 339, 768, 13582, 8, 70, 9, 272, 347, 16225, 2031, 589, 12, 1011, 958, 304, 267, 1526, 275, 1056, 14, 589, 14, 362, 360, 1418, 297, 4074, 267, 340, 1453, 63, 571, 14, 576, 63, 4995, 14, 1418, 365, 488, 503, 1526, 508, 1453, 63, 571, 14, 576, 63, 4995, 14, 1418, 26, 288, 372, 289, 2031, 589, 12, 1011, 958, 9, 267, 372, 298, 324, 11497, 401, 13952, 339, 372, 16225, 421, 199, 318, 1218, 63, 571, 8, 888, 12, 3931, 63, 5649, 29, 403, 304, 272, 519, 30253, 63, 7530, 85, 63, 571, 275, 16704, 3460, 354, 3368, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1122, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 272, 768, 6537, 63, 1178, 272, 347, 2198, 63, 362, 837, 267, 340, 1056, 14, 765, 508, 283, 2970, 356, 288, 1056, 63, 1162, 275, 1056, 14, 589, 267, 587, 26, 288, 1056, 63, 1162, 275, 1056, 14, 362, 63, 1001, 8, 3990, 29, 549, 9, 267, 340, 283, 81, 7, 440, 315, 1056, 63, 1162, 26, 288, 372, 23819, 8, 705, 628, 3364, 2198, 2725, 2013, 1288, 7901, 267, 587, 26, 288, 862, 26, 355, 666, 275, 1453, 63, 571, 14, 576, 63, 4995, 14, 5005, 8, 1069, 63, 1162, 9, 355, 1177, 275, 1453, 63, 571, 14, 576, 63, 4995, 14, 1122, 8, 576, 9, 355, 372, 23819, 8, 1310, 9, 288, 871, 6378, 1685, 547, 465, 325, 26, 355, 372, 23819, 6333, 705, 582, 11491, 1674, 908, 8, 69, 6769, 395, 7901, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1023, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 1015, 837, 267, 372, 23819, 3252, 1023, 356, 636, 1023, 363, 1552, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 888, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 519, 30253, 888, 837, 267, 372, 23819, 8, 888, 14, 305, 63, 807, 1012, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1205, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 2004, 837, 267, 372, 23819, 8, 1818, 63, 571, 14, 576, 63, 4995, 14, 362, 63, 1205, 1012, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 27374, 3102, 2968, 2970, 1105, 272, 347, 16509, 837, 267, 372, 298, 5006, 687, 820, 30253, 653, 20237, 26, 298, 435, 636, 1023, 363, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 2834, 401, 3102, 2968, 4030, 1105, 272, 768, 6537, 63, 1178, 272, 347, 3560, 837, 267, 666, 63, 875, 275, 1056, 14, 362, 63, 576, 8, 305, 63, 505, 29, 549, 9, 267, 1453, 63, 571, 14, 576, 63, 4995, 14, 928, 63, 2834, 63, 1412, 8, 576, 63, 875, 12, 1056, 14, 589, 9, 267, 372, 23819, 8, 815, 628, 7588, 8239, 4765, 6093, 63, 1412, 63, 1580, 29, 1818, 63, 571, 14, 576, 63, 4995, 14, 2834, 63, 4687, 63, 1580, 1012, 339, 2050, 14, 19602, 8, 1501, 29, 888, 459, 793, 63, 493, 995, 2166, 29, 888, 459, 793, 63, 1896, 1105, 272, 2050, 14, 12685, 15921, 8, 549, 9, 272, 2050, 14, 815, 480, 5688 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 7534, 199, 646, 2050, 199, 646, 747, 199, 504, 9143, 492, 14018, 199, 199, 504, 7209, 492, 16704, 199, 504, 7209, 492, 1453, 63, 571, 199, 504, 7209, 492, 23819, 199, 504, 7209, 492, 1056, 199, 504, 23386, 14, 6508, 492, 644, 28732, 199, 199, 504, 519, 30253, 63, 7530, 85, 14, 888, 492, 820, 30253, 14176, 53, 2028, 199, 504, 519, 30253, 63, 7530, 85, 14, 576, 63, 4995, 492, 3918, 11691, 12, 6378, 1685, 547, 199, 504, 519, 30253, 63, 7530, 85, 14, 1023, 492, 636, 1023, 363, 421, 199, 318, 1218, 63, 1273, 2087, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 1122, 12467, 1318, 358, 272, 1798, 14, 525, 63, 2094, 3654, 67, 297, 2850, 888, 297, 717, 1720, 628, 888, 570, 12, 1006, 314, 1414, 1004, 1511, 883, 2597, 506, 3032, 4799, 282, 334, 1001, 13, 15317, 9, 298, 435, 2490, 298, 888, 570, 14, 25377, 1414, 1004, 1249, 5452, 13823, 531, 272, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 1000, 63, 1238, 63, 3220, 297, 717, 1720, 534, 3619, 3035, 1402, 370, 367, 1798, 370, 675, 358, 272, 1798, 14, 525, 63, 2094, 3654, 69, 297, 2850, 29809, 323, 297, 3415, 2968, 2503, 297, 283, 10836, 374, 297, 283, 1246, 995, 717, 1720, 534, 6777, 2435, 370, 31102, 334, 885, 26, 488, 284, 14, 69, 14, 675, 3486, 6137, 315, 1475, 5942, 272, 1798, 14, 525, 63, 2094, 3654, 76, 297, 2850, 3671, 297, 3415, 2968, 271, 297, 283, 287, 995, 1720, 628, 1238, 436, 666, 2637, 531, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 2664, 23958, 63, 493, 297, 717, 1720, 534, 493, 543, 333, 5277, 69, 3141, 63, 1027, 63, 4445, 63, 22677, 358, 272, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 515, 297, 1720, 628, 515, 2382, 1402, 1584, 911, 506, 6290, 531, 272, 1798, 14, 525, 63, 2094, 4517, 7379, 297, 1720, 628, 1918, 7679, 370, 675, 14, 13083, 282, 7679, 1978, 536, 503, 282, 769, 402, 298, 435, 5644, 298, 4608, 11673, 701, 10029, 531, 272, 1798, 14, 525, 63, 2094, 3654, 48, 297, 2850, 719, 297, 730, 29, 442, 12, 1720, 534, 719, 641, 1314, 370, 1255, 1654, 358, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1418, 297, 717, 1720, 628, 1178, 1526, 14, 982, 663, 12, 17100, 4145, 1314, 2793, 1133, 5647, 642, 1526, 465, 282, 1827, 2725, 531, 272, 1798, 14, 525, 63, 2094, 3654, 87, 297, 2850, 952, 297, 1720, 534, 493, 2382, 9610, 911, 506, 6290, 358, 339, 372, 1798, 421, 199, 318, 5074, 63, 1178, 8, 70, 304, 272, 408, 55, 8146, 282, 1056, 3016, 543, 1526, 6299, 1041, 339, 768, 13582, 8, 70, 9, 272, 347, 16225, 2031, 589, 12, 1011, 958, 304, 267, 1526, 275, 1056, 14, 589, 14, 362, 360, 1418, 297, 4074, 267, 340, 1453, 63, 571, 14, 576, 63, 4995, 14, 1418, 365, 488, 503, 1526, 508, 1453, 63, 571, 14, 576, 63, 4995, 14, 1418, 26, 288, 372, 289, 2031, 589, 12, 1011, 958, 9, 267, 372, 298, 324, 11497, 401, 13952, 339, 372, 16225, 421, 199, 318, 1218, 63, 571, 8, 888, 12, 3931, 63, 5649, 29, 403, 304, 272, 519, 30253, 63, 7530, 85, 63, 571, 275, 16704, 3460, 354, 3368, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1122, 401, 3102, 2968, 2970, 297, 283, 4030, 1105, 272, 768, 6537, 63, 1178, 272, 347, 2198, 63, 362, 837, 267, 340, 1056, 14, 765, 508, 283, 2970, 356, 288, 1056, 63, 1162, 275, 1056, 14, 589, 267, 587, 26, 288, 1056, 63, 1162, 275, 1056, 14, 362, 63, 1001, 8, 3990, 29, 549, 9, 267, 340, 283, 81, 7, 440, 315, 1056, 63, 1162, 26, 288, 372, 23819, 8, 705, 628, 3364, 2198, 2725, 2013, 1288, 7901, 267, 587, 26, 288, 862, 26, 355, 666, 275, 1453, 63, 571, 14, 576, 63, 4995, 14, 5005, 8, 1069, 63, 1162, 9, 355, 1177, 275, 1453, 63, 571, 14, 576, 63, 4995, 14, 1122, 8, 576, 9, 355, 372, 23819, 8, 1310, 9, 288, 871, 6378, 1685, 547, 465, 325, 26, 355, 372, 23819, 6333, 705, 582, 11491, 1674, 908, 8, 69, 6769, 395, 7901, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1023, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 1015, 837, 267, 372, 23819, 3252, 1023, 356, 636, 1023, 363, 1552, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 888, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 519, 30253, 888, 837, 267, 372, 23819, 8, 888, 14, 305, 63, 807, 1012, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 1205, 401, 3102, 2968, 2970, 1105, 272, 768, 6537, 63, 1178, 272, 347, 2004, 837, 267, 372, 23819, 8, 1818, 63, 571, 14, 576, 63, 4995, 14, 362, 63, 1205, 1012, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 27374, 3102, 2968, 2970, 1105, 272, 347, 16509, 837, 267, 372, 298, 5006, 687, 820, 30253, 653, 20237, 26, 298, 435, 636, 1023, 363, 339, 768, 6360, 65, 63, 7530, 85, 63, 571, 14, 4449, 4769, 2834, 401, 3102, 2968, 4030, 1105, 272, 768, 6537, 63, 1178, 272, 347, 3560, 837, 267, 666, 63, 875, 275, 1056, 14, 362, 63, 576, 8, 305, 63, 505, 29, 549, 9, 267, 1453, 63, 571, 14, 576, 63, 4995, 14, 928, 63, 2834, 63, 1412, 8, 576, 63, 875, 12, 1056, 14, 589, 9, 267, 372, 23819, 8, 815, 628, 7588, 8239, 4765, 6093, 63, 1412, 63, 1580, 29, 1818, 63, 571, 14, 576, 63, 4995, 14, 2834, 63, 4687, 63, 1580, 1012, 339, 2050, 14, 19602, 8, 1501, 29, 888, 459, 793, 63, 493, 995, 2166, 29, 888, 459, 793, 63, 1896, 1105, 272, 2050, 14, 12685, 15921, 8, 549, 9, 272, 2050, 14, 815, 480, 5688, 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,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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 ]
tinloaf/home-assistant
homeassistant/components/sensor/deconz.py
1
8961
""" Support for deCONZ sensor. For more details about this component, please refer to the documentation at https://home-assistant.io/components/sensor.deconz/ """ from homeassistant.components.deconz.const import ( ATTR_DARK, ATTR_ON, CONF_ALLOW_CLIP_SENSOR, DECONZ_REACHABLE, DOMAIN as DECONZ_DOMAIN) from homeassistant.const import ( ATTR_BATTERY_LEVEL, ATTR_VOLTAGE, DEVICE_CLASS_BATTERY) from homeassistant.core import callback from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import Entity from homeassistant.util import slugify DEPENDENCIES = ['deconz'] ATTR_CURRENT = 'current' ATTR_DAYLIGHT = 'daylight' ATTR_EVENT_ID = 'event_id' async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Old way of setting up deCONZ sensors.""" pass async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the deCONZ sensors.""" gateway = hass.data[DECONZ_DOMAIN] @callback def async_add_sensor(sensors): """Add sensors from deCONZ.""" from pydeconz.sensor import DECONZ_SENSOR, SWITCH as DECONZ_REMOTE entities = [] allow_clip_sensor = config_entry.data.get(CONF_ALLOW_CLIP_SENSOR, True) for sensor in sensors: if sensor.type in DECONZ_SENSOR and \ not (not allow_clip_sensor and sensor.type.startswith('CLIP')): if sensor.type in DECONZ_REMOTE: if sensor.battery: entities.append(DeconzBattery(sensor, gateway)) else: entities.append(DeconzSensor(sensor, gateway)) async_add_entities(entities, True) gateway.listeners.append( async_dispatcher_connect(hass, 'deconz_new_sensor', async_add_sensor)) async_add_sensor(gateway.api.sensors.values()) class DeconzSensor(Entity): """Representation of a sensor.""" def __init__(self, sensor, gateway): """Set up sensor and add update callback to get data from websocket.""" self._sensor = sensor self.gateway = gateway self.unsub_dispatcher = None async def async_added_to_hass(self): """Subscribe to sensors events.""" self._sensor.register_async_callback(self.async_update_callback) self.gateway.deconz_ids[self.entity_id] = self._sensor.deconz_id self.unsub_dispatcher = async_dispatcher_connect( self.hass, DECONZ_REACHABLE, self.async_update_callback) async def async_will_remove_from_hass(self) -> None: """Disconnect sensor object when removed.""" if self.unsub_dispatcher is not None: self.unsub_dispatcher() self._sensor.remove_callback(self.async_update_callback) self._sensor = None @callback def async_update_callback(self, reason): """Update the sensor's state. If reason is that state is updated, or reachable has changed or battery has changed. """ if reason['state'] or \ 'reachable' in reason['attr'] or \ 'battery' in reason['attr'] or \ 'on' in reason['attr']: self.async_schedule_update_ha_state() @property def state(self): """Return the state of the sensor.""" return self._sensor.state @property def name(self): """Return the name of the sensor.""" return self._sensor.name @property def unique_id(self): """Return a unique identifier for this sensor.""" return self._sensor.uniqueid @property def device_class(self): """Return the class of the sensor.""" return self._sensor.sensor_class @property def icon(self): """Return the icon to use in the frontend.""" return self._sensor.sensor_icon @property def unit_of_measurement(self): """Return the unit of measurement of this sensor.""" return self._sensor.sensor_unit @property def available(self): """Return true if sensor is available.""" return self.gateway.available and self._sensor.reachable @property def should_poll(self): """No polling needed.""" return False @property def device_state_attributes(self): """Return the state attributes of the sensor.""" from pydeconz.sensor import LIGHTLEVEL attr = {} if self._sensor.battery: attr[ATTR_BATTERY_LEVEL] = self._sensor.battery if self._sensor.on is not None: attr[ATTR_ON] = self._sensor.on if self._sensor.type in LIGHTLEVEL and self._sensor.dark is not None: attr[ATTR_DARK] = self._sensor.dark if self.unit_of_measurement == 'Watts': attr[ATTR_CURRENT] = self._sensor.current attr[ATTR_VOLTAGE] = self._sensor.voltage if self._sensor.sensor_class == 'daylight': attr[ATTR_DAYLIGHT] = self._sensor.daylight return attr @property def device_info(self): """Return a device description for device registry.""" if (self._sensor.uniqueid is None or self._sensor.uniqueid.count(':') != 7): return None serial = self._sensor.uniqueid.split('-', 1)[0] bridgeid = self.gateway.api.config.bridgeid return { 'connections': {(CONNECTION_ZIGBEE, serial)}, 'identifiers': {(DECONZ_DOMAIN, serial)}, 'manufacturer': self._sensor.manufacturer, 'model': self._sensor.modelid, 'name': self._sensor.name, 'sw_version': self._sensor.swversion, 'via_hub': (DECONZ_DOMAIN, bridgeid), } class DeconzBattery(Entity): """Battery class for when a device is only represented as an event.""" def __init__(self, sensor, gateway): """Register dispatcher callback for update of battery state.""" self._sensor = sensor self.gateway = gateway self.unsub_dispatcher = None self._name = '{} {}'.format(self._sensor.name, 'Battery Level') self._unit_of_measurement = "%" async def async_added_to_hass(self): """Subscribe to sensors events.""" self._sensor.register_async_callback(self.async_update_callback) self.gateway.deconz_ids[self.entity_id] = self._sensor.deconz_id self.unsub_dispatcher = async_dispatcher_connect( self.hass, DECONZ_REACHABLE, self.async_update_callback) async def async_will_remove_from_hass(self) -> None: """Disconnect sensor object when removed.""" if self.unsub_dispatcher is not None: self.unsub_dispatcher() self._sensor.remove_callback(self.async_update_callback) self._sensor = None @callback def async_update_callback(self, reason): """Update the battery's state, if needed.""" if 'reachable' in reason['attr'] or 'battery' in reason['attr']: self.async_schedule_update_ha_state() @property def state(self): """Return the state of the battery.""" return self._sensor.battery @property def name(self): """Return the name of the battery.""" return self._name @property def unique_id(self): """Return a unique identifier for the device.""" return self._sensor.uniqueid @property def device_class(self): """Return the class of the sensor.""" return DEVICE_CLASS_BATTERY @property def unit_of_measurement(self): """Return the unit of measurement of this entity.""" return self._unit_of_measurement @property def available(self): """Return true if sensor is available.""" return self.gateway.available and self._sensor.reachable @property def should_poll(self): """No polling needed.""" return False @property def device_state_attributes(self): """Return the state attributes of the battery.""" attr = { ATTR_EVENT_ID: slugify(self._sensor.name), } return attr @property def device_info(self): """Return a device description for device registry.""" if (self._sensor.uniqueid is None or self._sensor.uniqueid.count(':') != 7): return None serial = self._sensor.uniqueid.split('-', 1)[0] bridgeid = self.gateway.api.config.bridgeid return { 'connections': {(CONNECTION_ZIGBEE, serial)}, 'identifiers': {(DECONZ_DOMAIN, serial)}, 'manufacturer': self._sensor.manufacturer, 'model': self._sensor.modelid, 'name': self._sensor.name, 'sw_version': self._sensor.swversion, 'via_hub': (DECONZ_DOMAIN, bridgeid), }
apache-2.0
[ 624, 199, 11532, 367, 477, 1864, 58, 8778, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 271, 388, 90, 15, 199, 624, 199, 504, 8846, 14, 4608, 14, 271, 388, 90, 14, 1297, 492, 334, 272, 10762, 63, 36, 5748, 12, 10762, 63, 615, 12, 6392, 63, 12231, 63, 1981, 1772, 63, 24151, 12, 3265, 1864, 58, 63, 24345, 1244, 2617, 12, 272, 15265, 465, 3265, 1864, 58, 63, 7378, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 28839, 1157, 57, 63, 11817, 12, 10762, 63, 12209, 52, 2962, 12, 11643, 63, 6885, 63, 28839, 1157, 57, 9, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 7546, 14, 1782, 63, 5189, 492, 11287, 63, 58, 1277, 6773, 37, 199, 504, 8846, 14, 7546, 14, 14913, 492, 5316, 63, 14913, 63, 2242, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 504, 8846, 14, 1974, 492, 29864, 199, 199, 25743, 9415, 2563, 275, 788, 271, 388, 90, 418, 199, 199, 5280, 63, 14211, 275, 283, 1818, 7, 199, 5280, 63, 11655, 21613, 275, 283, 2977, 4040, 7, 199, 5280, 63, 8193, 63, 998, 275, 283, 1430, 63, 344, 7, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 16411, 4340, 402, 4260, 1536, 477, 1864, 58, 19678, 1041, 272, 986, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 12, 1101, 63, 2373, 12, 5316, 63, 525, 63, 8327, 304, 272, 408, 1084, 1536, 314, 477, 1864, 58, 19678, 1041, 272, 10391, 275, 6298, 14, 576, 59, 1093, 1864, 58, 63, 7378, 61, 339, 768, 3058, 272, 347, 5316, 63, 525, 63, 8956, 8, 22675, 304, 267, 408, 1123, 19678, 687, 477, 1864, 58, 1041, 267, 687, 1134, 271, 388, 90, 14, 8956, 492, 3265, 1864, 58, 63, 24151, 12, 17548, 15894, 465, 3265, 1864, 58, 63, 16058, 267, 9045, 275, 942, 267, 2040, 63, 7548, 63, 8956, 275, 1101, 63, 2373, 14, 576, 14, 362, 8, 3103, 63, 12231, 63, 1981, 1772, 63, 24151, 12, 715, 9, 267, 367, 8778, 315, 19678, 26, 288, 340, 8778, 14, 466, 315, 3265, 1864, 58, 63, 24151, 436, 971, 2049, 440, 334, 1397, 2040, 63, 7548, 63, 8956, 436, 8778, 14, 466, 14, 2460, 360, 1981, 1772, 8109, 355, 340, 8778, 14, 466, 315, 3265, 1864, 58, 63, 16058, 26, 490, 340, 8778, 14, 21113, 26, 717, 9045, 14, 740, 8, 872, 388, 90, 34, 13891, 8, 8956, 12, 10391, 430, 355, 587, 26, 490, 9045, 14, 740, 8, 872, 388, 90, 10160, 8, 8956, 12, 10391, 430, 267, 5316, 63, 525, 63, 8327, 8, 8327, 12, 715, 9, 339, 10391, 14, 17301, 14, 740, 8, 267, 5316, 63, 14913, 63, 2242, 8, 5387, 12, 283, 271, 388, 90, 63, 1222, 63, 8956, 297, 5316, 63, 525, 63, 8956, 430, 339, 5316, 63, 525, 63, 8956, 8, 7019, 14, 1246, 14, 22675, 14, 1459, 1012, 421, 199, 533, 1487, 388, 90, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 8778, 12, 10391, 304, 267, 408, 1084, 1536, 8778, 436, 1050, 1678, 3233, 370, 664, 666, 687, 24897, 1041, 267, 291, 423, 8956, 275, 8778, 267, 291, 14, 7019, 275, 10391, 267, 291, 14, 324, 954, 63, 14913, 275, 488, 339, 5316, 347, 5316, 63, 3270, 63, 475, 63, 5387, 8, 277, 304, 267, 408, 2610, 5355, 370, 19678, 4474, 1041, 267, 291, 423, 8956, 14, 2683, 63, 4146, 63, 3058, 8, 277, 14, 4146, 63, 873, 63, 3058, 9, 267, 291, 14, 7019, 14, 271, 388, 90, 63, 1580, 59, 277, 14, 4502, 63, 344, 61, 275, 291, 423, 8956, 14, 271, 388, 90, 63, 344, 267, 291, 14, 324, 954, 63, 14913, 275, 5316, 63, 14913, 63, 2242, 8, 288, 291, 14, 5387, 12, 3265, 1864, 58, 63, 24345, 1244, 2617, 12, 291, 14, 4146, 63, 873, 63, 3058, 9, 339, 5316, 347, 5316, 63, 14117, 63, 2168, 63, 504, 63, 5387, 8, 277, 9, 1035, 488, 26, 267, 408, 16761, 8778, 909, 1380, 4829, 1041, 267, 340, 291, 14, 324, 954, 63, 14913, 365, 440, 488, 26, 288, 291, 14, 324, 954, 63, 14913, 342, 267, 291, 423, 8956, 14, 2168, 63, 3058, 8, 277, 14, 4146, 63, 873, 63, 3058, 9, 267, 291, 423, 8956, 275, 488, 339, 768, 3058, 272, 347, 5316, 63, 873, 63, 3058, 8, 277, 12, 4499, 304, 267, 408, 4152, 314, 8778, 1159, 1174, 14, 398, 982, 4499, 365, 626, 1174, 365, 4588, 12, 267, 503, 29542, 965, 2896, 503, 330, 13891, 965, 2896, 14, 267, 408, 267, 340, 4499, 459, 929, 418, 503, 971, 1779, 283, 15837, 7, 315, 4499, 459, 962, 418, 503, 971, 1779, 283, 21113, 7, 315, 4499, 459, 962, 418, 503, 971, 1779, 283, 265, 7, 315, 4499, 459, 962, 2565, 288, 291, 14, 4146, 63, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 929, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 354, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 5148, 367, 642, 8778, 1041, 267, 372, 291, 423, 8956, 14, 3235, 344, 339, 768, 1829, 272, 347, 2243, 63, 533, 8, 277, 304, 267, 408, 1767, 314, 1021, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 8956, 63, 533, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 370, 675, 315, 314, 22523, 1041, 267, 372, 291, 423, 8956, 14, 8956, 63, 4677, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277, 304, 267, 408, 1767, 314, 4137, 402, 18216, 402, 642, 8778, 1041, 267, 372, 291, 423, 8956, 14, 8956, 63, 3248 ]
[ 199, 11532, 367, 477, 1864, 58, 8778, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 271, 388, 90, 15, 199, 624, 199, 504, 8846, 14, 4608, 14, 271, 388, 90, 14, 1297, 492, 334, 272, 10762, 63, 36, 5748, 12, 10762, 63, 615, 12, 6392, 63, 12231, 63, 1981, 1772, 63, 24151, 12, 3265, 1864, 58, 63, 24345, 1244, 2617, 12, 272, 15265, 465, 3265, 1864, 58, 63, 7378, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 28839, 1157, 57, 63, 11817, 12, 10762, 63, 12209, 52, 2962, 12, 11643, 63, 6885, 63, 28839, 1157, 57, 9, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 7546, 14, 1782, 63, 5189, 492, 11287, 63, 58, 1277, 6773, 37, 199, 504, 8846, 14, 7546, 14, 14913, 492, 5316, 63, 14913, 63, 2242, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 504, 8846, 14, 1974, 492, 29864, 199, 199, 25743, 9415, 2563, 275, 788, 271, 388, 90, 418, 199, 199, 5280, 63, 14211, 275, 283, 1818, 7, 199, 5280, 63, 11655, 21613, 275, 283, 2977, 4040, 7, 199, 5280, 63, 8193, 63, 998, 275, 283, 1430, 63, 344, 7, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 16411, 4340, 402, 4260, 1536, 477, 1864, 58, 19678, 1041, 272, 986, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 12, 1101, 63, 2373, 12, 5316, 63, 525, 63, 8327, 304, 272, 408, 1084, 1536, 314, 477, 1864, 58, 19678, 1041, 272, 10391, 275, 6298, 14, 576, 59, 1093, 1864, 58, 63, 7378, 61, 339, 768, 3058, 272, 347, 5316, 63, 525, 63, 8956, 8, 22675, 304, 267, 408, 1123, 19678, 687, 477, 1864, 58, 1041, 267, 687, 1134, 271, 388, 90, 14, 8956, 492, 3265, 1864, 58, 63, 24151, 12, 17548, 15894, 465, 3265, 1864, 58, 63, 16058, 267, 9045, 275, 942, 267, 2040, 63, 7548, 63, 8956, 275, 1101, 63, 2373, 14, 576, 14, 362, 8, 3103, 63, 12231, 63, 1981, 1772, 63, 24151, 12, 715, 9, 267, 367, 8778, 315, 19678, 26, 288, 340, 8778, 14, 466, 315, 3265, 1864, 58, 63, 24151, 436, 971, 2049, 440, 334, 1397, 2040, 63, 7548, 63, 8956, 436, 8778, 14, 466, 14, 2460, 360, 1981, 1772, 8109, 355, 340, 8778, 14, 466, 315, 3265, 1864, 58, 63, 16058, 26, 490, 340, 8778, 14, 21113, 26, 717, 9045, 14, 740, 8, 872, 388, 90, 34, 13891, 8, 8956, 12, 10391, 430, 355, 587, 26, 490, 9045, 14, 740, 8, 872, 388, 90, 10160, 8, 8956, 12, 10391, 430, 267, 5316, 63, 525, 63, 8327, 8, 8327, 12, 715, 9, 339, 10391, 14, 17301, 14, 740, 8, 267, 5316, 63, 14913, 63, 2242, 8, 5387, 12, 283, 271, 388, 90, 63, 1222, 63, 8956, 297, 5316, 63, 525, 63, 8956, 430, 339, 5316, 63, 525, 63, 8956, 8, 7019, 14, 1246, 14, 22675, 14, 1459, 1012, 421, 199, 533, 1487, 388, 90, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 8778, 12, 10391, 304, 267, 408, 1084, 1536, 8778, 436, 1050, 1678, 3233, 370, 664, 666, 687, 24897, 1041, 267, 291, 423, 8956, 275, 8778, 267, 291, 14, 7019, 275, 10391, 267, 291, 14, 324, 954, 63, 14913, 275, 488, 339, 5316, 347, 5316, 63, 3270, 63, 475, 63, 5387, 8, 277, 304, 267, 408, 2610, 5355, 370, 19678, 4474, 1041, 267, 291, 423, 8956, 14, 2683, 63, 4146, 63, 3058, 8, 277, 14, 4146, 63, 873, 63, 3058, 9, 267, 291, 14, 7019, 14, 271, 388, 90, 63, 1580, 59, 277, 14, 4502, 63, 344, 61, 275, 291, 423, 8956, 14, 271, 388, 90, 63, 344, 267, 291, 14, 324, 954, 63, 14913, 275, 5316, 63, 14913, 63, 2242, 8, 288, 291, 14, 5387, 12, 3265, 1864, 58, 63, 24345, 1244, 2617, 12, 291, 14, 4146, 63, 873, 63, 3058, 9, 339, 5316, 347, 5316, 63, 14117, 63, 2168, 63, 504, 63, 5387, 8, 277, 9, 1035, 488, 26, 267, 408, 16761, 8778, 909, 1380, 4829, 1041, 267, 340, 291, 14, 324, 954, 63, 14913, 365, 440, 488, 26, 288, 291, 14, 324, 954, 63, 14913, 342, 267, 291, 423, 8956, 14, 2168, 63, 3058, 8, 277, 14, 4146, 63, 873, 63, 3058, 9, 267, 291, 423, 8956, 275, 488, 339, 768, 3058, 272, 347, 5316, 63, 873, 63, 3058, 8, 277, 12, 4499, 304, 267, 408, 4152, 314, 8778, 1159, 1174, 14, 398, 982, 4499, 365, 626, 1174, 365, 4588, 12, 267, 503, 29542, 965, 2896, 503, 330, 13891, 965, 2896, 14, 267, 408, 267, 340, 4499, 459, 929, 418, 503, 971, 1779, 283, 15837, 7, 315, 4499, 459, 962, 418, 503, 971, 1779, 283, 21113, 7, 315, 4499, 459, 962, 418, 503, 971, 1779, 283, 265, 7, 315, 4499, 459, 962, 2565, 288, 291, 14, 4146, 63, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 929, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 354, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 5148, 367, 642, 8778, 1041, 267, 372, 291, 423, 8956, 14, 3235, 344, 339, 768, 1829, 272, 347, 2243, 63, 533, 8, 277, 304, 267, 408, 1767, 314, 1021, 402, 314, 8778, 1041, 267, 372, 291, 423, 8956, 14, 8956, 63, 533, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 370, 675, 315, 314, 22523, 1041, 267, 372, 291, 423, 8956, 14, 8956, 63, 4677, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277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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 ]
sudosurootdev/external_chromium_org
tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py
39
9433
# Copyright 2014 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. import contextlib import csv import logging import operator import os import platform import re import shutil import tempfile import zipfile from telemetry import decorators from telemetry.core.platform import platform_backend from telemetry.core.platform import power_monitor from telemetry.util import cloud_storage from telemetry.util import path from telemetry.util import statistics try: import win32con # pylint: disable=F0401 import win32event # pylint: disable=F0401 import win32process # pylint: disable=F0401 except ImportError: win32con = None win32event = None win32process = None START_EVENT = 'ippet_StartEvent' QUIT_EVENT = 'ippet_QuitEvent' class IppetError(Exception): pass @decorators.Cache def IppetPath(): # Look for pre-installed IPPET. ippet_path = path.FindInstalledWindowsApplication(os.path.join( 'Intel', 'Intel(R) Platform Power Estimation Tool', 'ippet.exe')) if ippet_path: return ippet_path # Look for IPPET installed previously by this script. ippet_path = os.path.join( path.GetTelemetryDir(), 'bin', 'win', 'ippet', 'ippet.exe') if path.IsExecutable(ippet_path): return ippet_path # Install IPPET. zip_path = os.path.join(path.GetTelemetryDir(), 'bin', 'win', 'ippet.zip') cloud_storage.GetIfChanged(zip_path, bucket=cloud_storage.PUBLIC_BUCKET) with zipfile.ZipFile(zip_path, 'r') as zip_file: zip_file.extractall(os.path.dirname(zip_path)) os.remove(zip_path) if path.IsExecutable(ippet_path): return ippet_path return None class IppetPowerMonitor(power_monitor.PowerMonitor): def __init__(self, backend): super(IppetPowerMonitor, self).__init__() self._backend = backend self._ippet_handle = None self._output_dir = None def CanMonitorPower(self): if not win32event: return False # TODO(dtu): This should work on Windows 7, but it's flaky on the bots. # http://crbug.com/336558 windows_8_or_later = ( self._backend.GetOSName() == 'win' and self._backend.GetOSVersionName() >= platform_backend.WIN8) if not windows_8_or_later: return False # This check works on Windows only. family, model = map(int, re.match('.+ Family ([0-9]+) Model ([0-9]+)', platform.processor()).groups()) # Model numbers from: # https://software.intel.com/en-us/articles/intel-architecture-and- \ # processor-identification-with-cpuid-model-and-family-numbers # http://www.speedtraq.com sandy_bridge_or_later = ('Intel' in platform.processor() and family == 6 and (model in (0x2A, 0x2D) or model >= 0x30)) if not sandy_bridge_or_later: return False if not IppetPath(): return False return True def CanMeasurePerApplicationPower(self): return self.CanMonitorPower() def StartMonitoringPower(self, browser): assert not self._ippet_handle, 'Called StartMonitoringPower() twice.' self._output_dir = tempfile.mkdtemp() parameters = ['-log_dir', self._output_dir, '-signals', 'START,QUIT', '-battery', 'n', '-disk', 'n', '-gpu', 'n', '-enable_web', 'n', '-zip', 'n', '-i', '0.1'] try: with contextlib.closing(win32event.CreateEvent( None, True, False, START_EVENT)) as start_event: self._ippet_handle = self._backend.LaunchApplication( IppetPath(), parameters, elevate_privilege=True) wait_code = win32event.WaitForSingleObject(start_event, 5000) if wait_code != win32event.WAIT_OBJECT_0: if wait_code == win32event.WAIT_TIMEOUT: raise IppetError('Timed out waiting for IPPET to start.') else: raise IppetError('Error code %d while waiting for IPPET to start.' % wait_code) except: # In case of emergency, don't leave IPPET processes hanging around. if self._ippet_handle: try: exit_code = win32process.GetExitCodeProcess(self._ippet_handle) if exit_code == win32con.STILL_ACTIVE: win32process.TerminateProcess(self._ippet_handle, 0) finally: self._ippet_handle.Close() self._ippet_handle = None raise def StopMonitoringPower(self): assert self._ippet_handle, ( 'Called StopMonitoringPower() before StartMonitoringPower().') try: # Stop IPPET. with contextlib.closing(win32event.OpenEvent( win32event.EVENT_MODIFY_STATE, False, QUIT_EVENT)) as quit_event: win32event.SetEvent(quit_event) # Wait for IPPET process to exit. wait_code = win32event.WaitForSingleObject(self._ippet_handle, 20000) if wait_code != win32event.WAIT_OBJECT_0: if wait_code == win32event.WAIT_TIMEOUT: raise IppetError('Timed out waiting for IPPET to close.') else: raise IppetError('Error code %d while waiting for IPPET to close.' % wait_code) finally: # If we need to, forcefully kill IPPET. try: exit_code = win32process.GetExitCodeProcess(self._ippet_handle) if exit_code == win32con.STILL_ACTIVE: win32process.TerminateProcess(self._ippet_handle, 0) raise IppetError('IPPET is still running but should have stopped.') elif exit_code != 0: raise IppetError('IPPET closed with exit code %d.' % exit_code) finally: self._ippet_handle.Close() self._ippet_handle = None # Read IPPET's log file. log_file = os.path.join(self._output_dir, 'ippet_log_processes.xls') try: with open(log_file, 'r') as f: reader = csv.DictReader(f, dialect='excel-tab') data = list(reader)[1:] # The first iteration only reports temperature. except IOError: logging.error('Output directory %s contains: %s', self._output_dir, os.listdir(self._output_dir)) raise shutil.rmtree(self._output_dir) self._output_dir = None def get(*args, **kwargs): """Pull all iterations of a field from the IPPET data as a list. Args: args: A list representing the field name. mult: A cosntant to multiply the field's value by, for unit conversions. default: The default value if the field is not found in the iteration. Returns: A list containing the field's value across all iterations. """ key = '\\\\.\\' + '\\'.join(args) def value(line): if key in line: return line[key] elif 'default' in kwargs: return kwargs['default'] else: raise KeyError('Key "%s" not found in data and ' 'no default was given.' % key) return [float(value(line)) * kwargs.get('mult', 1) for line in data] result = { 'identifier': 'ippet', 'power_samples_mw': get('Power(_Total)', 'Package W', mult=1000), 'energy_consumption_mwh': sum(map(operator.mul, get('Power(_Total)', 'Package W', mult=1000), get('sys', 'Interval(secs)', mult=1./3600.))), 'component_utilization': { 'whole_package': { 'average_temperature_c': statistics.ArithmeticMean(get( 'Temperature(Package)', 'Current C')), }, 'cpu': { 'power_samples_mw': get('Power(_Total)', 'CPU W', mult=1000), 'energy_consumption_mwh': sum(map(operator.mul, get('Power(_Total)', 'CPU W', mult=1000), get('sys', 'Interval(secs)', mult=1./3600.))), }, 'disk': { 'power_samples_mw': get('Power(_Total)', 'Disk W', mult=1000), 'energy_consumption_mwh': sum(map(operator.mul, get('Power(_Total)', 'Disk W', mult=1000), get('sys', 'Interval(secs)', mult=1./3600.))), }, 'gpu': { 'power_samples_mw': get('Power(_Total)', 'GPU W', mult=1000), 'energy_consumption_mwh': sum(map(operator.mul, get('Power(_Total)', 'GPU W', mult=1000), get('sys', 'Interval(secs)', mult=1./3600.))), }, }, } # Find Chrome processes in data. Note that this won't work if there are # extra Chrome processes lying around. chrome_keys = set() for iteration in data: for key in iteration.iterkeys(): parts = key.split('\\') if (len(parts) >= 4 and re.match(r'Process\(Google Chrome [0-9]+\)', parts[3])): chrome_keys.add(parts[3]) # Add Chrome process power usage to result. # Note that this is only an estimate of Chrome's CPU power usage. if chrome_keys: per_process_power_usage = [ get(key, 'CPU Power W', default=0, mult=1000) for key in chrome_keys] result['application_energy_consumption_mwh'] = ( sum(map(operator.mul, map(sum, zip(*per_process_power_usage)), get('sys', 'Interval(secs)', mult=1./3600.)))) return result
bsd-3-clause
[ 3, 1898, 6927, 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, 646, 15502, 199, 646, 7392, 199, 646, 2050, 199, 646, 4182, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 5145, 199, 646, 5549, 199, 646, 10392, 199, 199, 504, 17298, 492, 20419, 199, 504, 17298, 14, 1018, 14, 3246, 492, 4298, 63, 4620, 199, 504, 17298, 14, 1018, 14, 3246, 492, 7074, 63, 7157, 199, 504, 17298, 14, 1974, 492, 8002, 63, 3494, 199, 504, 17298, 14, 1974, 492, 931, 199, 504, 17298, 14, 1974, 492, 11076, 199, 199, 893, 26, 523, 492, 4747, 708, 388, 221, 327, 4287, 26, 3507, 29, 38, 28025, 523, 492, 4747, 708, 1430, 221, 327, 4287, 26, 3507, 29, 38, 28025, 523, 492, 4747, 708, 1412, 221, 327, 4287, 26, 3507, 29, 38, 28025, 199, 2590, 3545, 26, 523, 4747, 708, 388, 275, 488, 523, 4747, 708, 1430, 275, 488, 523, 4747, 708, 1412, 275, 488, 421, 199, 7363, 63, 8193, 275, 283, 11088, 63, 3162, 2390, 7, 199, 2328, 649, 63, 8193, 275, 283, 11088, 63, 24145, 2390, 7, 421, 199, 533, 31045, 8096, 547, 8, 1726, 304, 523, 986, 421, 199, 32, 11582, 14, 4437, 199, 318, 31045, 8096, 2042, 837, 523, 327, 12077, 367, 876, 13, 7657, 3531, 48, 775, 14, 523, 3384, 8096, 63, 515, 275, 931, 14, 6591, 21268, 8647, 5039, 8, 736, 14, 515, 14, 904, 8, 489, 283, 27528, 297, 283, 27528, 8, 50, 9, 16078, 18879, 15896, 8182, 15650, 297, 283, 11088, 14, 5803, 1333, 523, 340, 3384, 8096, 63, 515, 26, 272, 372, 3384, 8096, 63, 515, 819, 327, 12077, 367, 3531, 48, 775, 4903, 10889, 701, 642, 2884, 14, 523, 3384, 8096, 63, 515, 275, 747, 14, 515, 14, 904, 8, 489, 931, 14, 1002, 24944, 10987, 3567, 1062, 283, 1393, 297, 283, 2676, 297, 283, 11088, 297, 283, 11088, 14, 5803, 358, 523, 340, 931, 14, 1831, 18039, 8, 11088, 63, 515, 304, 272, 372, 3384, 8096, 63, 515, 819, 327, 13276, 3531, 48, 775, 14, 523, 3482, 63, 515, 275, 747, 14, 515, 14, 904, 8, 515, 14, 1002, 24944, 10987, 3567, 1062, 283, 1393, 297, 283, 2676, 297, 283, 11088, 14, 3065, 358, 523, 8002, 63, 3494, 14, 1002, 3917, 6970, 8, 3065, 63, 515, 12, 5315, 29, 4091, 63, 3494, 14, 19476, 63, 20156, 9, 523, 543, 10392, 14, 15016, 8, 3065, 63, 515, 12, 283, 82, 358, 465, 3482, 63, 493, 26, 272, 3482, 63, 493, 14, 5005, 452, 8, 736, 14, 515, 14, 3475, 8, 3065, 63, 515, 430, 523, 747, 14, 2168, 8, 3065, 63, 515, 9, 819, 340, 931, 14, 1831, 18039, 8, 11088, 63, 515, 304, 272, 372, 3384, 8096, 63, 515, 819, 372, 488, 421, 199, 533, 31045, 8096, 6921, 13189, 8, 5652, 63, 7157, 14, 6921, 13189, 304, 523, 347, 636, 826, 721, 277, 12, 4865, 304, 272, 1613, 8, 6583, 8096, 6921, 13189, 12, 291, 2843, 826, 4533, 272, 291, 423, 4620, 275, 4865, 272, 291, 423, 11088, 63, 2479, 275, 488, 272, 291, 423, 1199, 63, 694, 275, 488, 819, 347, 6855, 13189, 6921, 8, 277, 304, 272, 340, 440, 4747, 708, 1430, 26, 489, 372, 756, 339, 327, 3254, 8, 3583, 85, 304, 961, 1077, 1736, 641, 5417, 1520, 12, 1325, 652, 1159, 17566, 10562, 641, 314, 31726, 14, 272, 327, 1455, 921, 1556, 1266, 14, 957, 15, 1153, 10027, 24, 272, 10061, 63, 24, 63, 269, 63, 18103, 275, 334, 267, 291, 423, 4620, 14, 1002, 3100, 985, 342, 508, 283, 2676, 7, 436, 267, 291, 423, 4620, 14, 1002, 3100, 3353, 985, 342, 2356, 4298, 63, 4620, 14, 7941, 24, 9, 272, 340, 440, 10061, 63, 24, 63, 269, 63, 18103, 26, 489, 372, 756, 339, 327, 961, 1104, 5419, 641, 5417, 1454, 14, 272, 9614, 12, 1402, 275, 2341, 8, 442, 12, 295, 14, 1431, 5175, 11, 481, 4632, 7287, 16, 13, 25, 11896, 5822, 7287, 16, 13, 25, 28798, 717, 4298, 14, 6459, 8801, 2634, 1012, 272, 327, 5822, 5579, 687, 26, 272, 327, 4178, 921, 15619, 14, 22264, 14, 957, 15, 287, 13, 527, 15, 19813, 15, 22264, 13, 19134, 13, 460, 13, 971, 272, 327, 12495, 13, 73, 24926, 13, 1045, 13, 1850, 1535, 13, 1238, 13, 460, 13, 6606, 13, 10548, 272, 327, 1455, 921, 1544, 14, 7625, 1239, 81, 14, 957, 272, 308, 460, 89, 63, 9528, 63, 269, 63, 18103, 275, 661, 27528, 7, 315, 4298, 14, 6459, 342, 436, 9614, 508, 1227, 436, 2490, 334, 1238, 315, 334, 16, 88, 18, 33, 12, 378, 88, 18, 36, 9, 503, 1402, 2356, 378, 88, 1216, 430, 272, 340, 440, 308, 460, 89, 63, 9528, 63, 269, 63, 18103, 26, 489, 372, 756, 339, 340, 440, 31045, 8096, 2042, 837, 489, 372, 756, 339, 372, 715, 819, 347, 6855, 18611, 2623, 5039, 6921, 8, 277, 304, 272, 372, 291, 14, 6049, 13189, 6921, 342, 819, 347, 7707, 13189, 316, 6921, 8, 277, 12, 7042, 304, 272, 702, 440, 291, 423, 11088, 63, 2479, 12, 283, 10474, 7707, 13189, 316, 6921, 342, 13373, 3530, 272, 291, 423, 1199, 63, 694, 275, 5549, 14, 11983, 342, 272, 2633, 275, 11573, 793, 63, 694, 297, 291, 423, 1199, 63, 694, 12, 2475, 10458, 297, 283, 7363, 12, 2328, 649, 297, 2116, 2475, 21113, 297, 283, 78, 297, 2475, 4032, 297, 283, 78, 297, 2475, 6477, 297, 283, 78, 297, 2116, 2475, 4296, 63, 2520, 297, 283, 78, 297, 2475, 3065, 297, 283, 78, 297, 2475, 73, 297, 283, 16, 14, 17, 418, 339, 862, 26, 489, 543, 15502, 14, 11707, 8, 2676, 708, 1430, 14, 2499, 2390, 8, 881, 488, 12, 715, 12, 756, 12, 13910, 63, 8193, 430, 465, 1343, 63, 1430, 26, 267, 291, 423, 11088, 63, 2479, 275, 291, 423, 4620, 14, 18543, 5039, 8, 288, 31045, 8096, 2042, 1062, 2633, 12, 12993, 2409, 63, 1359, 17228, 29, 549, 9, 267, 3618, 63, 600, 275, 4747, 708, 1430, 14, 21433, 7200, 1692, 8, 928 ]
[ 1898, 6927, 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, 646, 15502, 199, 646, 7392, 199, 646, 2050, 199, 646, 4182, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 5145, 199, 646, 5549, 199, 646, 10392, 199, 199, 504, 17298, 492, 20419, 199, 504, 17298, 14, 1018, 14, 3246, 492, 4298, 63, 4620, 199, 504, 17298, 14, 1018, 14, 3246, 492, 7074, 63, 7157, 199, 504, 17298, 14, 1974, 492, 8002, 63, 3494, 199, 504, 17298, 14, 1974, 492, 931, 199, 504, 17298, 14, 1974, 492, 11076, 199, 199, 893, 26, 523, 492, 4747, 708, 388, 221, 327, 4287, 26, 3507, 29, 38, 28025, 523, 492, 4747, 708, 1430, 221, 327, 4287, 26, 3507, 29, 38, 28025, 523, 492, 4747, 708, 1412, 221, 327, 4287, 26, 3507, 29, 38, 28025, 199, 2590, 3545, 26, 523, 4747, 708, 388, 275, 488, 523, 4747, 708, 1430, 275, 488, 523, 4747, 708, 1412, 275, 488, 421, 199, 7363, 63, 8193, 275, 283, 11088, 63, 3162, 2390, 7, 199, 2328, 649, 63, 8193, 275, 283, 11088, 63, 24145, 2390, 7, 421, 199, 533, 31045, 8096, 547, 8, 1726, 304, 523, 986, 421, 199, 32, 11582, 14, 4437, 199, 318, 31045, 8096, 2042, 837, 523, 327, 12077, 367, 876, 13, 7657, 3531, 48, 775, 14, 523, 3384, 8096, 63, 515, 275, 931, 14, 6591, 21268, 8647, 5039, 8, 736, 14, 515, 14, 904, 8, 489, 283, 27528, 297, 283, 27528, 8, 50, 9, 16078, 18879, 15896, 8182, 15650, 297, 283, 11088, 14, 5803, 1333, 523, 340, 3384, 8096, 63, 515, 26, 272, 372, 3384, 8096, 63, 515, 819, 327, 12077, 367, 3531, 48, 775, 4903, 10889, 701, 642, 2884, 14, 523, 3384, 8096, 63, 515, 275, 747, 14, 515, 14, 904, 8, 489, 931, 14, 1002, 24944, 10987, 3567, 1062, 283, 1393, 297, 283, 2676, 297, 283, 11088, 297, 283, 11088, 14, 5803, 358, 523, 340, 931, 14, 1831, 18039, 8, 11088, 63, 515, 304, 272, 372, 3384, 8096, 63, 515, 819, 327, 13276, 3531, 48, 775, 14, 523, 3482, 63, 515, 275, 747, 14, 515, 14, 904, 8, 515, 14, 1002, 24944, 10987, 3567, 1062, 283, 1393, 297, 283, 2676, 297, 283, 11088, 14, 3065, 358, 523, 8002, 63, 3494, 14, 1002, 3917, 6970, 8, 3065, 63, 515, 12, 5315, 29, 4091, 63, 3494, 14, 19476, 63, 20156, 9, 523, 543, 10392, 14, 15016, 8, 3065, 63, 515, 12, 283, 82, 358, 465, 3482, 63, 493, 26, 272, 3482, 63, 493, 14, 5005, 452, 8, 736, 14, 515, 14, 3475, 8, 3065, 63, 515, 430, 523, 747, 14, 2168, 8, 3065, 63, 515, 9, 819, 340, 931, 14, 1831, 18039, 8, 11088, 63, 515, 304, 272, 372, 3384, 8096, 63, 515, 819, 372, 488, 421, 199, 533, 31045, 8096, 6921, 13189, 8, 5652, 63, 7157, 14, 6921, 13189, 304, 523, 347, 636, 826, 721, 277, 12, 4865, 304, 272, 1613, 8, 6583, 8096, 6921, 13189, 12, 291, 2843, 826, 4533, 272, 291, 423, 4620, 275, 4865, 272, 291, 423, 11088, 63, 2479, 275, 488, 272, 291, 423, 1199, 63, 694, 275, 488, 819, 347, 6855, 13189, 6921, 8, 277, 304, 272, 340, 440, 4747, 708, 1430, 26, 489, 372, 756, 339, 327, 3254, 8, 3583, 85, 304, 961, 1077, 1736, 641, 5417, 1520, 12, 1325, 652, 1159, 17566, 10562, 641, 314, 31726, 14, 272, 327, 1455, 921, 1556, 1266, 14, 957, 15, 1153, 10027, 24, 272, 10061, 63, 24, 63, 269, 63, 18103, 275, 334, 267, 291, 423, 4620, 14, 1002, 3100, 985, 342, 508, 283, 2676, 7, 436, 267, 291, 423, 4620, 14, 1002, 3100, 3353, 985, 342, 2356, 4298, 63, 4620, 14, 7941, 24, 9, 272, 340, 440, 10061, 63, 24, 63, 269, 63, 18103, 26, 489, 372, 756, 339, 327, 961, 1104, 5419, 641, 5417, 1454, 14, 272, 9614, 12, 1402, 275, 2341, 8, 442, 12, 295, 14, 1431, 5175, 11, 481, 4632, 7287, 16, 13, 25, 11896, 5822, 7287, 16, 13, 25, 28798, 717, 4298, 14, 6459, 8801, 2634, 1012, 272, 327, 5822, 5579, 687, 26, 272, 327, 4178, 921, 15619, 14, 22264, 14, 957, 15, 287, 13, 527, 15, 19813, 15, 22264, 13, 19134, 13, 460, 13, 971, 272, 327, 12495, 13, 73, 24926, 13, 1045, 13, 1850, 1535, 13, 1238, 13, 460, 13, 6606, 13, 10548, 272, 327, 1455, 921, 1544, 14, 7625, 1239, 81, 14, 957, 272, 308, 460, 89, 63, 9528, 63, 269, 63, 18103, 275, 661, 27528, 7, 315, 4298, 14, 6459, 342, 436, 9614, 508, 1227, 436, 2490, 334, 1238, 315, 334, 16, 88, 18, 33, 12, 378, 88, 18, 36, 9, 503, 1402, 2356, 378, 88, 1216, 430, 272, 340, 440, 308, 460, 89, 63, 9528, 63, 269, 63, 18103, 26, 489, 372, 756, 339, 340, 440, 31045, 8096, 2042, 837, 489, 372, 756, 339, 372, 715, 819, 347, 6855, 18611, 2623, 5039, 6921, 8, 277, 304, 272, 372, 291, 14, 6049, 13189, 6921, 342, 819, 347, 7707, 13189, 316, 6921, 8, 277, 12, 7042, 304, 272, 702, 440, 291, 423, 11088, 63, 2479, 12, 283, 10474, 7707, 13189, 316, 6921, 342, 13373, 3530, 272, 291, 423, 1199, 63, 694, 275, 5549, 14, 11983, 342, 272, 2633, 275, 11573, 793, 63, 694, 297, 291, 423, 1199, 63, 694, 12, 2475, 10458, 297, 283, 7363, 12, 2328, 649, 297, 2116, 2475, 21113, 297, 283, 78, 297, 2475, 4032, 297, 283, 78, 297, 2475, 6477, 297, 283, 78, 297, 2116, 2475, 4296, 63, 2520, 297, 283, 78, 297, 2475, 3065, 297, 283, 78, 297, 2475, 73, 297, 283, 16, 14, 17, 418, 339, 862, 26, 489, 543, 15502, 14, 11707, 8, 2676, 708, 1430, 14, 2499, 2390, 8, 881, 488, 12, 715, 12, 756, 12, 13910, 63, 8193, 430, 465, 1343, 63, 1430, 26, 267, 291, 423, 11088, 63, 2479, 275, 291, 423, 4620, 14, 18543, 5039, 8, 288, 31045, 8096, 2042, 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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 ]
qlands/onadata
onadata/apps/api/viewsets/note_viewset.py
10
2530
from django.utils.translation import ugettext as _ from guardian.shortcuts import assign_perm from rest_framework import exceptions from rest_framework import status from rest_framework.response import Response from rest_framework.viewsets import ModelViewSet from onadata.apps.api import permissions from onadata.libs.mixins.view_permission_mixin import ViewPermissionMixin from onadata.libs.serializers.note_serializer import NoteSerializer from onadata.apps.logger.models import Note class NoteViewSet(ViewPermissionMixin, ModelViewSet): """## Add Notes to a submission A `POST` payload of parameters: `note` - the note string to add to a data point `instance` - the data point id <pre class="prettyprint"> <b>POST</b> /api/v1/notes</pre> Payload {"instance": 1, "note": "This is a note."} > Response > > { > "id": 1, > "instance": 1, > "note": "This is a note." > ... > } > > HTTP 201 OK # Get List of notes for a data point A `GET` request will return the list of notes applied to a data point. <pre class="prettyprint"> <b>GET</b> /api/v1/notes</pre> > Response > > [{ > "id": 1, > "instance": 1, > "note": "This is a note." > ... > }, ...] > > > HTTP 200 OK """ queryset = Note.objects.all() serializer_class = NoteSerializer permission_classes = [permissions.ViewDjangoObjectPermissions, permissions.IsAuthenticated, ] def pre_save(self, obj): # throws PermissionDenied if request.user has no permission to xform if not self.request.user.has_perm('change_xform', obj.instance.xform): raise exceptions.PermissionDenied( _(u"You are not authorized to add/change notes on this form.")) def post_save(self, obj, created=False): if created: assign_perm('add_note', self.request.user, obj) assign_perm('change_note', self.request.user, obj) assign_perm('delete_note', self.request.user, obj) assign_perm('view_note', self.request.user, obj) # make sure parsed_instance saves to mongo db obj.instance.parsed_instance.save() def destroy(self, request, *args, **kwargs): obj = self.get_object() instance = obj.instance obj.delete() # update mongo data instance.parsed_instance.save() return Response(status=status.HTTP_204_NO_CONTENT)
bsd-2-clause
[ 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 8129, 31186, 14, 17469, 492, 5090, 63, 8220, 199, 199, 504, 4618, 63, 4857, 492, 4967, 199, 504, 4618, 63, 4857, 492, 2004, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 1345, 2193, 492, 5822, 21902, 199, 199, 504, 641, 1517, 14, 5181, 14, 1246, 492, 3443, 199, 504, 641, 1517, 14, 8450, 14, 30192, 14, 1345, 63, 5693, 63, 20406, 492, 10935, 7980, 4256, 199, 504, 641, 1517, 14, 8450, 14, 12844, 14, 4610, 63, 8349, 492, 3390, 7299, 199, 504, 641, 1517, 14, 5181, 14, 2921, 14, 992, 492, 3390, 421, 199, 533, 3390, 21902, 8, 2768, 7980, 4256, 12, 5822, 21902, 304, 272, 408, 309, 2654, 8144, 370, 282, 13071, 199, 199, 33, 658, 4030, 64, 4886, 402, 2633, 26, 339, 658, 4610, 64, 446, 314, 5317, 1059, 370, 1050, 370, 282, 666, 2376, 272, 658, 842, 64, 446, 314, 666, 2376, 1305, 421, 665, 657, 1021, 628, 9118, 1361, 1743, 523, 665, 66, 30, 4030, 1108, 66, 30, 1182, 1246, 15, 86, 17, 15, 5983, 1108, 657, 30, 199, 199, 17215, 339, 2420, 842, 582, 413, 12, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 93, 819, 690, 7232, 523, 690, 523, 690, 258, 469, 523, 690, 3515, 298, 344, 582, 413, 12, 523, 690, 3515, 298, 842, 582, 413, 12, 523, 690, 3515, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 523, 690, 3515, 2263, 523, 690, 258, 789, 523, 690, 523, 690, 258, 3101, 1784, 9949, 199, 199, 3, 2372, 3820, 402, 12681, 367, 282, 666, 2376, 199, 199, 33, 658, 2970, 64, 1056, 911, 372, 314, 769, 402, 12681, 6781, 370, 282, 666, 2376, 14, 421, 665, 657, 1021, 628, 9118, 1361, 1743, 523, 665, 66, 30, 2970, 1108, 66, 30, 1182, 1246, 15, 86, 17, 15, 5983, 1108, 657, 30, 8330, 690, 7232, 523, 690, 523, 690, 258, 8910, 523, 690, 3515, 298, 344, 582, 413, 12, 523, 690, 3515, 298, 842, 582, 413, 12, 523, 690, 3515, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 523, 690, 3515, 2263, 523, 690, 258, 1660, 21214, 523, 690, 523, 690, 523, 690, 263, 3101, 1926, 9949, 199, 624, 272, 7594, 275, 3390, 14, 1462, 14, 452, 342, 272, 9146, 63, 533, 275, 3390, 7299, 272, 4983, 63, 2888, 275, 359, 6060, 14, 2768, 9323, 1692, 17004, 12, 2079, 3443, 14, 1831, 30871, 12, 1622, 339, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 327, 24266, 23724, 340, 1056, 14, 751, 965, 949, 4983, 370, 671, 964, 267, 340, 440, 291, 14, 1069, 14, 751, 14, 1989, 63, 8220, 360, 1461, 63, 24226, 297, 1559, 14, 842, 14, 24226, 304, 288, 746, 4967, 14, 7980, 15729, 8, 355, 12561, 85, 2, 5556, 787, 440, 18788, 370, 1050, 15, 1461, 12681, 641, 642, 1824, 13853, 339, 347, 2963, 63, 2117, 8, 277, 12, 1559, 12, 2737, 29, 797, 304, 267, 340, 2737, 26, 288, 5090, 63, 8220, 360, 525, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1461, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1807, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1345, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 398, 327, 1852, 3238, 4565, 63, 842, 23050, 370, 18006, 1592, 267, 1559, 14, 842, 14, 6751, 63, 842, 14, 2117, 342, 339, 347, 11972, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1559, 275, 291, 14, 362, 63, 785, 342, 267, 1256, 275, 1559, 14, 842, 267, 1559, 14, 1807, 342, 267, 327, 1678, 18006, 666, 267, 1256, 14, 6751, 63, 842, 14, 2117, 342, 267, 372, 7232, 8, 1205, 29, 1205, 14, 2856, 63, 6686, 63, 2826, 63, 9663, 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 ]
[ 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 8129, 31186, 14, 17469, 492, 5090, 63, 8220, 199, 199, 504, 4618, 63, 4857, 492, 4967, 199, 504, 4618, 63, 4857, 492, 2004, 199, 504, 4618, 63, 4857, 14, 1310, 492, 7232, 199, 504, 4618, 63, 4857, 14, 1345, 2193, 492, 5822, 21902, 199, 199, 504, 641, 1517, 14, 5181, 14, 1246, 492, 3443, 199, 504, 641, 1517, 14, 8450, 14, 30192, 14, 1345, 63, 5693, 63, 20406, 492, 10935, 7980, 4256, 199, 504, 641, 1517, 14, 8450, 14, 12844, 14, 4610, 63, 8349, 492, 3390, 7299, 199, 504, 641, 1517, 14, 5181, 14, 2921, 14, 992, 492, 3390, 421, 199, 533, 3390, 21902, 8, 2768, 7980, 4256, 12, 5822, 21902, 304, 272, 408, 309, 2654, 8144, 370, 282, 13071, 199, 199, 33, 658, 4030, 64, 4886, 402, 2633, 26, 339, 658, 4610, 64, 446, 314, 5317, 1059, 370, 1050, 370, 282, 666, 2376, 272, 658, 842, 64, 446, 314, 666, 2376, 1305, 421, 665, 657, 1021, 628, 9118, 1361, 1743, 523, 665, 66, 30, 4030, 1108, 66, 30, 1182, 1246, 15, 86, 17, 15, 5983, 1108, 657, 30, 199, 199, 17215, 339, 2420, 842, 582, 413, 12, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 93, 819, 690, 7232, 523, 690, 523, 690, 258, 469, 523, 690, 3515, 298, 344, 582, 413, 12, 523, 690, 3515, 298, 842, 582, 413, 12, 523, 690, 3515, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 523, 690, 3515, 2263, 523, 690, 258, 789, 523, 690, 523, 690, 258, 3101, 1784, 9949, 199, 199, 3, 2372, 3820, 402, 12681, 367, 282, 666, 2376, 199, 199, 33, 658, 2970, 64, 1056, 911, 372, 314, 769, 402, 12681, 6781, 370, 282, 666, 2376, 14, 421, 665, 657, 1021, 628, 9118, 1361, 1743, 523, 665, 66, 30, 2970, 1108, 66, 30, 1182, 1246, 15, 86, 17, 15, 5983, 1108, 657, 30, 8330, 690, 7232, 523, 690, 523, 690, 258, 8910, 523, 690, 3515, 298, 344, 582, 413, 12, 523, 690, 3515, 298, 842, 582, 413, 12, 523, 690, 3515, 298, 4610, 582, 298, 2765, 365, 282, 5317, 2122, 523, 690, 3515, 2263, 523, 690, 258, 1660, 21214, 523, 690, 523, 690, 523, 690, 263, 3101, 1926, 9949, 199, 624, 272, 7594, 275, 3390, 14, 1462, 14, 452, 342, 272, 9146, 63, 533, 275, 3390, 7299, 272, 4983, 63, 2888, 275, 359, 6060, 14, 2768, 9323, 1692, 17004, 12, 2079, 3443, 14, 1831, 30871, 12, 1622, 339, 347, 876, 63, 2117, 8, 277, 12, 1559, 304, 267, 327, 24266, 23724, 340, 1056, 14, 751, 965, 949, 4983, 370, 671, 964, 267, 340, 440, 291, 14, 1069, 14, 751, 14, 1989, 63, 8220, 360, 1461, 63, 24226, 297, 1559, 14, 842, 14, 24226, 304, 288, 746, 4967, 14, 7980, 15729, 8, 355, 12561, 85, 2, 5556, 787, 440, 18788, 370, 1050, 15, 1461, 12681, 641, 642, 1824, 13853, 339, 347, 2963, 63, 2117, 8, 277, 12, 1559, 12, 2737, 29, 797, 304, 267, 340, 2737, 26, 288, 5090, 63, 8220, 360, 525, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1461, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1807, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 288, 5090, 63, 8220, 360, 1345, 63, 4610, 297, 291, 14, 1069, 14, 751, 12, 1559, 9, 398, 327, 1852, 3238, 4565, 63, 842, 23050, 370, 18006, 1592, 267, 1559, 14, 842, 14, 6751, 63, 842, 14, 2117, 342, 339, 347, 11972, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1559, 275, 291, 14, 362, 63, 785, 342, 267, 1256, 275, 1559, 14, 842, 267, 1559, 14, 1807, 342, 267, 327, 1678, 18006, 666, 267, 1256, 14, 6751, 63, 842, 14, 2117, 342, 267, 372, 7232, 8, 1205, 29, 1205, 14, 2856, 63, 6686, 63, 2826, 63, 9663, 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, 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 ]
yb-kim/gemV
configs/example/memtest.py
9
8083
# Copyright (c) 2006-2007 The Regents of The University of Michigan # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # 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; # neither the name of the copyright holders 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 # OWNER 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. # # Authors: Ron Dreslinski import optparse import sys import m5 from m5.objects import * parser = optparse.OptionParser() parser.add_option("-a", "--atomic", action="store_true", help="Use atomic (non-timing) mode") parser.add_option("-b", "--blocking", action="store_true", help="Use blocking caches") parser.add_option("-l", "--maxloads", metavar="N", default=0, help="Stop after N loads") parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, metavar="T", help="Stop after T ticks") # # The "tree" specification is a colon-separated list of one or more # integers. The first integer is the number of caches/testers # connected directly to main memory. The last integer in the list is # the number of testers associated with the uppermost level of memory # (L1 cache, if there are caches, or main memory if no caches). Thus # if there is only one integer, there are no caches, and the integer # specifies the number of testers connected directly to main memory. # The other integers (if any) specify the number of caches at each # level of the hierarchy between. # # Examples: # # "2:1" Two caches connected to memory with a single tester behind each # (single-level hierarchy, two testers total) # # "2:2:1" Two-level hierarchy, 2 L1s behind each of 2 L2s, 4 testers total # parser.add_option("-t", "--treespec", type="string", default="8:1", help="Colon-separated multilevel tree specification, " "see script comments for details " "[default: %default]") parser.add_option("--force-bus", action="store_true", help="Use bus between levels even with single cache") parser.add_option("-f", "--functional", type="int", default=0, metavar="PCT", help="Target percentage of functional accesses " "[default: %default]") parser.add_option("-u", "--uncacheable", type="int", default=0, metavar="PCT", help="Target percentage of uncacheable accesses " "[default: %default]") parser.add_option("--progress", type="int", default=1000, metavar="NLOADS", help="Progress message interval " "[default: %default]") parser.add_option("--sys-clock", action="store", type="string", default='1GHz', help = """Top-level clock for blocks running at system speed""") (options, args) = parser.parse_args() if args: print "Error: script doesn't take any positional arguments" sys.exit(1) block_size = 64 try: treespec = [int(x) for x in options.treespec.split(':')] numtesters = reduce(lambda x,y: x*y, treespec) except: print "Error parsing treespec option" sys.exit(1) if numtesters > block_size: print "Error: Number of testers limited to %s because of false sharing" \ % (block_size) sys.exit(1) if len(treespec) < 1: print "Error parsing treespec" sys.exit(1) # define prototype L1 cache proto_l1 = BaseCache(size = '32kB', assoc = 4, hit_latency = 1, response_latency = 1, tgts_per_mshr = 8) if options.blocking: proto_l1.mshrs = 1 else: proto_l1.mshrs = 4 # build a list of prototypes, one for each level of treespec, starting # at the end (last entry is tester objects) prototypes = [ MemTest(atomic=options.atomic, max_loads=options.maxloads, percent_functional=options.functional, percent_uncacheable=options.uncacheable, progress_interval=options.progress) ] # next comes L1 cache, if any if len(treespec) > 1: prototypes.insert(0, proto_l1) # now add additional cache levels (if any) by scaling L1 params for scale in treespec[:-2]: # clone previous level and update params prev = prototypes[0] next = prev() next.size = prev.size * scale next.latency = prev.latency * 10 next.assoc = prev.assoc * scale next.mshrs = prev.mshrs * scale prototypes.insert(0, next) # system simulated system = System(funcmem = SimpleMemory(in_addr_map = False), funcbus = NoncoherentBus(), physmem = SimpleMemory(latency = "100ns"), cache_line_size = block_size) system.voltage_domain = VoltageDomain(voltage = '1V') system.clk_domain = SrcClockDomain(clock = options.sys_clock, voltage_domain = system.voltage_domain) def make_level(spec, prototypes, attach_obj, attach_port): fanout = spec[0] parent = attach_obj # use attach obj as config parent too if len(spec) > 1 and (fanout > 1 or options.force_bus): port = getattr(attach_obj, attach_port) new_bus = CoherentBus(width=16) if (port.role == 'MASTER'): new_bus.slave = port attach_port = "master" else: new_bus.master = port attach_port = "slave" parent.cpu_side_bus = new_bus attach_obj = new_bus objs = [prototypes[0]() for i in xrange(fanout)] if len(spec) > 1: # we just built caches, more levels to go parent.cache = objs for cache in objs: cache.mem_side = getattr(attach_obj, attach_port) make_level(spec[1:], prototypes[1:], cache, "cpu_side") else: # we just built the MemTest objects parent.cpu = objs for t in objs: t.test = getattr(attach_obj, attach_port) t.functional = system.funcbus.slave make_level(treespec, prototypes, system.physmem, "port") # connect reference memory to funcbus system.funcbus.master = system.funcmem.port # ----------------------- # run simulation # ----------------------- root = Root( full_system = False, system = system ) if options.atomic: root.system.mem_mode = 'atomic' else: root.system.mem_mode = 'timing' # The system port is never used in the tester so merely connect it # to avoid problems root.system.system_port = root.system.funcbus.slave # Not much point in this being higher than the L1 latency m5.ticks.setGlobalFrequency('1ns') # instantiate configuration m5.instantiate() # simulate until program terminates exit_event = m5.simulate(options.maxtick) print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 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, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 32472, 577, 470, 472, 10728, 199, 199, 646, 8691, 199, 646, 984, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 199, 2087, 14, 525, 63, 1422, 6096, 65, 401, 4320, 10910, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 15374, 334, 2865, 13, 14639, 9, 818, 531, 199, 2087, 14, 525, 63, 1422, 6096, 66, 401, 4320, 13091, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 14592, 18014, 531, 199, 2087, 14, 525, 63, 1422, 6096, 76, 401, 4320, 988, 3640, 401, 8214, 628, 46, 401, 849, 29, 16, 12, 2116, 1720, 628, 6293, 2410, 653, 14404, 531, 199, 2087, 14, 525, 63, 1422, 6096, 77, 401, 4320, 988, 8284, 401, 730, 628, 442, 401, 849, 29, 77, 21, 14, 4261, 11763, 12, 2116, 8214, 628, 52, 401, 2116, 1720, 628, 6293, 2410, 377, 17779, 531, 199, 199, 3, 199, 3, 710, 298, 2350, 2, 8929, 365, 282, 18307, 13, 12794, 769, 402, 1373, 503, 1655, 199, 3, 9446, 14, 221, 710, 1642, 3000, 365, 314, 1329, 402, 18014, 15, 744, 878, 199, 3, 8539, 5370, 370, 2446, 4402, 14, 221, 710, 2061, 3000, 315, 314, 769, 365, 199, 3, 314, 1329, 402, 221, 744, 878, 4568, 543, 314, 7008, 2786, 2166, 402, 4402, 199, 3, 334, 44, 17, 2581, 12, 340, 2337, 787, 18014, 12, 503, 2446, 4402, 340, 949, 18014, 680, 221, 20227, 199, 3, 340, 2337, 365, 1454, 1373, 3000, 12, 2337, 787, 949, 18014, 12, 436, 314, 3000, 199, 3, 9314, 314, 1329, 402, 221, 744, 878, 8539, 5370, 370, 2446, 4402, 14, 199, 3, 710, 1163, 9446, 334, 692, 1263, 9, 4165, 314, 1329, 402, 18014, 737, 1924, 199, 3, 2166, 402, 314, 14446, 3382, 14, 199, 3, 199, 3, 6058, 26, 199, 3, 199, 3, 221, 298, 18, 26, 17, 2, 259, 16853, 18014, 8539, 370, 4402, 543, 282, 2849, 17570, 22172, 1924, 199, 3, 3698, 334, 4780, 13, 1896, 14446, 12, 2877, 221, 744, 878, 3141, 9, 199, 3, 199, 3, 221, 298, 18, 26, 18, 26, 17, 2, 221, 16853, 13, 1896, 14446, 12, 499, 491, 17, 83, 22172, 1924, 402, 499, 491, 18, 83, 12, 841, 221, 744, 878, 3141, 199, 3, 199, 2087, 14, 525, 63, 1422, 6096, 84, 401, 4320, 14635, 733, 401, 730, 628, 875, 401, 849, 628, 24, 26, 17, 401, 2116, 1720, 628, 2001, 265, 13, 12794, 3510, 1896, 3123, 8929, 12, 298, 2116, 298, 3239, 2884, 6786, 367, 2436, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 199, 2087, 14, 525, 63, 1422, 6739, 3990, 13, 5610, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 10414, 3382, 11106, 2755, 543, 2849, 2581, 531, 199, 199, 2087, 14, 525, 63, 1422, 6096, 70, 401, 4320, 15481, 401, 730, 628, 442, 401, 849, 29, 16, 12, 2116, 8214, 628, 48, 1028, 401, 2116, 1720, 628, 4277, 16327, 402, 22380, 1066, 5804, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 2087, 14, 525, 63, 1422, 6096, 85, 401, 4320, 324, 1637, 461, 401, 730, 628, 442, 401, 849, 29, 16, 12, 2116, 8214, 628, 48, 1028, 401, 2116, 1720, 628, 4277, 16327, 402, 625, 1637, 461, 1066, 5804, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 199, 2087, 14, 525, 63, 1422, 6739, 5734, 401, 730, 628, 442, 401, 849, 29, 5279, 12, 2116, 8214, 628, 46, 7405, 51, 401, 2116, 1720, 628, 11504, 1245, 6252, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 2087, 14, 525, 63, 1422, 6739, 1274, 13, 9597, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2116, 849, 534, 17, 39, 13026, 297, 2116, 1720, 275, 408, 6105, 13, 1896, 12516, 367, 5664, 3879, 737, 2656, 2116, 8112, 6141, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 1249, 26, 1362, 870, 298, 547, 26, 2884, 3181, 1133, 5452, 1263, 11333, 2368, 2, 1362, 984, 14, 2224, 8, 17, 9, 199, 199, 1457, 63, 890, 275, 5049, 199, 199, 893, 26, 1362, 14416, 733, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1511, 14 ]
[ 1898, 334, 67, 9, 8315, 13, 9488, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 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, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 32472, 577, 470, 472, 10728, 199, 199, 646, 8691, 199, 646, 984, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 199, 2087, 275, 8691, 14, 14553, 342, 199, 199, 2087, 14, 525, 63, 1422, 6096, 65, 401, 4320, 10910, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 15374, 334, 2865, 13, 14639, 9, 818, 531, 199, 2087, 14, 525, 63, 1422, 6096, 66, 401, 4320, 13091, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 14592, 18014, 531, 199, 2087, 14, 525, 63, 1422, 6096, 76, 401, 4320, 988, 3640, 401, 8214, 628, 46, 401, 849, 29, 16, 12, 2116, 1720, 628, 6293, 2410, 653, 14404, 531, 199, 2087, 14, 525, 63, 1422, 6096, 77, 401, 4320, 988, 8284, 401, 730, 628, 442, 401, 849, 29, 77, 21, 14, 4261, 11763, 12, 2116, 8214, 628, 52, 401, 2116, 1720, 628, 6293, 2410, 377, 17779, 531, 199, 199, 3, 199, 3, 710, 298, 2350, 2, 8929, 365, 282, 18307, 13, 12794, 769, 402, 1373, 503, 1655, 199, 3, 9446, 14, 221, 710, 1642, 3000, 365, 314, 1329, 402, 18014, 15, 744, 878, 199, 3, 8539, 5370, 370, 2446, 4402, 14, 221, 710, 2061, 3000, 315, 314, 769, 365, 199, 3, 314, 1329, 402, 221, 744, 878, 4568, 543, 314, 7008, 2786, 2166, 402, 4402, 199, 3, 334, 44, 17, 2581, 12, 340, 2337, 787, 18014, 12, 503, 2446, 4402, 340, 949, 18014, 680, 221, 20227, 199, 3, 340, 2337, 365, 1454, 1373, 3000, 12, 2337, 787, 949, 18014, 12, 436, 314, 3000, 199, 3, 9314, 314, 1329, 402, 221, 744, 878, 8539, 5370, 370, 2446, 4402, 14, 199, 3, 710, 1163, 9446, 334, 692, 1263, 9, 4165, 314, 1329, 402, 18014, 737, 1924, 199, 3, 2166, 402, 314, 14446, 3382, 14, 199, 3, 199, 3, 6058, 26, 199, 3, 199, 3, 221, 298, 18, 26, 17, 2, 259, 16853, 18014, 8539, 370, 4402, 543, 282, 2849, 17570, 22172, 1924, 199, 3, 3698, 334, 4780, 13, 1896, 14446, 12, 2877, 221, 744, 878, 3141, 9, 199, 3, 199, 3, 221, 298, 18, 26, 18, 26, 17, 2, 221, 16853, 13, 1896, 14446, 12, 499, 491, 17, 83, 22172, 1924, 402, 499, 491, 18, 83, 12, 841, 221, 744, 878, 3141, 199, 3, 199, 2087, 14, 525, 63, 1422, 6096, 84, 401, 4320, 14635, 733, 401, 730, 628, 875, 401, 849, 628, 24, 26, 17, 401, 2116, 1720, 628, 2001, 265, 13, 12794, 3510, 1896, 3123, 8929, 12, 298, 2116, 298, 3239, 2884, 6786, 367, 2436, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 199, 2087, 14, 525, 63, 1422, 6739, 3990, 13, 5610, 401, 1595, 628, 1617, 63, 2052, 401, 2116, 1720, 628, 6119, 10414, 3382, 11106, 2755, 543, 2849, 2581, 531, 199, 199, 2087, 14, 525, 63, 1422, 6096, 70, 401, 4320, 15481, 401, 730, 628, 442, 401, 849, 29, 16, 12, 2116, 8214, 628, 48, 1028, 401, 2116, 1720, 628, 4277, 16327, 402, 22380, 1066, 5804, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 2087, 14, 525, 63, 1422, 6096, 85, 401, 4320, 324, 1637, 461, 401, 730, 628, 442, 401, 849, 29, 16, 12, 2116, 8214, 628, 48, 1028, 401, 2116, 1720, 628, 4277, 16327, 402, 625, 1637, 461, 1066, 5804, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 199, 2087, 14, 525, 63, 1422, 6739, 5734, 401, 730, 628, 442, 401, 849, 29, 5279, 12, 2116, 8214, 628, 46, 7405, 51, 401, 2116, 1720, 628, 11504, 1245, 6252, 298, 2116, 7369, 885, 26, 450, 885, 12523, 199, 2087, 14, 525, 63, 1422, 6739, 1274, 13, 9597, 401, 1595, 628, 1617, 401, 730, 628, 875, 401, 2116, 849, 534, 17, 39, 13026, 297, 2116, 1720, 275, 408, 6105, 13, 1896, 12516, 367, 5664, 3879, 737, 2656, 2116, 8112, 6141, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 1249, 26, 1362, 870, 298, 547, 26, 2884, 3181, 1133, 5452, 1263, 11333, 2368, 2, 1362, 984, 14, 2224, 8, 17, 9, 199, 199, 1457, 63, 890, 275, 5049, 199, 199, 893, 26, 1362, 14416, 733, 275, 359, 442, 8, 88, 9, 367, 671, 315, 1511, 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,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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 ]
nishad-jobsglobal/odoo-marriot
addons/account_payment/account_payment.py
212
19161
# -*- 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/>. # ############################################################################## import logging import time from openerp.osv import fields, osv _logger = logging.getLogger(__name__) class payment_mode(osv.osv): _name= 'payment.mode' _description= 'Payment Mode' _columns = { 'name': fields.char('Name', required=True, help='Mode of Payment'), 'bank_id': fields.many2one('res.partner.bank', "Bank account", required=True,help='Bank Account for the Payment Mode'), 'journal': fields.many2one('account.journal', 'Journal', required=True, domain=[('type', 'in', ('bank','cash'))], help='Bank or Cash Journal for the Payment Mode'), 'company_id': fields.many2one('res.company', 'Company',required=True), 'partner_id':fields.related('company_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True,), } _defaults = { 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id } def suitable_bank_types(self, cr, uid, payment_code=None, context=None): """Return the codes of the bank type that are suitable for the given payment type code""" if not payment_code: return [] cr.execute(""" SELECT pb.state FROM res_partner_bank pb JOIN payment_mode pm ON (pm.bank_id = pb.id) WHERE pm.id = %s """, [payment_code]) return [x[0] for x in cr.fetchall()] def onchange_company_id (self, cr, uid, ids, company_id=False, context=None): result = {} if company_id: partner_id = self.pool.get('res.company').browse(cr, uid, company_id, context=context).partner_id.id result['partner_id'] = partner_id return {'value': result} class payment_order(osv.osv): _name = 'payment.order' _description = 'Payment Order' _rec_name = 'reference' _order = 'id desc' #dead code def get_wizard(self, type): _logger.warning("No wizard found for the payment type '%s'.", type) return None def _total(self, cursor, user, ids, name, args, context=None): if not ids: return {} res = {} for order in self.browse(cursor, user, ids, context=context): if order.line_ids: res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0) else: res[order.id] = 0.0 return res _columns = { 'date_scheduled': fields.date('Scheduled Date', states={'done':[('readonly', True)]}, help='Select a date if you have chosen Preferred Date to be fixed.'), 'reference': fields.char('Reference', required=1, states={'done': [('readonly', True)]}, copy=False), 'mode': fields.many2one('payment.mode', 'Payment Mode', select=True, required=1, states={'done': [('readonly', True)]}, help='Select the Payment Mode to be applied.'), 'state': fields.selection([ ('draft', 'Draft'), ('cancel', 'Cancelled'), ('open', 'Confirmed'), ('done', 'Done')], 'Status', select=True, copy=False, help='When an order is placed the status is \'Draft\'.\n Once the bank is confirmed the status is set to \'Confirmed\'.\n Then the order is paid the status is \'Done\'.'), 'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done': [('readonly', True)]}), 'total': fields.function(_total, string="Total", type='float'), 'user_id': fields.many2one('res.users', 'Responsible', required=True, states={'done': [('readonly', True)]}), 'date_prefered': fields.selection([ ('now', 'Directly'), ('due', 'Due date'), ('fixed', 'Fixed date') ], "Preferred Date", change_default=True, required=True, states={'done': [('readonly', True)]}, help="Choose an option for the Payment Order:'Fixed' stands for a date specified by you.'Directly' stands for the direct execution.'Due date' stands for the scheduled date of execution."), 'date_created': fields.date('Creation Date', readonly=True), 'date_done': fields.date('Execution Date', readonly=True), 'company_id': fields.related('mode', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), } _defaults = { 'user_id': lambda self,cr,uid,context: uid, 'state': 'draft', 'date_prefered': 'due', 'date_created': lambda *a: time.strftime('%Y-%m-%d'), 'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'), } def set_to_draft(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'draft'}) self.create_workflow(cr, uid, ids) return True def action_open(self, cr, uid, ids, *args): ir_seq_obj = self.pool.get('ir.sequence') for order in self.read(cr, uid, ids, ['reference']): if not order['reference']: reference = ir_seq_obj.get(cr, uid, 'payment.order') self.write(cr, uid, order['id'], {'reference':reference}) return True def set_done(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')}) self.signal_workflow(cr, uid, ids, 'done') return True def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} payment_line_obj = self.pool.get('payment.line') payment_line_ids = [] if (vals.get('date_prefered', False) == 'fixed' and not vals.get('date_scheduled', False)) or vals.get('date_scheduled', False): for order in self.browse(cr, uid, ids, context=context): for line in order.line_ids: payment_line_ids.append(line.id) payment_line_obj.write(cr, uid, payment_line_ids, {'date': vals.get('date_scheduled', False)}, context=context) elif vals.get('date_prefered', False) == 'due': vals.update({'date_scheduled': False}) for order in self.browse(cr, uid, ids, context=context): for line in order.line_ids: payment_line_obj.write(cr, uid, [line.id], {'date': line.ml_maturity_date}, context=context) elif vals.get('date_prefered', False) == 'now': vals.update({'date_scheduled': False}) for order in self.browse(cr, uid, ids, context=context): for line in order.line_ids: payment_line_ids.append(line.id) payment_line_obj.write(cr, uid, payment_line_ids, {'date': False}, context=context) return super(payment_order, self).write(cr, uid, ids, vals, context=context) class payment_line(osv.osv): _name = 'payment.line' _description = 'Payment Line' def translate(self, orig): return { "due_date": "date_maturity", "reference": "ref"}.get(orig, orig) def _info_owner(self, cr, uid, ids, name=None, args=None, context=None): result = {} for line in self.browse(cr, uid, ids, context=context): owner = line.order_id.mode.bank_id.partner_id result[line.id] = self._get_info_partner(cr, uid, owner, context=context) return result def _get_info_partner(self,cr, uid, partner_record, context=None): if not partner_record: return False st = partner_record.street or '' st1 = partner_record.street2 or '' zip = partner_record.zip or '' city = partner_record.city or '' zip_city = zip + ' ' + city cntry = partner_record.country_id and partner_record.country_id.name or '' return partner_record.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry def _info_partner(self, cr, uid, ids, name=None, args=None, context=None): result = {} for line in self.browse(cr, uid, ids, context=context): result[line.id] = False if not line.partner_id: break result[line.id] = self._get_info_partner(cr, uid, line.partner_id, context=context) return result #dead code def select_by_name(self, cr, uid, ids, name, args, context=None): if not ids: return {} partner_obj = self.pool.get('res.partner') cr.execute("""SELECT pl.id, ml.%s FROM account_move_line ml INNER JOIN payment_line pl ON (ml.id = pl.move_line_id) WHERE pl.id IN %%s"""% self.translate(name), (tuple(ids),)) res = dict(cr.fetchall()) if name == 'partner_id': partner_name = {} for p_id, p_name in partner_obj.name_get(cr, uid, filter(lambda x:x and x != 0,res.values()), context=context): partner_name[p_id] = p_name for id in ids: if id in res and partner_name: res[id] = (res[id],partner_name[res[id]]) else: res[id] = (False,False) else: for id in ids: res.setdefault(id, (False, "")) return res def _amount(self, cursor, user, ids, name, args, context=None): if not ids: return {} currency_obj = self.pool.get('res.currency') if context is None: context = {} res = {} for line in self.browse(cursor, user, ids, context=context): ctx = context.copy() ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d') res[line.id] = currency_obj.compute(cursor, user, line.currency.id, line.company_currency.id, line.amount_currency, context=ctx) return res def _get_currency(self, cr, uid, context=None): user_obj = self.pool.get('res.users') currency_obj = self.pool.get('res.currency') user = user_obj.browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.currency_id.id else: return currency_obj.search(cr, uid, [('rate', '=', 1.0)])[0] def _get_date(self, cr, uid, context=None): if context is None: context = {} payment_order_obj = self.pool.get('payment.order') date = False if context.get('order_id') and context['order_id']: order = payment_order_obj.browse(cr, uid, context['order_id'], context=context) if order.date_prefered == 'fixed': date = order.date_scheduled else: date = time.strftime('%Y-%m-%d') return date def _get_ml_inv_ref(self, cr, uid, ids, *a): res = {} for id in self.browse(cr, uid, ids): res[id.id] = False if id.move_line_id: if id.move_line_id.invoice: res[id.id] = id.move_line_id.invoice.id return res def _get_ml_maturity_date(self, cr, uid, ids, *a): res = {} for id in self.browse(cr, uid, ids): if id.move_line_id: res[id.id] = id.move_line_id.date_maturity else: res[id.id] = False return res def _get_ml_created_date(self, cr, uid, ids, *a): res = {} for id in self.browse(cr, uid, ids): if id.move_line_id: res[id.id] = id.move_line_id.date_created else: res[id.id] = False return res _columns = { 'name': fields.char('Your Reference', required=True), 'communication': fields.char('Communication', required=True, help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"), 'communication2': fields.char('Communication 2', help='The successor message of Communication.'), 'move_line_id': fields.many2one('account.move.line', 'Entry line', domain=[('reconcile_id', '=', False), ('account_id.type', '=', 'payable')], help='This Entry Line will be referred for the information of the ordering customer.'), 'amount_currency': fields.float('Amount in Partner Currency', digits=(16, 2), required=True, help='Payment amount in the partner currency'), 'currency': fields.many2one('res.currency','Partner Currency', required=True), 'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True), 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank Account'), 'order_id': fields.many2one('payment.order', 'Order', required=True, ondelete='cascade', select=True), 'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'), 'amount': fields.function(_amount, string='Amount in Company Currency', type='float', help='Payment amount in the company currency'), 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date", type='date', help="Invoice Effective Date"), 'ml_maturity_date': fields.function(_get_ml_maturity_date, type='date', string='Due Date'), 'ml_inv_ref': fields.function(_get_ml_inv_ref, type='many2one', relation='account.invoice', string='Invoice Ref.'), 'info_owner': fields.function(_info_owner, string="Owner Account", type="text", help='Address of the Main Partner'), 'info_partner': fields.function(_info_partner, string="Destination Account", type="text", help='Address of the Ordering Customer.'), 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"), 'create_date': fields.datetime('Created', readonly=True), 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True), 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line'), 'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), } _defaults = { 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence' ).get(cursor, user, 'payment.line'), 'state': 'normal', 'currency': _get_currency, 'company_currency': _get_currency, 'date': _get_date, } _sql_constraints = [ ('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'), ] def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_scheduled, currency=False, company_currency=False, context=None): data = {} move_line_obj = self.pool.get('account.move.line') data['amount_currency'] = data['communication'] = data['partner_id'] = data['bank_id'] = data['amount'] = False if move_line_id: line = move_line_obj.browse(cr, uid, move_line_id, context=context) data['amount_currency'] = line.amount_residual_currency res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, company_currency, context) if res: data['amount'] = res['value']['amount'] data['partner_id'] = line.partner_id.id temp = line.currency_id and line.currency_id.id or False if not temp: if line.invoice: data['currency'] = line.invoice.currency_id.id else: data['currency'] = temp # calling onchange of partner and updating data dictionary temp_dict = self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type) data.update(temp_dict['value']) data['communication'] = line.ref if date_prefered == 'now': #no payment date => immediate payment data['date'] = False elif date_prefered == 'due': data['date'] = line.date_maturity elif date_prefered == 'fixed': data['date'] = date_scheduled return {'value': data} def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None): if (not amount) or (not cmpny_currency): return {'value': {'amount': False}} res = {} currency_obj = self.pool.get('res.currency') company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency, amount) res['amount'] = company_amount return {'value': res} def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None): data = {} partner_obj = self.pool.get('res.partner') payment_mode_obj = self.pool.get('payment.mode') data['info_partner'] = data['bank_id'] = False if partner_id: part_obj = partner_obj.browse(cr, uid, partner_id, context=context) partner = part_obj.name or '' data['info_partner'] = self._get_info_partner(cr, uid, part_obj, context=context) if part_obj.bank_ids and payment_type: bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, context=context) for bank in part_obj.bank_ids: if bank.state in bank_type: data['bank_id'] = bank.id break return {'value': data} def fields_get(self, cr, uid, fields=None, context=None, write_access=True, attributes=None): res = super(payment_line, self).fields_get(cr, uid, fields, context, write_access, attributes) if 'communication2' in res: res['communication2'].setdefault('states', {}) res['communication2']['states']['structured'] = [('readonly', True)] res['communication2']['states']['normal'] = [('readonly', False)] return res # 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, 2050, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 11628, 63, 632, 8, 4795, 14, 4795, 304, 272, 485, 354, 29, 283, 7948, 14, 632, 7, 272, 485, 1802, 29, 283, 22374, 4900, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 1415, 29, 549, 12, 1720, 534, 1385, 402, 25523, 659, 267, 283, 9860, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 14, 9860, 297, 298, 14814, 2933, 401, 288, 1415, 29, 549, 12, 3437, 534, 14814, 9973, 367, 314, 25523, 4900, 659, 267, 283, 7067, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 7067, 297, 283, 25909, 297, 1415, 29, 549, 12, 288, 2881, 11699, 466, 297, 283, 262, 297, 661, 9860, 1673, 20084, 1333, 467, 1720, 534, 14814, 503, 445, 1119, 22142, 367, 314, 25523, 4900, 659, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 2427, 29, 549, 395, 267, 283, 3899, 63, 344, 356, 955, 14, 2407, 360, 4627, 63, 344, 1673, 3899, 63, 344, 297, 466, 534, 3479, 18, 368, 297, 5690, 534, 470, 14, 3899, 297, 875, 534, 24120, 297, 1617, 29, 549, 4706, 339, 789, 272, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 2400, 291, 12, 1556, 12, 1535, 12, 67, 26, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 286, 680, 4627, 63, 344, 14, 344, 272, 789, 339, 347, 11233, 63, 9860, 63, 1313, 8, 277, 12, 2467, 12, 1747, 12, 11628, 63, 600, 29, 403, 12, 1067, 29, 403, 304, 267, 408, 1767, 314, 9479, 402, 314, 16297, 730, 626, 787, 11233, 267, 367, 314, 1627, 11628, 730, 1233, 624, 267, 340, 440, 11628, 63, 600, 26, 288, 372, 942, 267, 2467, 14, 2526, 4852, 10468, 10446, 14, 929, 288, 4442, 522, 63, 3899, 63, 9860, 10446, 288, 10593, 11628, 63, 632, 14207, 5258, 334, 7073, 14, 9860, 63, 344, 275, 10446, 14, 344, 9, 288, 6038, 14207, 14, 344, 275, 450, 83, 10327, 359, 7948, 63, 600, 566, 267, 372, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 347, 20258, 63, 4627, 63, 344, 334, 277, 12, 2467, 12, 1747, 12, 2762, 12, 7233, 63, 344, 29, 797, 12, 1067, 29, 403, 304, 267, 754, 275, 1052, 267, 340, 7233, 63, 344, 26, 288, 5854, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 4627, 1959, 4570, 8, 1556, 12, 1747, 12, 7233, 63, 344, 12, 1067, 29, 1100, 680, 3899, 63, 344, 14, 344, 288, 754, 459, 3899, 63, 344, 418, 275, 5854, 63, 344, 267, 372, 791, 585, 356, 754, 93, 4388, 199, 533, 11628, 63, 1648, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 7948, 14, 1648, 7, 272, 485, 1802, 275, 283, 22374, 9240, 7, 272, 485, 2761, 63, 354, 275, 283, 4443, 7, 272, 485, 1648, 275, 283, 344, 4328, 7, 339, 327, 10957, 1233, 272, 347, 664, 63, 9819, 8, 277, 12, 730, 304, 267, 485, 2921, 14, 3764, 480, 1944, 12262, 1911, 367, 314, 11628, 730, 1543, 83, 30532, 730, 9, 267, 372, 488, 339, 347, 485, 2923, 8, 277, 12, 3920, 12, 922, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 340, 440, 2762, 26, 288, 372, 1052, 267, 522, 275, 1052, 267, 367, 1865, 315, 291, 14, 4570, 8, 3937, 12, 922, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 1865, 14, 604, 63, 1580, 26, 355, 522, 59, 1648, 14, 344, 61, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 435, 612, 14, 4606, 12, 1865, 14, 604, 63, 1580, 12, 378, 14, 16, 9, 288, 587, 26, 355, 522, 59, 1648, 14, 344, 61, 275, 378, 14, 16, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 602, 63, 19274, 356, 1504, 14, 602, 360, 15535, 68, 6148, 297, 6363, 3713, 4456, 30536, 6753, 297, 715, 26804, 1720, 534, 5446, 282, 1434, 340, 1265, 1172, 12414, 510, 1121, 7165, 6148, 370, 506, 6317, 8038, 267, 283, 4443, 356, 1504, 14, 1560, 360, 5083, 297, 1415, 29, 17, 12, 6363, 3713, 4456, 356, 4274, 6753, 297, 715, 26804, 1331, 29, 797, 395, 267, 283, 632, 356, 1504, 14, 3479, 18, 368, 360, 7948, 14, 632, 297, 283, 22374, 4900, 297, 3504, 29, 549, 12, 1415, 29, 17, 12, 6363, 3713, 4456, 356, 4274, 6753, 297, 715, 26804, 1720, 534, 5446, 314, 25523, 4900, 370, 506, 6781, 8038, 267, 283, 929, 356, 1504, 14, 5592, 779, 288, 661, 7185, 297, 283, 18332, 659, 288, 661, 6406, 297, 283, 22127, 659, 288, 661, 1490, 297, 283, 714, 11451, 659, 288, 661, 4456, 297 ]
[ 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, 2050, 199, 646, 900, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 11628, 63, 632, 8, 4795, 14, 4795, 304, 272, 485, 354, 29, 283, 7948, 14, 632, 7, 272, 485, 1802, 29, 283, 22374, 4900, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 985, 297, 1415, 29, 549, 12, 1720, 534, 1385, 402, 25523, 659, 267, 283, 9860, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 14, 9860, 297, 298, 14814, 2933, 401, 288, 1415, 29, 549, 12, 3437, 534, 14814, 9973, 367, 314, 25523, 4900, 659, 267, 283, 7067, 356, 1504, 14, 3479, 18, 368, 360, 2048, 14, 7067, 297, 283, 25909, 297, 1415, 29, 549, 12, 288, 2881, 11699, 466, 297, 283, 262, 297, 661, 9860, 1673, 20084, 1333, 467, 1720, 534, 14814, 503, 445, 1119, 22142, 367, 314, 25523, 4900, 659, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 2427, 29, 549, 395, 267, 283, 3899, 63, 344, 356, 955, 14, 2407, 360, 4627, 63, 344, 1673, 3899, 63, 344, 297, 466, 534, 3479, 18, 368, 297, 5690, 534, 470, 14, 3899, 297, 875, 534, 24120, 297, 1617, 29, 549, 4706, 339, 789, 272, 485, 4322, 275, 469, 267, 283, 4627, 63, 344, 356, 2400, 291, 12, 1556, 12, 1535, 12, 67, 26, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 286, 680, 4627, 63, 344, 14, 344, 272, 789, 339, 347, 11233, 63, 9860, 63, 1313, 8, 277, 12, 2467, 12, 1747, 12, 11628, 63, 600, 29, 403, 12, 1067, 29, 403, 304, 267, 408, 1767, 314, 9479, 402, 314, 16297, 730, 626, 787, 11233, 267, 367, 314, 1627, 11628, 730, 1233, 624, 267, 340, 440, 11628, 63, 600, 26, 288, 372, 942, 267, 2467, 14, 2526, 4852, 10468, 10446, 14, 929, 288, 4442, 522, 63, 3899, 63, 9860, 10446, 288, 10593, 11628, 63, 632, 14207, 5258, 334, 7073, 14, 9860, 63, 344, 275, 10446, 14, 344, 9, 288, 6038, 14207, 14, 344, 275, 450, 83, 10327, 359, 7948, 63, 600, 566, 267, 372, 359, 88, 59, 16, 61, 367, 671, 315, 2467, 14, 10174, 5106, 339, 347, 20258, 63, 4627, 63, 344, 334, 277, 12, 2467, 12, 1747, 12, 2762, 12, 7233, 63, 344, 29, 797, 12, 1067, 29, 403, 304, 267, 754, 275, 1052, 267, 340, 7233, 63, 344, 26, 288, 5854, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 4627, 1959, 4570, 8, 1556, 12, 1747, 12, 7233, 63, 344, 12, 1067, 29, 1100, 680, 3899, 63, 344, 14, 344, 288, 754, 459, 3899, 63, 344, 418, 275, 5854, 63, 344, 267, 372, 791, 585, 356, 754, 93, 4388, 199, 533, 11628, 63, 1648, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 283, 7948, 14, 1648, 7, 272, 485, 1802, 275, 283, 22374, 9240, 7, 272, 485, 2761, 63, 354, 275, 283, 4443, 7, 272, 485, 1648, 275, 283, 344, 4328, 7, 339, 327, 10957, 1233, 272, 347, 664, 63, 9819, 8, 277, 12, 730, 304, 267, 485, 2921, 14, 3764, 480, 1944, 12262, 1911, 367, 314, 11628, 730, 1543, 83, 30532, 730, 9, 267, 372, 488, 339, 347, 485, 2923, 8, 277, 12, 3920, 12, 922, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 340, 440, 2762, 26, 288, 372, 1052, 267, 522, 275, 1052, 267, 367, 1865, 315, 291, 14, 4570, 8, 3937, 12, 922, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 1865, 14, 604, 63, 1580, 26, 355, 522, 59, 1648, 14, 344, 61, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 435, 612, 14, 4606, 12, 1865, 14, 604, 63, 1580, 12, 378, 14, 16, 9, 288, 587, 26, 355, 522, 59, 1648, 14, 344, 61, 275, 378, 14, 16, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 602, 63, 19274, 356, 1504, 14, 602, 360, 15535, 68, 6148, 297, 6363, 3713, 4456, 30536, 6753, 297, 715, 26804, 1720, 534, 5446, 282, 1434, 340, 1265, 1172, 12414, 510, 1121, 7165, 6148, 370, 506, 6317, 8038, 267, 283, 4443, 356, 1504, 14, 1560, 360, 5083, 297, 1415, 29, 17, 12, 6363, 3713, 4456, 356, 4274, 6753, 297, 715, 26804, 1331, 29, 797, 395, 267, 283, 632, 356, 1504, 14, 3479, 18, 368, 360, 7948, 14, 632, 297, 283, 22374, 4900, 297, 3504, 29, 549, 12, 1415, 29, 17, 12, 6363, 3713, 4456, 356, 4274, 6753, 297, 715, 26804, 1720, 534, 5446, 314, 25523, 4900, 370, 506, 6781, 8038, 267, 283, 929, 356, 1504, 14, 5592, 779, 288, 661, 7185, 297, 283, 18332, 659, 288, 661, 6406, 297, 283, 22127, 659, 288, 661, 1490, 297, 283, 714, 11451, 659, 288, 661, 4456, 297, 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, 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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 ]
chalasr/Flask-P2P
venv/lib/python2.7/site-packages/jinja2/parser.py
637
35186
# -*- coding: utf-8 -*- """ jinja2.parser ~~~~~~~~~~~~~ Implements the template parser. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ from jinja2 import nodes from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError from jinja2.lexer import describe_token, describe_token_expr from jinja2._compat import next, imap #: statements that callinto _statement_keywords = frozenset(['for', 'if', 'block', 'extends', 'print', 'macro', 'include', 'from', 'import', 'set']) _compare_operators = frozenset(['eq', 'ne', 'lt', 'lteq', 'gt', 'gteq']) class Parser(object): """This is the central parsing class Jinja2 uses. It's passed to extensions and can be used to parse expressions or statements. """ def __init__(self, environment, source, name=None, filename=None, state=None): self.environment = environment self.stream = environment._tokenize(source, name, filename, state) self.name = name self.filename = filename self.closed = False self.extensions = {} for extension in environment.iter_extensions(): for tag in extension.tags: self.extensions[tag] = extension.parse self._last_identifier = 0 self._tag_stack = [] self._end_token_stack = [] def fail(self, msg, lineno=None, exc=TemplateSyntaxError): """Convenience method that raises `exc` with the message, passed line number or last line number as well as the current name and filename. """ if lineno is None: lineno = self.stream.current.lineno raise exc(msg, lineno, self.name, self.filename) def _fail_ut_eof(self, name, end_token_stack, lineno): expected = [] for exprs in end_token_stack: expected.extend(imap(describe_token_expr, exprs)) if end_token_stack: currently_looking = ' or '.join( "'%s'" % describe_token_expr(expr) for expr in end_token_stack[-1]) else: currently_looking = None if name is None: message = ['Unexpected end of template.'] else: message = ['Encountered unknown tag \'%s\'.' % name] if currently_looking: if name is not None and name in expected: message.append('You probably made a nesting mistake. Jinja ' 'is expecting this tag, but currently looking ' 'for %s.' % currently_looking) else: message.append('Jinja was looking for the following tags: ' '%s.' % currently_looking) if self._tag_stack: message.append('The innermost block that needs to be ' 'closed is \'%s\'.' % self._tag_stack[-1]) self.fail(' '.join(message), lineno) def fail_unknown_tag(self, name, lineno=None): """Called if the parser encounters an unknown tag. Tries to fail with a human readable error message that could help to identify the problem. """ return self._fail_ut_eof(name, self._end_token_stack, lineno) def fail_eof(self, end_tokens=None, lineno=None): """Like fail_unknown_tag but for end of template situations.""" stack = list(self._end_token_stack) if end_tokens is not None: stack.append(end_tokens) return self._fail_ut_eof(None, stack, lineno) def is_tuple_end(self, extra_end_rules=None): """Are we at the end of a tuple?""" if self.stream.current.type in ('variable_end', 'block_end', 'rparen'): return True elif extra_end_rules is not None: return self.stream.current.test_any(extra_end_rules) return False def free_identifier(self, lineno=None): """Return a new free identifier as :class:`~jinja2.nodes.InternalName`.""" self._last_identifier += 1 rv = object.__new__(nodes.InternalName) nodes.Node.__init__(rv, 'fi%d' % self._last_identifier, lineno=lineno) return rv def parse_statement(self): """Parse a single statement.""" token = self.stream.current if token.type != 'name': self.fail('tag name expected', token.lineno) self._tag_stack.append(token.value) pop_tag = True try: if token.value in _statement_keywords: return getattr(self, 'parse_' + self.stream.current.value)() if token.value == 'call': return self.parse_call_block() if token.value == 'filter': return self.parse_filter_block() ext = self.extensions.get(token.value) if ext is not None: return ext(self) # did not work out, remove the token we pushed by accident # from the stack so that the unknown tag fail function can # produce a proper error message. self._tag_stack.pop() pop_tag = False self.fail_unknown_tag(token.value, token.lineno) finally: if pop_tag: self._tag_stack.pop() def parse_statements(self, end_tokens, drop_needle=False): """Parse multiple statements into a list until one of the end tokens is reached. This is used to parse the body of statements as it also parses template data if appropriate. The parser checks first if the current token is a colon and skips it if there is one. Then it checks for the block end and parses until if one of the `end_tokens` is reached. Per default the active token in the stream at the end of the call is the matched end token. If this is not wanted `drop_needle` can be set to `True` and the end token is removed. """ # the first token may be a colon for python compatibility self.stream.skip_if('colon') # in the future it would be possible to add whole code sections # by adding some sort of end of statement token and parsing those here. self.stream.expect('block_end') result = self.subparse(end_tokens) # we reached the end of the template too early, the subparser # does not check for this, so we do that now if self.stream.current.type == 'eof': self.fail_eof(end_tokens) if drop_needle: next(self.stream) return result def parse_set(self): """Parse an assign statement.""" lineno = next(self.stream).lineno target = self.parse_assign_target() self.stream.expect('assign') expr = self.parse_tuple() return nodes.Assign(target, expr, lineno=lineno) def parse_for(self): """Parse a for loop.""" lineno = self.stream.expect('name:for').lineno target = self.parse_assign_target(extra_end_rules=('name:in',)) self.stream.expect('name:in') iter = self.parse_tuple(with_condexpr=False, extra_end_rules=('name:recursive',)) test = None if self.stream.skip_if('name:if'): test = self.parse_expression() recursive = self.stream.skip_if('name:recursive') body = self.parse_statements(('name:endfor', 'name:else')) if next(self.stream).value == 'endfor': else_ = [] else: else_ = self.parse_statements(('name:endfor',), drop_needle=True) return nodes.For(target, iter, body, else_, test, recursive, lineno=lineno) def parse_if(self): """Parse an if construct.""" node = result = nodes.If(lineno=self.stream.expect('name:if').lineno) while 1: node.test = self.parse_tuple(with_condexpr=False) node.body = self.parse_statements(('name:elif', 'name:else', 'name:endif')) token = next(self.stream) if token.test('name:elif'): new_node = nodes.If(lineno=self.stream.current.lineno) node.else_ = [new_node] node = new_node continue elif token.test('name:else'): node.else_ = self.parse_statements(('name:endif',), drop_needle=True) else: node.else_ = [] break return result def parse_block(self): node = nodes.Block(lineno=next(self.stream).lineno) node.name = self.stream.expect('name').value node.scoped = self.stream.skip_if('name:scoped') # common problem people encounter when switching from django # to jinja. we do not support hyphens in block names, so let's # raise a nicer error message in that case. if self.stream.current.type == 'sub': self.fail('Block names in Jinja have to be valid Python ' 'identifiers and may not contain hyphens, use an ' 'underscore instead.') node.body = self.parse_statements(('name:endblock',), drop_needle=True) self.stream.skip_if('name:' + node.name) return node def parse_extends(self): node = nodes.Extends(lineno=next(self.stream).lineno) node.template = self.parse_expression() return node def parse_import_context(self, node, default): if self.stream.current.test_any('name:with', 'name:without') and \ self.stream.look().test('name:context'): node.with_context = next(self.stream).value == 'with' self.stream.skip() else: node.with_context = default return node def parse_include(self): node = nodes.Include(lineno=next(self.stream).lineno) node.template = self.parse_expression() if self.stream.current.test('name:ignore') and \ self.stream.look().test('name:missing'): node.ignore_missing = True self.stream.skip(2) else: node.ignore_missing = False return self.parse_import_context(node, True) def parse_import(self): node = nodes.Import(lineno=next(self.stream).lineno) node.template = self.parse_expression() self.stream.expect('name:as') node.target = self.parse_assign_target(name_only=True).name return self.parse_import_context(node, False) def parse_from(self): node = nodes.FromImport(lineno=next(self.stream).lineno) node.template = self.parse_expression() self.stream.expect('name:import') node.names = [] def parse_context(): if self.stream.current.value in ('with', 'without') and \ self.stream.look().test('name:context'): node.with_context = next(self.stream).value == 'with' self.stream.skip() return True return False while 1: if node.names: self.stream.expect('comma') if self.stream.current.type == 'name': if parse_context(): break target = self.parse_assign_target(name_only=True) if target.name.startswith('_'): self.fail('names starting with an underline can not ' 'be imported', target.lineno, exc=TemplateAssertionError) if self.stream.skip_if('name:as'): alias = self.parse_assign_target(name_only=True) node.names.append((target.name, alias.name)) else: node.names.append(target.name) if parse_context() or self.stream.current.type != 'comma': break else: break if not hasattr(node, 'with_context'): node.with_context = False self.stream.skip_if('comma') return node def parse_signature(self, node): node.args = args = [] node.defaults = defaults = [] self.stream.expect('lparen') while self.stream.current.type != 'rparen': if args: self.stream.expect('comma') arg = self.parse_assign_target(name_only=True) arg.set_ctx('param') if self.stream.skip_if('assign'): defaults.append(self.parse_expression()) args.append(arg) self.stream.expect('rparen') def parse_call_block(self): node = nodes.CallBlock(lineno=next(self.stream).lineno) if self.stream.current.type == 'lparen': self.parse_signature(node) else: node.args = [] node.defaults = [] node.call = self.parse_expression() if not isinstance(node.call, nodes.Call): self.fail('expected call', node.lineno) node.body = self.parse_statements(('name:endcall',), drop_needle=True) return node def parse_filter_block(self): node = nodes.FilterBlock(lineno=next(self.stream).lineno) node.filter = self.parse_filter(None, start_inline=True) node.body = self.parse_statements(('name:endfilter',), drop_needle=True) return node def parse_macro(self): node = nodes.Macro(lineno=next(self.stream).lineno) node.name = self.parse_assign_target(name_only=True).name self.parse_signature(node) node.body = self.parse_statements(('name:endmacro',), drop_needle=True) return node def parse_print(self): node = nodes.Output(lineno=next(self.stream).lineno) node.nodes = [] while self.stream.current.type != 'block_end': if node.nodes: self.stream.expect('comma') node.nodes.append(self.parse_expression()) return node def parse_assign_target(self, with_tuple=True, name_only=False, extra_end_rules=None): """Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are wanted `name_only` can be set to `True`. The `extra_end_rules` parameter is forwarded to the tuple parsing function. """ if name_only: token = self.stream.expect('name') target = nodes.Name(token.value, 'store', lineno=token.lineno) else: if with_tuple: target = self.parse_tuple(simplified=True, extra_end_rules=extra_end_rules) else: target = self.parse_primary() target.set_ctx('store') if not target.can_assign(): self.fail('can\'t assign to %r' % target.__class__. __name__.lower(), target.lineno) return target def parse_expression(self, with_condexpr=True): """Parse an expression. Per default all expressions are parsed, if the optional `with_condexpr` parameter is set to `False` conditional expressions are not parsed. """ if with_condexpr: return self.parse_condexpr() return self.parse_or() def parse_condexpr(self): lineno = self.stream.current.lineno expr1 = self.parse_or() while self.stream.skip_if('name:if'): expr2 = self.parse_or() if self.stream.skip_if('name:else'): expr3 = self.parse_condexpr() else: expr3 = None expr1 = nodes.CondExpr(expr2, expr1, expr3, lineno=lineno) lineno = self.stream.current.lineno return expr1 def parse_or(self): lineno = self.stream.current.lineno left = self.parse_and() while self.stream.skip_if('name:or'): right = self.parse_and() left = nodes.Or(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_and(self): lineno = self.stream.current.lineno left = self.parse_not() while self.stream.skip_if('name:and'): right = self.parse_not() left = nodes.And(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_not(self): if self.stream.current.test('name:not'): lineno = next(self.stream).lineno return nodes.Not(self.parse_not(), lineno=lineno) return self.parse_compare() def parse_compare(self): lineno = self.stream.current.lineno expr = self.parse_add() ops = [] while 1: token_type = self.stream.current.type if token_type in _compare_operators: next(self.stream) ops.append(nodes.Operand(token_type, self.parse_add())) elif self.stream.skip_if('name:in'): ops.append(nodes.Operand('in', self.parse_add())) elif self.stream.current.test('name:not') and \ self.stream.look().test('name:in'): self.stream.skip(2) ops.append(nodes.Operand('notin', self.parse_add())) else: break lineno = self.stream.current.lineno if not ops: return expr return nodes.Compare(expr, ops, lineno=lineno) def parse_add(self): lineno = self.stream.current.lineno left = self.parse_sub() while self.stream.current.type == 'add': next(self.stream) right = self.parse_sub() left = nodes.Add(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_sub(self): lineno = self.stream.current.lineno left = self.parse_concat() while self.stream.current.type == 'sub': next(self.stream) right = self.parse_concat() left = nodes.Sub(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_concat(self): lineno = self.stream.current.lineno args = [self.parse_mul()] while self.stream.current.type == 'tilde': next(self.stream) args.append(self.parse_mul()) if len(args) == 1: return args[0] return nodes.Concat(args, lineno=lineno) def parse_mul(self): lineno = self.stream.current.lineno left = self.parse_div() while self.stream.current.type == 'mul': next(self.stream) right = self.parse_div() left = nodes.Mul(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_div(self): lineno = self.stream.current.lineno left = self.parse_floordiv() while self.stream.current.type == 'div': next(self.stream) right = self.parse_floordiv() left = nodes.Div(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_floordiv(self): lineno = self.stream.current.lineno left = self.parse_mod() while self.stream.current.type == 'floordiv': next(self.stream) right = self.parse_mod() left = nodes.FloorDiv(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_mod(self): lineno = self.stream.current.lineno left = self.parse_pow() while self.stream.current.type == 'mod': next(self.stream) right = self.parse_pow() left = nodes.Mod(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_pow(self): lineno = self.stream.current.lineno left = self.parse_unary() while self.stream.current.type == 'pow': next(self.stream) right = self.parse_unary() left = nodes.Pow(left, right, lineno=lineno) lineno = self.stream.current.lineno return left def parse_unary(self, with_filter=True): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type == 'sub': next(self.stream) node = nodes.Neg(self.parse_unary(False), lineno=lineno) elif token_type == 'add': next(self.stream) node = nodes.Pos(self.parse_unary(False), lineno=lineno) else: node = self.parse_primary() node = self.parse_postfix(node) if with_filter: node = self.parse_filter_expr(node) return node def parse_primary(self): token = self.stream.current if token.type == 'name': if token.value in ('true', 'false', 'True', 'False'): node = nodes.Const(token.value in ('true', 'True'), lineno=token.lineno) elif token.value in ('none', 'None'): node = nodes.Const(None, lineno=token.lineno) else: node = nodes.Name(token.value, 'load', lineno=token.lineno) next(self.stream) elif token.type == 'string': next(self.stream) buf = [token.value] lineno = token.lineno while self.stream.current.type == 'string': buf.append(self.stream.current.value) next(self.stream) node = nodes.Const(''.join(buf), lineno=lineno) elif token.type in ('integer', 'float'): next(self.stream) node = nodes.Const(token.value, lineno=token.lineno) elif token.type == 'lparen': next(self.stream) node = self.parse_tuple(explicit_parentheses=True) self.stream.expect('rparen') elif token.type == 'lbracket': node = self.parse_list() elif token.type == 'lbrace': node = self.parse_dict() else: self.fail("unexpected '%s'" % describe_token(token), token.lineno) return node def parse_tuple(self, simplified=False, with_condexpr=True, extra_end_rules=None, explicit_parentheses=False): """Works like `parse_expression` but if multiple expressions are delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created. This method could also return a regular expression instead of a tuple if no commas where found. The default parsing mode is a full tuple. If `simplified` is `True` only names and literals are parsed. The `no_condexpr` parameter is forwarded to :meth:`parse_expression`. Because tuples do not require delimiters and may end in a bogus comma an extra hint is needed that marks the end of a tuple. For example for loops support tuples between `for` and `in`. In that case the `extra_end_rules` is set to ``['name:in']``. `explicit_parentheses` is true if the parsing was triggered by an expression in parentheses. This is used to figure out if an empty tuple is a valid expression or not. """ lineno = self.stream.current.lineno if simplified: parse = self.parse_primary elif with_condexpr: parse = self.parse_expression else: parse = lambda: self.parse_expression(with_condexpr=False) args = [] is_tuple = False while 1: if args: self.stream.expect('comma') if self.is_tuple_end(extra_end_rules): break args.append(parse()) if self.stream.current.type == 'comma': is_tuple = True else: break lineno = self.stream.current.lineno if not is_tuple: if args: return args[0] # if we don't have explicit parentheses, an empty tuple is # not a valid expression. This would mean nothing (literally # nothing) in the spot of an expression would be an empty # tuple. if not explicit_parentheses: self.fail('Expected an expression, got \'%s\'' % describe_token(self.stream.current)) return nodes.Tuple(args, 'load', lineno=lineno) def parse_list(self): token = self.stream.expect('lbracket') items = [] while self.stream.current.type != 'rbracket': if items: self.stream.expect('comma') if self.stream.current.type == 'rbracket': break items.append(self.parse_expression()) self.stream.expect('rbracket') return nodes.List(items, lineno=token.lineno) def parse_dict(self): token = self.stream.expect('lbrace') items = [] while self.stream.current.type != 'rbrace': if items: self.stream.expect('comma') if self.stream.current.type == 'rbrace': break key = self.parse_expression() self.stream.expect('colon') value = self.parse_expression() items.append(nodes.Pair(key, value, lineno=key.lineno)) self.stream.expect('rbrace') return nodes.Dict(items, lineno=token.lineno) def parse_postfix(self, node): while 1: token_type = self.stream.current.type if token_type == 'dot' or token_type == 'lbracket': node = self.parse_subscript(node) # calls are valid both after postfix expressions (getattr # and getitem) as well as filters and tests elif token_type == 'lparen': node = self.parse_call(node) else: break return node def parse_filter_expr(self, node): while 1: token_type = self.stream.current.type if token_type == 'pipe': node = self.parse_filter(node) elif token_type == 'name' and self.stream.current.value == 'is': node = self.parse_test(node) # calls are valid both after postfix expressions (getattr # and getitem) as well as filters and tests elif token_type == 'lparen': node = self.parse_call(node) else: break return node def parse_subscript(self, node): token = next(self.stream) if token.type == 'dot': attr_token = self.stream.current next(self.stream) if attr_token.type == 'name': return nodes.Getattr(node, attr_token.value, 'load', lineno=token.lineno) elif attr_token.type != 'integer': self.fail('expected name or number', attr_token.lineno) arg = nodes.Const(attr_token.value, lineno=attr_token.lineno) return nodes.Getitem(node, arg, 'load', lineno=token.lineno) if token.type == 'lbracket': args = [] while self.stream.current.type != 'rbracket': if args: self.stream.expect('comma') args.append(self.parse_subscribed()) self.stream.expect('rbracket') if len(args) == 1: arg = args[0] else: arg = nodes.Tuple(args, 'load', lineno=token.lineno) return nodes.Getitem(node, arg, 'load', lineno=token.lineno) self.fail('expected subscript expression', self.lineno) def parse_subscribed(self): lineno = self.stream.current.lineno if self.stream.current.type == 'colon': next(self.stream) args = [None] else: node = self.parse_expression() if self.stream.current.type != 'colon': return node next(self.stream) args = [node] if self.stream.current.type == 'colon': args.append(None) elif self.stream.current.type not in ('rbracket', 'comma'): args.append(self.parse_expression()) else: args.append(None) if self.stream.current.type == 'colon': next(self.stream) if self.stream.current.type not in ('rbracket', 'comma'): args.append(self.parse_expression()) else: args.append(None) else: args.append(None) return nodes.Slice(lineno=lineno, *args) def parse_call(self, node): token = self.stream.expect('lparen') args = [] kwargs = [] dyn_args = dyn_kwargs = None require_comma = False def ensure(expr): if not expr: self.fail('invalid syntax for function call expression', token.lineno) while self.stream.current.type != 'rparen': if require_comma: self.stream.expect('comma') # support for trailing comma if self.stream.current.type == 'rparen': break if self.stream.current.type == 'mul': ensure(dyn_args is None and dyn_kwargs is None) next(self.stream) dyn_args = self.parse_expression() elif self.stream.current.type == 'pow': ensure(dyn_kwargs is None) next(self.stream) dyn_kwargs = self.parse_expression() else: ensure(dyn_args is None and dyn_kwargs is None) if self.stream.current.type == 'name' and \ self.stream.look().type == 'assign': key = self.stream.current.value self.stream.skip(2) value = self.parse_expression() kwargs.append(nodes.Keyword(key, value, lineno=value.lineno)) else: ensure(not kwargs) args.append(self.parse_expression()) require_comma = True self.stream.expect('rparen') if node is None: return args, kwargs, dyn_args, dyn_kwargs return nodes.Call(node, args, kwargs, dyn_args, dyn_kwargs, lineno=token.lineno) def parse_filter(self, node, start_inline=False): while self.stream.current.type == 'pipe' or start_inline: if not start_inline: next(self.stream) token = self.stream.expect('name') name = token.value while self.stream.current.type == 'dot': next(self.stream) name += '.' + self.stream.expect('name').value if self.stream.current.type == 'lparen': args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None) else: args = [] kwargs = [] dyn_args = dyn_kwargs = None node = nodes.Filter(node, name, args, kwargs, dyn_args, dyn_kwargs, lineno=token.lineno) start_inline = False return node def parse_test(self, node): token = next(self.stream) if self.stream.current.test('name:not'): next(self.stream) negated = True else: negated = False name = self.stream.expect('name').value while self.stream.current.type == 'dot': next(self.stream) name += '.' + self.stream.expect('name').value dyn_args = dyn_kwargs = None kwargs = [] if self.stream.current.type == 'lparen': args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None) elif self.stream.current.type in ('name', 'string', 'integer', 'float', 'lparen', 'lbracket', 'lbrace') and not \ self.stream.current.test_any('name:else', 'name:or', 'name:and'): if self.stream.current.test('name:is'): self.fail('You cannot chain multiple tests with is') args = [self.parse_expression()] else: args = [] node = nodes.Test(node, name, args, kwargs, dyn_args, dyn_kwargs, lineno=token.lineno) if negated: node = nodes.Not(node, lineno=token.lineno) return node def subparse(self, end_tokens=None): body = [] data_buffer = [] add_data = data_buffer.append if end_tokens is not None: self._end_token_stack.append(end_tokens) def flush_data(): if data_buffer: lineno = data_buffer[0].lineno body.append(nodes.Output(data_buffer[:], lineno=lineno)) del data_buffer[:] try: while self.stream: token = self.stream.current if token.type == 'data': if token.value: add_data(nodes.TemplateData(token.value, lineno=token.lineno)) next(self.stream) elif token.type == 'variable_begin': next(self.stream) add_data(self.parse_tuple(with_condexpr=True)) self.stream.expect('variable_end') elif token.type == 'block_begin': flush_data() next(self.stream) if end_tokens is not None and \ self.stream.current.test_any(*end_tokens): return body rv = self.parse_statement() if isinstance(rv, list): body.extend(rv) else: body.append(rv) self.stream.expect('block_end') else: raise AssertionError('internal parsing error') flush_data() finally: if end_tokens is not None: self._end_token_stack.pop() return body def parse(self): """Parse the whole template into a `Template` node.""" result = nodes.Template(self.subparse(), lineno=1) result.set_environment(self.environment) return result
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 2087, 272, 32202, 94, 339, 24664, 314, 1978, 1798, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10321, 18, 492, 3380, 199, 504, 10321, 18, 14, 3924, 492, 17762, 12, 5458, 14844, 199, 504, 10321, 18, 14, 11729, 492, 13743, 63, 1418, 12, 13743, 63, 1418, 63, 3684, 199, 504, 10321, 18, 423, 5819, 492, 2163, 12, 23646, 421, 199, 12573, 9834, 626, 1240, 9924, 221, 199, 63, 6242, 63, 7511, 275, 9522, 2941, 509, 297, 283, 692, 297, 283, 1457, 297, 283, 11036, 297, 283, 1361, 297, 639, 283, 11300, 297, 283, 2613, 297, 283, 504, 297, 283, 646, 297, 639, 283, 409, 1105, 199, 63, 5785, 63, 12688, 275, 9522, 2941, 4077, 297, 283, 685, 297, 283, 4116, 297, 283, 20740, 81, 297, 283, 3308, 297, 283, 19586, 81, 1105, 421, 199, 533, 10191, 8, 785, 304, 272, 408, 2765, 365, 314, 18796, 6057, 1021, 17300, 18, 4440, 14, 221, 2779, 1159, 3032, 370, 272, 5478, 436, 883, 506, 1202, 370, 2198, 8455, 503, 9834, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3734, 12, 1350, 12, 536, 29, 403, 12, 1788, 29, 403, 12, 326, 1174, 29, 403, 304, 267, 291, 14, 5418, 275, 3734, 267, 291, 14, 1745, 275, 3734, 423, 15246, 8, 1365, 12, 536, 12, 1788, 12, 1174, 9, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5359, 275, 1052, 267, 367, 3329, 315, 3734, 14, 1661, 63, 5359, 837, 288, 367, 1947, 315, 3329, 14, 2969, 26, 355, 291, 14, 5359, 59, 1450, 61, 275, 3329, 14, 1122, 267, 291, 423, 2019, 63, 5364, 275, 378, 267, 291, 423, 1450, 63, 2340, 275, 942, 267, 291, 423, 500, 63, 1418, 63, 2340, 275, 942, 339, 347, 2449, 8, 277, 12, 1499, 12, 5874, 29, 403, 12, 3178, 29, 20837, 304, 267, 408, 714, 23329, 1083, 626, 6534, 658, 2804, 64, 543, 314, 1245, 12, 3032, 267, 1004, 1329, 503, 2061, 1004, 1329, 465, 5521, 465, 314, 1453, 536, 436, 267, 1788, 14, 267, 408, 267, 340, 5874, 365, 488, 26, 288, 5874, 275, 291, 14, 1745, 14, 1818, 14, 3469, 267, 746, 3178, 8, 1328, 12, 5874, 12, 291, 14, 354, 12, 291, 14, 1501, 9, 339, 347, 485, 1633, 63, 337, 63, 11670, 8, 277, 12, 536, 12, 1284, 63, 1418, 63, 2340, 12, 5874, 304, 267, 1420, 275, 942, 267, 367, 23770, 315, 1284, 63, 1418, 63, 2340, 26, 288, 1420, 14, 2880, 8, 15311, 8, 11935, 63, 1418, 63, 3684, 12, 23770, 430, 267, 340, 1284, 63, 1418, 63, 2340, 26, 288, 5544, 63, 11660, 316, 275, 283, 503, 1987, 904, 8, 355, 17648, 83, 4065, 450, 13743, 63, 1418, 63, 3684, 8, 3684, 9, 355, 367, 5348, 315, 1284, 63, 1418, 63, 2340, 1988, 17, 566, 267, 587, 26, 288, 5544, 63, 11660, 316, 275, 488, 398, 340, 536, 365, 488, 26, 288, 1245, 275, 788, 8708, 1284, 402, 1978, 14, 418, 267, 587, 26, 288, 1245, 275, 788, 1327, 12613, 5809, 1947, 19095, 83, 60, 30484, 450, 536, 61, 398, 340, 5544, 63, 11660, 316, 26, 288, 340, 536, 365, 440, 488, 436, 536, 315, 1420, 26, 355, 1245, 14, 740, 360, 5556, 8646, 6326, 282, 19500, 27572, 1728, 14, 17300, 283, 3044, 283, 374, 21055, 642, 1947, 12, 1325, 5544, 10023, 283, 3044, 283, 509, 450, 83, 3530, 450, 5544, 63, 11660, 316, 9, 288, 587, 26, 355, 1245, 14, 740, 360, 42, 4135, 1990, 10023, 367, 314, 2569, 3762, 26, 283, 3044, 1543, 83, 3530, 450, 5544, 63, 11660, 316, 9, 398, 340, 291, 423, 1450, 63, 2340, 26, 288, 1245, 14, 740, 360, 1918, 6506, 2786, 1853, 626, 4839, 370, 506, 283, 2574, 283, 5938, 365, 19095, 83, 60, 30484, 450, 291, 423, 1450, 63, 2340, 1988, 17, 566, 398, 291, 14, 1633, 360, 1987, 904, 8, 1188, 395, 5874, 9, 339, 347, 2449, 63, 5187, 63, 1450, 8, 277, 12, 536, 12, 5874, 29, 403, 304, 267, 408, 10474, 340, 314, 1798, 655, 16558, 376, 5809, 1947, 14, 221, 377, 1996, 370, 2449, 267, 543, 282, 11779, 12701, 1125, 1245, 626, 4293, 1720, 370, 10405, 267, 314, 5160, 14, 267, 408, 267, 372, 291, 423, 1633, 63, 337, 63, 11670, 8, 354, 12, 291, 423, 500, 63, 1418, 63, 2340, 12, 5874, 9, 339, 347, 2449, 63, 11670, 8, 277, 12, 1284, 63, 4504, 29, 403, 12, 5874, 29, 403, 304, 267, 408, 12545, 2449, 63, 5187, 63, 1450, 1325, 367, 1284, 402, 1978, 24325, 1041, 267, 3464, 275, 769, 8, 277, 423, 500, 63, 1418, 63, 2340, 9, 267, 340, 1284, 63, 4504, 365, 440, 488, 26, 288, 3464, 14, 740, 8, 500, 63, 4504, 9, 267, 372, 291, 423, 1633, 63, 337, 63, 11670, 8, 403, 12, 3464, 12, 5874, 9, 339, 347, 365, 63, 2960, 63, 500, 8, 277, 12, 2402, 63, 500, 63, 4423, 29, 403, 304, 267, 408, 17683, 781, 737, 314, 1284, 402, 282, 2008, 30196, 267, 340, 291, 14, 1745, 14, 1818, 14, 466, 315, 661, 1975, 63, 500, 297, 283, 1457, 63, 500, 297, 283, 82, 9575, 735, 288, 372, 715, 267, 916, 2402, 63, 500, 63, 4423, 365, 440, 488, 26, 288, 372, 291, 14, 1745, 14, 1818, 14, 396, 63, 1629, 8, 2911, 63, 500, 63, 4423, 9, 267, 372, 756, 339, 347, 2867, 63, 5364, 8, 277, 12, 5874, 29, 403, 304, 267, 408, 1767, 282, 892, 2867, 5148, 465, 520, 533, 6054, 12264, 18, 14, 2415, 14, 8405, 985, 17105, 267, 291, 423, 2019, 63, 5364, 847, 413, 267, 4336, 275, 909, 855, 1222, 721, 2415, 14, 8405, 985, 9, 267, 3380, 14, 1716, 855, 826, 721, 6310, 12, 283, 329, 5, 68, 7, 450, 291, 423, 2019, 63, 5364, 12, 5874, 29, 3469, 9, 267, 372, 4336, 339, 347, 2198, 63, 6242, 8, 277, 304, 267, 408, 4003, 282, 2849, 5164, 1041, 267, 1526 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 2087, 272, 32202, 94, 339, 24664, 314, 1978, 1798, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10321, 18, 492, 3380, 199, 504, 10321, 18, 14, 3924, 492, 17762, 12, 5458, 14844, 199, 504, 10321, 18, 14, 11729, 492, 13743, 63, 1418, 12, 13743, 63, 1418, 63, 3684, 199, 504, 10321, 18, 423, 5819, 492, 2163, 12, 23646, 421, 199, 12573, 9834, 626, 1240, 9924, 221, 199, 63, 6242, 63, 7511, 275, 9522, 2941, 509, 297, 283, 692, 297, 283, 1457, 297, 283, 11036, 297, 283, 1361, 297, 639, 283, 11300, 297, 283, 2613, 297, 283, 504, 297, 283, 646, 297, 639, 283, 409, 1105, 199, 63, 5785, 63, 12688, 275, 9522, 2941, 4077, 297, 283, 685, 297, 283, 4116, 297, 283, 20740, 81, 297, 283, 3308, 297, 283, 19586, 81, 1105, 421, 199, 533, 10191, 8, 785, 304, 272, 408, 2765, 365, 314, 18796, 6057, 1021, 17300, 18, 4440, 14, 221, 2779, 1159, 3032, 370, 272, 5478, 436, 883, 506, 1202, 370, 2198, 8455, 503, 9834, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3734, 12, 1350, 12, 536, 29, 403, 12, 1788, 29, 403, 12, 326, 1174, 29, 403, 304, 267, 291, 14, 5418, 275, 3734, 267, 291, 14, 1745, 275, 3734, 423, 15246, 8, 1365, 12, 536, 12, 1788, 12, 1174, 9, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1501, 275, 1788, 267, 291, 14, 5938, 275, 756, 267, 291, 14, 5359, 275, 1052, 267, 367, 3329, 315, 3734, 14, 1661, 63, 5359, 837, 288, 367, 1947, 315, 3329, 14, 2969, 26, 355, 291, 14, 5359, 59, 1450, 61, 275, 3329, 14, 1122, 267, 291, 423, 2019, 63, 5364, 275, 378, 267, 291, 423, 1450, 63, 2340, 275, 942, 267, 291, 423, 500, 63, 1418, 63, 2340, 275, 942, 339, 347, 2449, 8, 277, 12, 1499, 12, 5874, 29, 403, 12, 3178, 29, 20837, 304, 267, 408, 714, 23329, 1083, 626, 6534, 658, 2804, 64, 543, 314, 1245, 12, 3032, 267, 1004, 1329, 503, 2061, 1004, 1329, 465, 5521, 465, 314, 1453, 536, 436, 267, 1788, 14, 267, 408, 267, 340, 5874, 365, 488, 26, 288, 5874, 275, 291, 14, 1745, 14, 1818, 14, 3469, 267, 746, 3178, 8, 1328, 12, 5874, 12, 291, 14, 354, 12, 291, 14, 1501, 9, 339, 347, 485, 1633, 63, 337, 63, 11670, 8, 277, 12, 536, 12, 1284, 63, 1418, 63, 2340, 12, 5874, 304, 267, 1420, 275, 942, 267, 367, 23770, 315, 1284, 63, 1418, 63, 2340, 26, 288, 1420, 14, 2880, 8, 15311, 8, 11935, 63, 1418, 63, 3684, 12, 23770, 430, 267, 340, 1284, 63, 1418, 63, 2340, 26, 288, 5544, 63, 11660, 316, 275, 283, 503, 1987, 904, 8, 355, 17648, 83, 4065, 450, 13743, 63, 1418, 63, 3684, 8, 3684, 9, 355, 367, 5348, 315, 1284, 63, 1418, 63, 2340, 1988, 17, 566, 267, 587, 26, 288, 5544, 63, 11660, 316, 275, 488, 398, 340, 536, 365, 488, 26, 288, 1245, 275, 788, 8708, 1284, 402, 1978, 14, 418, 267, 587, 26, 288, 1245, 275, 788, 1327, 12613, 5809, 1947, 19095, 83, 60, 30484, 450, 536, 61, 398, 340, 5544, 63, 11660, 316, 26, 288, 340, 536, 365, 440, 488, 436, 536, 315, 1420, 26, 355, 1245, 14, 740, 360, 5556, 8646, 6326, 282, 19500, 27572, 1728, 14, 17300, 283, 3044, 283, 374, 21055, 642, 1947, 12, 1325, 5544, 10023, 283, 3044, 283, 509, 450, 83, 3530, 450, 5544, 63, 11660, 316, 9, 288, 587, 26, 355, 1245, 14, 740, 360, 42, 4135, 1990, 10023, 367, 314, 2569, 3762, 26, 283, 3044, 1543, 83, 3530, 450, 5544, 63, 11660, 316, 9, 398, 340, 291, 423, 1450, 63, 2340, 26, 288, 1245, 14, 740, 360, 1918, 6506, 2786, 1853, 626, 4839, 370, 506, 283, 2574, 283, 5938, 365, 19095, 83, 60, 30484, 450, 291, 423, 1450, 63, 2340, 1988, 17, 566, 398, 291, 14, 1633, 360, 1987, 904, 8, 1188, 395, 5874, 9, 339, 347, 2449, 63, 5187, 63, 1450, 8, 277, 12, 536, 12, 5874, 29, 403, 304, 267, 408, 10474, 340, 314, 1798, 655, 16558, 376, 5809, 1947, 14, 221, 377, 1996, 370, 2449, 267, 543, 282, 11779, 12701, 1125, 1245, 626, 4293, 1720, 370, 10405, 267, 314, 5160, 14, 267, 408, 267, 372, 291, 423, 1633, 63, 337, 63, 11670, 8, 354, 12, 291, 423, 500, 63, 1418, 63, 2340, 12, 5874, 9, 339, 347, 2449, 63, 11670, 8, 277, 12, 1284, 63, 4504, 29, 403, 12, 5874, 29, 403, 304, 267, 408, 12545, 2449, 63, 5187, 63, 1450, 1325, 367, 1284, 402, 1978, 24325, 1041, 267, 3464, 275, 769, 8, 277, 423, 500, 63, 1418, 63, 2340, 9, 267, 340, 1284, 63, 4504, 365, 440, 488, 26, 288, 3464, 14, 740, 8, 500, 63, 4504, 9, 267, 372, 291, 423, 1633, 63, 337, 63, 11670, 8, 403, 12, 3464, 12, 5874, 9, 339, 347, 365, 63, 2960, 63, 500, 8, 277, 12, 2402, 63, 500, 63, 4423, 29, 403, 304, 267, 408, 17683, 781, 737, 314, 1284, 402, 282, 2008, 30196, 267, 340, 291, 14, 1745, 14, 1818, 14, 466, 315, 661, 1975, 63, 500, 297, 283, 1457, 63, 500, 297, 283, 82, 9575, 735, 288, 372, 715, 267, 916, 2402, 63, 500, 63, 4423, 365, 440, 488, 26, 288, 372, 291, 14, 1745, 14, 1818, 14, 396, 63, 1629, 8, 2911, 63, 500, 63, 4423, 9, 267, 372, 756, 339, 347, 2867, 63, 5364, 8, 277, 12, 5874, 29, 403, 304, 267, 408, 1767, 282, 892, 2867, 5148, 465, 520, 533, 6054, 12264, 18, 14, 2415, 14, 8405, 985, 17105, 267, 291, 423, 2019, 63, 5364, 847, 413, 267, 4336, 275, 909, 855, 1222, 721, 2415, 14, 8405, 985, 9, 267, 3380, 14, 1716, 855, 826, 721, 6310, 12, 283, 329, 5, 68, 7, 450, 291, 423, 2019, 63, 5364, 12, 5874, 29, 3469, 9, 267, 372, 4336, 339, 347, 2198, 63, 6242, 8, 277, 304, 267, 408, 4003, 282, 2849, 5164, 1041, 267, 1526, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ptonner/GPy
GPy/util/linalg_gpu.py
15
3038
# Copyright (c) 2012, GPy authors (see AUTHORS.txt). # Licensed under the BSD 3-clause license (see LICENSE.txt) # # The utility functions for GPU computation # import numpy as np from ..util import gpu_init try: from pycuda.reduction import ReductionKernel from pycuda.elementwise import ElementwiseKernel # log|A| for A is a low triangle matrix # logDiagSum(A, A.shape[0]+1) logDiagSum = ReductionKernel(np.float64, neutral="0", reduce_expr="a+b", map_expr="i%step==0?log(x[i]):0", arguments="double *x, int step") strideSum = ReductionKernel(np.float64, neutral="0", reduce_expr="a+b", map_expr="i%step==0?x[i]:0", arguments="double *x, int step") # np.trace(np.dot(A,B)) (also equivalent to (A*B.T).sum() ) A - a1 x a2, B - a2 x a1 traceDot = ReductionKernel(np.float64, neutral="0", reduce_expr="a+b", map_expr="A[i]*B[(i%a1)*a2+i/a1]", arguments="double *A, double *B, int a1, int a2") #======================================================================================= # Element-wise functions #======================================================================================= # log(X) log = ElementwiseKernel("double *in, double *out", "out[i] = log(in[i])", "log_element") # log(1.0-X) logOne = ElementwiseKernel("double *in, double *out", "out[i] = log(1.-in[i])", "logOne_element") # multiplication with broadcast on the last dimension (out = shorter[:,None]*longer) mul_bcast = ElementwiseKernel("double *out, double *shorter, double *longer, int shorter_size", "out[i] = longer[i]*shorter[i%shorter_size]", "mul_bcast") # multiplication with broadcast on the first dimension (out = shorter[None,:]*longer) mul_bcast_first = ElementwiseKernel("double *out, double *shorter, double *longer, int first_dim", "out[i] = longer[i]*shorter[i/first_dim]", "mul_bcast") # sum through the middle dimension (size_2) of a 3D matrix (size_1, size_2, size_3) sum_axis = ElementwiseKernel("double *out, double *in, int size_1, int size_2", "out[i] += sum_axis_element(in, size_1, size_2, i)", "sum_axis",preamble=""" __device__ double sum_axis_element(double *in, int size_1, int size_2, int idx) { int k = idx/size_1; int i = idx%size_1; double sum=0; for(int j=0;j<size_2;j++) { sum += in[(k*size_2+j)*size_1+i]; } return sum; } """) # the outer product between two vectors (out = np.dot(v1,v2.T)) outer_prod = ElementwiseKernel("double *out, double *v1, double *v2, int v1_size", "out[i] = v1[i%v1_size]*v2[i/v1_size]", "outer_prod") # the outer product between two vectors (out = np.einsum('na,nb->nab',m1,m2) a=dim1, b=dim2 ) join_prod = ElementwiseKernel("double *out, double *m1, double *m2, int dim1, int dim2", "out[i] = m1[(i%dim1)*dim1+(i%(dim1*dim2))/dim1]*m2[(i%dim1)*dim1+i/(dim1*dim2)]", "join_prod") except: pass
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 12, 598, 2713, 11462, 334, 3239, 10610, 14, 2424, 680, 199, 3, 3909, 1334, 314, 6289, 650, 13, 8501, 4190, 334, 3239, 5113, 14, 2424, 9, 421, 199, 3, 199, 3, 710, 11420, 3423, 367, 18613, 14009, 199, 3, 199, 646, 2680, 465, 980, 199, 199, 504, 2508, 1974, 492, 21758, 63, 826, 199, 199, 893, 26, 272, 687, 1134, 16309, 14, 22508, 492, 820, 24095, 14127, 272, 687, 1134, 16309, 14, 2108, 2605, 492, 6566, 2605, 14127, 2286, 327, 943, 92, 33, 92, 367, 437, 365, 282, 6465, 26268, 3634, 272, 327, 943, 16094, 6959, 8, 33, 12, 437, 14, 1392, 59, 16, 2807, 17, 9, 272, 943, 16094, 6959, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 73, 5, 2926, 389, 16, 31, 793, 8, 88, 59, 73, 4682, 16, 401, 2368, 628, 3157, 627, 88, 12, 1109, 3650, 531, 2286, 7345, 6959, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 73, 5, 2926, 389, 16, 31, 88, 59, 73, 2189, 16, 401, 2368, 628, 3157, 627, 88, 12, 1109, 3650, 531, 2286, 327, 980, 14, 3446, 8, 1590, 14, 3287, 8, 33, 12, 34, 430, 334, 12344, 7353, 370, 334, 33, 10, 34, 14, 52, 680, 1838, 342, 776, 437, 446, 282, 17, 671, 282, 18, 12, 699, 446, 282, 18, 671, 282, 17, 272, 3307, 14004, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 33, 59, 73, 3672, 34, 7528, 73, 5, 65, 17, 3342, 65, 18, 11, 73, 15, 65, 17, 11472, 2368, 628, 3157, 627, 33, 12, 4270, 627, 34, 12, 1109, 282, 17, 12, 1109, 282, 18, 531, 2286, 32314, 1280, 18673, 272, 327, 6566, 13, 2605, 3423, 272, 32314, 1280, 18673, 2286, 327, 943, 8, 56, 9, 272, 943, 275, 6566, 2605, 14127, 480, 3157, 627, 262, 12, 4270, 627, 548, 401, 298, 548, 59, 73, 61, 275, 943, 8, 262, 59, 73, 566, 401, 298, 793, 63, 2108, 531, 2286, 327, 943, 8, 17, 14, 16, 13, 56, 9, 272, 943, 4395, 275, 6566, 2605, 14127, 480, 3157, 627, 262, 12, 4270, 627, 548, 401, 298, 548, 59, 73, 61, 275, 943, 8, 17, 23683, 262, 59, 73, 566, 401, 298, 793, 4395, 63, 2108, 531, 2286, 327, 24638, 543, 11180, 641, 314, 2061, 6240, 334, 548, 275, 18299, 3981, 403, 3672, 5298, 836, 9, 272, 19207, 63, 66, 2931, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 609, 3968, 12, 4270, 627, 5298, 836, 12, 1109, 18299, 63, 890, 401, 298, 548, 59, 73, 61, 275, 8088, 59, 73, 3672, 609, 3968, 59, 73, 5, 609, 3968, 63, 890, 11472, 298, 3703, 63, 66, 2931, 531, 2286, 327, 24638, 543, 11180, 641, 314, 1642, 6240, 334, 548, 275, 18299, 59, 403, 21063, 10, 5298, 836, 9, 272, 19207, 63, 66, 2931, 63, 2246, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 609, 3968, 12, 4270, 627, 5298, 836, 12, 1109, 1642, 63, 3572, 401, 298, 548, 59, 73, 61, 275, 8088, 59, 73, 3672, 609, 3968, 59, 73, 15, 2246, 63, 3572, 11472, 298, 3703, 63, 66, 2931, 531, 2286, 327, 3089, 4012, 314, 12180, 6240, 334, 890, 63, 18, 9, 402, 282, 650, 36, 3634, 334, 890, 63, 17, 12, 1568, 63, 18, 12, 1568, 63, 19, 9, 5591, 3089, 63, 3127, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 262, 12, 1109, 1568, 63, 17, 12, 1109, 1568, 63, 18, 401, 298, 548, 59, 73, 61, 847, 3089, 63, 3127, 63, 2108, 8, 262, 12, 1568, 63, 17, 12, 1568, 63, 18, 12, 284, 4186, 298, 1838, 63, 3127, 401, 17918, 11916, 18418, 636, 1782, 363, 4270, 3089, 63, 3127, 63, 2108, 8, 3157, 627, 262, 12, 1109, 1568, 63, 17, 12, 1109, 1568, 63, 18, 12, 1109, 4280, 9, 267, 469, 288, 1109, 1022, 275, 4280, 15, 890, 63, 17, 27, 288, 1109, 284, 275, 4280, 5, 890, 63, 17, 27, 288, 4270, 3089, 29, 16, 27, 288, 367, 8, 442, 1335, 29, 16, 27, 74, 28, 890, 63, 18, 27, 74, 25659, 469, 355, 3089, 847, 315, 7528, 75, 10, 890, 63, 18, 11, 74, 3342, 890, 63, 17, 11, 73, 11566, 288, 789, 288, 372, 3089, 27, 267, 789, 267, 7857, 2286, 327, 314, 6890, 3336, 3382, 2877, 11102, 334, 548, 275, 980, 14, 3287, 8, 86, 17, 12, 86, 18, 14, 52, 430, 272, 6890, 63, 8788, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 86, 17, 12, 4270, 627, 86, 18, 12, 1109, 373, 17, 63, 890, 401, 298, 548, 59, 73, 61, 275, 373, 17, 59, 73, 5, 86, 17, 63, 890, 3672, 86, 18, 59, 73, 15, 86, 17, 63, 890, 11472, 298, 7837, 63, 8788, 531, 339, 327, 314, 6890, 3336, 3382, 2877, 11102, 334, 548, 275, 980, 14, 22404, 360, 3540, 12, 4994, 5118, 78, 371, 297, 77, 17, 12, 77, 18, 9, 282, 29, 3572, 17, 12, 330, 29, 3572, 18, 776, 272, 4263, 63, 8788, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 77, 17, 12, 4270, 627, 77, 18, 12, 1109, 8134, 17, 12, 1109, 8134, 18, 401, 298, 548, 59, 73, 61, 275, 333, 17, 7528, 73, 5, 3572, 17, 3342, 3572, 17, 15622, 73, 2840, 3572, 17, 10, 3572, 18, 13342, 3572, 17, 3672, 77, 18, 7528, 73, 5, 3572, 17, 3342, 3572, 17, 11, 73, 7985, 3572, 17, 10, 3572, 18, 1874, 401, 298, 904, 63, 8788, 531, 199, 199, 2590, 26, 272, 986, 10813, 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 ]
[ 1898, 334, 67, 9, 6029, 12, 598, 2713, 11462, 334, 3239, 10610, 14, 2424, 680, 199, 3, 3909, 1334, 314, 6289, 650, 13, 8501, 4190, 334, 3239, 5113, 14, 2424, 9, 421, 199, 3, 199, 3, 710, 11420, 3423, 367, 18613, 14009, 199, 3, 199, 646, 2680, 465, 980, 199, 199, 504, 2508, 1974, 492, 21758, 63, 826, 199, 199, 893, 26, 272, 687, 1134, 16309, 14, 22508, 492, 820, 24095, 14127, 272, 687, 1134, 16309, 14, 2108, 2605, 492, 6566, 2605, 14127, 2286, 327, 943, 92, 33, 92, 367, 437, 365, 282, 6465, 26268, 3634, 272, 327, 943, 16094, 6959, 8, 33, 12, 437, 14, 1392, 59, 16, 2807, 17, 9, 272, 943, 16094, 6959, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 73, 5, 2926, 389, 16, 31, 793, 8, 88, 59, 73, 4682, 16, 401, 2368, 628, 3157, 627, 88, 12, 1109, 3650, 531, 2286, 7345, 6959, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 73, 5, 2926, 389, 16, 31, 88, 59, 73, 2189, 16, 401, 2368, 628, 3157, 627, 88, 12, 1109, 3650, 531, 2286, 327, 980, 14, 3446, 8, 1590, 14, 3287, 8, 33, 12, 34, 430, 334, 12344, 7353, 370, 334, 33, 10, 34, 14, 52, 680, 1838, 342, 776, 437, 446, 282, 17, 671, 282, 18, 12, 699, 446, 282, 18, 671, 282, 17, 272, 3307, 14004, 275, 820, 24095, 14127, 8, 1590, 14, 1609, 772, 12, 1279, 29358, 628, 16, 401, 7114, 63, 3684, 628, 65, 11, 66, 401, 2341, 63, 3684, 628, 33, 59, 73, 3672, 34, 7528, 73, 5, 65, 17, 3342, 65, 18, 11, 73, 15, 65, 17, 11472, 2368, 628, 3157, 627, 33, 12, 4270, 627, 34, 12, 1109, 282, 17, 12, 1109, 282, 18, 531, 2286, 32314, 1280, 18673, 272, 327, 6566, 13, 2605, 3423, 272, 32314, 1280, 18673, 2286, 327, 943, 8, 56, 9, 272, 943, 275, 6566, 2605, 14127, 480, 3157, 627, 262, 12, 4270, 627, 548, 401, 298, 548, 59, 73, 61, 275, 943, 8, 262, 59, 73, 566, 401, 298, 793, 63, 2108, 531, 2286, 327, 943, 8, 17, 14, 16, 13, 56, 9, 272, 943, 4395, 275, 6566, 2605, 14127, 480, 3157, 627, 262, 12, 4270, 627, 548, 401, 298, 548, 59, 73, 61, 275, 943, 8, 17, 23683, 262, 59, 73, 566, 401, 298, 793, 4395, 63, 2108, 531, 2286, 327, 24638, 543, 11180, 641, 314, 2061, 6240, 334, 548, 275, 18299, 3981, 403, 3672, 5298, 836, 9, 272, 19207, 63, 66, 2931, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 609, 3968, 12, 4270, 627, 5298, 836, 12, 1109, 18299, 63, 890, 401, 298, 548, 59, 73, 61, 275, 8088, 59, 73, 3672, 609, 3968, 59, 73, 5, 609, 3968, 63, 890, 11472, 298, 3703, 63, 66, 2931, 531, 2286, 327, 24638, 543, 11180, 641, 314, 1642, 6240, 334, 548, 275, 18299, 59, 403, 21063, 10, 5298, 836, 9, 272, 19207, 63, 66, 2931, 63, 2246, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 609, 3968, 12, 4270, 627, 5298, 836, 12, 1109, 1642, 63, 3572, 401, 298, 548, 59, 73, 61, 275, 8088, 59, 73, 3672, 609, 3968, 59, 73, 15, 2246, 63, 3572, 11472, 298, 3703, 63, 66, 2931, 531, 2286, 327, 3089, 4012, 314, 12180, 6240, 334, 890, 63, 18, 9, 402, 282, 650, 36, 3634, 334, 890, 63, 17, 12, 1568, 63, 18, 12, 1568, 63, 19, 9, 5591, 3089, 63, 3127, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 262, 12, 1109, 1568, 63, 17, 12, 1109, 1568, 63, 18, 401, 298, 548, 59, 73, 61, 847, 3089, 63, 3127, 63, 2108, 8, 262, 12, 1568, 63, 17, 12, 1568, 63, 18, 12, 284, 4186, 298, 1838, 63, 3127, 401, 17918, 11916, 18418, 636, 1782, 363, 4270, 3089, 63, 3127, 63, 2108, 8, 3157, 627, 262, 12, 1109, 1568, 63, 17, 12, 1109, 1568, 63, 18, 12, 1109, 4280, 9, 267, 469, 288, 1109, 1022, 275, 4280, 15, 890, 63, 17, 27, 288, 1109, 284, 275, 4280, 5, 890, 63, 17, 27, 288, 4270, 3089, 29, 16, 27, 288, 367, 8, 442, 1335, 29, 16, 27, 74, 28, 890, 63, 18, 27, 74, 25659, 469, 355, 3089, 847, 315, 7528, 75, 10, 890, 63, 18, 11, 74, 3342, 890, 63, 17, 11, 73, 11566, 288, 789, 288, 372, 3089, 27, 267, 789, 267, 7857, 2286, 327, 314, 6890, 3336, 3382, 2877, 11102, 334, 548, 275, 980, 14, 3287, 8, 86, 17, 12, 86, 18, 14, 52, 430, 272, 6890, 63, 8788, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 86, 17, 12, 4270, 627, 86, 18, 12, 1109, 373, 17, 63, 890, 401, 298, 548, 59, 73, 61, 275, 373, 17, 59, 73, 5, 86, 17, 63, 890, 3672, 86, 18, 59, 73, 15, 86, 17, 63, 890, 11472, 298, 7837, 63, 8788, 531, 339, 327, 314, 6890, 3336, 3382, 2877, 11102, 334, 548, 275, 980, 14, 22404, 360, 3540, 12, 4994, 5118, 78, 371, 297, 77, 17, 12, 77, 18, 9, 282, 29, 3572, 17, 12, 330, 29, 3572, 18, 776, 272, 4263, 63, 8788, 275, 6566, 2605, 14127, 480, 3157, 627, 548, 12, 4270, 627, 77, 17, 12, 4270, 627, 77, 18, 12, 1109, 8134, 17, 12, 1109, 8134, 18, 401, 298, 548, 59, 73, 61, 275, 333, 17, 7528, 73, 5, 3572, 17, 3342, 3572, 17, 15622, 73, 2840, 3572, 17, 10, 3572, 18, 13342, 3572, 17, 3672, 77, 18, 7528, 73, 5, 3572, 17, 3342, 3572, 17, 11, 73, 7985, 3572, 17, 10, 3572, 18, 1874, 401, 298, 904, 63, 8788, 531, 199, 199, 2590, 26, 272, 986, 10813, 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, 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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 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 ]
ajs124/esp-idf
tools/esp_app_trace/pylibelf/iterators/__init__.py
14
5322
import sys import os from .. import * from ..constants import * from ..types import * from ..util import * from ctypes import * def sections(elf, **kwargs): i = None ndx = 0 # we skip the first null section if 'info' in kwargs: if (isinstance(kwargs['info'], Elf_Scn)): info = elf_ndxscn(kwargs['info']) else: info = kwargs['info'] else: info = None while 1: i = elf_nextscn(elf, i) ndx += 1 if (not bool(i)): break try: if ('name' in kwargs and section_name(elf, i) != kwargs['name']): continue if ('type' in kwargs and section_type(elf, i) != kwargs['type']): continue if ('link' in kwargs and section_link(elf, i) != kwargs['link']): continue if (info != None and section_hdr(elf, i).sh_info != info): continue except ValueError: print "Error iterating over section ", i continue if ('ndx' in kwargs and kwargs['ndx']): yield (ndx, i.contents) else: yield i.contents def shdrs(elf): i = None while 1: i = elf_nextscn(elf, i) if (not bool(i)): break yield select(elf, 'getshdr')(i.contents).contents def phdrs(elf): phdrTbl = select(elf, "getphdr")(elf) ehdr = select(elf, "getehdr")(elf).contents phdrCnt = ehdr.e_phnum for i in xrange(0, phdrCnt): yield phdrTbl[i] def data(elf_scn): i = None while 1: i = elf_getdata(elf_scn, i) if (not bool(i)): break yield i.contents def strings(v): if (isinstance(v, Elf_Data)): strtab_data = v size = strtab_data.d_size buf = cast(strtab_data.d_buf, POINTER(c_char)) start = 0; while start < size: end = start; while buf[end] != '\x00': end += 1 yield (strtab_data.d_off + start, buf[start:end]) start = end+1 elif (isinstance(v, Elf_Scn)): for d in data(v): strtab_data = d size = strtab_data.d_size buf = cast(strtab_data.d_buf, POINTER(c_char)) start = 0; while start < size: end = start; while buf[end] != '\x00': end += 1 yield (strtab_data.d_off + start, buf[start:end]) start = end+1 def arr_iter(data, itemT, ind = False): size = data.d_size if size % sizeof(itemT) != 0: raise Exception("Data size not a multiple of symbol size!") buf = cast(data.d_buf, POINTER(itemT)) nelems = size / sizeof(itemT) for i in xrange(0, nelems): if ind: yield (i, buf[i]) else: yield buf[i] def syms(elf, v = None): symT = Elf32_Sym if (is32(elf)) else Elf64_Sym if v == None: for s in sections(elf): hdr = section_hdr(elf, s) if (hdr.sh_type != SHT_SYMTAB and hdr.sh_type != SHT_DYNSYM): continue for d in data(s): for (ind, sym) in arr_iter(d, symT, True): yield (ind, sym) elif isinstance(v, Elf_Scn): for d in data(v): for (ind, sym) in arr_iter(d, symT, True): yield (ind, sym) else: assert isinstance(v, Elf_Data) for (ind, sym) in arr_iter(v, symT, True): yield (ind, sym) def rels(elf, **kwargs): relT = Elf32_Rel if (is32(elf)) else Elf64_Rel if 'section' in kwargs: secl = sections(elf, type = SHT_REL, info = kwargs['section']) else: secl = sections(elf, type = SHT_REL) if 'range' in kwargs: for scn in secl: for d in data(scn): for rel in arr_iter(d, relT): if (rel.r_offset >= kwargs['range'][0] and rel.r_offset < kwargs['range'][1]): yield (rel, section_hdr(elf, scn).sh_link) else: for scn in secl: for d in data(scn): for rel in arr_iter(d, relT): yield (rel, section_hdr(elf, scn).sh_link) def relas(elf, **kwargs): relT = Elf32_Rela if (is32(elf)) else Elf64_Rela if 'section' in kwargs: scn = kwargs['section'] if (type(scn) == str): scn = list(sections(elf, name=scn))[0] if (isinstance(scn, Elf_Scn)): scn = elf_ndxscn(byref(scn)) secl = list(sections(elf, type = SHT_RELA, info = scn)) else: secl = list(sections(elf, type = SHT_RELA)) if 'range' in kwargs: for scn in secl: for d in data(scn): for rel in arr_iter(d, relT): if (rel.r_offset + rel.r_addend >= kwargs['range'][0] and rel.r_offset + rel.r_addend < kwargs['range'][1]): yield (rel, section_hdr(elf, scn).sh_link) else: addSecId = kwargs['withSectionId']==True \ if 'withSectionId' in kwargs \ else False if not addSecId: for scn in secl: for d in data(scn): for rel in arr_iter(d, relT): yield (rel, section_hdr(elf, scn).sh_link) else: for scn in secl: for d in data(scn): for rel in arr_iter(d, relT): yield (rel, section_hdr(elf, scn).sh_info) def getOnlyData(scn): d = elf_getdata(scn, None); assert bool(elf_getdata(scn, d)) == False return d def dyns(elf): relT = Elf64_Dyn for scn in sections(elf, name=".dynamic"): for d in data(scn): for dyn in arr_iter(d, relT): yield dyn def elfs(fname): fd = os.open(fname, os.O_RDONLY) ar = elf_begin(fd, ELF_C_READ, None) i = None while 1: i = elf_begin(fd, ELF_C_READ, ar) if (not bool(i)): break yield i elf_end(ar) os.close(fd)
apache-2.0
[ 646, 984, 199, 646, 747, 199, 504, 2508, 492, 627, 199, 504, 2508, 5559, 492, 627, 199, 504, 2508, 1313, 492, 627, 199, 504, 2508, 1974, 492, 627, 199, 504, 5577, 492, 627, 199, 199, 318, 10189, 8, 25371, 12, 1011, 958, 304, 523, 284, 275, 488, 523, 5222, 88, 275, 378, 327, 781, 3372, 314, 1642, 2973, 3420, 523, 340, 283, 815, 7, 315, 2074, 26, 272, 340, 334, 6074, 8, 958, 459, 815, 995, 662, 276, 63, 51, 6413, 2298, 489, 2256, 275, 325, 276, 63, 31818, 551, 78, 8, 958, 459, 815, 1105, 272, 587, 26, 489, 2256, 275, 2074, 459, 815, 418, 523, 587, 26, 272, 2256, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 2184, 551, 78, 8, 25371, 12, 284, 9, 272, 5222, 88, 847, 413, 339, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 862, 26, 489, 340, 661, 354, 7, 315, 2074, 436, 3420, 63, 354, 8, 25371, 12, 284, 9, 1137, 2074, 459, 354, 9090, 267, 1980, 2541, 340, 661, 466, 7, 315, 2074, 436, 3420, 63, 466, 8, 25371, 12, 284, 9, 1137, 2074, 459, 466, 9090, 267, 1980, 2541, 340, 661, 1073, 7, 315, 2074, 436, 3420, 63, 1073, 8, 25371, 12, 284, 9, 1137, 2074, 459, 1073, 9090, 267, 1980, 2541, 340, 334, 815, 1137, 488, 436, 3420, 63, 11244, 8, 25371, 12, 284, 680, 609, 63, 815, 1137, 2256, 304, 267, 1980, 272, 871, 1722, 26, 489, 870, 298, 547, 25012, 1806, 3420, 3872, 284, 489, 1980, 339, 340, 661, 31818, 7, 315, 2074, 436, 2074, 459, 31818, 9090, 489, 1995, 334, 31818, 12, 284, 14, 4407, 9, 272, 587, 26, 489, 1995, 284, 14, 4407, 421, 199, 318, 1033, 68, 2393, 8, 25371, 304, 523, 284, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 2184, 551, 78, 8, 25371, 12, 284, 9, 272, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 1995, 3504, 8, 25371, 12, 283, 362, 609, 5012, 7533, 73, 14, 4407, 680, 4407, 199, 199, 318, 3945, 68, 2393, 8, 25371, 304, 523, 3945, 5012, 52, 3345, 275, 3504, 8, 25371, 12, 298, 362, 838, 5012, 25232, 25371, 9, 523, 325, 11244, 275, 3504, 8, 25371, 12, 298, 31508, 11244, 25232, 25371, 680, 4407, 523, 3945, 5012, 31847, 275, 325, 11244, 14, 69, 63, 838, 1507, 819, 367, 284, 315, 4945, 8, 16, 12, 3945, 5012, 31847, 304, 272, 1995, 3945, 5012, 52, 3345, 59, 73, 61, 199, 199, 318, 666, 8, 25371, 63, 551, 78, 304, 523, 284, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 29160, 8, 25371, 63, 551, 78, 12, 284, 9, 339, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 1995, 284, 14, 4407, 199, 199, 318, 3326, 8, 86, 304, 523, 340, 334, 6074, 8, 86, 12, 662, 276, 63, 1451, 2298, 272, 620, 2902, 63, 576, 275, 373, 272, 1568, 275, 620, 2902, 63, 576, 14, 68, 63, 890, 272, 4123, 275, 9106, 8, 495, 2902, 63, 576, 14, 68, 63, 1436, 12, 6569, 8, 67, 63, 1560, 430, 272, 1343, 275, 378, 27, 272, 1830, 1343, 665, 1568, 26, 489, 1284, 275, 1343, 27, 489, 1830, 4123, 59, 500, 61, 1137, 1557, 88, 383, 356, 1284, 847, 413, 489, 1995, 334, 495, 2902, 63, 576, 14, 68, 63, 1997, 435, 1343, 12, 4123, 59, 928, 26, 500, 566, 2541, 1343, 275, 1284, 11, 17, 523, 916, 334, 6074, 8, 86, 12, 662, 276, 63, 51, 6413, 2298, 272, 367, 366, 315, 666, 8, 86, 304, 489, 620, 2902, 63, 576, 275, 366, 489, 1568, 275, 620, 2902, 63, 576, 14, 68, 63, 890, 489, 4123, 275, 9106, 8, 495, 2902, 63, 576, 14, 68, 63, 1436, 12, 6569, 8, 67, 63, 1560, 430, 489, 1343, 275, 378, 27, 489, 1830, 1343, 665, 1568, 26, 267, 1284, 275, 1343, 27, 267, 1830, 4123, 59, 500, 61, 1137, 1557, 88, 383, 356, 1284, 847, 413, 267, 1995, 334, 495, 2902, 63, 576, 14, 68, 63, 1997, 435, 1343, 12, 4123, 59, 928, 26, 500, 566, 398, 1343, 275, 1284, 11, 17, 421, 199, 318, 7953, 63, 1661, 8, 576, 12, 1242, 52, 12, 7654, 275, 756, 304, 523, 1568, 275, 666, 14, 68, 63, 890, 819, 340, 1568, 450, 13855, 8, 1053, 52, 9, 1137, 378, 26, 272, 746, 2186, 480, 1451, 1568, 440, 282, 3663, 402, 5272, 1568, 9124, 819, 4123, 275, 9106, 8, 576, 14, 68, 63, 1436, 12, 6569, 8, 1053, 52, 430, 523, 1279, 274, 706, 275, 1568, 1182, 13855, 8, 1053, 52, 9, 819, 367, 284, 315, 4945, 8, 16, 12, 1279, 274, 706, 304, 272, 340, 7654, 26, 489, 1995, 334, 73, 12, 4123, 59, 73, 566, 272, 587, 26, 489, 1995, 4123, 59, 73, 61, 199, 199, 318, 25308, 8, 25371, 12, 373, 275, 488, 304, 523, 4678, 52, 275, 662, 276, 708, 63, 16594, 340, 334, 374, 708, 8, 25371, 430, 587, 662, 276, 772, 63, 16594, 523, 340, 373, 508, 488, 26, 272, 367, 308, 315, 10189, 8, 25371, 304, 489, 15260, 275, 3420, 63, 11244, 8, 25371, 12, 308, 9, 2541, 340, 334, 11244, 14, 609, 63, 466, 1137, 428, 2148, 63, 4669, 5747, 1217, 436, 15260, 14, 609, 63, 466, 1137, 428, 2148, 63, 11446, 2709, 57, 45, 304, 267, 1980, 2541, 367, 366, 315, 666, 8, 83, 304, 267, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 68, 12, 4678, 52, 12, 715, 304, 881, 1995, 334, 688, 12, 4678, 9, 523, 916, 1228, 8, 86, 12, 662, 276, 63, 51, 6413, 304, 272, 367, 366, 315, 666, 8, 86, 304, 489, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 68, 12, 4678, 52, 12, 715, 304, 267, 1995, 334, 688, 12, 4678, 9, 523, 587, 26, 272, 702, 1228, 8, 86, 12, 662, 276, 63, 1451, 9, 272, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 86, 12, 4678, 52, 12, 715, 304, 489, 1995, 334, 688, 12, 4678, 9, 199, 199, 318, 295, 478, 8, 25371, 12, 1011, 958, 304 ]
[ 984, 199, 646, 747, 199, 504, 2508, 492, 627, 199, 504, 2508, 5559, 492, 627, 199, 504, 2508, 1313, 492, 627, 199, 504, 2508, 1974, 492, 627, 199, 504, 5577, 492, 627, 199, 199, 318, 10189, 8, 25371, 12, 1011, 958, 304, 523, 284, 275, 488, 523, 5222, 88, 275, 378, 327, 781, 3372, 314, 1642, 2973, 3420, 523, 340, 283, 815, 7, 315, 2074, 26, 272, 340, 334, 6074, 8, 958, 459, 815, 995, 662, 276, 63, 51, 6413, 2298, 489, 2256, 275, 325, 276, 63, 31818, 551, 78, 8, 958, 459, 815, 1105, 272, 587, 26, 489, 2256, 275, 2074, 459, 815, 418, 523, 587, 26, 272, 2256, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 2184, 551, 78, 8, 25371, 12, 284, 9, 272, 5222, 88, 847, 413, 339, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 862, 26, 489, 340, 661, 354, 7, 315, 2074, 436, 3420, 63, 354, 8, 25371, 12, 284, 9, 1137, 2074, 459, 354, 9090, 267, 1980, 2541, 340, 661, 466, 7, 315, 2074, 436, 3420, 63, 466, 8, 25371, 12, 284, 9, 1137, 2074, 459, 466, 9090, 267, 1980, 2541, 340, 661, 1073, 7, 315, 2074, 436, 3420, 63, 1073, 8, 25371, 12, 284, 9, 1137, 2074, 459, 1073, 9090, 267, 1980, 2541, 340, 334, 815, 1137, 488, 436, 3420, 63, 11244, 8, 25371, 12, 284, 680, 609, 63, 815, 1137, 2256, 304, 267, 1980, 272, 871, 1722, 26, 489, 870, 298, 547, 25012, 1806, 3420, 3872, 284, 489, 1980, 339, 340, 661, 31818, 7, 315, 2074, 436, 2074, 459, 31818, 9090, 489, 1995, 334, 31818, 12, 284, 14, 4407, 9, 272, 587, 26, 489, 1995, 284, 14, 4407, 421, 199, 318, 1033, 68, 2393, 8, 25371, 304, 523, 284, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 2184, 551, 78, 8, 25371, 12, 284, 9, 272, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 1995, 3504, 8, 25371, 12, 283, 362, 609, 5012, 7533, 73, 14, 4407, 680, 4407, 199, 199, 318, 3945, 68, 2393, 8, 25371, 304, 523, 3945, 5012, 52, 3345, 275, 3504, 8, 25371, 12, 298, 362, 838, 5012, 25232, 25371, 9, 523, 325, 11244, 275, 3504, 8, 25371, 12, 298, 31508, 11244, 25232, 25371, 680, 4407, 523, 3945, 5012, 31847, 275, 325, 11244, 14, 69, 63, 838, 1507, 819, 367, 284, 315, 4945, 8, 16, 12, 3945, 5012, 31847, 304, 272, 1995, 3945, 5012, 52, 3345, 59, 73, 61, 199, 199, 318, 666, 8, 25371, 63, 551, 78, 304, 523, 284, 275, 488, 523, 1830, 413, 26, 272, 284, 275, 325, 276, 63, 29160, 8, 25371, 63, 551, 78, 12, 284, 9, 339, 340, 334, 1397, 2155, 8, 73, 2298, 489, 2059, 339, 1995, 284, 14, 4407, 199, 199, 318, 3326, 8, 86, 304, 523, 340, 334, 6074, 8, 86, 12, 662, 276, 63, 1451, 2298, 272, 620, 2902, 63, 576, 275, 373, 272, 1568, 275, 620, 2902, 63, 576, 14, 68, 63, 890, 272, 4123, 275, 9106, 8, 495, 2902, 63, 576, 14, 68, 63, 1436, 12, 6569, 8, 67, 63, 1560, 430, 272, 1343, 275, 378, 27, 272, 1830, 1343, 665, 1568, 26, 489, 1284, 275, 1343, 27, 489, 1830, 4123, 59, 500, 61, 1137, 1557, 88, 383, 356, 1284, 847, 413, 489, 1995, 334, 495, 2902, 63, 576, 14, 68, 63, 1997, 435, 1343, 12, 4123, 59, 928, 26, 500, 566, 2541, 1343, 275, 1284, 11, 17, 523, 916, 334, 6074, 8, 86, 12, 662, 276, 63, 51, 6413, 2298, 272, 367, 366, 315, 666, 8, 86, 304, 489, 620, 2902, 63, 576, 275, 366, 489, 1568, 275, 620, 2902, 63, 576, 14, 68, 63, 890, 489, 4123, 275, 9106, 8, 495, 2902, 63, 576, 14, 68, 63, 1436, 12, 6569, 8, 67, 63, 1560, 430, 489, 1343, 275, 378, 27, 489, 1830, 1343, 665, 1568, 26, 267, 1284, 275, 1343, 27, 267, 1830, 4123, 59, 500, 61, 1137, 1557, 88, 383, 356, 1284, 847, 413, 267, 1995, 334, 495, 2902, 63, 576, 14, 68, 63, 1997, 435, 1343, 12, 4123, 59, 928, 26, 500, 566, 398, 1343, 275, 1284, 11, 17, 421, 199, 318, 7953, 63, 1661, 8, 576, 12, 1242, 52, 12, 7654, 275, 756, 304, 523, 1568, 275, 666, 14, 68, 63, 890, 819, 340, 1568, 450, 13855, 8, 1053, 52, 9, 1137, 378, 26, 272, 746, 2186, 480, 1451, 1568, 440, 282, 3663, 402, 5272, 1568, 9124, 819, 4123, 275, 9106, 8, 576, 14, 68, 63, 1436, 12, 6569, 8, 1053, 52, 430, 523, 1279, 274, 706, 275, 1568, 1182, 13855, 8, 1053, 52, 9, 819, 367, 284, 315, 4945, 8, 16, 12, 1279, 274, 706, 304, 272, 340, 7654, 26, 489, 1995, 334, 73, 12, 4123, 59, 73, 566, 272, 587, 26, 489, 1995, 4123, 59, 73, 61, 199, 199, 318, 25308, 8, 25371, 12, 373, 275, 488, 304, 523, 4678, 52, 275, 662, 276, 708, 63, 16594, 340, 334, 374, 708, 8, 25371, 430, 587, 662, 276, 772, 63, 16594, 523, 340, 373, 508, 488, 26, 272, 367, 308, 315, 10189, 8, 25371, 304, 489, 15260, 275, 3420, 63, 11244, 8, 25371, 12, 308, 9, 2541, 340, 334, 11244, 14, 609, 63, 466, 1137, 428, 2148, 63, 4669, 5747, 1217, 436, 15260, 14, 609, 63, 466, 1137, 428, 2148, 63, 11446, 2709, 57, 45, 304, 267, 1980, 2541, 367, 366, 315, 666, 8, 83, 304, 267, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 68, 12, 4678, 52, 12, 715, 304, 881, 1995, 334, 688, 12, 4678, 9, 523, 916, 1228, 8, 86, 12, 662, 276, 63, 51, 6413, 304, 272, 367, 366, 315, 666, 8, 86, 304, 489, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 68, 12, 4678, 52, 12, 715, 304, 267, 1995, 334, 688, 12, 4678, 9, 523, 587, 26, 272, 702, 1228, 8, 86, 12, 662, 276, 63, 1451, 9, 272, 367, 334, 688, 12, 4678, 9, 315, 7953, 63, 1661, 8, 86, 12, 4678, 52, 12, 715, 304, 489, 1995, 334, 688, 12, 4678, 9, 199, 199, 318, 295, 478, 8, 25371, 12, 1011, 958, 304, 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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. # # 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. """Class that runs a named gsutil command.""" from __future__ import absolute_import import difflib import logging import os import pkgutil import sys import textwrap import time import boto from boto.storage_uri import BucketStorageUri import gslib from gslib.cloud_api_delegator import CloudApiDelegator from gslib.command import Command from gslib.command import CreateGsutilLogger from gslib.command import GetFailureCount from gslib.command import OLD_ALIAS_MAP from gslib.command import ShutDownGsutil import gslib.commands from gslib.cs_api_map import ApiSelector from gslib.cs_api_map import GsutilApiClassMapFactory from gslib.cs_api_map import GsutilApiMapFactory from gslib.exception import CommandException from gslib.gcs_json_api import GcsJsonApi from gslib.no_op_credentials import NoOpCredentials from gslib.tab_complete import MakeCompleter from gslib.util import CompareVersions from gslib.util import GetGsutilVersionModifiedTime from gslib.util import GSUTIL_PUB_TARBALL from gslib.util import IsRunningInteractively from gslib.util import LAST_CHECKED_FOR_GSUTIL_UPDATE_TIMESTAMP_FILE from gslib.util import LookUpGsutilVersion from gslib.util import MultiprocessingIsAvailable from gslib.util import RELEASE_NOTES_URL from gslib.util import SECONDS_PER_DAY from gslib.util import UTF8 def HandleArgCoding(args): """Handles coding of command-line args. Args: args: array of command-line args. Returns: array of command-line args. Raises: CommandException: if errors encountered. """ # Python passes arguments from the command line as byte strings. To # correctly interpret them, we decode ones other than -h and -p args (which # will be passed as headers, and thus per HTTP spec should not be encoded) as # utf-8. The exception is x-goog-meta-* headers, which are allowed to contain # non-ASCII content (and hence, should be decoded), per # https://developers.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata processing_header = False for i in range(len(args)): arg = args[i] # Commands like mv can run this function twice; don't decode twice. try: decoded = arg if isinstance(arg, unicode) else arg.decode(UTF8) except UnicodeDecodeError: raise CommandException('\n'.join(textwrap.wrap( 'Invalid encoding for argument (%s). Arguments must be decodable as ' 'Unicode. NOTE: the argument printed above replaces the problematic ' 'characters with a hex-encoded printable representation. For more ' 'details (including how to convert to a gsutil-compatible encoding) ' 'see `gsutil help encoding`.' % repr(arg)))) if processing_header: if arg.lower().startswith('x-goog-meta'): args[i] = decoded else: try: # Try to encode as ASCII to check for invalid header values (which # can't be sent over HTTP). decoded.encode('ascii') except UnicodeEncodeError: # Raise the CommandException using the decoded value because # _OutputAndExit function re-encodes at the end. raise CommandException( 'Invalid non-ASCII header value (%s).\nOnly ASCII characters are ' 'allowed in headers other than x-goog-meta- headers' % decoded) else: args[i] = decoded processing_header = (arg in ('-h', '-p')) return args class CommandRunner(object): """Runs gsutil commands and does some top-level argument handling.""" def __init__(self, bucket_storage_uri_class=BucketStorageUri, gsutil_api_class_map_factory=GsutilApiClassMapFactory, command_map=None): """Instantiates a CommandRunner. Args: bucket_storage_uri_class: Class to instantiate for cloud StorageUris. Settable for testing/mocking. gsutil_api_class_map_factory: Creates map of cloud storage interfaces. Settable for testing/mocking. command_map: Map of command names to their implementations for testing/mocking. If not set, the map is built dynamically. """ self.bucket_storage_uri_class = bucket_storage_uri_class self.gsutil_api_class_map_factory = gsutil_api_class_map_factory if command_map: self.command_map = command_map else: self.command_map = self._LoadCommandMap() def _LoadCommandMap(self): """Returns dict mapping each command_name to implementing class.""" # Import all gslib.commands submodules. for _, module_name, _ in pkgutil.iter_modules(gslib.commands.__path__): __import__('gslib.commands.%s' % module_name) command_map = {} # Only include Command subclasses in the dict. for command in Command.__subclasses__(): command_map[command.command_spec.command_name] = command for command_name_aliases in command.command_spec.command_name_aliases: command_map[command_name_aliases] = command return command_map def _ConfigureCommandArgumentParserArguments( self, parser, arguments, gsutil_api): """Configures an argument parser with the given arguments. Args: parser: argparse parser object. arguments: array of CommandArgument objects. gsutil_api: gsutil Cloud API instance to use. Raises: RuntimeError: if argument is configured with unsupported completer """ for command_argument in arguments: action = parser.add_argument( *command_argument.args, **command_argument.kwargs) if command_argument.completer: action.completer = MakeCompleter(command_argument.completer, gsutil_api) def ConfigureCommandArgumentParsers(self, subparsers): """Configures argparse arguments and argcomplete completers for commands. Args: subparsers: argparse object that can be used to add parsers for subcommands (called just 'commands' in gsutil) """ # This should match the support map for the "ls" command. support_map = { 'gs': [ApiSelector.XML, ApiSelector.JSON], 's3': [ApiSelector.XML] } default_map = { 'gs': ApiSelector.JSON, 's3': ApiSelector.XML } gsutil_api_map = GsutilApiMapFactory.GetApiMap( self.gsutil_api_class_map_factory, support_map, default_map) logger = CreateGsutilLogger('tab_complete') gsutil_api = CloudApiDelegator( self.bucket_storage_uri_class, gsutil_api_map, logger, debug=0) for command in set(self.command_map.values()): command_parser = subparsers.add_parser( command.command_spec.command_name, add_help=False) if isinstance(command.command_spec.argparse_arguments, dict): subcommand_parsers = command_parser.add_subparsers() subcommand_argument_dict = command.command_spec.argparse_arguments for subcommand, arguments in subcommand_argument_dict.iteritems(): subcommand_parser = subcommand_parsers.add_parser( subcommand, add_help=False) self._ConfigureCommandArgumentParserArguments( subcommand_parser, arguments, gsutil_api) else: self._ConfigureCommandArgumentParserArguments( command_parser, command.command_spec.argparse_arguments, gsutil_api) def RunNamedCommand(self, command_name, args=None, headers=None, debug=0, parallel_operations=False, test_method=None, skip_update_check=False, logging_filters=None, do_shutdown=True): """Runs the named command. Used by gsutil main, commands built atop other commands, and tests. Args: command_name: The name of the command being run. args: Command-line args (arg0 = actual arg, not command name ala bash). headers: Dictionary containing optional HTTP headers to pass to boto. debug: Debug level to pass in to boto connection (range 0..3). parallel_operations: Should command operations be executed in parallel? test_method: Optional general purpose method for testing purposes. Application and semantics of this method will vary by command and test type. skip_update_check: Set to True to disable checking for gsutil updates. logging_filters: Optional list of logging.Filters to apply to this command's logger. do_shutdown: Stop all parallelism framework workers iff this is True. Raises: CommandException: if errors encountered. Returns: Return value(s) from Command that was run. """ if (not skip_update_check and self.MaybeCheckForAndOfferSoftwareUpdate(command_name, debug)): command_name = 'update' args = ['-n'] if not args: args = [] # Include api_version header in all commands. api_version = boto.config.get_value('GSUtil', 'default_api_version', '1') if not headers: headers = {} headers['x-goog-api-version'] = api_version if command_name not in self.command_map: close_matches = difflib.get_close_matches( command_name, self.command_map.keys(), n=1) if close_matches: # Instead of suggesting a deprecated command alias, suggest the new # name for that command. translated_command_name = ( OLD_ALIAS_MAP.get(close_matches[0], close_matches)[0]) print >> sys.stderr, 'Did you mean this?' print >> sys.stderr, '\t%s' % translated_command_name elif command_name == 'update' and gslib.IS_PACKAGE_INSTALL: sys.stderr.write( 'Update command is not supported for package installs; ' 'please instead update using your package manager.') raise CommandException('Invalid command "%s".' % command_name) if '--help' in args: new_args = [command_name] original_command_class = self.command_map[command_name] subcommands = original_command_class.help_spec.subcommand_help_text.keys() for arg in args: if arg in subcommands: new_args.append(arg) break # Take the first match and throw away the rest. args = new_args command_name = 'help' args = HandleArgCoding(args) command_class = self.command_map[command_name] command_inst = command_class( self, args, headers, debug, parallel_operations, self.bucket_storage_uri_class, self.gsutil_api_class_map_factory, test_method, logging_filters, command_alias_used=command_name) return_code = command_inst.RunCommand() if MultiprocessingIsAvailable()[0] and do_shutdown: ShutDownGsutil() if GetFailureCount() > 0: return_code = 1 return return_code def MaybeCheckForAndOfferSoftwareUpdate(self, command_name, debug): """Checks the last time we checked for an update and offers one if needed. Offer is made if the time since the last update check is longer than the configured threshold offers the user to update gsutil. Args: command_name: The name of the command being run. debug: Debug level to pass in to boto connection (range 0..3). Returns: True if the user decides to update. """ # Don't try to interact with user if: # - gsutil is not connected to a tty (e.g., if being run from cron); # - user is running gsutil -q # - user is running the config command (which could otherwise attempt to # check for an update for a user running behind a proxy, who has not yet # configured gsutil to go through the proxy; for such users we need the # first connection attempt to be made by the gsutil config command). # - user is running the version command (which gets run when using # gsutil -D, which would prevent users with proxy config problems from # sending us gsutil -D output). # - user is running the update command (which could otherwise cause an # additional note that an update is available when user is already trying # to perform an update); # - user specified gs_host (which could be a non-production different # service instance, in which case credentials won't work for checking # gsutil tarball). # - user is using a Cloud SDK install (which should only be updated via # gcloud components update) logger = logging.getLogger() gs_host = boto.config.get('Credentials', 'gs_host', None) if (not IsRunningInteractively() or command_name in ('config', 'update', 'ver', 'version') or not logger.isEnabledFor(logging.INFO) or gs_host or os.environ.get('CLOUDSDK_WRAPPER') == '1'): return False software_update_check_period = boto.config.getint( 'GSUtil', 'software_update_check_period', 30) # Setting software_update_check_period to 0 means periodic software # update checking is disabled. if software_update_check_period == 0: return False cur_ts = int(time.time()) if not os.path.isfile(LAST_CHECKED_FOR_GSUTIL_UPDATE_TIMESTAMP_FILE): # Set last_checked_ts from date of VERSION file, so if the user installed # an old copy of gsutil it will get noticed (and an update offered) the # first time they try to run it. last_checked_ts = GetGsutilVersionModifiedTime() with open(LAST_CHECKED_FOR_GSUTIL_UPDATE_TIMESTAMP_FILE, 'w') as f: f.write(str(last_checked_ts)) else: try: with open(LAST_CHECKED_FOR_GSUTIL_UPDATE_TIMESTAMP_FILE, 'r') as f: last_checked_ts = int(f.readline()) except (TypeError, ValueError): return False if (cur_ts - last_checked_ts > software_update_check_period * SECONDS_PER_DAY): # Create a credential-less gsutil API to check for the public # update tarball. gsutil_api = GcsJsonApi(self.bucket_storage_uri_class, logger, credentials=NoOpCredentials(), debug=debug) cur_ver = LookUpGsutilVersion(gsutil_api, GSUTIL_PUB_TARBALL) with open(LAST_CHECKED_FOR_GSUTIL_UPDATE_TIMESTAMP_FILE, 'w') as f: f.write(str(cur_ts)) (g, m) = CompareVersions(cur_ver, gslib.VERSION) if m: print '\n'.join(textwrap.wrap( 'A newer version of gsutil (%s) is available than the version you ' 'are running (%s). NOTE: This is a major new version, so it is ' 'strongly recommended that you review the release note details at ' '%s before updating to this version, especially if you use gsutil ' 'in scripts.' % (cur_ver, gslib.VERSION, RELEASE_NOTES_URL))) if gslib.IS_PACKAGE_INSTALL: return False print answer = raw_input('Would you like to update [y/N]? ') return answer and answer.lower()[0] == 'y' elif g: print '\n'.join(textwrap.wrap( 'A newer version of gsutil (%s) is available than the version you ' 'are running (%s). A detailed log of gsutil release changes is ' 'available at %s if you would like to read them before updating.' % (cur_ver, gslib.VERSION, RELEASE_NOTES_URL))) if gslib.IS_PACKAGE_INSTALL: return False print answer = raw_input('Would you like to update [Y/n]? ') return not answer or answer.lower()[0] != 'n' return False
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 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, 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, 624, 2543, 626, 7858, 282, 4310, 24986, 1414, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 27070, 199, 646, 2050, 199, 646, 747, 199, 646, 28728, 199, 646, 984, 199, 646, 13390, 199, 646, 900, 199, 199, 646, 6055, 199, 504, 6055, 14, 3494, 63, 2302, 492, 31479, 6408, 14014, 199, 646, 29563, 199, 504, 29563, 14, 4091, 63, 1246, 63, 23684, 707, 492, 8142, 7394, 3896, 24934, 199, 504, 29563, 14, 1531, 492, 5817, 199, 504, 29563, 14, 1531, 492, 2790, 32394, 1974, 4455, 199, 504, 29563, 14, 1531, 492, 2372, 6782, 2353, 199, 504, 29563, 14, 1531, 492, 593, 6533, 63, 12644, 63, 5443, 199, 504, 29563, 14, 1531, 492, 5244, 337, 3514, 32394, 1974, 199, 646, 29563, 14, 4405, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 13986, 11212, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 598, 83, 1974, 7394, 2543, 2956, 2927, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 598, 83, 1974, 7394, 2956, 2927, 199, 504, 29563, 14, 1971, 492, 5817, 1726, 199, 504, 29563, 14, 21757, 63, 1001, 63, 1246, 492, 598, 1259, 9653, 7394, 199, 504, 29563, 14, 889, 63, 411, 63, 6942, 492, 3091, 4619, 13428, 199, 504, 29563, 14, 2902, 63, 4883, 492, 4155, 6600, 351, 199, 504, 29563, 14, 1974, 492, 18955, 21167, 199, 504, 29563, 14, 1974, 492, 2372, 32394, 1974, 3353, 11911, 1366, 199, 504, 29563, 14, 1974, 492, 598, 51, 29076, 63, 13047, 63, 52, 8611, 1761, 199, 504, 29563, 14, 1974, 492, 6596, 9602, 607, 2967, 67, 9462, 199, 504, 29563, 14, 1974, 492, 491, 11307, 63, 8936, 1149, 63, 2707, 63, 8021, 29076, 63, 10383, 63, 20277, 63, 3817, 199, 504, 29563, 14, 1974, 492, 12077, 1721, 32394, 1974, 3353, 199, 504, 29563, 14, 1974, 492, 6879, 6338, 1831, 11464, 199, 504, 29563, 14, 1974, 492, 5363, 17177, 63, 4609, 654, 63, 2632, 199, 504, 29563, 14, 1974, 492, 5795, 1864, 3177, 63, 4227, 63, 11655, 199, 504, 29563, 14, 1974, 492, 9094, 24, 421, 199, 318, 8690, 6373, 35, 2691, 8, 589, 304, 523, 408, 23555, 2803, 402, 1414, 13, 604, 1249, 14, 819, 3033, 26, 272, 1249, 26, 1625, 402, 1414, 13, 604, 1249, 14, 819, 1803, 26, 272, 1625, 402, 1414, 13, 604, 1249, 14, 819, 6218, 26, 272, 5817, 1726, 26, 340, 2552, 14556, 14, 523, 408, 523, 327, 2018, 14933, 2368, 687, 314, 1414, 1004, 465, 3696, 3326, 14, 4005, 523, 327, 6657, 15579, 3062, 12, 781, 4849, 7869, 1163, 2419, 446, 72, 436, 446, 80, 1249, 334, 6777, 523, 327, 911, 506, 3032, 465, 2323, 12, 436, 12850, 1126, 3101, 3158, 1077, 440, 506, 5737, 9, 465, 523, 327, 2774, 13, 24, 14, 710, 1919, 365, 671, 13, 28069, 13, 2024, 13, 10, 2323, 12, 1314, 787, 4370, 370, 1395, 523, 327, 2222, 13, 12292, 1564, 334, 460, 19407, 12, 1077, 506, 11203, 395, 1126, 523, 327, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 458, 1974, 15, 525, 76, 3437, 15, 18356, 3007, 1692, 5142, 523, 6661, 63, 1291, 275, 756, 523, 367, 284, 315, 1425, 8, 552, 8, 589, 2298, 272, 1680, 275, 1249, 59, 73, 61, 272, 327, 5817, 83, 2839, 15413, 883, 1255, 642, 805, 13373, 27, 2793, 1133, 4849, 13373, 14, 272, 862, 26, 489, 11203, 275, 1680, 340, 1228, 8, 1273, 12, 2649, 9, 587, 1680, 14, 2708, 8, 6610, 24, 9, 272, 871, 18965, 26, 489, 746, 5817, 1726, 2258, 78, 1370, 904, 8, 505, 3823, 14, 3823, 8, 881, 283, 3364, 2644, 367, 1423, 4366, 83, 680, 7628, 1471, 506, 477, 7889, 461, 465, 283, 881, 283, 7087, 14, 6944, 26, 314, 1423, 12487, 3432, 19058, 314, 557, 31197, 283, 881, 283, 16516, 543, 282, 6318, 13, 8167, 21834, 6025, 14, 2104, 1655, 283, 881, 283, 5087, 334, 15768, 4212, 370, 3957, 370, 282, 24986, 13, 6490, 2644, 9, 283, 881, 283, 3239, 658, 458, 1974, 1720, 2644, 2313, 7, 450, 4700, 8, 1273, 7845, 272, 340, 6661, 63, 1291, 26, 489, 340, 1680, 14, 2325, 1252, 2460, 360, 88, 13, 28069, 13, 2024, 735, 267, 1249, 59, 73, 61, 275, 11203, 489, 587, 26, 267, 862, 26, 881, 327, 7649, 370, 3752, 465, 10485, 370, 1104, 367, 3866, 1406, 1338, 334, 6777, 881, 327, 883, 1133, 506, 4847, 1806, 3101, 680, 881, 11203, 14, 2143, 360, 4371, 358, 267, 871, 24094, 26, 881, 327, 14771, 314, 5817, 1726, 1808, 314, 11203, 574, 2952, 881, 327, 485, 2959, 3325, 6699, 805, 295, 13, 2143, 83, 737, 314, 1284, 14, 881, 746, 5817, 1726, 8, 1598, 283, 3364, 2222, 13, 12292, 1406, 574, 4366, 83, 12013, 78, 5903, 10485, 4110, 787, 283, 1598, 283, 6541, 315, 2323, 1163, 2419, 671, 13, 28069, 13, 2024, 13, 2323, 7, 450, 11203, 9, 272, 587, 26, 489, 1249, 59, 73, 61, 275, 11203, 272, 6661, 63, 1291, 275, 334, 1273, 315, 12291, 72, 297, 2475, 80, 1333, 523, 372, 1249, 421, 199, 533, 5817, 7446, 8, 785, 304, 523, 408, 16291, 24986, 3718, 436, 1630, 2005, 2746, 13, 1896, 1423, 7252, 1041, 819, 347, 636, 826, 721, 277, 12, 5315, 63, 3494, 63, 2302, 63, 533, 29, 12311, 6408, 14014 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 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, 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, 624, 2543, 626, 7858, 282, 4310, 24986, 1414, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 27070, 199, 646, 2050, 199, 646, 747, 199, 646, 28728, 199, 646, 984, 199, 646, 13390, 199, 646, 900, 199, 199, 646, 6055, 199, 504, 6055, 14, 3494, 63, 2302, 492, 31479, 6408, 14014, 199, 646, 29563, 199, 504, 29563, 14, 4091, 63, 1246, 63, 23684, 707, 492, 8142, 7394, 3896, 24934, 199, 504, 29563, 14, 1531, 492, 5817, 199, 504, 29563, 14, 1531, 492, 2790, 32394, 1974, 4455, 199, 504, 29563, 14, 1531, 492, 2372, 6782, 2353, 199, 504, 29563, 14, 1531, 492, 593, 6533, 63, 12644, 63, 5443, 199, 504, 29563, 14, 1531, 492, 5244, 337, 3514, 32394, 1974, 199, 646, 29563, 14, 4405, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 13986, 11212, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 598, 83, 1974, 7394, 2543, 2956, 2927, 199, 504, 29563, 14, 1259, 63, 1246, 63, 1130, 492, 598, 83, 1974, 7394, 2956, 2927, 199, 504, 29563, 14, 1971, 492, 5817, 1726, 199, 504, 29563, 14, 21757, 63, 1001, 63, 1246, 492, 598, 1259, 9653, 7394, 199, 504, 29563, 14, 889, 63, 411, 63, 6942, 492, 3091, 4619, 13428, 199, 504, 29563, 14, 2902, 63, 4883, 492, 4155, 6600, 351, 199, 504, 29563, 14, 1974, 492, 18955, 21167, 199, 504, 29563, 14, 1974, 492, 2372, 32394, 1974, 3353, 11911, 1366, 199, 504, 29563, 14, 1974, 492, 598, 51, 29076, 63, 13047, 63, 52, 8611, 1761, 199, 504, 29563, 14, 1974, 492, 6596, 9602, 607, 2967, 67, 9462, 199, 504, 29563, 14, 1974, 492, 491, 11307, 63, 8936, 1149, 63, 2707, 63, 8021, 29076, 63, 10383, 63, 20277, 63, 3817, 199, 504, 29563, 14, 1974, 492, 12077, 1721, 32394, 1974, 3353, 199, 504, 29563, 14, 1974, 492, 6879, 6338, 1831, 11464, 199, 504, 29563, 14, 1974, 492, 5363, 17177, 63, 4609, 654, 63, 2632, 199, 504, 29563, 14, 1974, 492, 5795, 1864, 3177, 63, 4227, 63, 11655, 199, 504, 29563, 14, 1974, 492, 9094, 24, 421, 199, 318, 8690, 6373, 35, 2691, 8, 589, 304, 523, 408, 23555, 2803, 402, 1414, 13, 604, 1249, 14, 819, 3033, 26, 272, 1249, 26, 1625, 402, 1414, 13, 604, 1249, 14, 819, 1803, 26, 272, 1625, 402, 1414, 13, 604, 1249, 14, 819, 6218, 26, 272, 5817, 1726, 26, 340, 2552, 14556, 14, 523, 408, 523, 327, 2018, 14933, 2368, 687, 314, 1414, 1004, 465, 3696, 3326, 14, 4005, 523, 327, 6657, 15579, 3062, 12, 781, 4849, 7869, 1163, 2419, 446, 72, 436, 446, 80, 1249, 334, 6777, 523, 327, 911, 506, 3032, 465, 2323, 12, 436, 12850, 1126, 3101, 3158, 1077, 440, 506, 5737, 9, 465, 523, 327, 2774, 13, 24, 14, 710, 1919, 365, 671, 13, 28069, 13, 2024, 13, 10, 2323, 12, 1314, 787, 4370, 370, 1395, 523, 327, 2222, 13, 12292, 1564, 334, 460, 19407, 12, 1077, 506, 11203, 395, 1126, 523, 327, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 458, 1974, 15, 525, 76, 3437, 15, 18356, 3007, 1692, 5142, 523, 6661, 63, 1291, 275, 756, 523, 367, 284, 315, 1425, 8, 552, 8, 589, 2298, 272, 1680, 275, 1249, 59, 73, 61, 272, 327, 5817, 83, 2839, 15413, 883, 1255, 642, 805, 13373, 27, 2793, 1133, 4849, 13373, 14, 272, 862, 26, 489, 11203, 275, 1680, 340, 1228, 8, 1273, 12, 2649, 9, 587, 1680, 14, 2708, 8, 6610, 24, 9, 272, 871, 18965, 26, 489, 746, 5817, 1726, 2258, 78, 1370, 904, 8, 505, 3823, 14, 3823, 8, 881, 283, 3364, 2644, 367, 1423, 4366, 83, 680, 7628, 1471, 506, 477, 7889, 461, 465, 283, 881, 283, 7087, 14, 6944, 26, 314, 1423, 12487, 3432, 19058, 314, 557, 31197, 283, 881, 283, 16516, 543, 282, 6318, 13, 8167, 21834, 6025, 14, 2104, 1655, 283, 881, 283, 5087, 334, 15768, 4212, 370, 3957, 370, 282, 24986, 13, 6490, 2644, 9, 283, 881, 283, 3239, 658, 458, 1974, 1720, 2644, 2313, 7, 450, 4700, 8, 1273, 7845, 272, 340, 6661, 63, 1291, 26, 489, 340, 1680, 14, 2325, 1252, 2460, 360, 88, 13, 28069, 13, 2024, 735, 267, 1249, 59, 73, 61, 275, 11203, 489, 587, 26, 267, 862, 26, 881, 327, 7649, 370, 3752, 465, 10485, 370, 1104, 367, 3866, 1406, 1338, 334, 6777, 881, 327, 883, 1133, 506, 4847, 1806, 3101, 680, 881, 11203, 14, 2143, 360, 4371, 358, 267, 871, 24094, 26, 881, 327, 14771, 314, 5817, 1726, 1808, 314, 11203, 574, 2952, 881, 327, 485, 2959, 3325, 6699, 805, 295, 13, 2143, 83, 737, 314, 1284, 14, 881, 746, 5817, 1726, 8, 1598, 283, 3364, 2222, 13, 12292, 1406, 574, 4366, 83, 12013, 78, 5903, 10485, 4110, 787, 283, 1598, 283, 6541, 315, 2323, 1163, 2419, 671, 13, 28069, 13, 2024, 13, 2323, 7, 450, 11203, 9, 272, 587, 26, 489, 1249, 59, 73, 61, 275, 11203, 272, 6661, 63, 1291, 275, 334, 1273, 315, 12291, 72, 297, 2475, 80, 1333, 523, 372, 1249, 421, 199, 533, 5817, 7446, 8, 785, 304, 523, 408, 16291, 24986, 3718, 436, 1630, 2005, 2746, 13, 1896,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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 ]
phisiart/tvm
topi/python/topi/util.py
1
2941
"""Common topi utilities""" from __future__ import absolute_import as _abs import tvm def get_const_int(expr): """Verifies expr is integer and get the constant value. Parameters ---------- expr : tvm.Expr or int The input expression. Returns ------- out_value : int The output. """ if isinstance(expr, int): return expr if not isinstance(expr, (tvm.expr.IntImm, tvm.expr.UIntImm)): expr = tvm.ir_pass.Simplify(expr) if not isinstance(expr, (tvm.expr.IntImm, tvm.expr.UIntImm)): raise ValueError("Expect value to be constant int") return expr.value def equal_const_int(expr, value): """Returns if expr equals value. Parameters ---------- expr : tvm.Expr The input expression. Returns ------- equal : bool Whether they equals. """ if isinstance(expr, int): return expr == value if not isinstance(expr, (tvm.expr.IntImm, tvm.expr.UIntImm)): expr = tvm.ir_pass.Simplify(expr) if not isinstance(expr, (tvm.expr.IntImm, tvm.expr.UIntImm)): return False return expr.value == value def get_const_tuple(in_tuple): """Verifies input tuple is IntImm, returns tuple of int. Parameters ---------- in_tuple : tuple of Expr The input. Returns ------- out_tuple : tuple of int The output. """ out_tuple = () for elem in in_tuple: value = get_const_int(elem) out_tuple = out_tuple + (value, ) return out_tuple def simplify(expr): """Simplify the expression if it is Expr, directly return if it is int. Parameters ---------- expr : Expr or int The input. Returns ------- out : Expr or int The simplified output """ return tvm.ir_pass.Simplify(expr) if isinstance(expr, tvm.expr.Expr) else expr def ravel_index(indices, shape): """Flatten the index tuple to 1D Parameters ---------- indices : tuple of int or tvm.expr.IntImm The input coordinates shape : tuple of int Shape of the tensor. Returns ------- idx : int or Expr The index after flattening """ idx = None for i, (shape_val, ind) in enumerate(zip(shape, indices)): if i != 0: idx = idx * shape_val + ind else: idx = ind return idx def unravel_index(idx, shape): """Convert the flattened ind to the coordinate array Parameters ---------- idx : int or tvm.expr.IntImm The 1D index shape : tuple of int Shape of the tensor Returns ------- indices : tuple of int or tvm.expr.IntImm Corresponding coordinate of the 1D index """ indices = [] for i in range(len(shape) - 1, -1, -1): indices.append(idx % shape[i]) idx = idx // shape[i] indices = indices[::-1] return indices
apache-2.0
[ 624, 7844, 370, 1038, 15841, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 465, 485, 2101, 199, 646, 31385, 199, 199, 318, 664, 63, 1297, 63, 442, 8, 3684, 304, 272, 408, 21168, 5348, 365, 3000, 436, 664, 314, 4413, 574, 14, 339, 3897, 272, 4143, 272, 5348, 520, 31385, 14, 8561, 503, 1109, 267, 710, 1324, 3965, 14, 339, 1803, 272, 5514, 272, 734, 63, 585, 520, 1109, 267, 710, 1072, 14, 272, 408, 272, 340, 1228, 8, 3684, 12, 1109, 304, 267, 372, 5348, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 5348, 275, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 746, 1722, 480, 13495, 574, 370, 506, 4413, 1109, 531, 272, 372, 5348, 14, 585, 421, 199, 318, 4472, 63, 1297, 63, 442, 8, 3684, 12, 574, 304, 272, 408, 3407, 340, 5348, 18527, 574, 14, 339, 3897, 272, 4143, 272, 5348, 520, 31385, 14, 8561, 267, 710, 1324, 3965, 14, 339, 1803, 272, 5514, 272, 4472, 520, 2155, 267, 7480, 2985, 18527, 14, 272, 408, 272, 340, 1228, 8, 3684, 12, 1109, 304, 267, 372, 5348, 508, 574, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 5348, 275, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 372, 756, 272, 372, 5348, 14, 585, 508, 574, 421, 199, 318, 664, 63, 1297, 63, 2960, 8, 262, 63, 2960, 304, 272, 408, 21168, 1324, 2008, 365, 9805, 27564, 12, 2529, 2008, 402, 1109, 14, 339, 3897, 272, 4143, 272, 315, 63, 2960, 520, 2008, 402, 14754, 267, 710, 1324, 14, 339, 1803, 272, 5514, 272, 734, 63, 2960, 520, 2008, 402, 1109, 267, 710, 1072, 14, 272, 408, 272, 734, 63, 2960, 275, 6248, 272, 367, 6193, 315, 315, 63, 2960, 26, 267, 574, 275, 664, 63, 1297, 63, 442, 8, 6086, 9, 267, 734, 63, 2960, 275, 734, 63, 2960, 435, 334, 585, 12, 776, 272, 372, 734, 63, 2960, 421, 199, 318, 15037, 8, 3684, 304, 272, 408, 51, 3236, 8209, 314, 3965, 340, 652, 365, 14754, 12, 5370, 372, 340, 652, 365, 1109, 14, 339, 3897, 272, 4143, 272, 5348, 520, 14754, 503, 1109, 267, 710, 1324, 14, 339, 1803, 272, 5514, 272, 734, 520, 14754, 503, 1109, 267, 710, 26867, 1072, 272, 408, 272, 372, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 340, 1228, 8, 3684, 12, 31385, 14, 3684, 14, 8561, 9, 587, 5348, 421, 199, 318, 660, 1090, 63, 1080, 8, 4108, 12, 2215, 304, 272, 408, 29302, 314, 1478, 2008, 370, 413, 36, 339, 3897, 272, 4143, 272, 4918, 520, 2008, 402, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 710, 1324, 8983, 339, 2215, 520, 2008, 402, 1109, 267, 16528, 402, 314, 2345, 14, 339, 1803, 272, 5514, 272, 4280, 520, 1109, 503, 14754, 267, 710, 1478, 2410, 9378, 316, 272, 408, 272, 4280, 275, 488, 272, 367, 284, 12, 334, 1392, 63, 637, 12, 7654, 9, 315, 3874, 8, 3065, 8, 1392, 12, 4918, 2298, 267, 340, 284, 1137, 378, 26, 288, 4280, 275, 4280, 627, 2215, 63, 637, 435, 7654, 267, 587, 26, 288, 4280, 275, 7654, 272, 372, 4280, 421, 199, 318, 625, 11186, 63, 1080, 8, 2996, 12, 2215, 304, 272, 408, 7306, 314, 18767, 7654, 370, 314, 10021, 1625, 339, 3897, 272, 4143, 272, 4280, 520, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 710, 413, 36, 1478, 339, 2215, 520, 2008, 402, 1109, 267, 16528, 402, 314, 2345, 339, 1803, 272, 5514, 272, 4918, 520, 2008, 402, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 7499, 31137, 10021, 402, 314, 413, 36, 1478, 272, 408, 272, 4918, 275, 942, 272, 367, 284, 315, 1425, 8, 552, 8, 1392, 9, 446, 413, 12, 446, 17, 12, 446, 17, 304, 267, 4918, 14, 740, 8, 2996, 450, 2215, 59, 73, 566, 267, 4280, 275, 4280, 5001, 2215, 59, 73, 61, 272, 4918, 275, 4918, 14172, 17, 61, 272, 372, 4918, 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 ]
[ 7844, 370, 1038, 15841, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 465, 485, 2101, 199, 646, 31385, 199, 199, 318, 664, 63, 1297, 63, 442, 8, 3684, 304, 272, 408, 21168, 5348, 365, 3000, 436, 664, 314, 4413, 574, 14, 339, 3897, 272, 4143, 272, 5348, 520, 31385, 14, 8561, 503, 1109, 267, 710, 1324, 3965, 14, 339, 1803, 272, 5514, 272, 734, 63, 585, 520, 1109, 267, 710, 1072, 14, 272, 408, 272, 340, 1228, 8, 3684, 12, 1109, 304, 267, 372, 5348, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 5348, 275, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 746, 1722, 480, 13495, 574, 370, 506, 4413, 1109, 531, 272, 372, 5348, 14, 585, 421, 199, 318, 4472, 63, 1297, 63, 442, 8, 3684, 12, 574, 304, 272, 408, 3407, 340, 5348, 18527, 574, 14, 339, 3897, 272, 4143, 272, 5348, 520, 31385, 14, 8561, 267, 710, 1324, 3965, 14, 339, 1803, 272, 5514, 272, 4472, 520, 2155, 267, 7480, 2985, 18527, 14, 272, 408, 272, 340, 1228, 8, 3684, 12, 1109, 304, 267, 372, 5348, 508, 574, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 5348, 275, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 272, 340, 440, 1228, 8, 3684, 12, 334, 84, 2611, 14, 3684, 14, 3241, 27564, 12, 31385, 14, 3684, 14, 13304, 27564, 2298, 267, 372, 756, 272, 372, 5348, 14, 585, 508, 574, 421, 199, 318, 664, 63, 1297, 63, 2960, 8, 262, 63, 2960, 304, 272, 408, 21168, 1324, 2008, 365, 9805, 27564, 12, 2529, 2008, 402, 1109, 14, 339, 3897, 272, 4143, 272, 315, 63, 2960, 520, 2008, 402, 14754, 267, 710, 1324, 14, 339, 1803, 272, 5514, 272, 734, 63, 2960, 520, 2008, 402, 1109, 267, 710, 1072, 14, 272, 408, 272, 734, 63, 2960, 275, 6248, 272, 367, 6193, 315, 315, 63, 2960, 26, 267, 574, 275, 664, 63, 1297, 63, 442, 8, 6086, 9, 267, 734, 63, 2960, 275, 734, 63, 2960, 435, 334, 585, 12, 776, 272, 372, 734, 63, 2960, 421, 199, 318, 15037, 8, 3684, 304, 272, 408, 51, 3236, 8209, 314, 3965, 340, 652, 365, 14754, 12, 5370, 372, 340, 652, 365, 1109, 14, 339, 3897, 272, 4143, 272, 5348, 520, 14754, 503, 1109, 267, 710, 1324, 14, 339, 1803, 272, 5514, 272, 734, 520, 14754, 503, 1109, 267, 710, 26867, 1072, 272, 408, 272, 372, 31385, 14, 723, 63, 1529, 14, 51, 3236, 8209, 8, 3684, 9, 340, 1228, 8, 3684, 12, 31385, 14, 3684, 14, 8561, 9, 587, 5348, 421, 199, 318, 660, 1090, 63, 1080, 8, 4108, 12, 2215, 304, 272, 408, 29302, 314, 1478, 2008, 370, 413, 36, 339, 3897, 272, 4143, 272, 4918, 520, 2008, 402, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 710, 1324, 8983, 339, 2215, 520, 2008, 402, 1109, 267, 16528, 402, 314, 2345, 14, 339, 1803, 272, 5514, 272, 4280, 520, 1109, 503, 14754, 267, 710, 1478, 2410, 9378, 316, 272, 408, 272, 4280, 275, 488, 272, 367, 284, 12, 334, 1392, 63, 637, 12, 7654, 9, 315, 3874, 8, 3065, 8, 1392, 12, 4918, 2298, 267, 340, 284, 1137, 378, 26, 288, 4280, 275, 4280, 627, 2215, 63, 637, 435, 7654, 267, 587, 26, 288, 4280, 275, 7654, 272, 372, 4280, 421, 199, 318, 625, 11186, 63, 1080, 8, 2996, 12, 2215, 304, 272, 408, 7306, 314, 18767, 7654, 370, 314, 10021, 1625, 339, 3897, 272, 4143, 272, 4280, 520, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 710, 413, 36, 1478, 339, 2215, 520, 2008, 402, 1109, 267, 16528, 402, 314, 2345, 339, 1803, 272, 5514, 272, 4918, 520, 2008, 402, 1109, 503, 31385, 14, 3684, 14, 3241, 27564, 267, 7499, 31137, 10021, 402, 314, 413, 36, 1478, 272, 408, 272, 4918, 275, 942, 272, 367, 284, 315, 1425, 8, 552, 8, 1392, 9, 446, 413, 12, 446, 17, 12, 446, 17, 304, 267, 4918, 14, 740, 8, 2996, 450, 2215, 59, 73, 566, 267, 4280, 275, 4280, 5001, 2215, 59, 73, 61, 272, 4918, 275, 4918, 14172, 17, 61, 272, 372, 4918, 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, 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,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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 ]
lukeiwanski/tensorflow
tensorflow/contrib/kfac/examples/tests/mnist_test.py
41
2500
# Copyright 2017 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. # ============================================================================== """Tests for mnist.py.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf from tensorflow.contrib.kfac.examples import mnist class MnistTest(tf.test.TestCase): def testValues(self): """Ensure values are in their expected range.""" with tf.Graph().as_default(): examples, labels = mnist.load_mnist( data_dir=None, num_epochs=1, batch_size=64, use_fake_data=True) with self.test_session() as sess: examples_, labels_ = sess.run([examples, labels]) self.assertTrue(np.all((0 <= examples_) & (examples_ < 1))) self.assertTrue(np.all((0 <= labels_) & (labels_ < 10))) def testFlattenedShapes(self): """Ensure images are flattened into their appropriate shape.""" with tf.Graph().as_default(): examples, labels = mnist.load_mnist( data_dir=None, num_epochs=1, batch_size=64, flatten_images=True, use_fake_data=True) with self.test_session() as sess: examples_, labels_ = sess.run([examples, labels]) self.assertEqual(examples_.shape, (64, 784)) self.assertEqual(labels_.shape, (64,)) def testNotFlattenedShapes(self): """Ensure non-flattened images are their appropriate shape.""" with tf.Graph().as_default(): examples, labels = mnist.load_mnist( data_dir=None, num_epochs=1, batch_size=64, flatten_images=False, use_fake_data=True) with self.test_session() as sess: examples_, labels_ = sess.run([examples, labels]) self.assertEqual(examples_.shape, (64, 28, 28, 1)) self.assertEqual(labels_.shape, (64,)) if __name__ == '__main__': tf.test.main()
apache-2.0
[ 3, 1898, 9708, 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, 2925, 367, 21945, 631, 14, 647, 1041, 199, 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, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 2828, 14, 75, 12668, 14, 8589, 492, 21945, 631, 421, 199, 533, 603, 78, 631, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 6550, 8, 277, 304, 272, 408, 13913, 1338, 787, 315, 3932, 1420, 1425, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 1967, 63, 13161, 29, 17, 12, 3522, 63, 890, 29, 772, 12, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 1815, 8, 1590, 14, 452, 1332, 16, 2695, 7251, 4602, 1253, 334, 8589, 63, 665, 413, 1724, 267, 291, 14, 1815, 8, 1590, 14, 452, 1332, 16, 2695, 3628, 4602, 1253, 334, 3512, 63, 665, 1616, 1724, 819, 347, 511, 29302, 379, 7238, 83, 8, 277, 304, 272, 408, 13913, 5935, 787, 18767, 1901, 3932, 5827, 2215, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 881, 1967, 63, 13161, 29, 17, 12, 881, 3522, 63, 890, 29, 772, 12, 881, 9378, 63, 4782, 29, 549, 12, 881, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 629, 8, 8589, 3754, 1392, 12, 334, 772, 12, 1520, 1349, 430, 267, 291, 14, 629, 8, 3512, 3754, 1392, 12, 334, 772, 4641, 819, 347, 511, 1763, 29302, 379, 7238, 83, 8, 277, 304, 272, 408, 13913, 2222, 13, 28079, 5935, 787, 3932, 5827, 2215, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 881, 1967, 63, 13161, 29, 17, 12, 881, 3522, 63, 890, 29, 772, 12, 881, 9378, 63, 4782, 29, 797, 12, 881, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 629, 8, 8589, 3754, 1392, 12, 334, 772, 12, 7294, 12, 7294, 12, 413, 430, 267, 291, 14, 629, 8, 3512, 3754, 1392, 12, 334, 772, 4641, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 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 ]
[ 1898, 9708, 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, 2925, 367, 21945, 631, 14, 647, 1041, 199, 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, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 2828, 14, 75, 12668, 14, 8589, 492, 21945, 631, 421, 199, 533, 603, 78, 631, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 511, 6550, 8, 277, 304, 272, 408, 13913, 1338, 787, 315, 3932, 1420, 1425, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 1967, 63, 13161, 29, 17, 12, 3522, 63, 890, 29, 772, 12, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 1815, 8, 1590, 14, 452, 1332, 16, 2695, 7251, 4602, 1253, 334, 8589, 63, 665, 413, 1724, 267, 291, 14, 1815, 8, 1590, 14, 452, 1332, 16, 2695, 3628, 4602, 1253, 334, 3512, 63, 665, 1616, 1724, 819, 347, 511, 29302, 379, 7238, 83, 8, 277, 304, 272, 408, 13913, 5935, 787, 18767, 1901, 3932, 5827, 2215, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 881, 1967, 63, 13161, 29, 17, 12, 881, 3522, 63, 890, 29, 772, 12, 881, 9378, 63, 4782, 29, 549, 12, 881, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 629, 8, 8589, 3754, 1392, 12, 334, 772, 12, 1520, 1349, 430, 267, 291, 14, 629, 8, 3512, 3754, 1392, 12, 334, 772, 4641, 819, 347, 511, 1763, 29302, 379, 7238, 83, 8, 277, 304, 272, 408, 13913, 2222, 13, 28079, 5935, 787, 3932, 5827, 2215, 1041, 272, 543, 2833, 14, 4578, 1252, 305, 63, 885, 837, 489, 7251, 12, 3628, 275, 21945, 631, 14, 912, 63, 32164, 8, 881, 666, 63, 694, 29, 403, 12, 881, 1967, 63, 13161, 29, 17, 12, 881, 3522, 63, 890, 29, 772, 12, 881, 9378, 63, 4782, 29, 797, 12, 881, 675, 63, 3183, 63, 576, 29, 549, 9, 2541, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 267, 7251, 3131, 3628, 63, 275, 4043, 14, 1065, 779, 8589, 12, 3628, 566, 267, 291, 14, 629, 8, 8589, 3754, 1392, 12, 334, 772, 12, 7294, 12, 7294, 12, 413, 430, 267, 291, 14, 629, 8, 3512, 3754, 1392, 12, 334, 772, 4641, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2833, 14, 396, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GaretJax/csat
csat/collectors/pygit/collector.py
1
15128
import os import datetime import git import tempfile import shutil import re from csat.paths import PathWalker from csat.graphml.builder import GraphMLDocument, Attribute from . import parser class ModuleNotFound(KeyError): pass class ModuleAlreadyTracked(KeyError): pass def timestamp_to_iso(timestamp): return datetime.datetime.fromtimestamp(timestamp).isoformat() class DependencyGraph(object): def __init__(self, keep_history): self.modules = {} self.authors = {} self.modifications = {} self._nextid = 0 self._nextauthorid = 0 self._init_graph() self.keep_history = False def _init_graph(self): self.graph = GraphMLDocument() self.graph.attr(Attribute.GRAPH, 'merge_key') self.graph.attr(Attribute.NODE, 'domain') self.graph.attr(Attribute.NODE, 'commits', 'int') self.graph.attr(Attribute.NODE, 'package') self.graph.attr(Attribute.ALL, 'type') self.graph.attr(Attribute.ALL, 'date_added') self.graph.attr(Attribute.ALL, 'commit_added') self.graph.attr(Attribute.ALL, 'author_added') self.graph.attr(Attribute.ALL, 'date_removed') self.graph.attr(Attribute.ALL, 'commit_removed') self.graph.attr(Attribute.ALL, 'author_removed') self.graph.attr(Attribute.ALL, 'email') self.graph.attr(Attribute.ALL, 'count', 'int') self.domains = self.graph.digraph(None, { 'merge_key': 'domain' }) self.components = self.domains.node(None, { 'domain': 'components' }).subgraph(None, { 'merge_key': 'package' }) self.developers = self.domains.node(None, { 'domain': 'people' }).subgraph(None, { 'merge_key': 'email' }) def email_from_commit(self, commit): email = commit.author.email # TODO: hardcoded is BAAAD! return re.sub(r'[0-9a-f-]{36}$', 'twistedmatrix.com', email) def add_modification(self, commit, module): email = self.email_from_commit(commit) try: authorid, authornode = self.authors[email] authornode['commits'] += 1 except KeyError: authorid = self._nextauthorid authornode = self.developers.node(authorid, { 'email': email, 'commits': 1, }) self.authors[email] = [authorid, authornode] self._nextauthorid += 1 modulenode = self.module(module) try: edge = self.modifications[authornode, modulenode] edge['commits'] += 1 except KeyError: edge = self.domains.edge(authornode, modulenode, { 'type': 'modification', 'count': 1, }) self.modifications[authornode, modulenode] = edge def add_module(self, commit, module): email = self.email_from_commit(commit) try: if not self.modules[module][2] and not self.keep_history: raise KeyError else: self.modules[module][2] = True except KeyError: self.modules[module] = [self._nextid, set(), True] self.components.node(self._nextid, { 'package': module.get_import_path(), 'type': 'package', # TODO: Nor really true 'date_added': timestamp_to_iso(commit.committed_date), 'commit_added': commit.hexsha, 'author_added': email, }) self._nextid += 1 else: # TODO: Update commit metadata pass def id(self, module): return self.modules[module][0] def module(self, module): return self.components.nodes[self.modules[module][0]] def dependency(self, source, target): try: key = self.module(source), self.module(target) return self.components.edges[key] except KeyError: return set() def remove_module(self, commit, module): spec = self.modules[module] assert not spec[1] spec[2] = False node = self.module(module) if self.keep_history: node['date_removed'] = timestamp_to_iso(commit.committed_date) node['commit_removed'] = commit.hexsha node['author_removed'] = self.email_from_commit(commit) else: self.components.remove_node(node) def get_dependencies(self, module): try: _, deps, active = self.modules[module] if not active: raise ModuleNotFound(module) except KeyError: raise ModuleNotFound(module) return deps def add_dependency(self, commit, source, target): self.add_module(commit, target) self.get_dependencies(source).add(target) self.components.edge(self.module(source), self.module(target), { 'type': 'dependency', 'date_added': timestamp_to_iso(commit.committed_date), 'commit_added': commit.hexsha, 'author_added': self.email_from_commit(commit), }) def add_dependencies(self, commit, source, targets): for target in targets: self.add_dependency(commit, source, target) def remove_dependency(self, commit, source, target): self.get_dependencies(source).remove(target) if self.keep_history: for edge in self.dependency(source, target): edge['date_removed'] = timestamp_to_iso(commit.committed_date) edge['commit_removed'] = commit.hexsha edge['author_removed'] = self.email_from_commit(commit) else: self.dependency(source, target).clear() def remove_dependencies(self, commit, source, targets): for target in targets: self.remove_dependency(commit, source, target) def write_graphml(self, stream): return self.graph.normalized().to_file(stream) class GitPythonCollector(object): def __init__(self, task_manager, logger, repo_url, rev, package, keep_history): self.tasks = task_manager self.log = logger self.repo_url = repo_url self.clone_path = None self.git = None self.rev = rev self.package_path = package.strip('/') try: self.base_path, self.package_name = self.package_path.rsplit('/', 1) except ValueError: self.base_path, self.package_name = '', self.package_path self.graph = DependencyGraph(keep_history=keep_history) def init_repo(self): self.checkout_task.statusText = ('Cloning repository to temporary ' 'location...') self.checkout_task.status = self.checkout_task.RUNNING self.clone_path = tempfile.mkdtemp(prefix='csat-pygit-') self.log.info('Cloning to temporary directory at {!r}'.format( self.clone_path)) self.repo = git.Repo.clone_from(self.repo_url, self.clone_path) self.checkout_task.setCompleted() self.git = self.repo.git def run(self): # Init tasks self.checkout_task = self.tasks.new('Source checkout') self.commit_task = self.tasks.new('Parsing commits') try: self.init_repo() commits = self.bootstrap() self.analyze(commits) finally: # Cleanup self.log.info('Removing temporary repository at {}'.format( self.clone_path)) shutil.rmtree(self.clone_path) return self.graph def bootstrap(self): self.commit_task.statusText = 'Getting commit summary...' self.count = 0 for commit in self.repo.iter_commits(self.rev): self.count += 1 if not self.count: raise ValueError('The provided revision specifier does not ' 'contain any commits.') self.commit_task.steps = self.count + 1 commits = self.repo.iter_commits(self.rev, max_count=self.count, reverse=True) commits = enumerate(commits) skip = False for i, commit in commits: self.git.checkout(commit.hexsha, force=True) package_dir = os.path.join(self.repo.working_dir, self.base_path) if os.path.exists(package_dir): self.log.info('First commit set to [{}]: {}'.format( commit.hexsha[:6], commit.summary.encode('utf-8'))) self.handle_initial_commit(commit) break elif not skip: skip = True self.log.warning('Package directory not found at initial ' 'commit [{}], fast forwarding...' .format(commit.hexsha[:6])) self.commit_task.statusText = ( 'Finding initial commit (skipping {}/{})...'.format( i + 1, self.count)) self.commit_task.makeStep() else: self.log.critical('Package directory not found in any commit in ' 'the given revspec.') raise RuntimeError('Package not found') self.commit_task.makeStep() return commits def analyze(self, commits): for i, commit in commits: try: summary = commit.summary.encode('utf-8') except LookupError: # Sometimes our git library does not want to play along summary = '' self.log.debug('Analyzing commit [{}]: {}'.format( commit.hexsha[:6], summary)) self.commit_task.statusText = 'Analyzing commit {}/{}...'.format( i + 1, self.count) self.git.checkout(commit.hexsha, force=True) paths = self.get_modified_paths(commit.parents[0]) self.handle_commit(commit, paths) self.commit_task.makeStep() self.log.info('Last commit is [{}]: {}'.format( commit.hexsha[:6], commit.summary.encode('utf-8'))) self.commit_task.setCompleted() def get_modified_paths(self, commit): for diff in commit.diff(): if diff.renamed: self.log.error('RENAMED {}'.format(diff.path)) #if diff.a_blob is None: # # File was created # self.log.error('CREATED {}'.format(diff.b_blob.path)) if diff.b_blob is None: # File was deleted deleted = True path = diff.a_blob.path else: deleted = False path = diff.b_blob.path path = path[len(self.base_path) + 1:] if self.base_path else path if self.filter_path(path): yield path, deleted def filter_path(self, path): # Keep only python files if not path.endswith('.py'): return False # Keep only files in the package if not path.startswith('{}/'.format(self.package_name)): return False # Exclude test files if '/test/' in path or path.endswith('test.py'): return False return True def get_dependent_modules(self, commit, module): imports = module.get_imports() imports = (imp for imp in imports if imp.is_submodule( self.package_name)) depends_on = set() package_dir = os.path.join(self.repo.working_dir, self.base_path) try: for imp in imports: paths = imp.get_paths() for p in paths: if os.path.exists(os.path.join(package_dir, p)): depends_on.add(parser.Module(p, package_dir)) break else: location = '{}:{}:{} @ {}'.format( module.path, imp.node.lineno, imp.node.col_offset, commit.hexsha[:6]) path_list = '\n'.join(' * {}'.format(p) for p in paths) msg = ( 'Could not find target for \'{}\' in {}, tried:\n{}' .format(imp.code(), location, path_list) ) self.log.warn(msg) except SyntaxError as e: location = '{}:{}:{}'.format(e.filename, e.lineno, e.offset) code = '>>> ' + e.text + ' ' * (e.offset + 3) + '^' error = '{}\n{}'.format(location, code) self.log.error('Could not parse module {!r} in commit {} ({})\n{}' .format(module.get_import_path(), commit.hexsha[:6], e.msg, error)) except ValueError as e: self.log.error('Could not parse module {!r} in commit {} ({})' .format(module.get_import_path(), commit.hexsha[:6], e)) return depends_on def handle_initial_commit(self, commit): package_dir = os.path.join(self.repo.working_dir, self.base_path) walker = PathWalker(package_dir, fullpath=False) walker.filter(filename=r'.*\.py') walker.exclude(directory=r'\.git') walker.exclude(directory=r'test') walker.exclude(directory=r'doc') def create_iter(paths): for p in paths: if self.filter_path(p): yield p, False self.handle_commit(commit, create_iter(walker.walk())) def handle_commit(self, commit, paths): package_dir = os.path.join(self.repo.working_dir, self.base_path) for path, deleted in paths: module = parser.Module(path, package_dir) if deleted: dependencies = set() else: dependencies = self.get_dependent_modules(commit, module) try: old_dependencies = self.graph.get_dependencies(module) removed = old_dependencies - dependencies added = dependencies - old_dependencies except ModuleNotFound: #assert not deleted self.log.debug('Created {!r}'.format(module)) self.graph.add_module(commit, module) added = dependencies removed = set() self.graph.add_modification(commit, module) if deleted: self.log.debug('Deleted {!r}'.format(module)) self.graph.remove_dependencies(commit, module, removed) self.graph.add_dependencies(commit, module, added) if deleted: self.graph.remove_module(commit, module) if not paths: self.log.debug('No source files modified, skipping commit {}' .format(commit.hexsha[:6]))
mit
[ 646, 747, 199, 646, 2197, 199, 646, 6135, 199, 646, 5549, 199, 646, 5145, 199, 646, 295, 199, 199, 504, 7117, 292, 14, 3771, 492, 6912, 26020, 199, 504, 7117, 292, 14, 2180, 757, 14, 5649, 492, 11513, 1698, 5564, 12, 3882, 199, 504, 1275, 492, 1798, 421, 199, 533, 5673, 4667, 8, 10230, 304, 272, 986, 421, 199, 533, 5673, 16760, 7927, 379, 8, 10230, 304, 272, 986, 421, 199, 318, 4913, 63, 475, 63, 4595, 8, 3954, 304, 272, 372, 2197, 14, 2083, 14, 18531, 8, 3954, 680, 17070, 342, 421, 199, 533, 22922, 4578, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4215, 63, 5570, 304, 267, 291, 14, 3112, 275, 1052, 267, 291, 14, 8149, 275, 1052, 267, 291, 14, 20945, 83, 275, 1052, 267, 291, 423, 14743, 5700, 275, 378, 267, 291, 423, 2184, 2502, 344, 275, 378, 267, 291, 423, 826, 63, 2180, 342, 267, 291, 14, 3250, 63, 5570, 275, 756, 339, 347, 485, 826, 63, 2180, 8, 277, 304, 267, 291, 14, 2180, 275, 11513, 1698, 5564, 342, 398, 291, 14, 2180, 14, 962, 8, 1646, 14, 25302, 12, 283, 5628, 63, 498, 358, 398, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 2261, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 18679, 297, 283, 442, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 2491, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 466, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 602, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 3543, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2502, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 602, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 3543, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2502, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2123, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 835, 297, 283, 442, 358, 398, 291, 14, 9756, 275, 291, 14, 2180, 14, 328, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2261, 7, 267, 3828, 398, 291, 14, 4608, 275, 291, 14, 9756, 14, 932, 8, 403, 12, 469, 288, 283, 2261, 356, 283, 4608, 7, 267, 789, 680, 954, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2491, 7, 267, 3828, 398, 291, 14, 23826, 275, 291, 14, 9756, 14, 932, 8, 403, 12, 469, 288, 283, 2261, 356, 283, 13562, 7, 267, 789, 680, 954, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2123, 7, 267, 3828, 339, 347, 3031, 63, 504, 63, 3543, 8, 277, 12, 5532, 304, 267, 3031, 275, 5532, 14, 2502, 14, 2123, 267, 327, 3254, 26, 7508, 15282, 365, 699, 2276, 1554, 1, 267, 372, 295, 14, 954, 8, 82, 3894, 16, 13, 25, 65, 13, 70, 13, 8194, 1344, 19204, 283, 12145, 3642, 14, 957, 297, 3031, 9, 339, 347, 1050, 63, 20945, 8, 277, 12, 5532, 12, 859, 304, 267, 3031, 275, 291, 14, 2123, 63, 504, 63, 3543, 8, 3543, 9, 267, 862, 26, 288, 4132, 344, 12, 4132, 932, 275, 291, 14, 8149, 59, 2123, 61, 288, 4132, 932, 459, 18679, 418, 847, 413, 267, 871, 4067, 26, 288, 4132, 344, 275, 291, 423, 2184, 2502, 344, 288, 4132, 932, 275, 291, 14, 23826, 14, 932, 8, 2502, 344, 12, 469, 355, 283, 2123, 356, 3031, 12, 355, 283, 18679, 356, 413, 12, 288, 3828, 288, 291, 14, 8149, 59, 2123, 61, 275, 359, 2502, 344, 12, 4132, 932, 61, 288, 291, 423, 2184, 2502, 344, 847, 413, 398, 859, 932, 275, 291, 14, 578, 8, 578, 9, 398, 862, 26, 288, 6275, 275, 291, 14, 20945, 83, 59, 2502, 932, 12, 859, 932, 61, 288, 6275, 459, 18679, 418, 847, 413, 267, 871, 4067, 26, 288, 6275, 275, 291, 14, 9756, 14, 5173, 8, 2502, 932, 12, 859, 932, 12, 469, 355, 283, 466, 356, 283, 20945, 297, 355, 283, 835, 356, 413, 12, 288, 3828, 288, 291, 14, 20945, 83, 59, 2502, 932, 12, 859, 932, 61, 275, 6275, 339, 347, 1050, 63, 578, 8, 277, 12, 5532, 12, 859, 304, 267, 3031, 275, 291, 14, 2123, 63, 504, 63, 3543, 8, 3543, 9, 267, 862, 26, 288, 340, 440, 291, 14, 3112, 59, 578, 1527, 18, 61, 436, 440, 291, 14, 3250, 63, 5570, 26, 355, 746, 4067, 288, 587, 26, 355, 291, 14, 3112, 59, 578, 1527, 18, 61, 275, 715, 267, 871, 4067, 26, 288, 291, 14, 3112, 59, 578, 61, 275, 359, 277, 423, 14743, 5700, 12, 663, 1062, 715, 61, 288, 291, 14, 4608, 14, 932, 8, 277, 423, 14743, 5700, 12, 469, 355, 283, 2491, 356, 859, 14, 362, 63, 646, 63, 515, 1062, 355, 283, 466, 356, 283, 2491, 297, 355, 327, 3254, 26, 653, 269, 7710, 2549, 355, 283, 602, 63, 3270, 356, 4913, 63, 475, 63, 4595, 8, 3543, 14, 20300, 63, 602, 395, 355, 283, 3543, 63, 3270, 356, 5532, 14, 4097, 4835, 12, 355, 283, 2502, 63, 3270, 356, 3031, 12, 288, 3828, 288, 291, 423, 14743, 5700, 847, 413, 267, 587, 26, 288, 327, 3254, 26, 6162, 5532, 3341, 288, 986, 339, 347, 1305, 8, 277, 12, 859, 304, 267, 372, 291, 14, 3112, 59, 578, 1527, 16, 61, 339, 347, 859, 8, 277, 12, 859, 304, 267, 372, 291, 14, 4608, 14, 2415, 59, 277, 14, 3112, 59, 578, 1527, 16, 2677, 339, 347, 5936, 8, 277, 12, 1350, 12, 1347, 304, 267, 862, 26, 288, 790, 275, 291, 14, 578, 8, 1365, 395, 291, 14, 578, 8, 1375, 9, 288, 372, 291, 14, 4608, 14, 6929, 59, 498, 61, 267, 871, 4067, 26, 288, 372, 663, 342, 339, 347, 2813, 63, 578, 8, 277, 12, 5532, 12, 859 ]
[ 747, 199, 646, 2197, 199, 646, 6135, 199, 646, 5549, 199, 646, 5145, 199, 646, 295, 199, 199, 504, 7117, 292, 14, 3771, 492, 6912, 26020, 199, 504, 7117, 292, 14, 2180, 757, 14, 5649, 492, 11513, 1698, 5564, 12, 3882, 199, 504, 1275, 492, 1798, 421, 199, 533, 5673, 4667, 8, 10230, 304, 272, 986, 421, 199, 533, 5673, 16760, 7927, 379, 8, 10230, 304, 272, 986, 421, 199, 318, 4913, 63, 475, 63, 4595, 8, 3954, 304, 272, 372, 2197, 14, 2083, 14, 18531, 8, 3954, 680, 17070, 342, 421, 199, 533, 22922, 4578, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4215, 63, 5570, 304, 267, 291, 14, 3112, 275, 1052, 267, 291, 14, 8149, 275, 1052, 267, 291, 14, 20945, 83, 275, 1052, 267, 291, 423, 14743, 5700, 275, 378, 267, 291, 423, 2184, 2502, 344, 275, 378, 267, 291, 423, 826, 63, 2180, 342, 267, 291, 14, 3250, 63, 5570, 275, 756, 339, 347, 485, 826, 63, 2180, 8, 277, 304, 267, 291, 14, 2180, 275, 11513, 1698, 5564, 342, 398, 291, 14, 2180, 14, 962, 8, 1646, 14, 25302, 12, 283, 5628, 63, 498, 358, 398, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 2261, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 18679, 297, 283, 442, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 8063, 12, 283, 2491, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 466, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 602, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 3543, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2502, 63, 3270, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 602, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 3543, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2502, 63, 10649, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 2123, 358, 267, 291, 14, 2180, 14, 962, 8, 1646, 14, 1761, 12, 283, 835, 297, 283, 442, 358, 398, 291, 14, 9756, 275, 291, 14, 2180, 14, 328, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2261, 7, 267, 3828, 398, 291, 14, 4608, 275, 291, 14, 9756, 14, 932, 8, 403, 12, 469, 288, 283, 2261, 356, 283, 4608, 7, 267, 789, 680, 954, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2491, 7, 267, 3828, 398, 291, 14, 23826, 275, 291, 14, 9756, 14, 932, 8, 403, 12, 469, 288, 283, 2261, 356, 283, 13562, 7, 267, 789, 680, 954, 2180, 8, 403, 12, 469, 288, 283, 5628, 63, 498, 356, 283, 2123, 7, 267, 3828, 339, 347, 3031, 63, 504, 63, 3543, 8, 277, 12, 5532, 304, 267, 3031, 275, 5532, 14, 2502, 14, 2123, 267, 327, 3254, 26, 7508, 15282, 365, 699, 2276, 1554, 1, 267, 372, 295, 14, 954, 8, 82, 3894, 16, 13, 25, 65, 13, 70, 13, 8194, 1344, 19204, 283, 12145, 3642, 14, 957, 297, 3031, 9, 339, 347, 1050, 63, 20945, 8, 277, 12, 5532, 12, 859, 304, 267, 3031, 275, 291, 14, 2123, 63, 504, 63, 3543, 8, 3543, 9, 267, 862, 26, 288, 4132, 344, 12, 4132, 932, 275, 291, 14, 8149, 59, 2123, 61, 288, 4132, 932, 459, 18679, 418, 847, 413, 267, 871, 4067, 26, 288, 4132, 344, 275, 291, 423, 2184, 2502, 344, 288, 4132, 932, 275, 291, 14, 23826, 14, 932, 8, 2502, 344, 12, 469, 355, 283, 2123, 356, 3031, 12, 355, 283, 18679, 356, 413, 12, 288, 3828, 288, 291, 14, 8149, 59, 2123, 61, 275, 359, 2502, 344, 12, 4132, 932, 61, 288, 291, 423, 2184, 2502, 344, 847, 413, 398, 859, 932, 275, 291, 14, 578, 8, 578, 9, 398, 862, 26, 288, 6275, 275, 291, 14, 20945, 83, 59, 2502, 932, 12, 859, 932, 61, 288, 6275, 459, 18679, 418, 847, 413, 267, 871, 4067, 26, 288, 6275, 275, 291, 14, 9756, 14, 5173, 8, 2502, 932, 12, 859, 932, 12, 469, 355, 283, 466, 356, 283, 20945, 297, 355, 283, 835, 356, 413, 12, 288, 3828, 288, 291, 14, 20945, 83, 59, 2502, 932, 12, 859, 932, 61, 275, 6275, 339, 347, 1050, 63, 578, 8, 277, 12, 5532, 12, 859, 304, 267, 3031, 275, 291, 14, 2123, 63, 504, 63, 3543, 8, 3543, 9, 267, 862, 26, 288, 340, 440, 291, 14, 3112, 59, 578, 1527, 18, 61, 436, 440, 291, 14, 3250, 63, 5570, 26, 355, 746, 4067, 288, 587, 26, 355, 291, 14, 3112, 59, 578, 1527, 18, 61, 275, 715, 267, 871, 4067, 26, 288, 291, 14, 3112, 59, 578, 61, 275, 359, 277, 423, 14743, 5700, 12, 663, 1062, 715, 61, 288, 291, 14, 4608, 14, 932, 8, 277, 423, 14743, 5700, 12, 469, 355, 283, 2491, 356, 859, 14, 362, 63, 646, 63, 515, 1062, 355, 283, 466, 356, 283, 2491, 297, 355, 327, 3254, 26, 653, 269, 7710, 2549, 355, 283, 602, 63, 3270, 356, 4913, 63, 475, 63, 4595, 8, 3543, 14, 20300, 63, 602, 395, 355, 283, 3543, 63, 3270, 356, 5532, 14, 4097, 4835, 12, 355, 283, 2502, 63, 3270, 356, 3031, 12, 288, 3828, 288, 291, 423, 14743, 5700, 847, 413, 267, 587, 26, 288, 327, 3254, 26, 6162, 5532, 3341, 288, 986, 339, 347, 1305, 8, 277, 12, 859, 304, 267, 372, 291, 14, 3112, 59, 578, 1527, 16, 61, 339, 347, 859, 8, 277, 12, 859, 304, 267, 372, 291, 14, 4608, 14, 2415, 59, 277, 14, 3112, 59, 578, 1527, 16, 2677, 339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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 ]
jaxxstorm/fullerite
src/diamond/collectors/userscripts/test/testuserscripts.py
30
2095
#!/usr/bin/python # coding=utf-8 ################################################################################ import os import sys from test import CollectorTestCase from test import get_collector_config from test import unittest from test import run_only from mock import patch from diamond.collector import Collector from userscripts import UserScriptsCollector ################################################################################ def run_only_if_kitchen_is_available(func): if sys.version_info < (2, 7): try: from kitchen.pycompat27 import subprocess except ImportError: subprocess = None else: import subprocess pred = lambda: subprocess is not None return run_only(func, pred) class TestUserScriptsCollector(CollectorTestCase): def setUp(self): config = get_collector_config('UserScriptsCollector', { 'interval': 10, 'scripts_path': os.path.dirname(__file__) + '/fixtures/', }) self.collector = UserScriptsCollector(config, None) def test_import(self): self.assertTrue(UserScriptsCollector) @run_only_if_kitchen_is_available @patch.object(Collector, 'publish') def test_should_work_with_example(self, publish_mock): self.collector.collect() metrics = { 'example.1': 42, 'example.2': 24, 'example.3': 12.1212, } self.setDocExample(collector=self.collector.__class__.__name__, metrics=metrics) self.assertPublishedMany(publish_mock, metrics) @run_only_if_kitchen_is_available @patch.object(Collector, 'publish') def test_should_skip_over_unrunnable_files(self, publish_mock): self.collector.collect() # Just make sure publish got called >0 times, if this test fails it'll # be due to raising an exception. Meh. assert publish_mock.call_args_list ################################################################################ if __name__ == "__main__": unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2803, 29, 1624, 13, 24, 199, 13289, 199, 199, 646, 747, 199, 646, 984, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 511, 492, 1255, 63, 2118, 199, 504, 1683, 492, 3371, 199, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 504, 922, 6429, 492, 2876, 25681, 12852, 199, 199, 13289, 421, 199, 318, 1255, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 8, 1532, 304, 272, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 267, 862, 26, 288, 687, 1022, 9414, 287, 14, 647, 5819, 1465, 492, 3873, 267, 871, 3545, 26, 288, 3873, 275, 488, 272, 587, 26, 267, 492, 3873, 272, 8869, 275, 2400, 26, 3873, 365, 440, 488, 272, 372, 1255, 63, 2118, 8, 1532, 12, 8869, 9, 421, 199, 533, 1379, 1899, 25681, 12852, 8, 12852, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 1899, 25681, 12852, 297, 469, 288, 283, 4284, 356, 1616, 12, 288, 283, 6429, 63, 515, 356, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 1994, 8769, 3678, 267, 3828, 398, 291, 14, 10946, 275, 2876, 25681, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 1899, 25681, 12852, 9, 339, 768, 1065, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 272, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 2694, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 10946, 14, 7112, 342, 398, 7186, 275, 469, 288, 283, 2694, 14, 17, 356, 5685, 12, 288, 283, 2694, 14, 18, 356, 5504, 12, 288, 283, 2694, 14, 19, 356, 3144, 14, 25481, 12, 267, 789, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 9, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 1065, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 272, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 2759, 63, 1883, 63, 324, 1065, 25757, 63, 1725, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 10946, 14, 7112, 342, 267, 327, 13870, 1852, 3238, 2780, 4788, 2797, 690, 16, 5431, 12, 340, 642, 511, 6918, 652, 7171, 267, 327, 506, 7037, 370, 17026, 376, 1919, 14, 3194, 72, 14, 267, 702, 2780, 63, 1805, 14, 1250, 63, 589, 63, 513, 199, 199, 13289, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2803, 29, 1624, 13, 24, 199, 13289, 199, 199, 646, 747, 199, 646, 984, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 511, 492, 1255, 63, 2118, 199, 504, 1683, 492, 3371, 199, 199, 504, 487, 24940, 14, 10946, 492, 3626, 3283, 199, 504, 922, 6429, 492, 2876, 25681, 12852, 199, 199, 13289, 421, 199, 318, 1255, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 8, 1532, 304, 272, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 267, 862, 26, 288, 687, 1022, 9414, 287, 14, 647, 5819, 1465, 492, 3873, 267, 871, 3545, 26, 288, 3873, 275, 488, 272, 587, 26, 267, 492, 3873, 272, 8869, 275, 2400, 26, 3873, 365, 440, 488, 272, 372, 1255, 63, 2118, 8, 1532, 12, 8869, 9, 421, 199, 533, 1379, 1899, 25681, 12852, 8, 12852, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 1899, 25681, 12852, 297, 469, 288, 283, 4284, 356, 1616, 12, 288, 283, 6429, 63, 515, 356, 747, 14, 515, 14, 3475, 3460, 493, 3368, 435, 1994, 8769, 3678, 267, 3828, 398, 291, 14, 10946, 275, 2876, 25681, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 1899, 25681, 12852, 9, 339, 768, 1065, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 272, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 2694, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 10946, 14, 7112, 342, 398, 7186, 275, 469, 288, 283, 2694, 14, 17, 356, 5685, 12, 288, 283, 2694, 14, 18, 356, 5504, 12, 288, 283, 2694, 14, 19, 356, 3144, 14, 25481, 12, 267, 789, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 9, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 1065, 63, 2118, 63, 692, 63, 6065, 24604, 63, 374, 63, 4561, 272, 768, 2068, 14, 785, 8, 12852, 12, 283, 4763, 358, 272, 347, 511, 63, 5626, 63, 2759, 63, 1883, 63, 324, 1065, 25757, 63, 1725, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 10946, 14, 7112, 342, 267, 327, 13870, 1852, 3238, 2780, 4788, 2797, 690, 16, 5431, 12, 340, 642, 511, 6918, 652, 7171, 267, 327, 506, 7037, 370, 17026, 376, 1919, 14, 3194, 72, 14, 267, 702, 2780, 63, 1805, 14, 1250, 63, 589, 63, 513, 199, 199, 13289, 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, 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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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 ]
cmgrote/tapiriik
tapiriik/services/api.py
3
3663
class ServiceExceptionScope: Account = "account" Service = "service" # Unlike Account and Service-level blocking exceptions, these are implemented via ActivityRecord.FailureCounts # Eventually, all errors might be stored in ActivityRecords Activity = "activity" class ServiceException(Exception): def __init__(self, message, scope=ServiceExceptionScope.Service, block=False, user_exception=None, trigger_exhaustive=True): Exception.__init__(self, message) self.Message = message self.UserException = user_exception self.Block = block self.Scope = scope self.TriggerExhaustive = trigger_exhaustive def __str__(self): return self.Message + " (user " + str(self.UserException) + " )" class ServiceWarning(ServiceException): pass class APIException(ServiceException): pass class APIWarning(ServiceWarning): pass # Theoretically, APIExcludeActivity should actually be a ServiceException with block=True, scope=Activity # It's on the to-do list. class APIExcludeActivity(Exception): def __init__(self, message, activity=None, activity_id=None, permanent=True, user_exception=None): Exception.__init__(self, message) self.Message = message self.Activity = activity self.ExternalActivityID = activity_id self.Permanent = permanent self.UserException = user_exception def __str__(self): return self.Message + " (activity " + str(self.ExternalActivityID) + ")" class UserExceptionType: # Account-level exceptions (not a hardcoded thing, just to keep these seperate) Authorization = "auth" RenewPassword = "renew_password" Locked = "locked" AccountFull = "full" AccountExpired = "expired" AccountUnpaid = "unpaid" # vs. expired, which implies it was at some point function, via payment or trial or otherwise. NonAthleteAccount = "non_athlete_account" # trainingpeaks # Activity-level exceptions FlowException = "flow" Private = "private" NoSupplier = "nosupplier" NotTriggered = "notrigger" Deferred = "deferred" # They've instructed us not to synchronize activities for some time after they complete PredatesWindow = "predates_window" # They've instructed us not to synchronize activities before some date RateLimited = "ratelimited" MissingCredentials = "credentials_missing" # They forgot to check the "Remember these details" box NotConfigured = "config_missing" # Don't think this error is even possible any more. StationaryUnsupported = "stationary" NonGPSUnsupported = "nongps" TypeUnsupported = "type_unsupported" InsufficientData = "data_insufficient" # Some services demand more data than others provide (ahem, N+) DownloadError = "download" ListingError = "list" # Cases when a service fails listing, so nothing can be uploaded to it. UploadError = "upload" SanityError = "sanity" Corrupt = "corrupt" # Kind of a scary term for what's generally "some data is missing" Untagged = "untagged" LiveTracking = "live" UnknownTZ = "tz_unknown" System = "system" Other = "other" class UserException: def __init__(self, type, extra=None, intervention_required=False, clear_group=None): self.Type = type self.Extra = extra # Unimplemented - displayed as part of the error message. self.InterventionRequired = intervention_required # Does the user need to dismiss this error? self.ClearGroup = clear_group if clear_group else type # Used to group error messages displayed to the user, and let them clear a group that share a common cause.
apache-2.0
[ 533, 7591, 1726, 7812, 26, 272, 9973, 275, 298, 2048, 2, 272, 7591, 275, 298, 1364, 2, 272, 327, 25059, 9973, 436, 7591, 13, 1896, 14592, 4967, 12, 3520, 787, 6366, 4799, 21885, 5433, 14, 6782, 23209, 272, 327, 6763, 3163, 12, 1006, 2552, 5594, 506, 5489, 315, 21885, 14941, 272, 21885, 275, 298, 8240, 2, 199, 199, 533, 7591, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 4194, 29, 3167, 1726, 7812, 14, 3167, 12, 1853, 29, 797, 12, 922, 63, 1971, 29, 403, 12, 6804, 63, 476, 2411, 833, 1912, 29, 549, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 2209, 275, 1245, 267, 291, 14, 1899, 1726, 275, 922, 63, 1971, 267, 291, 14, 3142, 275, 1853, 267, 291, 14, 7812, 275, 4194, 267, 291, 14, 16276, 920, 2411, 833, 1912, 275, 6804, 63, 476, 2411, 833, 1912, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2209, 435, 298, 334, 751, 298, 435, 620, 8, 277, 14, 1899, 1726, 9, 435, 298, 776, 2, 199, 199, 533, 7591, 3849, 8, 3167, 1726, 304, 272, 986, 199, 199, 533, 3261, 1726, 8, 3167, 1726, 304, 272, 986, 199, 199, 533, 3261, 3849, 8, 3167, 3849, 304, 272, 986, 199, 199, 3, 710, 720, 17269, 12, 3261, 29448, 14350, 1077, 5965, 506, 282, 7591, 1726, 543, 1853, 29, 549, 12, 4194, 29, 14350, 199, 3, 2779, 1159, 641, 314, 370, 13, 1117, 769, 14, 199, 199, 533, 3261, 29448, 14350, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 10679, 29, 403, 12, 10679, 63, 344, 29, 403, 12, 19860, 29, 549, 12, 922, 63, 1971, 29, 403, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 2209, 275, 1245, 267, 291, 14, 14350, 275, 10679, 267, 291, 14, 11389, 14350, 998, 275, 10679, 63, 344, 267, 291, 14, 31776, 275, 19860, 267, 291, 14, 1899, 1726, 275, 922, 63, 1971, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2209, 435, 298, 334, 8240, 298, 435, 620, 8, 277, 14, 11389, 14350, 998, 9, 435, 19607, 199, 199, 533, 2876, 1726, 804, 26, 272, 327, 9973, 13, 1896, 4967, 334, 1397, 282, 7508, 15282, 8377, 12, 2951, 370, 4215, 3520, 542, 529, 323, 9, 272, 21527, 275, 298, 1178, 2, 272, 10055, 546, 6139, 275, 298, 30766, 63, 2060, 2, 272, 15536, 379, 275, 298, 9325, 2, 272, 9973, 9042, 275, 298, 2861, 2, 272, 9973, 20898, 275, 298, 16340, 2, 272, 9973, 1358, 16555, 275, 298, 324, 16555, 2, 327, 8118, 14, 14721, 12, 1314, 22660, 652, 1990, 737, 2005, 2376, 805, 12, 4799, 11628, 503, 16324, 503, 4257, 14, 272, 10172, 33, 273, 1268, 6009, 275, 298, 2865, 63, 1619, 1268, 63, 2048, 2, 327, 6093, 23579, 339, 327, 21885, 13, 1896, 4967, 272, 20823, 1726, 275, 298, 1659, 2, 272, 18551, 275, 298, 4239, 2, 272, 3091, 30080, 275, 298, 12712, 384, 80, 5697, 2, 272, 2832, 6948, 11380, 275, 298, 1397, 322, 4162, 2, 272, 17448, 275, 298, 12116, 2, 327, 9322, 9064, 315, 11614, 2739, 440, 370, 31021, 30744, 367, 2005, 900, 2410, 2985, 4890, 272, 510, 581, 2335, 4301, 275, 298, 5991, 2335, 63, 3806, 2, 327, 9322, 9064, 315, 11614, 2739, 440, 370, 31021, 30744, 2544, 2005, 1434, 272, 26311, 7219, 5703, 275, 298, 1866, 14136, 2, 272, 15626, 13428, 275, 298, 6942, 63, 4752, 2, 327, 9322, 367, 7808, 370, 1104, 314, 298, 497, 1114, 3520, 2436, 2, 5689, 272, 2832, 9902, 275, 298, 888, 63, 4752, 2, 327, 7529, 1133, 13516, 642, 1125, 365, 2755, 3962, 1263, 1655, 14, 272, 1933, 425, 695, 12647, 275, 298, 10600, 695, 2, 272, 10172, 26359, 12647, 275, 298, 78, 951, 1190, 2, 272, 2434, 12647, 275, 298, 466, 63, 15267, 2, 272, 12062, 12983, 1451, 275, 298, 576, 63, 3617, 12983, 2, 327, 6601, 8500, 29237, 1655, 666, 2419, 11789, 5647, 334, 65, 27037, 12, 653, 8771, 272, 17955, 547, 275, 298, 4249, 2, 272, 3820, 316, 547, 275, 298, 513, 2, 327, 445, 3274, 1380, 282, 2435, 6918, 13778, 12, 880, 6548, 883, 506, 14238, 370, 652, 14, 272, 19149, 547, 275, 298, 5064, 2, 272, 22111, 547, 275, 298, 21614, 2, 272, 7499, 6987, 275, 298, 989, 6987, 2, 327, 1804, 688, 402, 282, 4061, 695, 6707, 367, 4052, 1159, 16711, 298, 3972, 666, 365, 4124, 2, 272, 738, 343, 24843, 275, 298, 31595, 2, 272, 24683, 23785, 275, 298, 6442, 2, 272, 14831, 14226, 275, 298, 3903, 63, 5187, 2, 272, 6187, 275, 298, 2253, 2, 272, 5439, 275, 298, 1848, 2, 199, 199, 533, 2876, 1726, 26, 272, 347, 636, 826, 721, 277, 12, 730, 12, 2402, 29, 403, 12, 1640, 18803, 63, 2427, 29, 797, 12, 5436, 63, 923, 29, 403, 304, 267, 291, 14, 804, 275, 730, 267, 291, 14, 7426, 275, 2402, 327, 1910, 13825, 446, 9080, 465, 1777, 402, 314, 1125, 1245, 14, 267, 291, 14, 2620, 18803, 8030, 275, 1640, 18803, 63, 2427, 327, 12078, 314, 922, 1929, 370, 2153, 18420, 642, 1125, 31, 267, 291, 14, 9721, 2448, 275, 5436, 63, 923, 340, 5436, 63, 923, 587, 730, 327, 8051, 370, 1572, 1125, 3788, 9080, 370, 314, 922, 12, 436, 4691, 3062, 5436, 282, 1572, 626, 8663, 282, 2863, 7675, 14, 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 ]
[ 7591, 1726, 7812, 26, 272, 9973, 275, 298, 2048, 2, 272, 7591, 275, 298, 1364, 2, 272, 327, 25059, 9973, 436, 7591, 13, 1896, 14592, 4967, 12, 3520, 787, 6366, 4799, 21885, 5433, 14, 6782, 23209, 272, 327, 6763, 3163, 12, 1006, 2552, 5594, 506, 5489, 315, 21885, 14941, 272, 21885, 275, 298, 8240, 2, 199, 199, 533, 7591, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 4194, 29, 3167, 1726, 7812, 14, 3167, 12, 1853, 29, 797, 12, 922, 63, 1971, 29, 403, 12, 6804, 63, 476, 2411, 833, 1912, 29, 549, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 2209, 275, 1245, 267, 291, 14, 1899, 1726, 275, 922, 63, 1971, 267, 291, 14, 3142, 275, 1853, 267, 291, 14, 7812, 275, 4194, 267, 291, 14, 16276, 920, 2411, 833, 1912, 275, 6804, 63, 476, 2411, 833, 1912, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2209, 435, 298, 334, 751, 298, 435, 620, 8, 277, 14, 1899, 1726, 9, 435, 298, 776, 2, 199, 199, 533, 7591, 3849, 8, 3167, 1726, 304, 272, 986, 199, 199, 533, 3261, 1726, 8, 3167, 1726, 304, 272, 986, 199, 199, 533, 3261, 3849, 8, 3167, 3849, 304, 272, 986, 199, 199, 3, 710, 720, 17269, 12, 3261, 29448, 14350, 1077, 5965, 506, 282, 7591, 1726, 543, 1853, 29, 549, 12, 4194, 29, 14350, 199, 3, 2779, 1159, 641, 314, 370, 13, 1117, 769, 14, 199, 199, 533, 3261, 29448, 14350, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 10679, 29, 403, 12, 10679, 63, 344, 29, 403, 12, 19860, 29, 549, 12, 922, 63, 1971, 29, 403, 304, 267, 2186, 855, 826, 721, 277, 12, 1245, 9, 267, 291, 14, 2209, 275, 1245, 267, 291, 14, 14350, 275, 10679, 267, 291, 14, 11389, 14350, 998, 275, 10679, 63, 344, 267, 291, 14, 31776, 275, 19860, 267, 291, 14, 1899, 1726, 275, 922, 63, 1971, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 2209, 435, 298, 334, 8240, 298, 435, 620, 8, 277, 14, 11389, 14350, 998, 9, 435, 19607, 199, 199, 533, 2876, 1726, 804, 26, 272, 327, 9973, 13, 1896, 4967, 334, 1397, 282, 7508, 15282, 8377, 12, 2951, 370, 4215, 3520, 542, 529, 323, 9, 272, 21527, 275, 298, 1178, 2, 272, 10055, 546, 6139, 275, 298, 30766, 63, 2060, 2, 272, 15536, 379, 275, 298, 9325, 2, 272, 9973, 9042, 275, 298, 2861, 2, 272, 9973, 20898, 275, 298, 16340, 2, 272, 9973, 1358, 16555, 275, 298, 324, 16555, 2, 327, 8118, 14, 14721, 12, 1314, 22660, 652, 1990, 737, 2005, 2376, 805, 12, 4799, 11628, 503, 16324, 503, 4257, 14, 272, 10172, 33, 273, 1268, 6009, 275, 298, 2865, 63, 1619, 1268, 63, 2048, 2, 327, 6093, 23579, 339, 327, 21885, 13, 1896, 4967, 272, 20823, 1726, 275, 298, 1659, 2, 272, 18551, 275, 298, 4239, 2, 272, 3091, 30080, 275, 298, 12712, 384, 80, 5697, 2, 272, 2832, 6948, 11380, 275, 298, 1397, 322, 4162, 2, 272, 17448, 275, 298, 12116, 2, 327, 9322, 9064, 315, 11614, 2739, 440, 370, 31021, 30744, 367, 2005, 900, 2410, 2985, 4890, 272, 510, 581, 2335, 4301, 275, 298, 5991, 2335, 63, 3806, 2, 327, 9322, 9064, 315, 11614, 2739, 440, 370, 31021, 30744, 2544, 2005, 1434, 272, 26311, 7219, 5703, 275, 298, 1866, 14136, 2, 272, 15626, 13428, 275, 298, 6942, 63, 4752, 2, 327, 9322, 367, 7808, 370, 1104, 314, 298, 497, 1114, 3520, 2436, 2, 5689, 272, 2832, 9902, 275, 298, 888, 63, 4752, 2, 327, 7529, 1133, 13516, 642, 1125, 365, 2755, 3962, 1263, 1655, 14, 272, 1933, 425, 695, 12647, 275, 298, 10600, 695, 2, 272, 10172, 26359, 12647, 275, 298, 78, 951, 1190, 2, 272, 2434, 12647, 275, 298, 466, 63, 15267, 2, 272, 12062, 12983, 1451, 275, 298, 576, 63, 3617, 12983, 2, 327, 6601, 8500, 29237, 1655, 666, 2419, 11789, 5647, 334, 65, 27037, 12, 653, 8771, 272, 17955, 547, 275, 298, 4249, 2, 272, 3820, 316, 547, 275, 298, 513, 2, 327, 445, 3274, 1380, 282, 2435, 6918, 13778, 12, 880, 6548, 883, 506, 14238, 370, 652, 14, 272, 19149, 547, 275, 298, 5064, 2, 272, 22111, 547, 275, 298, 21614, 2, 272, 7499, 6987, 275, 298, 989, 6987, 2, 327, 1804, 688, 402, 282, 4061, 695, 6707, 367, 4052, 1159, 16711, 298, 3972, 666, 365, 4124, 2, 272, 738, 343, 24843, 275, 298, 31595, 2, 272, 24683, 23785, 275, 298, 6442, 2, 272, 14831, 14226, 275, 298, 3903, 63, 5187, 2, 272, 6187, 275, 298, 2253, 2, 272, 5439, 275, 298, 1848, 2, 199, 199, 533, 2876, 1726, 26, 272, 347, 636, 826, 721, 277, 12, 730, 12, 2402, 29, 403, 12, 1640, 18803, 63, 2427, 29, 797, 12, 5436, 63, 923, 29, 403, 304, 267, 291, 14, 804, 275, 730, 267, 291, 14, 7426, 275, 2402, 327, 1910, 13825, 446, 9080, 465, 1777, 402, 314, 1125, 1245, 14, 267, 291, 14, 2620, 18803, 8030, 275, 1640, 18803, 63, 2427, 327, 12078, 314, 922, 1929, 370, 2153, 18420, 642, 1125, 31, 267, 291, 14, 9721, 2448, 275, 5436, 63, 923, 340, 5436, 63, 923, 587, 730, 327, 8051, 370, 1572, 1125, 3788, 9080, 370, 314, 922, 12, 436, 4691, 3062, 5436, 282, 1572, 626, 8663, 282, 2863, 7675, 14, 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, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
toshywoshy/ansible
test/units/modules/network/fortios/test_fortios_authentication_setting.py
21
8084
# Copyright 2019 Fortinet, 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 Ansible. If not, see <https://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os import json import pytest from mock import ANY from ansible.module_utils.network.fortios.fortios import FortiOSHandler try: from ansible.modules.network.fortios import fortios_authentication_setting except ImportError: pytest.skip("Could not load required modules for testing", allow_module_level=True) @pytest.fixture(autouse=True) def connection_mock(mocker): connection_class_mock = mocker.patch('ansible.modules.network.fortios.fortios_authentication_setting.Connection') return connection_class_mock fos_instance = FortiOSHandler(connection_mock) def test_authentication_setting_creation(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'authentication_setting': { 'active_auth_scheme': 'test_value_3', 'captive_portal': 'test_value_4', 'captive_portal_ip': 'test_value_5', 'captive_portal_ip6': 'test_value_6', 'captive_portal_port': '7', 'captive_portal_type': 'fqdn', 'captive_portal6': 'test_value_9', 'sso_auth_scheme': 'test_value_10' }, 'vdom': 'root'} is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance) expected_data = { 'active-auth-scheme': 'test_value_3', 'captive-portal': 'test_value_4', 'captive-portal-ip': 'test_value_5', 'captive-portal-ip6': 'test_value_6', 'captive-portal-port': '7', 'captive-portal-type': 'fqdn', 'captive-portal6': 'test_value_9', 'sso-auth-scheme': 'test_value_10' } set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200 def test_authentication_setting_creation_fails(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'error', 'http_method': 'POST', 'http_status': 500} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'authentication_setting': { 'active_auth_scheme': 'test_value_3', 'captive_portal': 'test_value_4', 'captive_portal_ip': 'test_value_5', 'captive_portal_ip6': 'test_value_6', 'captive_portal_port': '7', 'captive_portal_type': 'fqdn', 'captive_portal6': 'test_value_9', 'sso_auth_scheme': 'test_value_10' }, 'vdom': 'root'} is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance) expected_data = { 'active-auth-scheme': 'test_value_3', 'captive-portal': 'test_value_4', 'captive-portal-ip': 'test_value_5', 'captive-portal-ip6': 'test_value_6', 'captive-portal-port': '7', 'captive-portal-type': 'fqdn', 'captive-portal6': 'test_value_9', 'sso-auth-scheme': 'test_value_10' } set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 500 def test_authentication_setting_idempotent(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'error', 'http_method': 'DELETE', 'http_status': 404} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'authentication_setting': { 'active_auth_scheme': 'test_value_3', 'captive_portal': 'test_value_4', 'captive_portal_ip': 'test_value_5', 'captive_portal_ip6': 'test_value_6', 'captive_portal_port': '7', 'captive_portal_type': 'fqdn', 'captive_portal6': 'test_value_9', 'sso_auth_scheme': 'test_value_10' }, 'vdom': 'root'} is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance) expected_data = { 'active-auth-scheme': 'test_value_3', 'captive-portal': 'test_value_4', 'captive-portal-ip': 'test_value_5', 'captive-portal-ip6': 'test_value_6', 'captive-portal-port': '7', 'captive-portal-type': 'fqdn', 'captive-portal6': 'test_value_9', 'sso-auth-scheme': 'test_value_10' } set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert not changed assert response['status'] == 'error' assert response['http_status'] == 404 def test_authentication_setting_filter_foreign_attributes(mocker): schema_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.schema') set_method_result = {'status': 'success', 'http_method': 'POST', 'http_status': 200} set_method_mock = mocker.patch('ansible.module_utils.network.fortios.fortios.FortiOSHandler.set', return_value=set_method_result) input_data = { 'username': 'admin', 'state': 'present', 'authentication_setting': { 'random_attribute_not_valid': 'tag', 'active_auth_scheme': 'test_value_3', 'captive_portal': 'test_value_4', 'captive_portal_ip': 'test_value_5', 'captive_portal_ip6': 'test_value_6', 'captive_portal_port': '7', 'captive_portal_type': 'fqdn', 'captive_portal6': 'test_value_9', 'sso_auth_scheme': 'test_value_10' }, 'vdom': 'root'} is_error, changed, response = fortios_authentication_setting.fortios_authentication(input_data, fos_instance) expected_data = { 'active-auth-scheme': 'test_value_3', 'captive-portal': 'test_value_4', 'captive-portal-ip': 'test_value_5', 'captive-portal-ip6': 'test_value_6', 'captive-portal-port': '7', 'captive-portal-type': 'fqdn', 'captive-portal6': 'test_value_9', 'sso-auth-scheme': 'test_value_10' } set_method_mock.assert_called_with('authentication', 'setting', data=expected_data, vdom='root') schema_method_mock.assert_not_called() assert not is_error assert changed assert response['status'] == 'success' assert response['http_status'] == 200
gpl-3.0
[ 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 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, 2622, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 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, 646, 747, 199, 646, 2022, 199, 646, 4613, 199, 504, 1683, 492, 1821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 492, 22913, 2461, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 14551, 492, 19516, 63, 11725, 63, 6031, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 14551, 14, 14551, 63, 11725, 63, 6031, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 545, 83, 63, 842, 275, 22913, 2461, 8, 2105, 63, 1805, 9, 421, 199, 318, 511, 63, 11725, 63, 6031, 63, 8782, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 3742, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 1926, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 11725, 63, 6031, 356, 469, 288, 283, 2682, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 288, 283, 2874, 857, 63, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 288, 283, 2874, 857, 63, 8707, 63, 719, 356, 283, 23, 297, 288, 283, 2874, 857, 63, 8707, 63, 466, 356, 283, 18364, 297, 288, 283, 2874, 857, 63, 8707, 22, 356, 283, 396, 63, 585, 63, 25, 297, 288, 283, 25479, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 709, 7, 267, 1660, 267, 283, 23779, 356, 283, 1231, 936, 339, 365, 63, 705, 12, 2896, 12, 1177, 275, 19516, 63, 11725, 63, 6031, 14, 14551, 63, 11725, 8, 1210, 63, 576, 12, 15509, 63, 842, 9, 339, 1420, 63, 576, 275, 469, 267, 283, 2682, 13, 1178, 13, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 267, 283, 2874, 857, 13, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 267, 283, 2874, 857, 13, 8707, 13, 711, 356, 283, 396, 63, 585, 63, 21, 297, 267, 283, 2874, 857, 13, 8707, 13, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 267, 283, 2874, 857, 13, 8707, 13, 719, 356, 283, 23, 297, 267, 283, 2874, 857, 13, 8707, 13, 466, 356, 283, 18364, 297, 267, 283, 2874, 857, 13, 8707, 22, 356, 283, 396, 63, 585, 63, 25, 297, 267, 283, 25479, 13, 1178, 13, 5512, 356, 283, 396, 63, 585, 63, 709, 7, 272, 789, 339, 663, 63, 765, 63, 1805, 14, 479, 63, 3527, 63, 1045, 360, 11725, 297, 283, 6031, 297, 666, 29, 2062, 63, 576, 12, 20822, 534, 1231, 358, 272, 4177, 63, 765, 63, 1805, 14, 479, 63, 1397, 63, 3527, 342, 272, 702, 440, 365, 63, 705, 272, 702, 2896, 272, 702, 1177, 459, 1205, 418, 508, 283, 3742, 7, 272, 702, 1177, 459, 1014, 63, 1205, 418, 508, 1926, 421, 199, 318, 511, 63, 11725, 63, 6031, 63, 8782, 63, 15762, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 705, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 6891, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 11725, 63, 6031, 356, 469, 288, 283, 2682, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 288, 283, 2874, 857, 63, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 288, 283, 2874, 857, 63, 8707, 63, 719, 356, 283, 23, 297, 288, 283, 2874, 857 ]
[ 1898, 20312, 30205, 10811, 12, 3277, 14, 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, 2622, 14, 221, 982, 440, 12, 1937, 665, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 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, 646, 747, 199, 646, 2022, 199, 646, 4613, 199, 504, 1683, 492, 1821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 492, 22913, 2461, 199, 199, 893, 26, 272, 687, 3242, 14, 3112, 14, 1200, 14, 14551, 492, 19516, 63, 11725, 63, 6031, 199, 2590, 3545, 26, 272, 4613, 14, 2759, 480, 6531, 440, 2248, 1415, 4621, 367, 5343, 401, 2040, 63, 578, 63, 1896, 29, 549, 9, 421, 199, 32, 4462, 14, 5997, 8, 6898, 7130, 29, 549, 9, 199, 318, 1950, 63, 1805, 8, 27899, 304, 272, 1950, 63, 533, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 3112, 14, 1200, 14, 14551, 14, 14551, 63, 11725, 63, 6031, 14, 3225, 358, 272, 372, 1950, 63, 533, 63, 1805, 421, 199, 545, 83, 63, 842, 275, 22913, 2461, 8, 2105, 63, 1805, 9, 421, 199, 318, 511, 63, 11725, 63, 6031, 63, 8782, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 3742, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 1926, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 11725, 63, 6031, 356, 469, 288, 283, 2682, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 288, 283, 2874, 857, 63, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 288, 283, 2874, 857, 63, 8707, 63, 719, 356, 283, 23, 297, 288, 283, 2874, 857, 63, 8707, 63, 466, 356, 283, 18364, 297, 288, 283, 2874, 857, 63, 8707, 22, 356, 283, 396, 63, 585, 63, 25, 297, 288, 283, 25479, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 709, 7, 267, 1660, 267, 283, 23779, 356, 283, 1231, 936, 339, 365, 63, 705, 12, 2896, 12, 1177, 275, 19516, 63, 11725, 63, 6031, 14, 14551, 63, 11725, 8, 1210, 63, 576, 12, 15509, 63, 842, 9, 339, 1420, 63, 576, 275, 469, 267, 283, 2682, 13, 1178, 13, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 267, 283, 2874, 857, 13, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 267, 283, 2874, 857, 13, 8707, 13, 711, 356, 283, 396, 63, 585, 63, 21, 297, 267, 283, 2874, 857, 13, 8707, 13, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 267, 283, 2874, 857, 13, 8707, 13, 719, 356, 283, 23, 297, 267, 283, 2874, 857, 13, 8707, 13, 466, 356, 283, 18364, 297, 267, 283, 2874, 857, 13, 8707, 22, 356, 283, 396, 63, 585, 63, 25, 297, 267, 283, 25479, 13, 1178, 13, 5512, 356, 283, 396, 63, 585, 63, 709, 7, 272, 789, 339, 663, 63, 765, 63, 1805, 14, 479, 63, 3527, 63, 1045, 360, 11725, 297, 283, 6031, 297, 666, 29, 2062, 63, 576, 12, 20822, 534, 1231, 358, 272, 4177, 63, 765, 63, 1805, 14, 479, 63, 1397, 63, 3527, 342, 272, 702, 440, 365, 63, 705, 272, 702, 2896, 272, 702, 1177, 459, 1205, 418, 508, 283, 3742, 7, 272, 702, 1177, 459, 1014, 63, 1205, 418, 508, 1926, 421, 199, 318, 511, 63, 11725, 63, 6031, 63, 8782, 63, 15762, 8, 27899, 304, 272, 4177, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 3629, 358, 339, 663, 63, 765, 63, 1099, 275, 791, 1205, 356, 283, 705, 297, 283, 1014, 63, 765, 356, 283, 4030, 297, 283, 1014, 63, 1205, 356, 6891, 93, 272, 663, 63, 765, 63, 1805, 275, 15981, 14, 2068, 360, 4853, 14, 578, 63, 1208, 14, 1200, 14, 14551, 14, 14551, 14, 29089, 14, 409, 297, 372, 63, 585, 29, 409, 63, 765, 63, 1099, 9, 339, 1324, 63, 576, 275, 469, 267, 283, 2473, 356, 283, 2113, 297, 267, 283, 929, 356, 283, 1881, 297, 267, 283, 11725, 63, 6031, 356, 469, 288, 283, 2682, 63, 1178, 63, 5512, 356, 283, 396, 63, 585, 63, 19, 297, 288, 283, 2874, 857, 63, 8707, 356, 283, 396, 63, 585, 63, 20, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 356, 283, 396, 63, 585, 63, 21, 297, 288, 283, 2874, 857, 63, 8707, 63, 711, 22, 356, 283, 396, 63, 585, 63, 22, 297, 288, 283, 2874, 857, 63, 8707, 63, 719, 356, 283, 23, 297, 288, 283, 2874, 857, 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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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 ]
HighwindONE/android_kernel_motorola_msm8226
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py
12980
5411
# SchedGui.py - Python extension for perf script, basic GUI code for # traces drawing and overview. # # Copyright (C) 2010 by Frederic Weisbecker <fweisbec@gmail.com> # # This software is distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. try: import wx except ImportError: raise ImportError, "You need to install the wxpython lib for this script" class RootFrame(wx.Frame): Y_OFFSET = 100 RECT_HEIGHT = 100 RECT_SPACE = 50 EVENT_MARKING_WIDTH = 5 def __init__(self, sched_tracer, title, parent = None, id = -1): wx.Frame.__init__(self, parent, id, title) (self.screen_width, self.screen_height) = wx.GetDisplaySize() self.screen_width -= 10 self.screen_height -= 10 self.zoom = 0.5 self.scroll_scale = 20 self.sched_tracer = sched_tracer self.sched_tracer.set_root_win(self) (self.ts_start, self.ts_end) = sched_tracer.interval() self.update_width_virtual() self.nr_rects = sched_tracer.nr_rectangles() + 1 self.height_virtual = RootFrame.Y_OFFSET + (self.nr_rects * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)) # whole window panel self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height)) # scrollable container self.scroll = wx.ScrolledWindow(self.panel) self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale) self.scroll.EnableScrolling(True, True) self.scroll.SetFocus() # scrollable drawing area self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width - 15, self.screen_height / 2)) self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint) self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press) self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down) self.scroll.Bind(wx.EVT_PAINT, self.on_paint) self.scroll.Bind(wx.EVT_KEY_DOWN, self.on_key_press) self.scroll.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down) self.scroll.Fit() self.Fit() self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, self.height_virtual, wx.SIZE_USE_EXISTING) self.txt = None self.Show(True) def us_to_px(self, val): return val / (10 ** 3) * self.zoom def px_to_us(self, val): return (val / self.zoom) * (10 ** 3) def scroll_start(self): (x, y) = self.scroll.GetViewStart() return (x * self.scroll_scale, y * self.scroll_scale) def scroll_start_us(self): (x, y) = self.scroll_start() return self.px_to_us(x) def paint_rectangle_zone(self, nr, color, top_color, start, end): offset_px = self.us_to_px(start - self.ts_start) width_px = self.us_to_px(end - self.ts_start) offset_py = RootFrame.Y_OFFSET + (nr * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)) width_py = RootFrame.RECT_HEIGHT dc = self.dc if top_color is not None: (r, g, b) = top_color top_color = wx.Colour(r, g, b) brush = wx.Brush(top_color, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangle(offset_px, offset_py, width_px, RootFrame.EVENT_MARKING_WIDTH) width_py -= RootFrame.EVENT_MARKING_WIDTH offset_py += RootFrame.EVENT_MARKING_WIDTH (r ,g, b) = color color = wx.Colour(r, g, b) brush = wx.Brush(color, wx.SOLID) dc.SetBrush(brush) dc.DrawRectangle(offset_px, offset_py, width_px, width_py) def update_rectangles(self, dc, start, end): start += self.ts_start end += self.ts_start self.sched_tracer.fill_zone(start, end) def on_paint(self, event): dc = wx.PaintDC(self.scroll_panel) self.dc = dc width = min(self.width_virtual, self.screen_width) (x, y) = self.scroll_start() start = self.px_to_us(x) end = self.px_to_us(x + width) self.update_rectangles(dc, start, end) def rect_from_ypixel(self, y): y -= RootFrame.Y_OFFSET rect = y / (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE) height = y % (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE) if rect < 0 or rect > self.nr_rects - 1 or height > RootFrame.RECT_HEIGHT: return -1 return rect def update_summary(self, txt): if self.txt: self.txt.Destroy() self.txt = wx.StaticText(self.panel, -1, txt, (0, (self.screen_height / 2) + 50)) def on_mouse_down(self, event): (x, y) = event.GetPositionTuple() rect = self.rect_from_ypixel(y) if rect == -1: return t = self.px_to_us(x) + self.ts_start self.sched_tracer.mouse_down(rect, t) def update_width_virtual(self): self.width_virtual = self.us_to_px(self.ts_end - self.ts_start) def __zoom(self, x): self.update_width_virtual() (xpos, ypos) = self.scroll.GetViewStart() xpos = self.us_to_px(x) / self.scroll_scale self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale, xpos, ypos) self.Refresh() def zoom_in(self): x = self.scroll_start_us() self.zoom *= 2 self.__zoom(x) def zoom_out(self): x = self.scroll_start_us() self.zoom /= 2 self.__zoom(x) def on_key_press(self, event): key = event.GetRawKeyCode() if key == ord("+"): self.zoom_in() return if key == ord("-"): self.zoom_out() return key = event.GetKeyCode() (x, y) = self.scroll.GetViewStart() if key == wx.WXK_RIGHT: self.scroll.Scroll(x + 1, y) elif key == wx.WXK_LEFT: self.scroll.Scroll(x - 1, y) elif key == wx.WXK_DOWN: self.scroll.Scroll(x, y + 1) elif key == wx.WXK_UP: self.scroll.Scroll(x, y - 1)
gpl-2.0
[ 3, 428, 1809, 4324, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 5678, 17160, 1233, 367, 199, 3, 198, 198, 28388, 17455, 436, 23503, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 893, 26, 199, 198, 646, 4818, 199, 2590, 3545, 26, 199, 198, 3730, 3545, 12, 298, 5556, 1929, 370, 3907, 314, 4818, 1548, 1973, 367, 642, 2884, 2, 421, 199, 533, 19059, 8, 6323, 14, 3160, 304, 199, 198, 57, 63, 14839, 275, 2948, 199, 198, 4168, 63, 13509, 275, 2948, 199, 198, 4168, 63, 11658, 275, 5238, 199, 198, 8193, 63, 10520, 1206, 63, 11139, 275, 959, 421, 198, 318, 636, 826, 721, 277, 12, 10286, 63, 16825, 12, 2538, 12, 1676, 275, 488, 12, 1305, 275, 446, 17, 304, 507, 198, 6323, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 1305, 12, 2538, 9, 2742, 198, 8, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 9, 275, 4818, 14, 1002, 7687, 2320, 342, 507, 198, 277, 14, 5410, 63, 2063, 4862, 1616, 507, 198, 277, 14, 5410, 63, 3333, 4862, 1616, 507, 198, 277, 14, 10598, 275, 378, 14, 21, 507, 198, 277, 14, 6755, 63, 3467, 275, 3388, 507, 198, 277, 14, 10487, 63, 16825, 275, 10286, 63, 16825, 507, 198, 277, 14, 10487, 63, 16825, 14, 409, 63, 1231, 63, 2676, 8, 277, 9, 507, 198, 8, 277, 14, 1086, 63, 928, 12, 291, 14, 1086, 63, 500, 9, 275, 10286, 63, 16825, 14, 4284, 342, 507, 198, 277, 14, 873, 63, 2063, 63, 2065, 342, 507, 198, 277, 14, 7865, 63, 23411, 275, 10286, 63, 16825, 14, 7865, 63, 1201, 13162, 342, 435, 413, 507, 198, 277, 14, 3333, 63, 2065, 275, 19059, 14, 57, 63, 14839, 435, 334, 277, 14, 7865, 63, 23411, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 2742, 198, 3, 8852, 4353, 12748, 507, 198, 277, 14, 7885, 275, 4818, 14, 10185, 8, 277, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 430, 2742, 198, 3, 13704, 461, 3970, 507, 198, 277, 14, 6755, 275, 4818, 14, 29145, 4301, 8, 277, 14, 7885, 9, 507, 198, 277, 14, 6755, 14, 1084, 13127, 16264, 8, 277, 14, 6755, 63, 3467, 12, 291, 14, 6755, 63, 3467, 12, 291, 14, 2063, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 12, 291, 14, 3333, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 9, 507, 198, 277, 14, 6755, 14, 6476, 13127, 316, 8, 549, 12, 715, 9, 507, 198, 277, 14, 6755, 14, 1084, 17310, 342, 2742, 198, 3, 13704, 461, 17455, 9150, 507, 198, 277, 14, 6755, 63, 7885, 275, 4818, 14, 10185, 8, 277, 14, 6755, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 446, 4114, 12, 291, 14, 5410, 63, 3333, 1182, 499, 430, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 2742, 198, 277, 14, 6755, 14, 13776, 342, 507, 198, 277, 14, 13776, 342, 2742, 198, 277, 14, 6755, 63, 7885, 14, 1084, 23370, 2801, 17, 12, 446, 17, 12, 291, 14, 2063, 63, 2065, 12, 291, 14, 3333, 63, 2065, 12, 4818, 14, 4305, 63, 4701, 63, 13301, 1206, 9, 2742, 198, 277, 14, 2424, 275, 488, 2742, 198, 277, 14, 6824, 8, 549, 9, 421, 198, 318, 2739, 63, 475, 63, 5326, 8, 277, 12, 1139, 304, 507, 198, 1107, 1139, 1182, 334, 709, 1011, 650, 9, 627, 291, 14, 10598, 421, 198, 318, 21162, 63, 475, 63, 527, 8, 277, 12, 1139, 304, 507, 198, 1107, 334, 637, 1182, 291, 14, 10598, 9, 627, 334, 709, 1011, 650, 9, 421, 198, 318, 13704, 63, 928, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 14, 1002, 2768, 3162, 342, 507, 198, 1107, 334, 88, 627, 291, 14, 6755, 63, 3467, 12, 612, 627, 291, 14, 6755, 63, 3467, 9, 421, 198, 318, 13704, 63, 928, 63, 527, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 63, 928, 342, 507, 198, 1107, 291, 14, 5326, 63, 475, 63, 527, 8, 88, 9, 421, 198, 318, 32055, 63, 19954, 63, 2619, 8, 277, 12, 14762, 12, 3164, 12, 2746, 63, 2326, 12, 1343, 12, 1284, 304, 507, 198, 2743, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 928, 446, 291, 14, 1086, 63, 928, 9, 507, 198, 2063, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 500, 446, 291, 14, 1086, 63, 928, 9, 2742, 198, 2743, 63, 647, 275, 19059, 14, 57, 63, 14839, 435, 334, 7865, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 507, 198, 2063, 63, 647, 275, 19059, 14, 4168, 63, 13509, 2742, 198, 3833, 275, 291, 14, 3833, 2742, 198, 692, 2746, 63, 2326, 365, 440, 488, 26, 686, 198, 8, 82, 12, 486, 12, 330, 9, 275, 2746, 63, 2326, 686, 198, 2119, 63, 2326, 275, 4818, 14 ]
[ 428, 1809, 4324, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 5678, 17160, 1233, 367, 199, 3, 198, 198, 28388, 17455, 436, 23503, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 481, 21919, 1567, 2136, 374, 1235, 22043, 665, 70, 1129, 374, 24554, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 365, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 421, 199, 893, 26, 199, 198, 646, 4818, 199, 2590, 3545, 26, 199, 198, 3730, 3545, 12, 298, 5556, 1929, 370, 3907, 314, 4818, 1548, 1973, 367, 642, 2884, 2, 421, 199, 533, 19059, 8, 6323, 14, 3160, 304, 199, 198, 57, 63, 14839, 275, 2948, 199, 198, 4168, 63, 13509, 275, 2948, 199, 198, 4168, 63, 11658, 275, 5238, 199, 198, 8193, 63, 10520, 1206, 63, 11139, 275, 959, 421, 198, 318, 636, 826, 721, 277, 12, 10286, 63, 16825, 12, 2538, 12, 1676, 275, 488, 12, 1305, 275, 446, 17, 304, 507, 198, 6323, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 1305, 12, 2538, 9, 2742, 198, 8, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 9, 275, 4818, 14, 1002, 7687, 2320, 342, 507, 198, 277, 14, 5410, 63, 2063, 4862, 1616, 507, 198, 277, 14, 5410, 63, 3333, 4862, 1616, 507, 198, 277, 14, 10598, 275, 378, 14, 21, 507, 198, 277, 14, 6755, 63, 3467, 275, 3388, 507, 198, 277, 14, 10487, 63, 16825, 275, 10286, 63, 16825, 507, 198, 277, 14, 10487, 63, 16825, 14, 409, 63, 1231, 63, 2676, 8, 277, 9, 507, 198, 8, 277, 14, 1086, 63, 928, 12, 291, 14, 1086, 63, 500, 9, 275, 10286, 63, 16825, 14, 4284, 342, 507, 198, 277, 14, 873, 63, 2063, 63, 2065, 342, 507, 198, 277, 14, 7865, 63, 23411, 275, 10286, 63, 16825, 14, 7865, 63, 1201, 13162, 342, 435, 413, 507, 198, 277, 14, 3333, 63, 2065, 275, 19059, 14, 57, 63, 14839, 435, 334, 277, 14, 7865, 63, 23411, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 2742, 198, 3, 8852, 4353, 12748, 507, 198, 277, 14, 7885, 275, 4818, 14, 10185, 8, 277, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 12, 291, 14, 5410, 63, 3333, 430, 2742, 198, 3, 13704, 461, 3970, 507, 198, 277, 14, 6755, 275, 4818, 14, 29145, 4301, 8, 277, 14, 7885, 9, 507, 198, 277, 14, 6755, 14, 1084, 13127, 16264, 8, 277, 14, 6755, 63, 3467, 12, 291, 14, 6755, 63, 3467, 12, 291, 14, 2063, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 12, 291, 14, 3333, 63, 2065, 1182, 291, 14, 6755, 63, 3467, 9, 507, 198, 277, 14, 6755, 14, 6476, 13127, 316, 8, 549, 12, 715, 9, 507, 198, 277, 14, 6755, 14, 1084, 17310, 342, 2742, 198, 3, 13704, 461, 17455, 9150, 507, 198, 277, 14, 6755, 63, 7885, 275, 4818, 14, 10185, 8, 277, 14, 6755, 12, 1568, 2687, 277, 14, 5410, 63, 2063, 446, 4114, 12, 291, 14, 5410, 63, 3333, 1182, 499, 430, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 63, 7885, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 8470, 2919, 12, 291, 14, 265, 63, 17486, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 3078, 63, 8819, 12, 291, 14, 265, 63, 498, 63, 2915, 9, 507, 198, 277, 14, 6755, 14, 8198, 8, 6323, 14, 12093, 63, 9894, 63, 8819, 12, 291, 14, 265, 63, 10544, 63, 2110, 9, 2742, 198, 277, 14, 6755, 14, 13776, 342, 507, 198, 277, 14, 13776, 342, 2742, 198, 277, 14, 6755, 63, 7885, 14, 1084, 23370, 2801, 17, 12, 446, 17, 12, 291, 14, 2063, 63, 2065, 12, 291, 14, 3333, 63, 2065, 12, 4818, 14, 4305, 63, 4701, 63, 13301, 1206, 9, 2742, 198, 277, 14, 2424, 275, 488, 2742, 198, 277, 14, 6824, 8, 549, 9, 421, 198, 318, 2739, 63, 475, 63, 5326, 8, 277, 12, 1139, 304, 507, 198, 1107, 1139, 1182, 334, 709, 1011, 650, 9, 627, 291, 14, 10598, 421, 198, 318, 21162, 63, 475, 63, 527, 8, 277, 12, 1139, 304, 507, 198, 1107, 334, 637, 1182, 291, 14, 10598, 9, 627, 334, 709, 1011, 650, 9, 421, 198, 318, 13704, 63, 928, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 14, 1002, 2768, 3162, 342, 507, 198, 1107, 334, 88, 627, 291, 14, 6755, 63, 3467, 12, 612, 627, 291, 14, 6755, 63, 3467, 9, 421, 198, 318, 13704, 63, 928, 63, 527, 8, 277, 304, 507, 198, 8, 88, 12, 612, 9, 275, 291, 14, 6755, 63, 928, 342, 507, 198, 1107, 291, 14, 5326, 63, 475, 63, 527, 8, 88, 9, 421, 198, 318, 32055, 63, 19954, 63, 2619, 8, 277, 12, 14762, 12, 3164, 12, 2746, 63, 2326, 12, 1343, 12, 1284, 304, 507, 198, 2743, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 928, 446, 291, 14, 1086, 63, 928, 9, 507, 198, 2063, 63, 5326, 275, 291, 14, 527, 63, 475, 63, 5326, 8, 500, 446, 291, 14, 1086, 63, 928, 9, 2742, 198, 2743, 63, 647, 275, 19059, 14, 57, 63, 14839, 435, 334, 7865, 627, 334, 6405, 3160, 14, 4168, 63, 13509, 435, 19059, 14, 4168, 63, 11658, 430, 507, 198, 2063, 63, 647, 275, 19059, 14, 4168, 63, 13509, 2742, 198, 3833, 275, 291, 14, 3833,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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 ]
gripped2/xbmc
addons/service.xbmc.versioncheck/lib/shellhandlerapt.py
152
4258
# -*- coding: utf-8 -*- # # Copyright (C) 2013 Team-XBMC # # 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/>. # import xbmc from common import * try: from subprocess import check_output from subprocess import call except: log('subprocess import error') class ShellHandlerApt: _pwd = "" def __init__(self, usesudo=False): self.sudo = usesudo installed, candidate = self._check_versions("xbmc", False) if not installed: # there is no package installed via repo, so we exit here log("No installed package found, exiting") import sys sys.exit(0) def _check_versions(self, package, update=True): _cmd = "apt-cache policy " + package if update and not self._update_cache(): return False, False try: result = check_output([_cmd], shell=True).split("\n") except Exception as error: log("ShellHandlerApt: exception while executing shell command %s: %s" %(_cmd, error)) return False, False if result[0].replace(":", "") == package: installed = result[1].split()[1] candidate = result[2].split()[1] if installed == "(none)": installed = False if candidate == "(none)": candiate = False return installed, candidate else: log("ShellHandlerApt: error during version check") return False, False def _update_cache(self): _cmd = 'apt-get update' try: if self.sudo: x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) else: x = check_output(_cmd.split()) except Exception as error: log("Exception while executing shell command %s: %s" %(_cmd, error)) return False return True def check_upgrade_available(self, package): '''returns True if newer package is available in the repositories''' installed, candidate = self._check_versions(package) if installed and candidate: if installed != candidate: log("Version installed %s" %installed) log("Version available %s" %candidate) return True else: log("Already on newest version") elif not installed: log("No installed package found") return False else: return False def upgrade_package(self, package): _cmd = "apt-get install -y " + package try: if self.sudo: x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) else: x = check_output(_cmd.split()) log("Upgrade successful") except Exception as error: log("Exception while executing shell command %s: %s" %(_cmd, error)) return False return True def upgrade_system(self): _cmd = "apt-get upgrade -y" try: log("Upgrading system") if self.sudo: x = check_output('echo \'%s\' | sudo -S %s' %(self._getpassword(), _cmd), shell=True) else: x = check_output(_cmd.split()) except Exception as error: log("Exception while executing shell command %s: %s" %(_cmd, error)) return False return True def _getpassword(self): if len(self._pwd) == 0: self._pwd = get_password_from_user() return self._pwd
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 1898, 334, 35, 9, 6171, 11682, 13, 20806, 7608, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 646, 11709, 199, 504, 2863, 492, 627, 199, 199, 893, 26, 272, 687, 3873, 492, 1104, 63, 1199, 272, 687, 3873, 492, 1240, 199, 2590, 26, 272, 943, 360, 5781, 492, 1125, 358, 421, 199, 533, 24599, 2461, 33, 541, 26, 339, 485, 14258, 275, 3087, 339, 347, 636, 826, 721, 277, 12, 4440, 5916, 29, 797, 304, 267, 291, 14, 12095, 275, 4440, 5916, 267, 4903, 12, 7627, 275, 291, 423, 1074, 63, 6234, 480, 21382, 401, 756, 9, 267, 340, 440, 4903, 26, 288, 327, 2337, 365, 949, 2559, 4903, 4799, 3831, 12, 880, 781, 4458, 2348, 288, 943, 480, 1944, 4903, 2559, 1911, 12, 24234, 531, 288, 492, 984, 288, 984, 14, 2224, 8, 16, 9, 339, 347, 485, 1074, 63, 6234, 8, 277, 12, 2559, 12, 1678, 29, 549, 304, 267, 485, 1760, 275, 298, 6182, 13, 1637, 4592, 298, 435, 2559, 398, 340, 1678, 436, 440, 291, 423, 873, 63, 1637, 837, 288, 372, 756, 12, 756, 398, 862, 26, 288, 754, 275, 1104, 63, 1199, 779, 63, 1760, 467, 5218, 29, 549, 680, 1294, 4582, 78, 531, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 8529, 2461, 33, 541, 26, 1919, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 12, 756, 398, 340, 754, 59, 16, 1055, 1814, 480, 6783, 6899, 508, 2559, 26, 288, 4903, 275, 754, 59, 17, 1055, 1294, 3430, 17, 61, 288, 7627, 275, 754, 59, 18, 1055, 1294, 3430, 17, 61, 288, 340, 4903, 508, 7340, 3592, 9, 582, 355, 4903, 275, 756, 288, 340, 7627, 508, 7340, 3592, 9, 582, 355, 883, 328, 323, 275, 756, 288, 372, 4903, 12, 7627, 267, 587, 26, 288, 943, 480, 8529, 2461, 33, 541, 26, 1125, 5309, 1015, 1104, 531, 288, 372, 756, 12, 756, 339, 347, 485, 873, 63, 1637, 8, 277, 304, 267, 485, 1760, 275, 283, 6182, 13, 362, 1678, 7, 267, 862, 26, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 1104, 63, 9375, 63, 4561, 8, 277, 12, 2559, 304, 267, 1449, 5808, 715, 340, 15666, 2559, 365, 2808, 315, 314, 23737, 2344, 267, 4903, 12, 7627, 275, 291, 423, 1074, 63, 6234, 8, 2491, 9, 267, 340, 4903, 436, 7627, 26, 288, 340, 4903, 1137, 7627, 26, 355, 943, 480, 3353, 4903, 221, 450, 83, 2, 450, 7657, 9, 355, 943, 480, 3353, 2808, 221, 450, 83, 2, 450, 9007, 9, 355, 372, 715, 288, 587, 26, 355, 943, 480, 16760, 641, 29608, 1015, 531, 267, 916, 440, 4903, 26, 355, 943, 480, 1944, 4903, 2559, 1911, 531, 355, 372, 756, 267, 587, 26, 288, 372, 756, 339, 347, 10754, 63, 2491, 8, 277, 12, 2559, 304, 267, 485, 1760, 275, 298, 6182, 13, 362, 3907, 446, 89, 298, 435, 2559, 267, 862, 26, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 288, 943, 480, 19217, 9512, 531, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 10754, 63, 2253, 8, 277, 304, 267, 485, 1760, 275, 298, 6182, 13, 362, 10754, 446, 89, 2, 267, 862, 26, 288, 943, 480, 1721, 16050, 2656, 531, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 485, 362, 2060, 8, 277, 304, 267, 340, 822, 8, 277, 423, 14258, 9, 508, 378, 26, 288, 291, 423, 14258, 275, 664, 63, 2060, 63, 504, 63, 751, 342, 267, 372, 291, 423, 14258, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 1898, 334, 35, 9, 6171, 11682, 13, 20806, 7608, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 646, 11709, 199, 504, 2863, 492, 627, 199, 199, 893, 26, 272, 687, 3873, 492, 1104, 63, 1199, 272, 687, 3873, 492, 1240, 199, 2590, 26, 272, 943, 360, 5781, 492, 1125, 358, 421, 199, 533, 24599, 2461, 33, 541, 26, 339, 485, 14258, 275, 3087, 339, 347, 636, 826, 721, 277, 12, 4440, 5916, 29, 797, 304, 267, 291, 14, 12095, 275, 4440, 5916, 267, 4903, 12, 7627, 275, 291, 423, 1074, 63, 6234, 480, 21382, 401, 756, 9, 267, 340, 440, 4903, 26, 288, 327, 2337, 365, 949, 2559, 4903, 4799, 3831, 12, 880, 781, 4458, 2348, 288, 943, 480, 1944, 4903, 2559, 1911, 12, 24234, 531, 288, 492, 984, 288, 984, 14, 2224, 8, 16, 9, 339, 347, 485, 1074, 63, 6234, 8, 277, 12, 2559, 12, 1678, 29, 549, 304, 267, 485, 1760, 275, 298, 6182, 13, 1637, 4592, 298, 435, 2559, 398, 340, 1678, 436, 440, 291, 423, 873, 63, 1637, 837, 288, 372, 756, 12, 756, 398, 862, 26, 288, 754, 275, 1104, 63, 1199, 779, 63, 1760, 467, 5218, 29, 549, 680, 1294, 4582, 78, 531, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 8529, 2461, 33, 541, 26, 1919, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 12, 756, 398, 340, 754, 59, 16, 1055, 1814, 480, 6783, 6899, 508, 2559, 26, 288, 4903, 275, 754, 59, 17, 1055, 1294, 3430, 17, 61, 288, 7627, 275, 754, 59, 18, 1055, 1294, 3430, 17, 61, 288, 340, 4903, 508, 7340, 3592, 9, 582, 355, 4903, 275, 756, 288, 340, 7627, 508, 7340, 3592, 9, 582, 355, 883, 328, 323, 275, 756, 288, 372, 4903, 12, 7627, 267, 587, 26, 288, 943, 480, 8529, 2461, 33, 541, 26, 1125, 5309, 1015, 1104, 531, 288, 372, 756, 12, 756, 339, 347, 485, 873, 63, 1637, 8, 277, 304, 267, 485, 1760, 275, 283, 6182, 13, 362, 1678, 7, 267, 862, 26, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 1104, 63, 9375, 63, 4561, 8, 277, 12, 2559, 304, 267, 1449, 5808, 715, 340, 15666, 2559, 365, 2808, 315, 314, 23737, 2344, 267, 4903, 12, 7627, 275, 291, 423, 1074, 63, 6234, 8, 2491, 9, 267, 340, 4903, 436, 7627, 26, 288, 340, 4903, 1137, 7627, 26, 355, 943, 480, 3353, 4903, 221, 450, 83, 2, 450, 7657, 9, 355, 943, 480, 3353, 2808, 221, 450, 83, 2, 450, 9007, 9, 355, 372, 715, 288, 587, 26, 355, 943, 480, 16760, 641, 29608, 1015, 531, 267, 916, 440, 4903, 26, 355, 943, 480, 1944, 4903, 2559, 1911, 531, 355, 372, 756, 267, 587, 26, 288, 372, 756, 339, 347, 10754, 63, 2491, 8, 277, 12, 2559, 304, 267, 485, 1760, 275, 298, 6182, 13, 362, 3907, 446, 89, 298, 435, 2559, 267, 862, 26, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 288, 943, 480, 19217, 9512, 531, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 10754, 63, 2253, 8, 277, 304, 267, 485, 1760, 275, 298, 6182, 13, 362, 10754, 446, 89, 2, 267, 862, 26, 288, 943, 480, 1721, 16050, 2656, 531, 288, 340, 291, 14, 12095, 26, 355, 671, 275, 1104, 63, 1199, 360, 7878, 19095, 83, 3985, 1204, 14682, 446, 51, 450, 83, 7, 2818, 277, 423, 362, 2060, 1062, 485, 1760, 395, 5218, 29, 549, 9, 288, 587, 26, 355, 671, 275, 1104, 63, 1199, 1547, 1760, 14, 1294, 1012, 267, 871, 2186, 465, 1125, 26, 288, 943, 480, 1726, 1830, 14043, 5218, 1414, 450, 83, 26, 450, 83, 2, 450, 1547, 1760, 12, 1125, 430, 288, 372, 756, 398, 372, 715, 339, 347, 485, 362, 2060, 8, 277, 304, 267, 340, 822, 8, 277, 423, 14258, 9, 508, 378, 26, 288, 291, 423, 14258, 275, 664, 63, 2060, 63, 504, 63, 751, 342, 267, 372, 291, 423, 14258, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jrper/fluidity
tests/diffusion-dg/stretch.py
5
1429
#!/usr/bin/env python from numpy import * import getopt, sys, os # Global variables filename = None xscale = None yscale = None def get_options(): global filename, xscale, yscale try: opts, args = getopt.getopt(sys.argv[1:], "f:x:y:", ["filename", "xscale", "yscale",""]) except getopt.GetoptError: print "ERROR: Bad arguments!" print usage() sys.exit(2) for o, a in opts: if o in ("-f", "--filename"): filename = a if o in ("-x", "--xscale"): xscale = int(float(a)) if o in ("-y", "--yscale"): yscale = int(float(a)) get_options() assert(filename != None) assert(xscale != None) assert(yscale != None) r = fromfile(filename+'.node',sep=' ') R = reshape(r[4:-1],((size(r)-5)/3,3)) #print xscale #print yscale Xvals = R[:,1]*xscale Yvals = R[:,2]*yscale nnodes = int(r[0]) dim = r[1] assert(dim==2) f = open(filename+'_stretched_x'+str(xscale)+'_y'+str(yscale)+'.node', 'w') f.write(str(int(nnodes))) f.write(' 2 0 0\n') for i in range(nnodes): s = "%d %18.18f %18.18f \n" % (i+1, Xvals[i], Yvals[i]) f.write(s) f.write("#produced by stretch.py from "+filename) f.close() os.system('cp '+filename+'.ele '+filename+'_stretched_x'+str(xscale)+'_y'+str(yscale)+'.ele') os.system('cp '+filename+'.edge '+filename+'_stretched_x'+str(xscale)+'_y'+str(yscale)+'.edge')
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 2680, 492, 627, 199, 646, 12733, 12, 984, 12, 747, 199, 199, 3, 13641, 2860, 199, 1501, 275, 488, 199, 88, 3467, 275, 488, 199, 89, 3467, 275, 488, 199, 199, 318, 664, 63, 1419, 837, 272, 2288, 1788, 12, 671, 3467, 12, 612, 3467, 2286, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 298, 70, 26, 88, 26, 89, 6783, 3521, 2097, 1501, 401, 298, 88, 3467, 401, 298, 89, 3467, 401, 341, 566, 272, 871, 12733, 14, 1002, 29368, 26, 267, 870, 298, 3170, 26, 8857, 2368, 9539, 267, 870, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 339, 367, 312, 12, 282, 315, 3999, 26, 267, 340, 312, 315, 19372, 70, 401, 4320, 1501, 2349, 288, 1788, 275, 282, 267, 340, 312, 315, 19372, 88, 401, 4320, 88, 3467, 2349, 288, 671, 3467, 275, 1109, 8, 1609, 8, 65, 430, 267, 340, 312, 315, 19372, 89, 401, 4320, 89, 3467, 2349, 288, 612, 3467, 275, 1109, 8, 1609, 8, 65, 430, 199, 199, 362, 63, 1419, 342, 199, 199, 479, 8, 1501, 1137, 488, 9, 199, 479, 8, 88, 3467, 1137, 488, 9, 199, 479, 8, 89, 3467, 1137, 488, 9, 199, 199, 82, 275, 687, 493, 8, 1501, 18098, 932, 297, 4127, 534, 5320, 199, 50, 275, 21460, 8, 82, 59, 20, 6809, 17, 467, 1332, 890, 8, 82, 7216, 21, 2447, 19, 12, 19, 430, 199, 199, 3, 1361, 671, 3467, 199, 3, 1361, 612, 3467, 199, 199, 56, 3643, 275, 820, 3981, 17, 3672, 88, 3467, 199, 57, 3643, 275, 820, 3981, 18, 3672, 89, 3467, 199, 199, 78, 2415, 275, 1109, 8, 82, 59, 16, 566, 199, 3572, 275, 519, 59, 17, 61, 199, 479, 8, 3572, 389, 18, 9, 199, 199, 70, 275, 1551, 8, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 932, 297, 283, 87, 358, 199, 70, 14, 952, 8, 495, 8, 442, 8, 78, 2415, 1724, 199, 70, 14, 952, 360, 499, 378, 378, 60, 78, 358, 199, 509, 284, 315, 1425, 8, 78, 2415, 304, 272, 308, 275, 2071, 68, 450, 1085, 14, 1085, 70, 450, 1085, 14, 1085, 70, 971, 78, 2, 450, 334, 73, 11, 17, 12, 1323, 3643, 59, 73, 467, 1488, 3643, 59, 73, 566, 272, 289, 14, 952, 8, 83, 9, 199, 70, 14, 952, 10064, 7832, 68, 701, 31262, 14, 647, 687, 7210, 1501, 9, 199, 70, 14, 1600, 342, 199, 199, 736, 14, 2253, 360, 1850, 6681, 1501, 18098, 8081, 6681, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 8081, 358, 199, 736, 14, 2253, 360, 1850, 6681, 1501, 18098, 5173, 6681, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 5173, 358, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 2680, 492, 627, 199, 646, 12733, 12, 984, 12, 747, 199, 199, 3, 13641, 2860, 199, 1501, 275, 488, 199, 88, 3467, 275, 488, 199, 89, 3467, 275, 488, 199, 199, 318, 664, 63, 1419, 837, 272, 2288, 1788, 12, 671, 3467, 12, 612, 3467, 2286, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 298, 70, 26, 88, 26, 89, 6783, 3521, 2097, 1501, 401, 298, 88, 3467, 401, 298, 89, 3467, 401, 341, 566, 272, 871, 12733, 14, 1002, 29368, 26, 267, 870, 298, 3170, 26, 8857, 2368, 9539, 267, 870, 4503, 342, 267, 984, 14, 2224, 8, 18, 9, 339, 367, 312, 12, 282, 315, 3999, 26, 267, 340, 312, 315, 19372, 70, 401, 4320, 1501, 2349, 288, 1788, 275, 282, 267, 340, 312, 315, 19372, 88, 401, 4320, 88, 3467, 2349, 288, 671, 3467, 275, 1109, 8, 1609, 8, 65, 430, 267, 340, 312, 315, 19372, 89, 401, 4320, 89, 3467, 2349, 288, 612, 3467, 275, 1109, 8, 1609, 8, 65, 430, 199, 199, 362, 63, 1419, 342, 199, 199, 479, 8, 1501, 1137, 488, 9, 199, 479, 8, 88, 3467, 1137, 488, 9, 199, 479, 8, 89, 3467, 1137, 488, 9, 199, 199, 82, 275, 687, 493, 8, 1501, 18098, 932, 297, 4127, 534, 5320, 199, 50, 275, 21460, 8, 82, 59, 20, 6809, 17, 467, 1332, 890, 8, 82, 7216, 21, 2447, 19, 12, 19, 430, 199, 199, 3, 1361, 671, 3467, 199, 3, 1361, 612, 3467, 199, 199, 56, 3643, 275, 820, 3981, 17, 3672, 88, 3467, 199, 57, 3643, 275, 820, 3981, 18, 3672, 89, 3467, 199, 199, 78, 2415, 275, 1109, 8, 82, 59, 16, 566, 199, 3572, 275, 519, 59, 17, 61, 199, 479, 8, 3572, 389, 18, 9, 199, 199, 70, 275, 1551, 8, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 932, 297, 283, 87, 358, 199, 70, 14, 952, 8, 495, 8, 442, 8, 78, 2415, 1724, 199, 70, 14, 952, 360, 499, 378, 378, 60, 78, 358, 199, 509, 284, 315, 1425, 8, 78, 2415, 304, 272, 308, 275, 2071, 68, 450, 1085, 14, 1085, 70, 450, 1085, 14, 1085, 70, 971, 78, 2, 450, 334, 73, 11, 17, 12, 1323, 3643, 59, 73, 467, 1488, 3643, 59, 73, 566, 272, 289, 14, 952, 8, 83, 9, 199, 70, 14, 952, 10064, 7832, 68, 701, 31262, 14, 647, 687, 7210, 1501, 9, 199, 70, 14, 1600, 342, 199, 199, 736, 14, 2253, 360, 1850, 6681, 1501, 18098, 8081, 6681, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 8081, 358, 199, 736, 14, 2253, 360, 1850, 6681, 1501, 18098, 5173, 6681, 1501, 28323, 270, 3292, 1809, 63, 88, 6828, 495, 8, 88, 3467, 20731, 63, 89, 6828, 495, 8, 89, 3467, 6393, 1370, 5173, 358, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dcsquared13/Diamond
src/collectors/memcached/memcached.py
22
5210
# coding=utf-8 """ Collect memcached stats #### Dependencies * subprocess #### Example Configuration MemcachedCollector.conf ``` enabled = True hosts = localhost:11211, app-1@localhost:11212, app-2@localhost:11213, etc ``` TO use a unix socket, set a host string like this ``` hosts = /path/to/blah.sock, app-1@/path/to/bleh.sock, ``` """ import diamond.collector import socket import re class MemcachedCollector(diamond.collector.Collector): GAUGES = [ 'bytes', 'connection_structures', 'curr_connections', 'curr_items', 'threads', 'reserved_fds', 'limit_maxbytes', 'hash_power_level', 'hash_bytes', 'hash_is_expanding', 'uptime' ] def get_default_config_help(self): config_help = super(MemcachedCollector, self).get_default_config_help() config_help.update({ 'publish': "Which rows of 'status' you would like to publish." + " Telnet host port' and type stats and hit enter to see the" + " list of possibilities. Leave unset to publish all.", 'hosts': "List of hosts, and ports to collect. Set an alias by " + " prefixing the host:port with alias@", }) return config_help def get_default_config(self): """ Returns the default collector settings """ config = super(MemcachedCollector, self).get_default_config() config.update({ 'path': 'memcached', # Which rows of 'status' you would like to publish. # 'telnet host port' and type stats and hit enter to see the list of # possibilities. # Leave unset to publish all # 'publish': '' # Connection settings 'hosts': ['localhost:11211'] }) return config def get_raw_stats(self, host, port): data = '' # connect try: if port is None: sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(host) else: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, int(port))) # request stats sock.send('stats\n') # something big enough to get whatever is sent back data = sock.recv(4096) except socket.error: self.log.exception('Failed to get stats from %s:%s', host, port) return data def get_stats(self, host, port): # stuff that's always ignored, aren't 'stats' ignored = ('libevent', 'pointer_size', 'time', 'version', 'repcached_version', 'replication', 'accepting_conns', 'pid') pid = None stats = {} data = self.get_raw_stats(host, port) # parse stats for line in data.splitlines(): pieces = line.split(' ') if pieces[0] != 'STAT' or pieces[1] in ignored: continue elif pieces[1] == 'pid': pid = pieces[2] continue if '.' in pieces[2]: stats[pieces[1]] = float(pieces[2]) else: stats[pieces[1]] = int(pieces[2]) # get max connection limit self.log.debug('pid %s', pid) try: cmdline = "/proc/%s/cmdline" % pid f = open(cmdline, 'r') m = re.search("-c\x00(\d+)", f.readline()) if m is not None: self.log.debug('limit connections %s', m.group(1)) stats['limit_maxconn'] = m.group(1) f.close() except: self.log.debug("Cannot parse command line options for memcached") return stats def collect(self): hosts = self.config.get('hosts') # Convert a string config value to be an array if isinstance(hosts, basestring): hosts = [hosts] for host in hosts: matches = re.search('((.+)\@)?([^:]+)(:(\d+))?', host) alias = matches.group(2) hostname = matches.group(3) port = matches.group(5) if alias is None: alias = hostname stats = self.get_stats(hostname, port) # figure out what we're configured to get, defaulting to everything desired = self.config.get('publish', stats.keys()) # for everything we want for stat in desired: if stat in stats: # we have it if stat in self.GAUGES: self.publish_gauge(alias + "." + stat, stats[stat]) else: self.publish_counter(alias + "." + stat, stats[stat]) else: # we don't, must be somehting configured in publish so we # should log an error about it self.log.error("No such key '%s' available, issue 'stats' " "for a full list", stat)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 7573, 5245, 5020, 4388, 199, 381, 1487, 3209, 421, 627, 3873, 199, 199, 381, 5679, 11595, 199, 199, 14169, 5245, 12852, 14, 2190, 199, 199, 32323, 272, 5223, 275, 715, 272, 7057, 275, 11667, 26, 6094, 845, 12, 1145, 13, 17, 32, 5967, 26, 6094, 713, 12, 1145, 13, 18, 32, 5967, 26, 6094, 969, 12, 5423, 199, 32323, 199, 199, 2566, 675, 282, 16572, 2838, 12, 663, 282, 1591, 1059, 2839, 642, 199, 199, 32323, 272, 7057, 275, 1182, 515, 15, 475, 15, 12702, 14, 5096, 12, 1145, 13, 17, 32, 15, 515, 15, 475, 15, 830, 72, 14, 5096, 12, 199, 32323, 199, 624, 199, 199, 646, 487, 24940, 14, 10946, 199, 646, 2838, 199, 646, 295, 421, 199, 533, 30465, 5245, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 272, 598, 9331, 39, 654, 275, 359, 267, 283, 2394, 297, 267, 283, 2105, 63, 13547, 297, 267, 283, 9808, 63, 7995, 297, 267, 283, 9808, 63, 1744, 297, 267, 283, 6962, 297, 267, 283, 10421, 63, 14240, 297, 267, 283, 3097, 63, 988, 2394, 297, 267, 283, 2227, 63, 5652, 63, 1896, 297, 267, 283, 2227, 63, 2394, 297, 267, 283, 2227, 63, 374, 63, 4441, 316, 297, 267, 283, 24853, 7, 272, 1622, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 14169, 5245, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 4763, 356, 355, 298, 31619, 4730, 402, 283, 1205, 7, 1265, 3955, 2839, 370, 2780, 2122, 435, 355, 298, 377, 352, 846, 1591, 1844, 7, 436, 730, 5020, 436, 9793, 9509, 370, 1937, 314, 2, 435, 355, 298, 769, 402, 2086, 23422, 14, 28015, 15376, 370, 2780, 1006, 4765, 288, 283, 5146, 356, 355, 298, 1296, 402, 7057, 12, 436, 8873, 370, 8775, 14, 2494, 376, 5162, 701, 298, 435, 355, 298, 2403, 316, 314, 1591, 26, 719, 543, 5162, 32, 401, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1803, 314, 849, 14910, 2202, 267, 408, 267, 1101, 275, 1613, 8, 14169, 5245, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 1101, 14, 873, 2561, 288, 283, 515, 356, 258, 283, 32567, 297, 953, 327, 26058, 4730, 402, 283, 1205, 7, 1265, 3955, 2839, 370, 2780, 14, 288, 327, 283, 31085, 1591, 1844, 7, 436, 730, 5020, 436, 9793, 9509, 370, 1937, 314, 769, 402, 288, 327, 2086, 23422, 14, 288, 327, 28015, 15376, 370, 2780, 1006, 288, 327, 283, 4763, 356, 2125, 953, 327, 8113, 2202, 288, 283, 5146, 356, 788, 5967, 26, 6094, 845, 418, 267, 3828, 267, 372, 1101, 339, 347, 664, 63, 1773, 63, 3200, 8, 277, 12, 1591, 12, 1844, 304, 267, 666, 275, 2125, 267, 327, 4907, 267, 862, 26, 288, 340, 1844, 365, 488, 26, 355, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 355, 6771, 14, 2242, 8, 1102, 9, 288, 587, 26, 355, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 355, 6771, 14, 2242, 1332, 1102, 12, 1109, 8, 719, 1724, 288, 327, 1056, 5020, 288, 6771, 14, 2254, 360, 3200, 60, 78, 358, 288, 327, 6020, 7282, 8321, 370, 664, 15685, 365, 4847, 1771, 288, 666, 275, 6771, 14, 7637, 8, 20579, 9, 267, 871, 2838, 14, 705, 26, 288, 291, 14, 793, 14, 1971, 360, 4276, 370, 664, 5020, 687, 450, 83, 2689, 83, 297, 3044, 1591, 12, 1844, 9, 267, 372, 666, 339, 347, 664, 63, 3200, 8, 277, 12, 1591, 12, 1844, 304, 267, 327, 8292, 626, 1159, 3544, 5525, 12, 10621, 1133, 283, 3200, 7, 267, 5525, 275, 661, 773, 1430, 297, 283, 3929, 63, 890, 297, 283, 521, 297, 283, 1023, 297, 673, 283, 1155, 5245, 63, 1023, 297, 283, 17144, 297, 283, 5694, 316, 63, 30039, 297, 673, 283, 3150, 358, 267, 4422, 275, 488, 398, 5020, 275, 1052, 267, 666, 275, 291, 14, 362, 63, 1773, 63, 3200, 8, 1102, 12, 1844, 9, 398, 327, 2198, 5020, 267, 367, 1004, 315, 666, 14, 7644, 837, 288, 10338, 275, 1004, 14, 1294, 360, 5320, 288, 340, 10338, 59, 16, 61, 1137, 283, 4315, 7, 503, 10338, 59, 17, 61, 315, 5525, 26, 355, 1980, 288, 916, 10338, 59, 17, 61, 508, 283, 3150, 356, 355, 4422, 275, 10338, 59, 18, 61, 355, 1980, 288, 340, 7815, 315, 10338, 59, 18, 2189, 355, 5020, 59, 15655, 59, 17, 2677, 275, 2069, 8, 15655, 59, 18, 566, 288, 587, 26, 355, 5020, 59, 15655, 59, 17, 2677, 275, 1109, 8, 15655, 59, 18, 566, 398, 327, 664, 1390, 1950, 2304, 267, 291, 14, 793, 14, 1757, 360, 3150, 450, 83, 297, 4422, 9, 267, 862, 26, 288, 21206, 275, 3286, 4687, 3149, 83, 15, 15612, 2, 450, 4422, 288, 289, 275, 1551, 8, 15612, 12, 283, 82, 358, 288, 333, 275, 295, 14, 1733, 6096, 67, 60, 88, 383, 2961, 68, 11, 4186, 289, 14, 6407, 1012, 288, 340, 333, 365, 440, 488, 26, 355, 291, 14, 793, 14, 1757, 360, 3097, 6947, 450, 83, 297, 333, 14, 923, 8, 17, 430, 355, 5020, 459, 3097, 63, 988, 1631, 418, 275, 333, 14, 923, 8, 17, 9, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 291, 14, 793, 14, 1757, 480, 6612, 2198, 1414, 1004, 1511, 367, 7573, 5245, 531, 398, 372, 5020, 339, 347, 8775, 8, 277, 304, 267, 7057, 275, 291, 14, 888, 14, 362, 360, 5146, 358, 398, 327, 7905, 282, 1059, 1101, 574, 370, 506, 376, 1625, 267, 340, 1228, 8, 5146, 12, 7116, 304, 288, 7057, 275, 359, 5146, 61, 398, 367, 1591, 315, 7057, 26, 288, 4450, 275, 295, 14, 1733, 360, 1332, 6977, 2862, 32, 5547, 7059, 26, 2807, 5130, 26, 2961, 68, 11, 430, 7044, 1591, 9, 288, 5162, 275, 4450, 14, 923, 8, 18, 9, 288, 6246, 275, 4450, 14, 923, 8 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 7573, 5245, 5020, 4388, 199, 381, 1487, 3209, 421, 627, 3873, 199, 199, 381, 5679, 11595, 199, 199, 14169, 5245, 12852, 14, 2190, 199, 199, 32323, 272, 5223, 275, 715, 272, 7057, 275, 11667, 26, 6094, 845, 12, 1145, 13, 17, 32, 5967, 26, 6094, 713, 12, 1145, 13, 18, 32, 5967, 26, 6094, 969, 12, 5423, 199, 32323, 199, 199, 2566, 675, 282, 16572, 2838, 12, 663, 282, 1591, 1059, 2839, 642, 199, 199, 32323, 272, 7057, 275, 1182, 515, 15, 475, 15, 12702, 14, 5096, 12, 1145, 13, 17, 32, 15, 515, 15, 475, 15, 830, 72, 14, 5096, 12, 199, 32323, 199, 624, 199, 199, 646, 487, 24940, 14, 10946, 199, 646, 2838, 199, 646, 295, 421, 199, 533, 30465, 5245, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 272, 598, 9331, 39, 654, 275, 359, 267, 283, 2394, 297, 267, 283, 2105, 63, 13547, 297, 267, 283, 9808, 63, 7995, 297, 267, 283, 9808, 63, 1744, 297, 267, 283, 6962, 297, 267, 283, 10421, 63, 14240, 297, 267, 283, 3097, 63, 988, 2394, 297, 267, 283, 2227, 63, 5652, 63, 1896, 297, 267, 283, 2227, 63, 2394, 297, 267, 283, 2227, 63, 374, 63, 4441, 316, 297, 267, 283, 24853, 7, 272, 1622, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 14169, 5245, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 4763, 356, 355, 298, 31619, 4730, 402, 283, 1205, 7, 1265, 3955, 2839, 370, 2780, 2122, 435, 355, 298, 377, 352, 846, 1591, 1844, 7, 436, 730, 5020, 436, 9793, 9509, 370, 1937, 314, 2, 435, 355, 298, 769, 402, 2086, 23422, 14, 28015, 15376, 370, 2780, 1006, 4765, 288, 283, 5146, 356, 355, 298, 1296, 402, 7057, 12, 436, 8873, 370, 8775, 14, 2494, 376, 5162, 701, 298, 435, 355, 298, 2403, 316, 314, 1591, 26, 719, 543, 5162, 32, 401, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 408, 267, 1803, 314, 849, 14910, 2202, 267, 408, 267, 1101, 275, 1613, 8, 14169, 5245, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 1101, 14, 873, 2561, 288, 283, 515, 356, 258, 283, 32567, 297, 953, 327, 26058, 4730, 402, 283, 1205, 7, 1265, 3955, 2839, 370, 2780, 14, 288, 327, 283, 31085, 1591, 1844, 7, 436, 730, 5020, 436, 9793, 9509, 370, 1937, 314, 769, 402, 288, 327, 2086, 23422, 14, 288, 327, 28015, 15376, 370, 2780, 1006, 288, 327, 283, 4763, 356, 2125, 953, 327, 8113, 2202, 288, 283, 5146, 356, 788, 5967, 26, 6094, 845, 418, 267, 3828, 267, 372, 1101, 339, 347, 664, 63, 1773, 63, 3200, 8, 277, 12, 1591, 12, 1844, 304, 267, 666, 275, 2125, 267, 327, 4907, 267, 862, 26, 288, 340, 1844, 365, 488, 26, 355, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 19584, 12, 2838, 14, 9469, 63, 9484, 9, 355, 6771, 14, 2242, 8, 1102, 9, 288, 587, 26, 355, 6771, 275, 2838, 14, 3450, 8, 3450, 14, 5699, 63, 11367, 12, 2838, 14, 9469, 63, 9484, 9, 355, 6771, 14, 2242, 1332, 1102, 12, 1109, 8, 719, 1724, 288, 327, 1056, 5020, 288, 6771, 14, 2254, 360, 3200, 60, 78, 358, 288, 327, 6020, 7282, 8321, 370, 664, 15685, 365, 4847, 1771, 288, 666, 275, 6771, 14, 7637, 8, 20579, 9, 267, 871, 2838, 14, 705, 26, 288, 291, 14, 793, 14, 1971, 360, 4276, 370, 664, 5020, 687, 450, 83, 2689, 83, 297, 3044, 1591, 12, 1844, 9, 267, 372, 666, 339, 347, 664, 63, 3200, 8, 277, 12, 1591, 12, 1844, 304, 267, 327, 8292, 626, 1159, 3544, 5525, 12, 10621, 1133, 283, 3200, 7, 267, 5525, 275, 661, 773, 1430, 297, 283, 3929, 63, 890, 297, 283, 521, 297, 283, 1023, 297, 673, 283, 1155, 5245, 63, 1023, 297, 283, 17144, 297, 283, 5694, 316, 63, 30039, 297, 673, 283, 3150, 358, 267, 4422, 275, 488, 398, 5020, 275, 1052, 267, 666, 275, 291, 14, 362, 63, 1773, 63, 3200, 8, 1102, 12, 1844, 9, 398, 327, 2198, 5020, 267, 367, 1004, 315, 666, 14, 7644, 837, 288, 10338, 275, 1004, 14, 1294, 360, 5320, 288, 340, 10338, 59, 16, 61, 1137, 283, 4315, 7, 503, 10338, 59, 17, 61, 315, 5525, 26, 355, 1980, 288, 916, 10338, 59, 17, 61, 508, 283, 3150, 356, 355, 4422, 275, 10338, 59, 18, 61, 355, 1980, 288, 340, 7815, 315, 10338, 59, 18, 2189, 355, 5020, 59, 15655, 59, 17, 2677, 275, 2069, 8, 15655, 59, 18, 566, 288, 587, 26, 355, 5020, 59, 15655, 59, 17, 2677, 275, 1109, 8, 15655, 59, 18, 566, 398, 327, 664, 1390, 1950, 2304, 267, 291, 14, 793, 14, 1757, 360, 3150, 450, 83, 297, 4422, 9, 267, 862, 26, 288, 21206, 275, 3286, 4687, 3149, 83, 15, 15612, 2, 450, 4422, 288, 289, 275, 1551, 8, 15612, 12, 283, 82, 358, 288, 333, 275, 295, 14, 1733, 6096, 67, 60, 88, 383, 2961, 68, 11, 4186, 289, 14, 6407, 1012, 288, 340, 333, 365, 440, 488, 26, 355, 291, 14, 793, 14, 1757, 360, 3097, 6947, 450, 83, 297, 333, 14, 923, 8, 17, 430, 355, 5020, 459, 3097, 63, 988, 1631, 418, 275, 333, 14, 923, 8, 17, 9, 288, 289, 14, 1600, 342, 267, 871, 26, 288, 291, 14, 793, 14, 1757, 480, 6612, 2198, 1414, 1004, 1511, 367, 7573, 5245, 531, 398, 372, 5020, 339, 347, 8775, 8, 277, 304, 267, 7057, 275, 291, 14, 888, 14, 362, 360, 5146, 358, 398, 327, 7905, 282, 1059, 1101, 574, 370, 506, 376, 1625, 267, 340, 1228, 8, 5146, 12, 7116, 304, 288, 7057, 275, 359, 5146, 61, 398, 367, 1591, 315, 7057, 26, 288, 4450, 275, 295, 14, 1733, 360, 1332, 6977, 2862, 32, 5547, 7059, 26, 2807, 5130, 26, 2961, 68, 11, 430, 7044, 1591, 9, 288, 5162, 275, 4450, 14, 923, 8, 18, 9, 288, 6246, 275, 4450, 14, 923, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
BackupTheBerlios/cuon-svn
cuon_client/cuon/Skeleton/skeleton.py
2
12773
# -*- coding: utf-8 -*- ##Copyright (C) [2005] [Jürgen Hamel, D-32584 Löhne] ##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, write to the ##Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. import sys import os import os.path from types import * import pygtk pygtk.require('2.0') import gtk import gtk.glade import gobject #from gtk import True, False import string import logging from cuon.Windows.chooseWindows import chooseWindows import cPickle #import cuon.OpenOffice.letter # localisation import locale, gettext locale.setlocale (locale.LC_NUMERIC, '') import threading import mx.DateTime class clientswindow(chooseWindows): def __init__(self, allTables): chooseWindows.__init__(self) self.singleClient = SingleClient.SingleClient(allTables) self.loadGlade('address.xml') self.win1 = self.getWidget('AddressMainwindow') self.setStatusBar() self.EntriesAddresses = 'addresses.xml' self.loadEntries(self.EntriesAddresses) self.singleAddress.setEntries(self.getDataEntries('addresses.xml') ) self.singleAddress.setGladeXml(self.xml) self.singleAddress.setTreeFields( ['lastname', 'firstname','city'] ) self.singleAddress.setStore( gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT) ) self.singleAddress.setTreeOrder('lastname, firstname') self.singleAddress.setListHeader([_('Lastname'), _('Firstname'), _('City')]) self.singleAddress.setTree(self.xml.get_widget('tree1') ) # set values for comboBox # Menu-items self.initMenuItems() # Close Menus for Tab self.addEnabledMenuItems('tabs','mi_address1') # seperate Menus self.addEnabledMenuItems('address','mi_address1') # enabledMenues for Address self.addEnabledMenuItems('editAddress','mi_new1') self.addEnabledMenuItems('editAddress','mi_clear1') self.addEnabledMenuItems('editAddress','mi_print1') self.addEnabledMenuItems('editAddress','mi_edit1') # tabs from notebook self.tabClients = 0 self.tabChanged() #Menu File def on_quit1_activate(self, event): self.out( "exit clients V1") self.closeWindow() #Menu Addressimport cuon.Login.User def on_save1_activate(self, event): self.out( "save addresses v2") self.singleAddress.save() self.setEntriesEditable(self.EntriesAddresses, False) self.tabChanged() def on_new1_activate(self, event): self.out( "new addresses v2") self.singleAddress.newRecord() self.setEntriesEditable(self.EntriesAddresses, True) def on_edit1_activate(self, event): self.out( "edit addresses v2") self.setEntriesEditable(self.EntriesAddresses, True) def on_delete1_activate(self, event): self.out( "delete addresses v2") self.singleAddress.deleteRecord() # Menu misc def on_MiscSave1_activate(self, event): self.out( "save Misc addresses v2") self.singleMisc.addressId = self.singleAddress.ID self.singleMisc.save() self.setEntriesEditable(self.EntriesAddressesMisc, False) self.tabChanged() def on_MiscEdit1_activate(self, event): self.out( "edit addresses v2") self.setEntriesEditable(self.EntriesAddressesMisc, True) #Menu Partner def on_PartnerSave1_activate(self, event): self.out( "save Partner addresses v2") self.singlePartner.addressId = self.singleAddress.ID self.singlePartner.save() self.setEntriesEditable(self.EntriesPartner, False) self.tabChanged() def on_PartnerNew1_activate(self, event): self.out( "new Partner addresses v2") self.singlePartner.newRecord() self.setEntriesEditable(self.EntriesPartner, True) def on_PartnerEdit1_activate(self, event): self.setEntriesEditable(self.EntriesPartner, True) def on_PartnerDelete1_activate(self, event): self.out( "delete Partner addresses v2") self.singlePartner.deleteRecord() #Menu Schedul def on_SchedulSave_activate(self, event): self.out( "save Schedul addresses v2") self.singleSchedul.partnerId = self.singlePartner.ID self.singleSchedul.save() self.setEntriesEditable(self.EntriesPartnerSchedul, False) self.tabChanged() def on_SchedulEdit1_activate(self, event): self.setEntriesEditable(self.EntriesPartnerSchedul, True) def on_SchedulNew_activate(self, event): self.out( "new Schedul for partner v2") self.singleSchedul.newRecord() self.setEntriesEditable(self.EntriesPartnerSchedul, True) def on_SchedulDelete_activate(self, event): self.out( "delete Schedul addresses v2") self.singleSchedul.deleteRecord() def on_gdeDate_date_changed(self, event ): print str(event) gdeSchedul = self.getWidget('gdeDate') newDate = gdeSchedul.get_time() print newDate ## def on_calendar1_day_selected(self, cal): ## print cal ## date = cal.get_date() ## print date ## print date[0] ## print date[1] ## print date[2] ## eSchedulDate = self.getWidget('eSchedulDate') ## newDate = mx.DateTime.DateTime(date[0], date[1] + 1, date[2]) ## sDate = newDate.strftime(self.oUser.userDateTimeFormatString) ## eSchedulDate.set_text(sDate) ## def on_eSchedulDate_changed(self, event): ## pass ## def on_hscale1_value_changed(self, hScale): ## tTime = None ## hourValue = hScale.get_value() ## eSchedulTime = self.getWidget('eSchedulTime') ## sTime = eSchedulTime.get_text() ## if sTime: ## tTime = mx.DateTime.strptime(sTime,self.oUser.userTimeFormatString) ## oldHour = tTime.hour ## oldMinute = tTime.minute ## print 'oldHour = ' + `oldHour` ## tTime = mx.DateTime.today(hourValue, oldMinute) ## else: ## tTime = mx.DateTime.today(hourValue, 0) ## sTime = tTime.strftime(self.oUser.userTimeFormatString) ## eSchedulTime.set_text(sTime) ## def on_vscale1_value_changed(self, vScale): ## tTime = None ## minuteValue = vScale.get_value() ## eSchedulTime = self.getWidget('eSchedulTime') ## sTime = eSchedulTime.get_text() ## if sTime: ## tTime = mx.DateTime.strptime(sTime,self.oUser.userTimeFormatString) ## oldHour = tTime.hour ## oldMinute = tTime.minute ## tTime = mx.DateTime.today(oldHour, minuteValue) ## else: ## tTime = mx.DateTime.today(0, minuteValue) ## sTime = tTime.strftime(self.oUser.userTimeFormatString) ## eSchedulTime.set_text(sTime) # Menu Lists def on_liAddressesPhone1_activate(self, event): self.out( "lists startet") Pdf = lists_addresses_phone1.lists_addresses_phone1() def on_liAddressesPhone11_activate(self, event): self.out( "lists startet") Pdf = lists_addresses_phone11.lists_addresses_phone11() #Menu Writer def on_newletter1_activate(self, event): self.out("writer startet ") fkey = 'cuonAddress' + `self.singleAddress.ID` self.out( fkey) self.pickleObject(fkey , self.singleAddress.getAddress(self.singleAddress.ID)) sExec = os.environ['CUON_OOEXEC'] os.system(sExec + ' cuon/OpenOffice/ooMain.py ' + fkey ) #letter1 = cuon.OpenOffice.letter.letter() #letter1.createAddress(singleAddress.ID) def on_chooseAddress_activate(self, event): # choose Address from other Modul if self.tabOption == self.tabAddress: print '############### Address choose ID ###################' self.setChooseValue(self.singleAddress.ID) self.closeWindow() elif self.tabOption == self.tabPartner: print '############### Address choose ID ###################' self.setChooseValue(self.singlePartner.ID) self.closeWindow() else: print '############### No ID found, choose ID -1 ###################' self.setChooseValue('-1') self.closeWindow() # search button def on_bSearch_clicked(self, event): self.out( 'Searching ....', self.ERROR) sName = self.getWidget('eFindName').get_text() sCity = self.getWidget('eFindCity').get_text() self.out('Name and City = ' + sName + ', ' + sCity, self.ERROR) self.singleAddress.sWhere = 'where lastname ~* \'.*' + sName + '.*\' and city ~* \'.*' + sCity + '.*\'' self.out(self.singleAddress.sWhere, self.ERROR) self.refreshTree() def refreshTree(self): self.singleAddress.disconnectTree() self.singlePartner.disconnectTree() if self.tabOption == self.tabAddress: self.singleAddress.connectTree() self.singleAddress.refreshTree() elif self.tabOption == self.tabMisc: self.singleMisc.sWhere ='where address_id = ' + `int(self.singleAddress.ID)` self.singleMisc.fillEntries(self.singleMisc.findSingleId()) elif self.tabOption == self.tabPartner: self.singlePartner.sWhere ='where addressid = ' + `int(self.singleAddress.ID)` self.singlePartner.connectTree() self.singlePartner.refreshTree() elif self.tabOption == self.tabSchedul: self.singleSchedul.sWhere ='where partnerid = ' + `int(self.singlePartner.ID)` self.singleSchedul.connectTree() self.singleSchedul.refreshTree() def tabChanged(self): self.out( 'tab changed to :' + str(self.tabOption)) if self.tabOption == self.tabAddress: #Address self.disableMenuItem('tabs') self.enableMenuItem('address') self.actualEntries = self.singleAddress.getEntries() self.editAction = 'editAddress' self.setStatusbarText(['']) self.setTreeVisible(True) self.out( 'Seite 0') elif self.tabOption == self.tabBank: self.out( 'Seite 2') self.disableMenuItem('tabs') self.enableMenuItem('bank') self.editAction = 'editBank' self.setTreeVisible(False) self.setStatusbarText([self.singleAddress.sStatus]) elif self.tabOption == self.tabMisc: self.out( 'Seite 3') self.disableMenuItem('tabs') self.enableMenuItem('misc') self.editAction = 'editMisc' self.setTreeVisible(False) self.setStatusbarText([self.singleAddress.sStatus]) elif self.tabOption == self.tabPartner: #Partner self.disableMenuItem('tabs') self.enableMenuItem('partner') self.out( 'Seite 1') self.editAction = 'editPartner' self.setTreeVisible(True) self.setStatusbarText([self.singleAddress.sStatus]) elif self.tabOption == self.tabSchedul: #Scheduling self.disableMenuItem('tabs') self.enableMenuItem('schedul') self.out( 'Seite 4') self.editAction = 'editSchedul' self.setTreeVisible(True) self.setStatusbarText([self.singlePartner.sStatus]) # refresh the Tree self.refreshTree() self.enableMenuItem(self.editAction) self.editEntries = False
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 309, 7384, 334, 35, 9, 359, 9397, 61, 221, 359, 42, 17709, 82, 2268, 869, 14868, 12, 577, 13, 708, 12248, 491, 14614, 72, 685, 61, 199, 199, 309, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 8987, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 309, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 199, 309, 3281, 1312, 369, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 1684, 844, 199, 309, 509, 1655, 2436, 14, 199, 199, 309, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 309, 10146, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 9948, 199, 646, 984, 199, 646, 747, 199, 646, 747, 14, 515, 199, 504, 2943, 492, 627, 199, 646, 1134, 12275, 199, 647, 12275, 14, 4365, 360, 18, 14, 16, 358, 199, 646, 8116, 199, 646, 8116, 14, 31589, 199, 646, 25595, 199, 3, 504, 8116, 492, 715, 12, 756, 199, 646, 1059, 199, 646, 2050, 199, 504, 286, 21615, 14, 8647, 14, 16143, 8647, 221, 492, 11496, 8647, 199, 646, 17572, 199, 3, 646, 286, 21615, 14, 4299, 31166, 14, 9269, 199, 3, 2257, 19914, 199, 646, 5867, 12, 9796, 199, 5508, 14, 409, 5508, 334, 5508, 14, 7027, 63, 28425, 12, 4074, 199, 646, 5796, 199, 646, 8728, 14, 3926, 421, 199, 533, 1890, 3519, 1528, 8, 16143, 8647, 304, 25979, 347, 636, 826, 721, 277, 12, 1006, 18845, 304, 398, 11496, 8647, 855, 826, 721, 277, 9, 267, 267, 291, 14, 4780, 3041, 275, 13050, 3041, 14, 7200, 3041, 8, 452, 18845, 9, 10813, 267, 291, 14, 912, 39, 17236, 360, 1562, 14, 1652, 358, 267, 291, 14, 2676, 17, 275, 291, 14, 362, 3339, 360, 1476, 6756, 3806, 358, 267, 291, 14, 409, 3694, 5281, 342, 7318, 291, 14, 17816, 20826, 275, 283, 7423, 14, 1652, 7, 2728, 291, 14, 912, 17816, 8, 277, 14, 17816, 20826, 9, 2728, 291, 14, 4780, 1476, 14, 409, 17816, 8, 277, 14, 29276, 17816, 360, 7423, 14, 1652, 358, 776, 267, 291, 14, 4780, 1476, 14, 409, 39, 17236, 8672, 8, 277, 14, 1652, 9, 267, 291, 14, 4780, 1476, 14, 409, 3987, 7304, 8, 788, 31164, 297, 283, 25603, 1673, 3690, 418, 776, 267, 291, 14, 4780, 1476, 14, 409, 5502, 8, 8116, 14, 1296, 5502, 8, 71, 785, 14, 2711, 63, 5353, 12, 25595, 14, 2711, 63, 5353, 12, 25595, 14, 2711, 63, 5353, 12, 257, 25595, 14, 2711, 63, 17459, 9, 776, 4960, 291, 14, 4780, 1476, 14, 409, 3987, 4738, 360, 31164, 12, 1642, 354, 358, 267, 291, 14, 4780, 1476, 14, 409, 1296, 2567, 779, 11252, 6090, 354, 659, 4018, 7147, 354, 659, 4018, 17024, 2023, 267, 291, 14, 4780, 1476, 14, 409, 3987, 8, 277, 14, 1652, 14, 362, 63, 3440, 360, 2350, 17, 358, 776, 8410, 2043, 398, 327, 663, 1338, 367, 20972, 3532, 13596, 398, 327, 18281, 13, 1744, 267, 291, 14, 826, 5977, 7412, 342, 398, 327, 15524, 603, 287, 527, 367, 23159, 267, 291, 14, 525, 6589, 5977, 7412, 360, 8741, 1673, 2664, 63, 1562, 17, 358, 2043, 2234, 267, 327, 542, 529, 323, 603, 287, 527, 267, 291, 14, 525, 6589, 5977, 7412, 360, 1562, 1673, 2664, 63, 1562, 17, 358, 1779, 398, 327, 5223, 29230, 10138, 367, 9906, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 1222, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 3584, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 1361, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 3773, 17, 358, 421, 1362, 31106, 327, 12187, 687, 20751, 267, 291, 14, 2902, 3041, 83, 275, 378, 1362, 268, 31106, 291, 14, 2902, 6970, 342, 268, 339, 327, 5977, 3814, 2049, 272, 347, 641, 63, 10589, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 2224, 13431, 812, 17, 531, 267, 291, 14, 1600, 4301, 342, 221, 1362, 268, 2378, 327, 5977, 2654, 470, 338, 412, 286, 21615, 14, 8880, 14, 1899, 2043, 272, 347, 641, 63, 2117, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 2117, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 2117, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 756, 9, 267, 291, 14, 2902, 6970, 342, 5493, 347, 641, 63, 1222, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 1222, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 1222, 5433, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 715, 9, 339, 347, 641, 63, 3773, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 3773, 7149, 373, 18, 531, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 715, 9, 2378, 347, 641, 63, 1807, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 1807, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 1807, 5433, 342, 339, 327, 18281, 18576, 272, 347, 641, 63, 29926, 8229, 17, 63, 8222, 8, 277, 12, 1566, 304, 2728, 291, 14, 548, 8, 298, 2117, 603, 10840, 7149, 373, 18, 531, 267, 291, 14, 4780, 29926, 14, 1562, 1304, 275, 291, 14, 4780, 1476, 14, 998, 2728, 291, 14, 4780, 29926, 14, 2117, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 29926, 12, 756, 9, 267, 291, 14, 2902, 6970, 342, 339, 347, 641 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 309, 7384, 334, 35, 9, 359, 9397, 61, 221, 359, 42, 17709, 82, 2268, 869, 14868, 12, 577, 13, 708, 12248, 491, 14614, 72, 685, 61, 199, 199, 309, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 309, 8987, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 309, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 199, 309, 3281, 1312, 369, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 1664, 1696, 1684, 844, 199, 309, 509, 1655, 2436, 14, 199, 199, 309, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 309, 10146, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 9948, 199, 646, 984, 199, 646, 747, 199, 646, 747, 14, 515, 199, 504, 2943, 492, 627, 199, 646, 1134, 12275, 199, 647, 12275, 14, 4365, 360, 18, 14, 16, 358, 199, 646, 8116, 199, 646, 8116, 14, 31589, 199, 646, 25595, 199, 3, 504, 8116, 492, 715, 12, 756, 199, 646, 1059, 199, 646, 2050, 199, 504, 286, 21615, 14, 8647, 14, 16143, 8647, 221, 492, 11496, 8647, 199, 646, 17572, 199, 3, 646, 286, 21615, 14, 4299, 31166, 14, 9269, 199, 3, 2257, 19914, 199, 646, 5867, 12, 9796, 199, 5508, 14, 409, 5508, 334, 5508, 14, 7027, 63, 28425, 12, 4074, 199, 646, 5796, 199, 646, 8728, 14, 3926, 421, 199, 533, 1890, 3519, 1528, 8, 16143, 8647, 304, 25979, 347, 636, 826, 721, 277, 12, 1006, 18845, 304, 398, 11496, 8647, 855, 826, 721, 277, 9, 267, 267, 291, 14, 4780, 3041, 275, 13050, 3041, 14, 7200, 3041, 8, 452, 18845, 9, 10813, 267, 291, 14, 912, 39, 17236, 360, 1562, 14, 1652, 358, 267, 291, 14, 2676, 17, 275, 291, 14, 362, 3339, 360, 1476, 6756, 3806, 358, 267, 291, 14, 409, 3694, 5281, 342, 7318, 291, 14, 17816, 20826, 275, 283, 7423, 14, 1652, 7, 2728, 291, 14, 912, 17816, 8, 277, 14, 17816, 20826, 9, 2728, 291, 14, 4780, 1476, 14, 409, 17816, 8, 277, 14, 29276, 17816, 360, 7423, 14, 1652, 358, 776, 267, 291, 14, 4780, 1476, 14, 409, 39, 17236, 8672, 8, 277, 14, 1652, 9, 267, 291, 14, 4780, 1476, 14, 409, 3987, 7304, 8, 788, 31164, 297, 283, 25603, 1673, 3690, 418, 776, 267, 291, 14, 4780, 1476, 14, 409, 5502, 8, 8116, 14, 1296, 5502, 8, 71, 785, 14, 2711, 63, 5353, 12, 25595, 14, 2711, 63, 5353, 12, 25595, 14, 2711, 63, 5353, 12, 257, 25595, 14, 2711, 63, 17459, 9, 776, 4960, 291, 14, 4780, 1476, 14, 409, 3987, 4738, 360, 31164, 12, 1642, 354, 358, 267, 291, 14, 4780, 1476, 14, 409, 1296, 2567, 779, 11252, 6090, 354, 659, 4018, 7147, 354, 659, 4018, 17024, 2023, 267, 291, 14, 4780, 1476, 14, 409, 3987, 8, 277, 14, 1652, 14, 362, 63, 3440, 360, 2350, 17, 358, 776, 8410, 2043, 398, 327, 663, 1338, 367, 20972, 3532, 13596, 398, 327, 18281, 13, 1744, 267, 291, 14, 826, 5977, 7412, 342, 398, 327, 15524, 603, 287, 527, 367, 23159, 267, 291, 14, 525, 6589, 5977, 7412, 360, 8741, 1673, 2664, 63, 1562, 17, 358, 2043, 2234, 267, 327, 542, 529, 323, 603, 287, 527, 267, 291, 14, 525, 6589, 5977, 7412, 360, 1562, 1673, 2664, 63, 1562, 17, 358, 1779, 398, 327, 5223, 29230, 10138, 367, 9906, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 1222, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 3584, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 1361, 17, 358, 267, 291, 14, 525, 6589, 5977, 7412, 360, 3773, 1476, 1673, 2664, 63, 3773, 17, 358, 421, 1362, 31106, 327, 12187, 687, 20751, 267, 291, 14, 2902, 3041, 83, 275, 378, 1362, 268, 31106, 291, 14, 2902, 6970, 342, 268, 339, 327, 5977, 3814, 2049, 272, 347, 641, 63, 10589, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 2224, 13431, 812, 17, 531, 267, 291, 14, 1600, 4301, 342, 221, 1362, 268, 2378, 327, 5977, 2654, 470, 338, 412, 286, 21615, 14, 8880, 14, 1899, 2043, 272, 347, 641, 63, 2117, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 2117, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 2117, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 756, 9, 267, 291, 14, 2902, 6970, 342, 5493, 347, 641, 63, 1222, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 1222, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 1222, 5433, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 715, 9, 339, 347, 641, 63, 3773, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 3773, 7149, 373, 18, 531, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 12, 715, 9, 2378, 347, 641, 63, 1807, 17, 63, 8222, 8, 277, 12, 1566, 304, 267, 291, 14, 548, 8, 298, 1807, 7149, 373, 18, 531, 267, 291, 14, 4780, 1476, 14, 1807, 5433, 342, 339, 327, 18281, 18576, 272, 347, 641, 63, 29926, 8229, 17, 63, 8222, 8, 277, 12, 1566, 304, 2728, 291, 14, 548, 8, 298, 2117, 603, 10840, 7149, 373, 18, 531, 267, 291, 14, 4780, 29926, 14, 1562, 1304, 275, 291, 14, 4780, 1476, 14, 998, 2728, 291, 14, 4780, 29926, 14, 2117, 342, 267, 291, 14, 409, 17816, 20957, 1224, 8, 277, 14, 17816, 20826, 29926, 12, 756, 9, 267, 291, 14, 2902, 6970, 342, 339, 347, 641, 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, 1 ]
conklinbd/MovementAnalysis
TemplateInstall/PortalDeploy/arcrest/manageags/_uploads.py
2
4279
from .._abstract.abstract import BaseAGSServer import os ######################################################################## class Uploads(BaseAGSServer): """ This resource is a collection of all the items that have been uploaded to the server. See: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Uploads/02r3000001qr000000/ """ _uploads = None _securityHandler = None _proxy_port = None _proxy_url = None _url = None #---------------------------------------------------------------------- def __init__(self, url, securityHandler, proxy_url=None, proxy_port=None, initialize=False): """Constructor""" if url.lower().find("uploads") < -1: self._url = url + "/uploads" else: self._url = url self._securityHandler = securityHandler self._proxy_port = proxy_port self._proxy_url = proxy_url #---------------------------------------------------------------------- @property def uploads(self): """ returns a collection of all the items that have been uploaded to the server. """ params = { "f" :"json" } return self._do_get(url=self._url, param_dict=params, header={}, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) #---------------------------------------------------------------------- def deleteItem(self, itemId): """ Deletes the uploaded item and its configuration. Inputs: itemId - unique ID of the item """ url = self._url + "/%s/delete" % itemId params = { "f" : "json" } return self._do_post(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) #---------------------------------------------------------------------- def item(self, itemId): """ This resource represents an item that has been uploaded to the server. Various workflows upload items and then process them on the server. For example, when publishing a GIS service from ArcGIS for Desktop or ArcGIS Server Manager, the application first uploads the service definition (.SD) to the server and then invokes the publishing geoprocessing tool to publish the service. Each uploaded item is identified by a unique name (itemID). The pathOnServer property locates the specific item in the ArcGIS Server system directory. The committed parameter is set to true once the upload of individual parts is complete. """ url = self._url + "/%s" % itemId params = { "f" : "json" } return self._do_get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) #---------------------------------------------------------------------- def uploadItem(self, filePath, description): """""" import urlparse url = self._url + "/upload" params = { "f" : "json" } files = [] files.append(('itemFile', filePath, os.path.basename(filePath))) parsed = urlparse.urlparse(url) return self._post_multipart(host=parsed.hostname, selector=parsed.path, files = files, fields=params, port=parsed.port, securityHandler=self._securityHandler, ssl=parsed.scheme.lower() == 'https', proxy_port=self._proxy_port, proxy_url=self._proxy_url)
apache-2.0
[ 504, 1275, 423, 6198, 14, 6198, 492, 3523, 1254, 51, 3120, 199, 646, 747, 199, 3949, 199, 533, 4949, 3640, 8, 1563, 1254, 51, 3120, 304, 272, 408, 272, 961, 2073, 365, 282, 3245, 402, 1006, 314, 2974, 626, 1172, 2757, 14238, 272, 370, 314, 1654, 14, 272, 1666, 26, 1455, 921, 4435, 14, 9912, 5668, 14, 957, 15, 287, 15, 3437, 15, 9912, 5668, 13, 3911, 13, 1246, 15, 1080, 14, 1360, 3, 15, 1721, 3640, 15, 996, 82, 19, 19983, 16596, 3273, 15, 272, 408, 272, 485, 21725, 275, 488, 272, 485, 4416, 2461, 275, 488, 272, 485, 3280, 63, 719, 275, 488, 272, 485, 3280, 63, 633, 275, 488, 272, 485, 633, 275, 488, 339, 22526, 272, 347, 636, 826, 721, 277, 12, 1166, 12, 6391, 2461, 12, 326, 4566, 63, 633, 29, 403, 12, 4566, 63, 719, 29, 403, 12, 326, 8265, 29, 797, 304, 267, 408, 11447, 624, 267, 340, 1166, 14, 2325, 1252, 1623, 480, 21725, 531, 665, 446, 17, 26, 288, 291, 423, 633, 275, 1166, 435, 3286, 21725, 2, 267, 587, 26, 288, 291, 423, 633, 275, 1166, 267, 291, 423, 4416, 2461, 275, 6391, 2461, 267, 291, 423, 3280, 63, 719, 275, 4566, 63, 719, 267, 291, 423, 3280, 63, 633, 275, 4566, 63, 633, 339, 22526, 272, 768, 1829, 272, 347, 26598, 8, 277, 304, 267, 408, 267, 2529, 282, 3245, 402, 1006, 314, 2974, 626, 1172, 2757, 14238, 370, 267, 314, 1654, 14, 267, 408, 267, 1862, 275, 469, 288, 298, 70, 2, 26673, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 362, 8, 633, 29, 277, 423, 633, 12, 1169, 1215, 63, 807, 29, 1162, 12, 1169, 1406, 10324, 1169, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 1169, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 1169, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 339, 22526, 272, 347, 3145, 2081, 8, 277, 12, 1242, 1304, 304, 267, 408, 1779, 28382, 314, 14238, 1242, 436, 2399, 2897, 14, 1779, 30520, 26, 1598, 1242, 1304, 446, 3747, 2870, 402, 314, 1242, 267, 408, 267, 1166, 275, 291, 423, 633, 435, 298, 3149, 83, 15, 1807, 2, 450, 1242, 1304, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 1932, 8, 633, 29, 633, 12, 1215, 63, 807, 29, 1162, 12, 2490, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 2490, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 2490, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 272, 22526, 272, 347, 1242, 8, 277, 12, 1242, 1304, 304, 267, 408, 267, 961, 2073, 8469, 376, 1242, 626, 965, 2757, 14238, 370, 314, 267, 1654, 14, 21107, 1785, 10431, 83, 5802, 2974, 436, 2066, 2112, 3062, 641, 314, 267, 1654, 14, 2104, 2893, 12, 1380, 2780, 316, 282, 598, 1311, 2435, 687, 437, 1195, 11092, 367, 267, 8055, 17827, 503, 437, 1195, 11092, 7146, 13537, 12, 314, 4223, 1642, 26598, 314, 267, 2435, 5492, 17048, 3693, 9, 370, 314, 1654, 436, 2066, 29761, 314, 267, 2780, 316, 2312, 11340, 670, 316, 4744, 370, 2780, 314, 2435, 14, 267, 7048, 14238, 1242, 365, 15836, 701, 282, 3747, 536, 334, 1053, 998, 680, 710, 267, 931, 3314, 3120, 3324, 16592, 83, 314, 2488, 1242, 315, 314, 437, 1195, 11092, 267, 7146, 2656, 2082, 14, 267, 710, 27659, 2725, 365, 663, 370, 2549, 5403, 314, 5802, 402, 267, 8212, 4184, 365, 4890, 14, 267, 408, 267, 1166, 275, 291, 423, 633, 435, 298, 3149, 83, 2, 450, 1242, 1304, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 362, 8, 633, 29, 633, 12, 1215, 63, 807, 29, 1162, 12, 1169, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 1169, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 1169, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 272, 22526, 272, 347, 5802, 2081, 8, 277, 12, 570, 2042, 12, 1369, 304, 267, 408, 624, 267, 492, 7097, 267, 1166, 275, 291, 423, 633, 435, 3286, 5064, 2, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 1584, 275, 942, 267, 1584, 14, 740, 4725, 1053, 1173, 297, 570, 2042, 12, 747, 14, 515, 14, 4846, 8, 27501, 1724, 267, 4565, 275, 7097, 14, 10290, 8, 633, 9, 267, 372, 291, 423, 1932, 63, 10123, 8, 1102, 29, 6751, 14, 4269, 12, 4318, 9759, 29, 6751, 14, 515, 12, 4318, 1584, 275, 1584, 12, 4318, 1504, 29, 1162, 12, 4318, 1844, 29, 6751, 14, 719, 12, 4318, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 4318, 6149, 29, 6751, 14, 5512, 14, 2325, 342, 508, 283, 2859, 297, 4318, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 12, 4318, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1275, 423, 6198, 14, 6198, 492, 3523, 1254, 51, 3120, 199, 646, 747, 199, 3949, 199, 533, 4949, 3640, 8, 1563, 1254, 51, 3120, 304, 272, 408, 272, 961, 2073, 365, 282, 3245, 402, 1006, 314, 2974, 626, 1172, 2757, 14238, 272, 370, 314, 1654, 14, 272, 1666, 26, 1455, 921, 4435, 14, 9912, 5668, 14, 957, 15, 287, 15, 3437, 15, 9912, 5668, 13, 3911, 13, 1246, 15, 1080, 14, 1360, 3, 15, 1721, 3640, 15, 996, 82, 19, 19983, 16596, 3273, 15, 272, 408, 272, 485, 21725, 275, 488, 272, 485, 4416, 2461, 275, 488, 272, 485, 3280, 63, 719, 275, 488, 272, 485, 3280, 63, 633, 275, 488, 272, 485, 633, 275, 488, 339, 22526, 272, 347, 636, 826, 721, 277, 12, 1166, 12, 6391, 2461, 12, 326, 4566, 63, 633, 29, 403, 12, 4566, 63, 719, 29, 403, 12, 326, 8265, 29, 797, 304, 267, 408, 11447, 624, 267, 340, 1166, 14, 2325, 1252, 1623, 480, 21725, 531, 665, 446, 17, 26, 288, 291, 423, 633, 275, 1166, 435, 3286, 21725, 2, 267, 587, 26, 288, 291, 423, 633, 275, 1166, 267, 291, 423, 4416, 2461, 275, 6391, 2461, 267, 291, 423, 3280, 63, 719, 275, 4566, 63, 719, 267, 291, 423, 3280, 63, 633, 275, 4566, 63, 633, 339, 22526, 272, 768, 1829, 272, 347, 26598, 8, 277, 304, 267, 408, 267, 2529, 282, 3245, 402, 1006, 314, 2974, 626, 1172, 2757, 14238, 370, 267, 314, 1654, 14, 267, 408, 267, 1862, 275, 469, 288, 298, 70, 2, 26673, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 362, 8, 633, 29, 277, 423, 633, 12, 1169, 1215, 63, 807, 29, 1162, 12, 1169, 1406, 10324, 1169, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 1169, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 1169, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 339, 22526, 272, 347, 3145, 2081, 8, 277, 12, 1242, 1304, 304, 267, 408, 1779, 28382, 314, 14238, 1242, 436, 2399, 2897, 14, 1779, 30520, 26, 1598, 1242, 1304, 446, 3747, 2870, 402, 314, 1242, 267, 408, 267, 1166, 275, 291, 423, 633, 435, 298, 3149, 83, 15, 1807, 2, 450, 1242, 1304, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 1932, 8, 633, 29, 633, 12, 1215, 63, 807, 29, 1162, 12, 2490, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 2490, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 2490, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 272, 22526, 272, 347, 1242, 8, 277, 12, 1242, 1304, 304, 267, 408, 267, 961, 2073, 8469, 376, 1242, 626, 965, 2757, 14238, 370, 314, 267, 1654, 14, 21107, 1785, 10431, 83, 5802, 2974, 436, 2066, 2112, 3062, 641, 314, 267, 1654, 14, 2104, 2893, 12, 1380, 2780, 316, 282, 598, 1311, 2435, 687, 437, 1195, 11092, 367, 267, 8055, 17827, 503, 437, 1195, 11092, 7146, 13537, 12, 314, 4223, 1642, 26598, 314, 267, 2435, 5492, 17048, 3693, 9, 370, 314, 1654, 436, 2066, 29761, 314, 267, 2780, 316, 2312, 11340, 670, 316, 4744, 370, 2780, 314, 2435, 14, 267, 7048, 14238, 1242, 365, 15836, 701, 282, 3747, 536, 334, 1053, 998, 680, 710, 267, 931, 3314, 3120, 3324, 16592, 83, 314, 2488, 1242, 315, 314, 437, 1195, 11092, 267, 7146, 2656, 2082, 14, 267, 710, 27659, 2725, 365, 663, 370, 2549, 5403, 314, 5802, 402, 267, 8212, 4184, 365, 4890, 14, 267, 408, 267, 1166, 275, 291, 423, 633, 435, 298, 3149, 83, 2, 450, 1242, 1304, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 372, 291, 423, 1117, 63, 362, 8, 633, 29, 633, 12, 1215, 63, 807, 29, 1162, 12, 1169, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 1169, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 12, 1169, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 9, 272, 22526, 272, 347, 5802, 2081, 8, 277, 12, 570, 2042, 12, 1369, 304, 267, 408, 624, 267, 492, 7097, 267, 1166, 275, 291, 423, 633, 435, 3286, 5064, 2, 267, 1862, 275, 469, 288, 298, 70, 2, 520, 298, 1001, 2, 267, 789, 267, 1584, 275, 942, 267, 1584, 14, 740, 4725, 1053, 1173, 297, 570, 2042, 12, 747, 14, 515, 14, 4846, 8, 27501, 1724, 267, 4565, 275, 7097, 14, 10290, 8, 633, 9, 267, 372, 291, 423, 1932, 63, 10123, 8, 1102, 29, 6751, 14, 4269, 12, 4318, 9759, 29, 6751, 14, 515, 12, 4318, 1584, 275, 1584, 12, 4318, 1504, 29, 1162, 12, 4318, 1844, 29, 6751, 14, 719, 12, 4318, 6391, 2461, 29, 277, 423, 4416, 2461, 12, 4318, 6149, 29, 6751, 14, 5512, 14, 2325, 342, 508, 283, 2859, 297, 4318, 4566, 63, 719, 29, 277, 423, 3280, 63, 719, 12, 4318, 4566, 63, 633, 29, 277, 423, 3280, 63, 633, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
mpf82/w2ui
server/python/django_w2ui/django_w2ui/views.py
9
7416
# -*- coding: utf-8 -*- from __future__ import unicode_literals import json import re from operator import or_ , and_ from django.core.paginator import Paginator from django.core.serializers.json import DjangoJSONEncoder from django.db import models from django.db.models import Q from django.http import HttpResponse, HttpResponseBadRequest from django.utils.six import text_type from django.utils.six.moves import reduce, xrange from django.views.generic import View from django.views.generic.list import MultipleObjectMixin from django.forms.models import modelform_factory from django.views.generic.detail import SingleObjectMixin from django.utils.timezone import is_aware import decimal import datetime import settings JSON_MIMETYPE = 'application/json' RE_FORMATTED = re.compile(r'\{(\w+)\}') #: SQLite unsupported field types for regex lookups UNSUPPORTED_REGEX_FIELDS = ( models.IntegerField, models.BooleanField, models.NullBooleanField, models.FloatField, models.DecimalField, ) class DjangoJSONEncoderMod(json.JSONEncoder): """ JSONEncoder subclass that knows how to encode date/time and decimal types. """ def default(self, o): # See "Date Time String Format" in the ECMA-262 specification. if isinstance(o, datetime.datetime): # r = o.isoformat() USER_SHORT_DATETIME_FORMAT = "%d-%m-%Y %H:%M" r = o.strftime(USER_SHORT_DATETIME_FORMAT) if o.microsecond: r = r[:23] + r[26:] if r.endswith('+00:00'): r = r[:-6] + 'Z' return r elif isinstance(o, datetime.date): USER_SHORT_DATETIME_FORMAT = "%d-%m-%Y" return o.strftime(USER_SHORT_DATETIME_FORMAT) # return o.isoformat() elif isinstance(o, datetime.time): if is_aware(o): raise ValueError("JSON can't represent timezone-aware times.") # r = o.isoformat() # if o.microsecond: # r = r[:12] USER_SHORT_TIME_FORMAT = "%H:%M" r = o.strftime(USER_SHORT_TIME_FORMAT) return r elif isinstance(o, decimal.Decimal): return str(o) else: return super(DjangoJSONEncoderMod, self).default(o) def get_real_field(model, field_name): ''' Get the real field from a model given its name. Handle nested models recursively (aka. ``__`` lookups) ''' parts = field_name.split('__') field = model._meta.get_field(parts[0]) if len(parts) == 1: return model._meta.get_field(field_name) elif isinstance(field, models.ForeignKey): return get_real_field(field.rel.to, '__'.join(parts[1:])) else: raise Exception('Unhandled field: %s' % field_name) class W2uiBaseView(View): fields = [] commands = {} data = {} def post(self, request, *args, **kwargs): self.data = json.loads(request.body) cmd = self.commands.get(self.data.get('cmd',''),'') if cmd: response = getattr(self,cmd)(self.data) else: response = self.error('unknown command "%s"' % self.data.get('cmd','')) return HttpResponse(json.dumps(response, cls=DjangoJSONEncoderMod),mimetype=JSON_MIMETYPE) def response(self,status, message, data): resp = { "status" : status, "message": message, } if data: resp.update(data) return resp def success(self,message="",data=None): return self.response('success',message,data) def error(self,message="",data=None): return self.response('error',message,data) class W2uiGridView(MultipleObjectMixin, W2uiBaseView): commands = { 'get': 'get_records', 'save': 'save_records', 'delete': 'delete_records', } def get_records(self,data): # TODO: convalida data qs = self.get_queryset() # search search = data.get('search',[]) filters = [] for param in search: term = param['value'] field = param['field'] typ = param['type'] operator = param['operator'] if field == 'recid': field = 'pk' type_search = "" if operator == "contains": type_search = '__i'+operator elif operator == "in": type_search = '__'+operator elif operator == "between": type_search = '__range' elif operator == "begins": type_search = '__istartswith' elif operator == "ends": type_search = '__iendswith' elif operator == "is": type_search = "__exact" filters.append((Q(**{field+type_search: term}))) if filters: searchLogic = data.get('searchLogic','AND') if searchLogic == "AND": searchLogic = and_ else: searchLogic = or_ qs = qs.filter(reduce(searchLogic, filters)) # sort sort = data.get('sort',[]) order = [] for param in sort: field = param['field'] if field == "recid": field = self.model._meta.pk.get_attname() direction = param['direction'] if direction == 'desc': field = '-' + field order.append(field) if order: qs = qs.order_by(*order) # fields qs = qs.values('pk',*self.fields) # pagination page_size = data.get('limit',1) start_index = data.get('offset',0) paginator = Paginator(qs, page_size) num_page = (start_index / page_size) + 1 page = paginator.page(num_page) return self.success(data={ "total" : page.paginator.count, "records" : list(page.object_list), }) def save_records(self,data): return self.error('method not implemented') # TODO: def delete_records(self,data): try: for obj in self.get_queryset().in_bulk(data['selected']).itervalues(): obj.delete() response = self.success() except Exception as e: response = self.error('error deleting records',{ 'exception': e }) return response def get_data(self): return self.data class W2uiFormView (SingleObjectMixin, W2uiBaseView): commands = { 'get-record': 'get_record', 'save-record': 'save_record', } def get_record(self,data): pk = data.get('recid',None) record = self.get_queryset().filter(pk=pk).values(*self.fields) if len(record) == 1: response = self.success(data={ 'record': record[0] }) else: response = self.error('record ID "%s" not found' % pk) return response def save_record(self,data): Form = modelform_factory(self.model, fields=self.fields) form = Form(data['record']) if form.is_valid(): obj = form.save(commit=False) if data['recid']: obj.pk = data['recid'] obj.save() response = self.success() else: response = self.error('errori nella form',form.errors) return response
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 4182, 492, 503, 63, 2360, 436, 63, 199, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 199, 504, 1639, 14, 1018, 14, 12844, 14, 1001, 492, 5634, 23069, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 1014, 492, 6183, 12, 6183, 12380, 199, 504, 1639, 14, 1208, 14, 4174, 492, 1318, 63, 466, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 7114, 12, 4945, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 199, 504, 1639, 14, 4196, 14, 6767, 14, 513, 492, 14326, 1692, 4256, 199, 504, 1639, 14, 3351, 14, 992, 492, 29312, 63, 3702, 199, 504, 1639, 14, 4196, 14, 6767, 14, 5506, 492, 13050, 1692, 4256, 199, 504, 1639, 14, 1208, 14, 7145, 492, 365, 63, 14600, 199, 646, 6107, 199, 646, 2197, 199, 646, 2202, 199, 199, 6243, 63, 45, 1469, 17509, 275, 283, 3578, 15, 1001, 7, 199, 199, 907, 63, 4807, 52, 1149, 275, 295, 14, 2014, 8, 82, 1154, 91, 2961, 87, 13439, 12216, 199, 199, 12573, 19245, 16313, 901, 2943, 367, 5163, 16807, 199, 1734, 15925, 63, 10710, 63, 12767, 275, 334, 272, 1709, 14, 3901, 12, 272, 1709, 14, 5036, 12, 272, 1709, 14, 29068, 12, 272, 1709, 14, 13019, 12, 272, 1709, 14, 15975, 12, 199, 9, 199, 199, 533, 5634, 23069, 9871, 8, 1001, 14, 23069, 304, 272, 408, 272, 4840, 6679, 5516, 626, 19428, 4212, 370, 3752, 1434, 15, 521, 436, 6107, 2943, 14, 272, 408, 272, 347, 849, 8, 277, 12, 312, 304, 267, 327, 1666, 298, 2506, 4703, 2624, 9701, 2, 315, 314, 15352, 2054, 13, 14820, 8929, 14, 267, 340, 1228, 8, 79, 12, 2197, 14, 2083, 304, 199, 3, 3777, 519, 275, 312, 14, 17070, 342, 288, 13044, 63, 13003, 63, 12488, 63, 4807, 275, 2071, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2, 288, 519, 275, 312, 14, 6205, 8, 3791, 63, 13003, 63, 12488, 63, 4807, 9, 288, 340, 312, 14, 16627, 26, 355, 519, 275, 519, 1491, 1789, 61, 435, 519, 59, 1479, 2938, 288, 340, 519, 14, 4130, 19975, 383, 26, 383, 735, 355, 519, 275, 519, 4439, 22, 61, 435, 283, 58, 7, 288, 372, 519, 267, 916, 1228, 8, 79, 12, 2197, 14, 602, 304, 288, 13044, 63, 13003, 63, 12488, 63, 4807, 275, 2071, 68, 3295, 77, 3295, 57, 2, 288, 372, 312, 14, 6205, 8, 3791, 63, 13003, 63, 12488, 63, 4807, 9, 199, 3, 3777, 372, 312, 14, 17070, 342, 267, 916, 1228, 8, 79, 12, 2197, 14, 521, 304, 288, 340, 365, 63, 14600, 8, 79, 304, 355, 746, 1722, 480, 6243, 883, 1133, 2954, 7137, 13, 14600, 5431, 2685, 199, 3, 3777, 519, 275, 312, 14, 17070, 342, 199, 3, 3777, 340, 312, 14, 16627, 26, 199, 3, 463, 519, 275, 519, 1491, 713, 61, 288, 13044, 63, 13003, 63, 4961, 63, 4807, 275, 2071, 40, 2689, 45, 2, 288, 519, 275, 312, 14, 6205, 8, 3791, 63, 13003, 63, 4961, 63, 4807, 9, 288, 372, 519, 267, 916, 1228, 8, 79, 12, 6107, 14, 6745, 304, 288, 372, 620, 8, 79, 9, 267, 587, 26, 288, 372, 1613, 8, 9323, 23069, 9871, 12, 291, 680, 885, 8, 79, 9, 199, 199, 318, 664, 63, 3093, 63, 698, 8, 1238, 12, 901, 63, 354, 304, 272, 1449, 272, 2372, 314, 3363, 901, 687, 282, 1402, 1627, 2399, 536, 14, 339, 8690, 6032, 1709, 15035, 334, 24685, 14, 9035, 1040, 16807, 9, 272, 1449, 272, 4184, 275, 901, 63, 354, 14, 1294, 10714, 358, 272, 901, 275, 1402, 423, 2024, 14, 362, 63, 698, 8, 4181, 59, 16, 566, 272, 340, 822, 8, 4181, 9, 508, 413, 26, 267, 372, 1402, 423, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 272, 916, 1228, 8, 698, 12, 1709, 14, 3190, 304, 267, 372, 664, 63, 3093, 63, 698, 8, 698, 14, 3369, 14, 475, 12, 2560, 1370, 904, 8, 4181, 59, 17, 16720, 272, 587, 26, 267, 746, 2186, 360, 1358, 11217, 901, 26, 450, 83, 7, 450, 901, 63, 354, 9, 421, 199, 533, 644, 18, 1907, 1563, 2768, 8, 2768, 304, 272, 1504, 275, 942, 272, 3718, 275, 1052, 272, 666, 275, 1052, 272, 347, 2963, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 576, 275, 2022, 14, 3640, 8, 1069, 14, 2030, 9, 267, 2088, 221, 275, 291, 14, 4405, 14, 362, 8, 277, 14, 576, 14, 362, 360, 1760, 25936, 17483, 267, 340, 2088, 26, 288, 1177, 275, 2519, 8, 277, 12, 1760, 5130, 277, 14, 576, 9, 267, 587, 26, 288, 1177, 275, 291, 14, 705, 360, 5187, 1414, 2071, 83, 4507, 450, 291, 14, 576, 14, 362, 360, 1760, 1673, 1333, 267, 372, 6183, 8, 1001, 14, 4180, 8, 1310, 12, 843, 29, 9323, 23069, 9871, 395, 17450, 29, 6243, 63, 45, 1469, 17509, 9, 272, 347, 1177, 8, 277, 12, 1205, 12, 1245, 12, 666, 304, 267, 3085, 275, 469, 326, 298, 1205, 2, 520, 2004, 12, 326, 298, 1188, 582, 1245, 12, 326, 789, 267, 340, 666, 26, 288, 3085, 14, 873, 8, 576, 9, 267, 372, 3085, 272, 347, 3182, 8, 277, 12, 1188, 8772, 576, 29, 403, 304, 267, 372, 291, 14, 1310, 360, 3742, 297, 1188, 12, 576, 9, 272, 347, 1125, 8, 277, 12, 1188, 8772, 576, 29, 403, 304, 267, 372, 291, 14, 1310, 360, 705, 297, 1188, 12, 576, 9, 199, 199, 533, 644, 18, 1907, 7900, 2768, 8, 8433, 1692, 4256, 12, 644, 18, 1907, 1563, 2768, 304, 272, 3718, 275, 469, 489, 283, 362, 356, 259, 283, 362, 63, 6502, 297, 489, 283, 2117, 356, 257, 283, 2117, 63, 6502, 297, 489, 283, 1807, 356, 283, 1807, 63, 6502, 297, 272, 789, 272, 347, 664, 63, 6502, 8, 277, 12, 576, 304, 267, 327, 3254, 26, 406, 1078, 65, 666, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 398 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 4182, 492, 503, 63, 2360, 436, 63, 199, 199, 504, 1639, 14, 1018, 14, 22073, 492, 28006, 8566, 199, 504, 1639, 14, 1018, 14, 12844, 14, 1001, 492, 5634, 23069, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 1014, 492, 6183, 12, 6183, 12380, 199, 504, 1639, 14, 1208, 14, 4174, 492, 1318, 63, 466, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 7114, 12, 4945, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 199, 504, 1639, 14, 4196, 14, 6767, 14, 513, 492, 14326, 1692, 4256, 199, 504, 1639, 14, 3351, 14, 992, 492, 29312, 63, 3702, 199, 504, 1639, 14, 4196, 14, 6767, 14, 5506, 492, 13050, 1692, 4256, 199, 504, 1639, 14, 1208, 14, 7145, 492, 365, 63, 14600, 199, 646, 6107, 199, 646, 2197, 199, 646, 2202, 199, 199, 6243, 63, 45, 1469, 17509, 275, 283, 3578, 15, 1001, 7, 199, 199, 907, 63, 4807, 52, 1149, 275, 295, 14, 2014, 8, 82, 1154, 91, 2961, 87, 13439, 12216, 199, 199, 12573, 19245, 16313, 901, 2943, 367, 5163, 16807, 199, 1734, 15925, 63, 10710, 63, 12767, 275, 334, 272, 1709, 14, 3901, 12, 272, 1709, 14, 5036, 12, 272, 1709, 14, 29068, 12, 272, 1709, 14, 13019, 12, 272, 1709, 14, 15975, 12, 199, 9, 199, 199, 533, 5634, 23069, 9871, 8, 1001, 14, 23069, 304, 272, 408, 272, 4840, 6679, 5516, 626, 19428, 4212, 370, 3752, 1434, 15, 521, 436, 6107, 2943, 14, 272, 408, 272, 347, 849, 8, 277, 12, 312, 304, 267, 327, 1666, 298, 2506, 4703, 2624, 9701, 2, 315, 314, 15352, 2054, 13, 14820, 8929, 14, 267, 340, 1228, 8, 79, 12, 2197, 14, 2083, 304, 199, 3, 3777, 519, 275, 312, 14, 17070, 342, 288, 13044, 63, 13003, 63, 12488, 63, 4807, 275, 2071, 68, 3295, 77, 3295, 57, 450, 40, 2689, 45, 2, 288, 519, 275, 312, 14, 6205, 8, 3791, 63, 13003, 63, 12488, 63, 4807, 9, 288, 340, 312, 14, 16627, 26, 355, 519, 275, 519, 1491, 1789, 61, 435, 519, 59, 1479, 2938, 288, 340, 519, 14, 4130, 19975, 383, 26, 383, 735, 355, 519, 275, 519, 4439, 22, 61, 435, 283, 58, 7, 288, 372, 519, 267, 916, 1228, 8, 79, 12, 2197, 14, 602, 304, 288, 13044, 63, 13003, 63, 12488, 63, 4807, 275, 2071, 68, 3295, 77, 3295, 57, 2, 288, 372, 312, 14, 6205, 8, 3791, 63, 13003, 63, 12488, 63, 4807, 9, 199, 3, 3777, 372, 312, 14, 17070, 342, 267, 916, 1228, 8, 79, 12, 2197, 14, 521, 304, 288, 340, 365, 63, 14600, 8, 79, 304, 355, 746, 1722, 480, 6243, 883, 1133, 2954, 7137, 13, 14600, 5431, 2685, 199, 3, 3777, 519, 275, 312, 14, 17070, 342, 199, 3, 3777, 340, 312, 14, 16627, 26, 199, 3, 463, 519, 275, 519, 1491, 713, 61, 288, 13044, 63, 13003, 63, 4961, 63, 4807, 275, 2071, 40, 2689, 45, 2, 288, 519, 275, 312, 14, 6205, 8, 3791, 63, 13003, 63, 4961, 63, 4807, 9, 288, 372, 519, 267, 916, 1228, 8, 79, 12, 6107, 14, 6745, 304, 288, 372, 620, 8, 79, 9, 267, 587, 26, 288, 372, 1613, 8, 9323, 23069, 9871, 12, 291, 680, 885, 8, 79, 9, 199, 199, 318, 664, 63, 3093, 63, 698, 8, 1238, 12, 901, 63, 354, 304, 272, 1449, 272, 2372, 314, 3363, 901, 687, 282, 1402, 1627, 2399, 536, 14, 339, 8690, 6032, 1709, 15035, 334, 24685, 14, 9035, 1040, 16807, 9, 272, 1449, 272, 4184, 275, 901, 63, 354, 14, 1294, 10714, 358, 272, 901, 275, 1402, 423, 2024, 14, 362, 63, 698, 8, 4181, 59, 16, 566, 272, 340, 822, 8, 4181, 9, 508, 413, 26, 267, 372, 1402, 423, 2024, 14, 362, 63, 698, 8, 698, 63, 354, 9, 272, 916, 1228, 8, 698, 12, 1709, 14, 3190, 304, 267, 372, 664, 63, 3093, 63, 698, 8, 698, 14, 3369, 14, 475, 12, 2560, 1370, 904, 8, 4181, 59, 17, 16720, 272, 587, 26, 267, 746, 2186, 360, 1358, 11217, 901, 26, 450, 83, 7, 450, 901, 63, 354, 9, 421, 199, 533, 644, 18, 1907, 1563, 2768, 8, 2768, 304, 272, 1504, 275, 942, 272, 3718, 275, 1052, 272, 666, 275, 1052, 272, 347, 2963, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 576, 275, 2022, 14, 3640, 8, 1069, 14, 2030, 9, 267, 2088, 221, 275, 291, 14, 4405, 14, 362, 8, 277, 14, 576, 14, 362, 360, 1760, 25936, 17483, 267, 340, 2088, 26, 288, 1177, 275, 2519, 8, 277, 12, 1760, 5130, 277, 14, 576, 9, 267, 587, 26, 288, 1177, 275, 291, 14, 705, 360, 5187, 1414, 2071, 83, 4507, 450, 291, 14, 576, 14, 362, 360, 1760, 1673, 1333, 267, 372, 6183, 8, 1001, 14, 4180, 8, 1310, 12, 843, 29, 9323, 23069, 9871, 395, 17450, 29, 6243, 63, 45, 1469, 17509, 9, 272, 347, 1177, 8, 277, 12, 1205, 12, 1245, 12, 666, 304, 267, 3085, 275, 469, 326, 298, 1205, 2, 520, 2004, 12, 326, 298, 1188, 582, 1245, 12, 326, 789, 267, 340, 666, 26, 288, 3085, 14, 873, 8, 576, 9, 267, 372, 3085, 272, 347, 3182, 8, 277, 12, 1188, 8772, 576, 29, 403, 304, 267, 372, 291, 14, 1310, 360, 3742, 297, 1188, 12, 576, 9, 272, 347, 1125, 8, 277, 12, 1188, 8772, 576, 29, 403, 304, 267, 372, 291, 14, 1310, 360, 705, 297, 1188, 12, 576, 9, 199, 199, 533, 644, 18, 1907, 7900, 2768, 8, 8433, 1692, 4256, 12, 644, 18, 1907, 1563, 2768, 304, 272, 3718, 275, 469, 489, 283, 362, 356, 259, 283, 362, 63, 6502, 297, 489, 283, 2117, 356, 257, 283, 2117, 63, 6502, 297, 489, 283, 1807, 356, 283, 1807, 63, 6502, 297, 272, 789, 272, 347, 664, 63, 6502, 8, 277, 12, 576, 304, 267, 327, 3254, 26, 406, 1078, 65, 666, 267, 6377, 275, 291, 14, 362, 63, 7924, 342, 398, 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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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 ]
ImageEngine/gaffer
python/GafferSceneUI/CollectPrimitiveVariablesUI.py
8
3501
########################################################################## # # Copyright (c) 2018, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the following # disclaimer. # # * 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. # # * Neither the name of John Haddon nor the names of # any other contributors to this software 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 OWNER 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. # ########################################################################## import Gaffer import GafferScene Gaffer.Metadata.registerNode( GafferScene.CollectPrimitiveVariables, "description", """ Make copies of target primitive variables with different suffixes, where the new suffixed copies come from different Contexts. By combining this with a TimeWarp, you can create copies of primitive variables at different times, useful for creating trail effects. """, "ui:spreadsheet:activeRowNamesConnection", "suffixes", "ui:spreadsheet:selectorContextVariablePlug", "suffixContextVariable", plugs = { "primitiveVariables" : [ "description", """ A match pattern for which primitive variables will be copied. """ ], "suffixes" : [ "description", """ The names of the new suffixes to add to copies of the target primitive variables. The new suffixed variables will be copied from different Contexts. """, ], "suffixContextVariable" : [ "description", """ The name of a Context Variable that is set to the current suffix when evaluating the input object. This can be used in upstream expressions and string substitutions to vary the object while creating the primvar copies. For example, you could drive a TimeWarp with this variable in order create copies of a primitive variable at different times. """, ], "requireVariation" : [ "description", """ If true, newly copied primitive variables will only be created if the source object is differs in some of the suffix Contexts. If the source object never changes, it will be passed through unchanged ( since there is no variation, you can just use the original primitive variables ). """ ], } )
bsd-3-clause
[ 26863, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 14894, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 420, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 14, 199, 3, 199, 3, 420, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 199, 3, 263, 314, 4084, 14, 199, 3, 199, 3, 420, 627, 11443, 314, 536, 402, 17815, 869, 9291, 6590, 314, 1561, 402, 199, 3, 263, 1263, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 263, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 263, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 16600, 199, 646, 16600, 14216, 199, 199, 17295, 1260, 14, 5142, 14, 2683, 1716, 8, 421, 198, 17295, 1260, 14216, 14, 25023, 22231, 11458, 12, 421, 198, 2, 1802, 401, 199, 198, 624, 199, 198, 5483, 6866, 402, 1347, 18944, 2860, 543, 3365, 19475, 12, 199, 198, 4509, 314, 892, 4739, 379, 6866, 11492, 687, 3365, 9470, 83, 14, 421, 198, 2175, 29391, 642, 543, 282, 4703, 55, 12868, 12, 1265, 883, 1218, 6866, 402, 199, 198, 16161, 2860, 737, 3365, 5431, 12, 2997, 367, 6425, 27225, 199, 198, 27626, 14, 199, 198, 7208, 421, 198, 2, 1907, 26, 19930, 26, 2682, 5810, 5866, 3225, 401, 298, 16097, 401, 199, 198, 2, 1907, 26, 19930, 26, 6662, 2998, 2773, 19173, 401, 298, 4511, 2998, 2773, 401, 421, 198, 1168, 85, 458, 275, 469, 507, 198, 2, 16161, 11458, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 33, 1336, 3851, 367, 1314, 18944, 2860, 911, 506, 8876, 14, 686, 198, 624, 2742, 198, 467, 2742, 198, 2, 16097, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 1918, 1561, 402, 314, 892, 19475, 370, 1050, 370, 6866, 402, 314, 1347, 686, 198, 16161, 2860, 14, 221, 710, 892, 4739, 379, 2860, 911, 506, 686, 198, 23581, 687, 3365, 9470, 83, 14, 686, 198, 7208, 2742, 198, 467, 2742, 198, 2, 4511, 2998, 2773, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 1918, 536, 402, 282, 9470, 4905, 626, 365, 663, 370, 314, 1453, 686, 198, 4511, 1380, 27083, 314, 1324, 909, 14, 961, 883, 506, 1202, 686, 198, 262, 18932, 8455, 436, 1059, 20873, 370, 17083, 686, 198, 1589, 909, 1830, 6425, 314, 1979, 77, 1391, 6866, 14, 6319, 198, 1858, 2893, 12, 1265, 4293, 12912, 282, 4703, 55, 12868, 543, 642, 686, 198, 1975, 315, 1865, 1218, 6866, 402, 282, 18944, 1750, 737, 686, 198, 14020, 5431, 14, 686, 198, 7208, 2742, 198, 467, 2742, 198, 2, 4365, 9958, 425, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 3917, 2549, 12, 13903, 8876, 18944, 2860, 911, 1454, 506, 2737, 686, 198, 692, 314, 1350, 909, 365, 22754, 315, 2005, 402, 314, 4739, 9470, 83, 14, 686, 198, 3917, 314, 1350, 909, 7078, 4493, 12, 652, 911, 506, 3032, 4012, 686, 198, 16914, 334, 3967, 2337, 365, 949, 29844, 12, 1265, 883, 2951, 675, 314, 686, 198, 5043, 18944, 2860, 7092, 686, 198, 624, 2742, 198, 467, 421, 198, 93, 199, 199, 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 ]
[ 199, 3, 199, 3, 221, 1898, 334, 67, 9, 14894, 12, 6047, 12580, 29410, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 221, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 221, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 221, 7647, 26, 199, 3, 199, 3, 420, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 14, 199, 3, 199, 3, 420, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 263, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 263, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 199, 3, 263, 314, 4084, 14, 199, 3, 199, 3, 420, 627, 11443, 314, 536, 402, 17815, 869, 9291, 6590, 314, 1561, 402, 199, 3, 263, 1263, 1163, 8417, 370, 642, 2032, 1443, 506, 1202, 370, 10692, 503, 199, 3, 263, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 199, 3, 263, 5313, 4983, 14, 199, 3, 199, 3, 221, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 221, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 221, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 221, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 221, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 221, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 221, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 221, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 221, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 3, 221, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 26863, 199, 199, 646, 16600, 199, 646, 16600, 14216, 199, 199, 17295, 1260, 14, 5142, 14, 2683, 1716, 8, 421, 198, 17295, 1260, 14216, 14, 25023, 22231, 11458, 12, 421, 198, 2, 1802, 401, 199, 198, 624, 199, 198, 5483, 6866, 402, 1347, 18944, 2860, 543, 3365, 19475, 12, 199, 198, 4509, 314, 892, 4739, 379, 6866, 11492, 687, 3365, 9470, 83, 14, 421, 198, 2175, 29391, 642, 543, 282, 4703, 55, 12868, 12, 1265, 883, 1218, 6866, 402, 199, 198, 16161, 2860, 737, 3365, 5431, 12, 2997, 367, 6425, 27225, 199, 198, 27626, 14, 199, 198, 7208, 421, 198, 2, 1907, 26, 19930, 26, 2682, 5810, 5866, 3225, 401, 298, 16097, 401, 199, 198, 2, 1907, 26, 19930, 26, 6662, 2998, 2773, 19173, 401, 298, 4511, 2998, 2773, 401, 421, 198, 1168, 85, 458, 275, 469, 507, 198, 2, 16161, 11458, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 33, 1336, 3851, 367, 1314, 18944, 2860, 911, 506, 8876, 14, 686, 198, 624, 2742, 198, 467, 2742, 198, 2, 16097, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 1918, 1561, 402, 314, 892, 19475, 370, 1050, 370, 6866, 402, 314, 1347, 686, 198, 16161, 2860, 14, 221, 710, 892, 4739, 379, 2860, 911, 506, 686, 198, 23581, 687, 3365, 9470, 83, 14, 686, 198, 7208, 2742, 198, 467, 2742, 198, 2, 4511, 2998, 2773, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 1918, 536, 402, 282, 9470, 4905, 626, 365, 663, 370, 314, 1453, 686, 198, 4511, 1380, 27083, 314, 1324, 909, 14, 961, 883, 506, 1202, 686, 198, 262, 18932, 8455, 436, 1059, 20873, 370, 17083, 686, 198, 1589, 909, 1830, 6425, 314, 1979, 77, 1391, 6866, 14, 6319, 198, 1858, 2893, 12, 1265, 4293, 12912, 282, 4703, 55, 12868, 543, 642, 686, 198, 1975, 315, 1865, 1218, 6866, 402, 282, 18944, 1750, 737, 686, 198, 14020, 5431, 14, 686, 198, 7208, 2742, 198, 467, 2742, 198, 2, 4365, 9958, 425, 2, 520, 359, 6319, 198, 2, 1802, 401, 686, 198, 624, 686, 198, 3917, 2549, 12, 13903, 8876, 18944, 2860, 911, 1454, 506, 2737, 686, 198, 692, 314, 1350, 909, 365, 22754, 315, 2005, 402, 314, 4739, 9470, 83, 14, 686, 198, 3917, 314, 1350, 909, 7078, 4493, 12, 652, 911, 506, 3032, 4012, 686, 198, 16914, 334, 3967, 2337, 365, 949, 29844, 12, 1265, 883, 2951, 675, 314, 686, 198, 5043, 18944, 2860, 7092, 686, 198, 624, 2742, 198, 467, 421, 198, 93, 199, 199, 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, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
lyndsysimon/osf.io
website/addons/googledrive/views/auth.py
12
4608
import httplib as http from datetime import datetime from flask import request from framework.flask import redirect # VOL-aware redirect from framework.sessions import session from framework.exceptions import HTTPError from framework.auth.decorators import must_be_logged_in from website import models from website.util import permissions from website.util import web_url_for from website.project.model import Node from website.project.decorators import ( must_have_addon, must_have_permission ) from website.addons.googledrive.client import GoogleAuthClient from website.addons.googledrive.utils import serialize_settings from website.addons.googledrive.model import GoogleDriveOAuthSettings @must_be_logged_in def googledrive_oauth_start(auth, **kwargs): """View function that does OAuth Authorization and returns access token""" # Run through the OAuth flow and retrieve credentials # Store the node ID on the session in order to get the correct redirect URL # upon finishing the flow user = auth.user nid = kwargs.get('nid') or kwargs.get('pid') node = models.Node.load(nid) if nid else None node_addon = user.get_addon('googledrive') # Fail if node provided and user not contributor if node and not node.is_contributor(user): raise HTTPError(http.FORBIDDEN) # Handle if user has already authorized google drive if node_addon and node_addon.has_auth: return redirect(web_url_for('user_addons')) client = GoogleAuthClient() authorization_url, state = client.start() session.data['googledrive_auth_state'] = state if nid: session.data['googledrive_auth_nid'] = nid return redirect(authorization_url) @must_be_logged_in def googledrive_oauth_finish(auth, **kwargs): """View called when the Oauth flow is completed. Adds a new GoogleDriveUserSettings record to the user and saves the user's access token and account info. """ user = auth.user node = Node.load(session.data.pop('googledrive_auth_nid', None)) # Handle request cancellations from Google's API if request.args.get('error'): if node: return redirect(node.web_url_for('node_setting')) return redirect(web_url_for('user_addons')) user.add_addon('googledrive') user.save() code = request.args.get('code') user_settings = user.get_addon('googledrive') state = session.data.pop('googledrive_auth_state') if state != request.args.get('state'): raise HTTPError(http.BAD_REQUEST) if code is None: raise HTTPError(http.BAD_REQUEST) auth_client = GoogleAuthClient() token = auth_client.finish(code) info = auth_client.userinfo(token['access_token']) # Attempt to attach an existing oauth settings model oauth_settings = GoogleDriveOAuthSettings.load(info['sub']) # Create a new oauth settings model if not oauth_settings: oauth_settings = GoogleDriveOAuthSettings() oauth_settings.user_id = info['sub'] oauth_settings.save() user_settings.oauth_settings = oauth_settings user_settings.username = info['name'] user_settings.access_token = token['access_token'] user_settings.refresh_token = token['refresh_token'] user_settings.expires_at = datetime.utcfromtimestamp(token['expires_at']) user_settings.save() if node: if node.has_addon('googledrive'): node_addon = node.get_addon('googledrive') node_addon.set_user_auth(user_settings) node_addon.save() return redirect(node.web_url_for('node_setting')) return redirect(web_url_for('user_addons')) @must_be_logged_in @must_have_addon('googledrive', 'user') def googledrive_oauth_delete_user(user_addon, **kwargs): user_addon.clear() user_addon.save() @must_have_permission(permissions.WRITE) @must_have_addon('googledrive', 'node') def googledrive_deauthorize(auth, node_addon, **kwargs): node_addon.deauthorize(auth=auth) node_addon.save() @must_have_permission(permissions.WRITE) @must_have_addon('googledrive', 'node') def googledrive_import_user_auth(auth, node_addon, **kwargs): """Import googledrive credentials from the currently logged-in user to a node. """ user = auth.user user_addon = user.get_addon('googledrive') if user_addon is None: raise HTTPError(http.BAD_REQUEST) node_addon.set_user_auth(user_addon) node_addon.save() return { 'result': serialize_settings(node_addon, user), 'message': 'Successfully imported access token from profile.', }
apache-2.0
[ 646, 8809, 465, 1455, 199, 504, 2197, 492, 2197, 199, 199, 504, 7209, 492, 1056, 199, 199, 504, 10059, 14, 15720, 492, 4660, 221, 327, 812, 2228, 13, 14600, 4660, 199, 504, 10059, 14, 11676, 492, 2351, 199, 504, 10059, 14, 3924, 492, 15050, 199, 504, 10059, 14, 1178, 14, 11582, 492, 1471, 63, 1235, 63, 12419, 63, 262, 199, 199, 504, 10691, 492, 1709, 199, 504, 10691, 14, 1974, 492, 3443, 199, 504, 10691, 14, 1974, 492, 3330, 63, 633, 63, 509, 199, 504, 10691, 14, 1715, 14, 1238, 492, 5013, 199, 504, 10691, 14, 1715, 14, 11582, 492, 334, 272, 1471, 63, 7804, 63, 9291, 12, 272, 1471, 63, 7804, 63, 5693, 199, 9, 199, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1258, 492, 4475, 2817, 3041, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1208, 492, 8437, 63, 1751, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1238, 492, 4475, 24276, 12906, 5268, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 928, 8, 1178, 12, 1011, 958, 304, 272, 408, 2768, 805, 626, 1630, 11715, 21527, 272, 436, 2529, 2879, 1526, 624, 272, 327, 3378, 4012, 314, 11715, 6369, 436, 8044, 6235, 272, 327, 13874, 314, 1031, 2870, 641, 314, 2351, 315, 1865, 370, 664, 314, 3211, 4660, 2851, 272, 327, 12188, 9578, 316, 314, 6369, 272, 922, 275, 1790, 14, 751, 272, 302, 344, 275, 2074, 14, 362, 360, 30411, 358, 503, 2074, 14, 362, 360, 3150, 358, 272, 1031, 275, 1709, 14, 1716, 14, 912, 8, 30411, 9, 340, 302, 344, 587, 488, 272, 1031, 63, 9291, 275, 922, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 339, 327, 12176, 340, 1031, 2741, 436, 922, 440, 11615, 272, 340, 1031, 436, 440, 1031, 14, 374, 63, 16833, 8, 751, 304, 267, 746, 15050, 8, 1014, 14, 2707, 34, 22436, 9, 339, 327, 8690, 340, 922, 965, 2575, 18788, 6233, 12912, 272, 340, 1031, 63, 9291, 436, 1031, 63, 9291, 14, 1989, 63, 1178, 26, 267, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 339, 1890, 275, 4475, 2817, 3041, 342, 272, 13448, 63, 633, 12, 1174, 275, 1890, 14, 928, 342, 339, 2351, 14, 576, 459, 28069, 1146, 6053, 63, 1178, 63, 929, 418, 275, 1174, 272, 340, 302, 344, 26, 267, 2351, 14, 576, 459, 28069, 1146, 6053, 63, 1178, 63, 30411, 418, 275, 302, 344, 339, 372, 4660, 8, 15846, 63, 633, 9, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 8192, 8, 1178, 12, 1011, 958, 304, 272, 408, 2768, 2797, 1380, 314, 593, 1178, 6369, 365, 9709, 14, 15747, 282, 892, 4475, 24276, 1899, 5268, 272, 2777, 370, 314, 922, 436, 23050, 314, 922, 1159, 2879, 1526, 436, 2933, 2256, 14, 272, 408, 272, 922, 275, 1790, 14, 751, 272, 1031, 275, 5013, 14, 912, 8, 1730, 14, 576, 14, 1935, 360, 28069, 1146, 6053, 63, 1178, 63, 30411, 297, 488, 430, 339, 327, 8690, 1056, 9311, 6011, 687, 4475, 1159, 3261, 272, 340, 1056, 14, 589, 14, 362, 360, 705, 735, 267, 340, 1031, 26, 288, 372, 4660, 8, 932, 14, 2520, 63, 633, 63, 509, 360, 932, 63, 6031, 1333, 267, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 339, 922, 14, 525, 63, 9291, 360, 28069, 1146, 6053, 358, 272, 922, 14, 2117, 342, 339, 1233, 275, 1056, 14, 589, 14, 362, 360, 600, 358, 272, 922, 63, 1751, 275, 922, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 339, 1174, 275, 2351, 14, 576, 14, 1935, 360, 28069, 1146, 6053, 63, 1178, 63, 929, 358, 272, 340, 1174, 1137, 1056, 14, 589, 14, 362, 360, 929, 735, 267, 746, 15050, 8, 1014, 14, 9439, 63, 6780, 9, 339, 340, 1233, 365, 488, 26, 267, 746, 15050, 8, 1014, 14, 9439, 63, 6780, 9, 339, 1790, 63, 1258, 275, 4475, 2817, 3041, 342, 272, 1526, 275, 1790, 63, 1258, 14, 8192, 8, 600, 9, 272, 2256, 275, 1790, 63, 1258, 14, 751, 815, 8, 1418, 459, 2732, 63, 1418, 1105, 339, 327, 23115, 370, 6554, 376, 3411, 9725, 2202, 1402, 272, 9725, 63, 1751, 275, 4475, 24276, 12906, 5268, 14, 912, 8, 815, 459, 954, 1105, 272, 327, 2790, 282, 892, 9725, 2202, 1402, 272, 340, 440, 9725, 63, 1751, 26, 267, 9725, 63, 1751, 275, 4475, 24276, 12906, 5268, 342, 267, 9725, 63, 1751, 14, 751, 63, 344, 275, 2256, 459, 954, 418, 267, 9725, 63, 1751, 14, 2117, 342, 272, 922, 63, 1751, 14, 6126, 63, 1751, 275, 9725, 63, 1751, 339, 922, 63, 1751, 14, 2473, 275, 2256, 459, 354, 418, 272, 922, 63, 1751, 14, 2732, 63, 1418, 275, 1526, 459, 2732, 63, 1418, 418, 272, 922, 63, 1751, 14, 6635, 63, 1418, 275, 1526, 459, 6635, 63, 1418, 418, 272, 922, 63, 1751, 14, 12342, 63, 292, 275, 2197, 14, 5834, 18531, 8, 1418, 459, 12342, 63, 292, 1105, 272, 922, 63, 1751, 14, 2117, 342, 339, 340, 1031, 26, 267, 340, 1031, 14, 1989, 63, 9291, 360, 28069, 1146, 6053, 735, 288, 1031, 63, 9291, 275, 1031, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 288, 1031, 63, 9291, 14, 409, 63, 751, 63, 1178, 8, 751, 63, 1751, 9, 288, 1031, 63, 9291, 14, 2117, 342, 267, 372, 4660, 8, 932, 14, 2520, 63, 633, 63, 509, 360, 932, 63, 6031, 1333, 272, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 32, 7790, 63, 7804, 63, 9291, 360, 28069, 1146, 6053, 297, 283, 751, 358, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 1807, 63, 751, 8, 751, 63, 9291, 12, 1011, 958, 304, 272, 922, 63, 9291, 14, 3584, 342, 272, 922, 63, 9291, 14, 2117, 342, 421, 199, 32, 7790, 63, 7804, 63, 5693, 8, 6060, 14, 10387, 9, 199, 32, 7790, 63, 7804, 63, 9291, 360, 28069, 1146, 6053, 297, 283, 932, 358 ]
[ 8809, 465, 1455, 199, 504, 2197, 492, 2197, 199, 199, 504, 7209, 492, 1056, 199, 199, 504, 10059, 14, 15720, 492, 4660, 221, 327, 812, 2228, 13, 14600, 4660, 199, 504, 10059, 14, 11676, 492, 2351, 199, 504, 10059, 14, 3924, 492, 15050, 199, 504, 10059, 14, 1178, 14, 11582, 492, 1471, 63, 1235, 63, 12419, 63, 262, 199, 199, 504, 10691, 492, 1709, 199, 504, 10691, 14, 1974, 492, 3443, 199, 504, 10691, 14, 1974, 492, 3330, 63, 633, 63, 509, 199, 504, 10691, 14, 1715, 14, 1238, 492, 5013, 199, 504, 10691, 14, 1715, 14, 11582, 492, 334, 272, 1471, 63, 7804, 63, 9291, 12, 272, 1471, 63, 7804, 63, 5693, 199, 9, 199, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1258, 492, 4475, 2817, 3041, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1208, 492, 8437, 63, 1751, 199, 504, 10691, 14, 10788, 14, 28069, 1146, 6053, 14, 1238, 492, 4475, 24276, 12906, 5268, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 928, 8, 1178, 12, 1011, 958, 304, 272, 408, 2768, 805, 626, 1630, 11715, 21527, 272, 436, 2529, 2879, 1526, 624, 272, 327, 3378, 4012, 314, 11715, 6369, 436, 8044, 6235, 272, 327, 13874, 314, 1031, 2870, 641, 314, 2351, 315, 1865, 370, 664, 314, 3211, 4660, 2851, 272, 327, 12188, 9578, 316, 314, 6369, 272, 922, 275, 1790, 14, 751, 272, 302, 344, 275, 2074, 14, 362, 360, 30411, 358, 503, 2074, 14, 362, 360, 3150, 358, 272, 1031, 275, 1709, 14, 1716, 14, 912, 8, 30411, 9, 340, 302, 344, 587, 488, 272, 1031, 63, 9291, 275, 922, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 339, 327, 12176, 340, 1031, 2741, 436, 922, 440, 11615, 272, 340, 1031, 436, 440, 1031, 14, 374, 63, 16833, 8, 751, 304, 267, 746, 15050, 8, 1014, 14, 2707, 34, 22436, 9, 339, 327, 8690, 340, 922, 965, 2575, 18788, 6233, 12912, 272, 340, 1031, 63, 9291, 436, 1031, 63, 9291, 14, 1989, 63, 1178, 26, 267, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 339, 1890, 275, 4475, 2817, 3041, 342, 272, 13448, 63, 633, 12, 1174, 275, 1890, 14, 928, 342, 339, 2351, 14, 576, 459, 28069, 1146, 6053, 63, 1178, 63, 929, 418, 275, 1174, 272, 340, 302, 344, 26, 267, 2351, 14, 576, 459, 28069, 1146, 6053, 63, 1178, 63, 30411, 418, 275, 302, 344, 339, 372, 4660, 8, 15846, 63, 633, 9, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 8192, 8, 1178, 12, 1011, 958, 304, 272, 408, 2768, 2797, 1380, 314, 593, 1178, 6369, 365, 9709, 14, 15747, 282, 892, 4475, 24276, 1899, 5268, 272, 2777, 370, 314, 922, 436, 23050, 314, 922, 1159, 2879, 1526, 436, 2933, 2256, 14, 272, 408, 272, 922, 275, 1790, 14, 751, 272, 1031, 275, 5013, 14, 912, 8, 1730, 14, 576, 14, 1935, 360, 28069, 1146, 6053, 63, 1178, 63, 30411, 297, 488, 430, 339, 327, 8690, 1056, 9311, 6011, 687, 4475, 1159, 3261, 272, 340, 1056, 14, 589, 14, 362, 360, 705, 735, 267, 340, 1031, 26, 288, 372, 4660, 8, 932, 14, 2520, 63, 633, 63, 509, 360, 932, 63, 6031, 1333, 267, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 339, 922, 14, 525, 63, 9291, 360, 28069, 1146, 6053, 358, 272, 922, 14, 2117, 342, 339, 1233, 275, 1056, 14, 589, 14, 362, 360, 600, 358, 272, 922, 63, 1751, 275, 922, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 339, 1174, 275, 2351, 14, 576, 14, 1935, 360, 28069, 1146, 6053, 63, 1178, 63, 929, 358, 272, 340, 1174, 1137, 1056, 14, 589, 14, 362, 360, 929, 735, 267, 746, 15050, 8, 1014, 14, 9439, 63, 6780, 9, 339, 340, 1233, 365, 488, 26, 267, 746, 15050, 8, 1014, 14, 9439, 63, 6780, 9, 339, 1790, 63, 1258, 275, 4475, 2817, 3041, 342, 272, 1526, 275, 1790, 63, 1258, 14, 8192, 8, 600, 9, 272, 2256, 275, 1790, 63, 1258, 14, 751, 815, 8, 1418, 459, 2732, 63, 1418, 1105, 339, 327, 23115, 370, 6554, 376, 3411, 9725, 2202, 1402, 272, 9725, 63, 1751, 275, 4475, 24276, 12906, 5268, 14, 912, 8, 815, 459, 954, 1105, 272, 327, 2790, 282, 892, 9725, 2202, 1402, 272, 340, 440, 9725, 63, 1751, 26, 267, 9725, 63, 1751, 275, 4475, 24276, 12906, 5268, 342, 267, 9725, 63, 1751, 14, 751, 63, 344, 275, 2256, 459, 954, 418, 267, 9725, 63, 1751, 14, 2117, 342, 272, 922, 63, 1751, 14, 6126, 63, 1751, 275, 9725, 63, 1751, 339, 922, 63, 1751, 14, 2473, 275, 2256, 459, 354, 418, 272, 922, 63, 1751, 14, 2732, 63, 1418, 275, 1526, 459, 2732, 63, 1418, 418, 272, 922, 63, 1751, 14, 6635, 63, 1418, 275, 1526, 459, 6635, 63, 1418, 418, 272, 922, 63, 1751, 14, 12342, 63, 292, 275, 2197, 14, 5834, 18531, 8, 1418, 459, 12342, 63, 292, 1105, 272, 922, 63, 1751, 14, 2117, 342, 339, 340, 1031, 26, 267, 340, 1031, 14, 1989, 63, 9291, 360, 28069, 1146, 6053, 735, 288, 1031, 63, 9291, 275, 1031, 14, 362, 63, 9291, 360, 28069, 1146, 6053, 358, 288, 1031, 63, 9291, 14, 409, 63, 751, 63, 1178, 8, 751, 63, 1751, 9, 288, 1031, 63, 9291, 14, 2117, 342, 267, 372, 4660, 8, 932, 14, 2520, 63, 633, 63, 509, 360, 932, 63, 6031, 1333, 272, 372, 4660, 8, 2520, 63, 633, 63, 509, 360, 751, 63, 10788, 1333, 421, 199, 32, 7790, 63, 1235, 63, 12419, 63, 262, 199, 32, 7790, 63, 7804, 63, 9291, 360, 28069, 1146, 6053, 297, 283, 751, 358, 199, 318, 2621, 974, 1146, 6053, 63, 6126, 63, 1807, 63, 751, 8, 751, 63, 9291, 12, 1011, 958, 304, 272, 922, 63, 9291, 14, 3584, 342, 272, 922, 63, 9291, 14, 2117, 342, 421, 199, 32, 7790, 63, 7804, 63, 5693, 8, 6060, 14, 10387, 9, 199, 32, 7790, 63, 7804, 63, 9291, 360, 28069, 1146, 6053, 297, 283, 932, 358, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mozilla/addons-server
src/olympia/reviewers/tests/test_utils.py
2
98875
# -*- coding: utf-8 -*- from datetime import datetime, timedelta from unittest import mock from unittest.mock import Mock, patch from django.conf import settings from django.core import mail from django.core.files.storage import default_storage as storage from django.test.utils import override_settings from django.urls import reverse from django.utils import translation import pytest import responses from olympia import amo from olympia.activity.models import ActivityLog, ActivityLogToken from olympia.addons.models import Addon, AddonApprovalsCounter, AddonReviewerFlags from olympia.amo.templatetags.jinja_helpers import absolutify from olympia.amo.tests import ( TestCase, addon_factory, file_factory, user_factory, version_factory, ) from olympia.amo.utils import send_mail from olympia.blocklist.models import Block, BlocklistSubmission from olympia.constants.promoted import ( LINE, RECOMMENDED, SPOTLIGHT, STRATEGIC, SPONSORED, ) from olympia.files.models import File from olympia.lib.crypto.tests.test_signing import ( _get_recommendation_data, _get_signature_details, ) from olympia.promoted.models import PromotedApproval from olympia.reviewers.models import ( AutoApprovalSummary, ReviewerScore, ReviewerSubscription, ViewExtensionQueue, ) from olympia.reviewers.utils import ( ReviewAddon, ReviewFiles, ReviewHelper, ReviewUnlisted, ViewUnlistedAllListTable, view_table_factory, ) from olympia.users.models import UserProfile from olympia.versions.models import VersionReviewerFlags from pyquery import PyQuery as pq pytestmark = pytest.mark.django_db REVIEW_FILES_STATUSES = (amo.STATUS_APPROVED, amo.STATUS_DISABLED) class TestViewExtensionQueueTable(TestCase): def setUp(self): super().setUp() self.table = view_table_factory(ViewExtensionQueue)([]) def test_addon_name(self): row = Mock() page = Mock() page.start_index = Mock() page.start_index.return_value = 1 row.addon_name = 'フォクすけといっしょ' row.addon_slug = 'test' row.latest_version = '0.12' self.table.set_page(page) a = pq(self.table.render_addon_name(row)) assert a.attr('href') == ( reverse('reviewers.review', args=[str(row.addon_slug)]) ) assert a.text() == 'フォクすけといっしょ 0.12' def test_addon_type_id(self): row = Mock() row.addon_type_id = amo.ADDON_EXTENSION assert str(self.table.render_addon_type_id(row)) == 'Extension' def test_waiting_time_in_days(self): row = Mock() row.waiting_time_days = 10 row.waiting_time_hours = 10 * 24 assert self.table.render_waiting_time_min(row) == '10 days' def test_waiting_time_one_day(self): row = Mock() row.waiting_time_days = 1 row.waiting_time_hours = 24 row.waiting_time_min = 60 * 24 assert self.table.render_waiting_time_min(row) == '1 day' def test_waiting_time_in_hours(self): row = Mock() row.waiting_time_days = 0 row.waiting_time_hours = 22 row.waiting_time_min = 60 * 22 assert self.table.render_waiting_time_min(row) == '22 hours' def test_waiting_time_in_min(self): row = Mock() row.waiting_time_days = 0 row.waiting_time_hours = 0 row.waiting_time_min = 11 assert self.table.render_waiting_time_min(row) == '11 minutes' def test_waiting_time_in_secs(self): row = Mock() row.waiting_time_days = 0 row.waiting_time_hours = 0 row.waiting_time_min = 0 assert self.table.render_waiting_time_min(row) == 'moments ago' def test_flags(self): row = Mock() row.flags = [('admin-review', 'Admin Review')] doc = pq(self.table.render_flags(row)) assert doc('div.ed-sprite-admin-review').length class TestUnlistedViewAllListTable(TestCase): def setUp(self): super(TestUnlistedViewAllListTable, self).setUp() self.table = ViewUnlistedAllListTable([]) def test_addon_name(self): row = Mock() page = Mock() page.start_index = Mock() page.start_index.return_value = 1 row.addon_name = 'フォクすけといっしょ' row.addon_slug = 'test' self.table.set_page(page) a = pq(self.table.render_addon_name(row)) assert a.attr('href') == reverse( 'reviewers.review', args=['unlisted', str(row.addon_slug)] ) assert a.text() == 'フォクすけといっしょ' def test_authors_few(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve')] doc = pq(self.table.render_authors(row)) assert doc('span').text() == 'bob steve' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url(123) assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url(456) assert doc('span').attr('title') == 'bob steve' def test_authors_four(self): row = Mock() row.authors = [(123, 'bob'), (456, 'steve'), (789, 'cvan'), (999, 'basta')] doc = pq(self.table.render_authors(row)) assert doc.text() == 'bob steve cvan ...' assert doc('span a:eq(0)').attr('href') == UserProfile.create_user_url(123) assert doc('span a:eq(1)').attr('href') == UserProfile.create_user_url(456) assert doc('span a:eq(2)').attr('href') == UserProfile.create_user_url(789) assert doc('span').attr('title') == 'bob steve cvan basta', doc.html() yesterday = datetime.today() - timedelta(days=1) class TestReviewHelperBase(TestCase): __test__ = False fixtures = ['base/addon_3615', 'base/users'] preamble = 'Mozilla Add-ons: Delicious Bookmarks 2.1.072' def setUp(self): super().setUp() class FakeRequest: user = UserProfile.objects.get(pk=10482) self.request = FakeRequest() self.addon = Addon.objects.get(pk=3615) self.version = self.addon.versions.all()[0] self.helper = self.get_helper() self.file = self.version.files.all()[0] self.create_paths() def _check_score(self, reviewed_type, bonus=0): scores = ReviewerScore.objects.all() assert len(scores) > 0 assert scores[0].score == amo.REVIEWED_SCORES[reviewed_type] + bonus assert scores[0].note_key == reviewed_type def remove_paths(self): for path in (self.file.file_path, self.file.guarded_file_path): if not storage.exists(path): storage.delete(path) def create_paths(self): for path in (self.file.file_path, self.file.guarded_file_path): if not storage.exists(path): with storage.open(path, 'w') as f: f.write('test data\n') self.addCleanup(self.remove_paths) def setup_data( self, status, file_status=amo.STATUS_AWAITING_REVIEW, channel=amo.RELEASE_CHANNEL_LISTED, content_review=False, type=amo.ADDON_EXTENSION, ): mail.outbox = [] ActivityLog.objects.for_addons(self.helper.addon).delete() self.addon.update(status=status, type=type) self.file.update(status=file_status) if channel == amo.RELEASE_CHANNEL_UNLISTED: self.make_addon_unlisted(self.addon) self.version.reload() self.file.reload() self.helper = self.get_helper(content_review=content_review) data = self.get_data().copy() self.helper.set_data(data) def get_data(self): return { 'comments': 'foo', 'action': 'public', 'operating_systems': 'osx', 'applications': 'Firefox', } def get_helper(self, content_review=False): return ReviewHelper( request=self.request, addon=self.addon, version=self.version, content_review=content_review, ) def setup_type(self, status): self.addon.update(status=status) return self.get_helper().handler.review_type def check_log_count(self, id): return ( ActivityLog.objects.for_addons(self.helper.addon).filter(action=id).count() ) # Those tests can call signing when making things public. We want to test that # it works correctly, so we set ENABLE_ADDON_SIGNING to True and mock the # actual signing call. @override_settings(ENABLE_ADDON_SIGNING=True) @mock.patch('olympia.lib.crypto.signing.call_signing', lambda f: None) class TestReviewHelper(TestReviewHelperBase): __test__ = True def test_no_request(self): self.request = None helper = self.get_helper() assert helper.content_review is False assert helper.actions == {} helper = self.get_helper(content_review=True) assert helper.content_review is True assert helper.actions == {} def test_type_nominated(self): assert self.setup_type(amo.STATUS_NOMINATED) == 'extension_nominated' def test_type_pending(self): assert self.setup_type(amo.STATUS_NULL) == 'extension_pending' assert self.setup_type(amo.STATUS_APPROVED) == 'extension_pending' assert self.setup_type(amo.STATUS_DISABLED) == 'extension_pending' def test_no_version(self): helper = ReviewHelper(request=self.request, addon=self.addon, version=None) assert helper.handler.review_type == 'extension_pending' def test_review_files(self): version_factory( addon=self.addon, created=self.version.created - timedelta(days=1), file_kw={'status': amo.STATUS_APPROVED}, ) for status in REVIEW_FILES_STATUSES: self.setup_data(status=status) assert self.helper.handler.__class__ == ReviewFiles def test_review_addon(self): self.setup_data(status=amo.STATUS_NOMINATED) assert self.helper.handler.__class__ == ReviewAddon def test_process_action_none(self): self.helper.set_data({'action': 'foo'}) with self.assertRaises(Exception): self.helper.process() def test_process_action_good(self): self.grant_permission(self.request.user, 'Addons:Review') self.helper = self.get_helper() self.helper.set_data({'action': 'reply', 'comments': 'foo'}) self.helper.process() assert len(mail.outbox) == 1 def test_action_details(self): for status in Addon.STATUS_CHOICES: self.addon.update(status=status) helper = self.get_helper() actions = helper.actions for k, v in actions.items(): assert str(v['details']), 'Missing details for: %s' % k def get_review_actions(self, addon_status, file_status, content_review=False): self.file.update(status=file_status) self.addon.update(status=addon_status) # Need to clear self.version.all_files cache since we updated the file. if self.version: del self.version.all_files return self.get_helper(content_review=content_review).actions def test_actions_full_nominated(self): self.grant_permission(self.request.user, 'Addons:Review') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_NOMINATED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_full_update(self): self.grant_permission(self.request.user, 'Addons:Review') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_full_nonpending(self): self.grant_permission(self.request.user, 'Addons:Review') expected = ['reject_multiple_versions', 'reply', 'super', 'comment'] f_statuses = [amo.STATUS_APPROVED, amo.STATUS_DISABLED] for file_status in f_statuses: assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=file_status ).keys() ) == expected ) def test_actions_public_post_review(self): self.grant_permission(self.request.user, 'Addons:Review') expected = ['reject_multiple_versions', 'reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) # Now make current version auto-approved... AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) expected = [ 'confirm_auto_approved', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) # Now make add a recommended promoted addon. The user should lose all # approve/reject actions. self.make_addon_promoted(self.addon, RECOMMENDED) expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) def test_actions_content_review(self): self.grant_permission(self.request.user, 'Addons:ContentReview') expected = [ 'approve_content', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True, ).keys() ) == expected ) def test_actions_content_review_non_approved_addon(self): # Content reviewers can also see add-ons before they are approved for # the first time. self.grant_permission(self.request.user, 'Addons:ContentReview') expected = [ 'approve_content', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_NOMINATED, file_status=amo.STATUS_AWAITING_REVIEW, content_review=True, ).keys() ) == expected ) def test_actions_public_static_theme(self): # Having Addons:Review and dealing with a public add-on would # normally be enough to give you access to reject multiple versions # action, but it should not be available if you're not theme reviewer. self.grant_permission(self.request.user, 'Addons:Review') self.addon.update(type=amo.ADDON_STATICTHEME) expected = [] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # Themes reviewers get access to everything, including reject multiple. self.request.user.groupuser_set.all().delete() self.grant_permission(self.request.user, 'Addons:ThemeReview') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_no_version(self): """Deleted addons and addons with no versions in that channel have no version set.""" expected = [] self.version = None assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) def test_actions_recommended(self): # Having Addons:Review is not enough to review # recommended extensions. self.make_addon_promoted(self.addon, RECOMMENDED) self.grant_permission(self.request.user, 'Addons:Review') expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_NOMINATED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # Having Addons:RecommendedReview allows you to do it. self.grant_permission(self.request.user, 'Addons:RecommendedReview') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_recommended_content_review(self): # Having Addons:ContentReview is not enough to content review # recommended extensions. self.make_addon_promoted(self.addon, RECOMMENDED) self.grant_permission(self.request.user, 'Addons:ContentReview') expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True, ).keys() ) == expected ) # Having Addons:RecommendedReview allows you to do it (though you'd # be better off just do a full review). self.grant_permission(self.request.user, 'Addons:RecommendedReview') expected = [ 'approve_content', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True, ).keys() ) == expected ) def test_actions_promoted_admin_review_needs_admin_permission(self): # Having Addons:Review or Addons:RecommendedReview # is not enough to review promoted addons that are in a group that is # admin_review=True. self.make_addon_promoted(self.addon, LINE) self.grant_permission(self.request.user, 'Addons:Review') expected = ['super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # only for groups that are admin_review though self.make_addon_promoted(self.addon, SPONSORED, approve_version=True) expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # change it back to an admin_review group self.make_addon_promoted(self.addon, SPOTLIGHT) self.grant_permission(self.request.user, 'Addons:RecommendedReview') expected = ['super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # you need admin review permission self.grant_permission(self.request.user, 'Reviews:Admin') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_unlisted(self): # Just regular review permissions don't let you do much on an unlisted # review page. self.version.update(channel=amo.RELEASE_CHANNEL_UNLISTED) self.grant_permission(self.request.user, 'Addons:Review') expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_NULL, file_status=amo.STATUS_AWAITING_REVIEW ).keys() ) == expected ) # Once you have ReviewUnlisted more actions are available. self.grant_permission(self.request.user, 'Addons:ReviewUnlisted') expected = [ 'public', 'reject_multiple_versions', 'block_multiple_versions', 'confirm_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_NULL, file_status=amo.STATUS_AWAITING_REVIEW ).keys() ) == expected ) # unlisted shouldn't be affected by promoted group status either self.make_addon_promoted(self.addon, LINE) assert ( list( self.get_review_actions( addon_status=amo.STATUS_NULL, file_status=amo.STATUS_AWAITING_REVIEW ).keys() ) == expected ) def test_actions_version_blocked(self): self.grant_permission(self.request.user, 'Addons:Review') # default case expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # But when the add-on is blocked 'public' shouldn't be available block = Block.objects.create(addon=self.addon, updated_by=self.request.user) del self.addon.block expected = ['reject', 'reject_multiple_versions', 'reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) # it's okay if the version is outside the blocked range though block.update(min_version=self.version.version + '.1') expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] del self.addon.block def test_actions_pending_rejection(self): # An addon having its latest version pending rejection won't be # reviewable by regular reviewers... self.grant_permission(self.request.user, 'Addons:Review') AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) VersionReviewerFlags.objects.create( version=self.version, pending_rejection=datetime.now() ) expected = ['reply', 'super', 'comment'] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) # ... unless there is a more recent version posted. expected = [ 'public', 'reject', 'reject_multiple_versions', 'reply', 'super', 'comment', ] self.version = version_factory(addon=self.addon) self.file = self.version.all_files[0] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_actions_pending_rejection_admin(self): # Admins can still do everything when there is a version pending # rejection. self.grant_permission(self.request.user, 'Addons:Review') self.grant_permission(self.request.user, 'Reviews:Admin') AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) VersionReviewerFlags.objects.create( version=self.version, pending_rejection=datetime.now() ) expected = [ 'confirm_auto_approved', 'reject_multiple_versions', 'reply', 'super', 'comment', ] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED ).keys() ) == expected ) # a more recent version posted does not change anything for admins. # confirm_auto_approved is still available since that version is still # the current_version, hasn't been rejected yet. # they have public/reject actions too, since the new version is # awaiting review. expected = [ 'public', 'reject', 'confirm_auto_approved', 'reject_multiple_versions', 'reply', 'super', 'comment', ] self.version = version_factory(addon=self.addon) self.file = self.version.all_files[0] assert ( list( self.get_review_actions( addon_status=amo.STATUS_APPROVED, file_status=amo.STATUS_AWAITING_REVIEW, ).keys() ) == expected ) def test_set_files(self): self.file.update(datestatuschanged=yesterday) self.helper.handler.set_files(amo.STATUS_APPROVED, self.version.files.all()) self.file = self.version.files.all()[0] assert self.file.status == amo.STATUS_APPROVED assert self.file.datestatuschanged.date() > yesterday.date() def test_logs(self): self.helper.set_data({'comments': 'something'}) self.helper.handler.log_action(amo.LOG.APPROVE_VERSION) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 def test_notify_email(self): self.helper.set_data(self.get_data()) base_fragment = 'To respond, please reply to this email or visit' user = self.addon.listed_authors[0] ActivityLogToken.objects.create(version=self.version, user=user) uuid = self.version.token.get(user=user).uuid.hex reply_email = 'reviewreply+%s@%s' % (uuid, settings.INBOUND_EMAIL_DOMAIN) templates = ( 'extension_nominated_to_approved', 'extension_nominated_to_rejected', 'extension_pending_to_rejected', 'theme_nominated_to_approved', 'theme_nominated_to_rejected', 'theme_pending_to_rejected', ) for template in templates: mail.outbox = [] self.helper.handler.notify_email(template, 'Sample subject %s, %s') assert len(mail.outbox) == 1 message = mail.outbox[0] assert base_fragment in message.body assert message.reply_to == [reply_email] mail.outbox = [] # This one does not inherit from base.txt because it's for unlisted # signing notification, which is not really something that necessitates # reviewer interaction, so it's simpler. template = 'unlisted_to_reviewed_auto' self.helper.handler.notify_email(template, 'Sample subject %s, %s') assert len(mail.outbox) == 1 message = mail.outbox[0] assert base_fragment not in message.body assert message.reply_to == [reply_email] def test_email_links(self): expected = { 'extension_nominated_to_approved': 'addon_url', 'extension_nominated_to_rejected': 'dev_versions_url', 'extension_pending_to_approved': 'addon_url', 'extension_pending_to_rejected': 'dev_versions_url', 'theme_nominated_to_approved': 'addon_url', 'theme_nominated_to_rejected': 'dev_versions_url', 'theme_pending_to_approved': 'addon_url', 'theme_pending_to_rejected': 'dev_versions_url', 'unlisted_to_reviewed_auto': 'dev_versions_url', 'reject_multiple_versions': 'dev_versions_url', 'reject_multiple_versions_with_delay': 'dev_versions_url', } self.helper.set_data(self.get_data()) context_data = self.helper.handler.get_context_data() for template, context_key in expected.items(): mail.outbox = [] self.helper.handler.notify_email(template, 'Sample subject %s, %s') assert len(mail.outbox) == 1 message = mail.outbox[0] assert context_key in context_data assert context_data.get(context_key) in message.body def test_send_reviewer_reply(self): self.setup_data(amo.STATUS_APPROVED) self.helper.handler.reviewer_reply() assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == self.preamble assert self.check_log_count(amo.LOG.REVIEWER_REPLY_VERSION.id) == 1 def test_email_no_locale(self): self.addon.name = {'es': '¿Dónde está la biblioteca?'} self.setup_data(amo.STATUS_NOMINATED) with translation.override('es'): assert translation.get_language() == 'es' self.helper.handler.approve_latest_version() assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ( 'Mozilla Add-ons: Delicious Bookmarks 2.1.072 Approved' ) assert '/en-US/firefox/addon/a3615' not in message.body assert '/es/firefox/addon/a3615' not in message.body assert '/addon/a3615' in message.body assert 'Your add-on, Delicious Bookmarks ' in message.body def test_email_no_name(self): self.addon.name.delete() self.addon.refresh_from_db() self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('Mozilla Add-ons: None 2.1.072 Approved') assert '/addon/a3615' in message.body assert 'Your add-on, None ' in message.body def test_nomination_to_public_no_files(self): self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) def test_nomination_to_public_and_current_version(self): self.setup_data(amo.STATUS_NOMINATED) self.addon = Addon.objects.get(pk=3615) self.addon.update(_current_version=None) assert not self.addon.current_version self.helper.handler.approve_latest_version() self.addon = Addon.objects.get(pk=3615) assert self.addon.current_version def test_nomination_to_public_new_addon(self): """Make sure new add-ons can be made public (bug 637959)""" status = amo.STATUS_NOMINATED self.setup_data(status) # Make sure we have no public files for version in self.addon.versions.all(): version.files.update(status=amo.STATUS_AWAITING_REVIEW) self.helper.handler.approve_latest_version() # Re-fetch the add-on addon = Addon.objects.get(pk=3615) assert addon.status == amo.STATUS_APPROVED assert addon.versions.all()[0].files.all()[0].status == (amo.STATUS_APPROVED) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == '%s Approved' % self.preamble # AddonApprovalsCounter counter is now at 1 for this addon since there # was a human review. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 1 self.assertCloseToNow(approval_counter.last_human_review) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 self._check_score(amo.REVIEWED_ADDON_FULL) def test_nomination_to_public_need_human_review(self): self.setup_data(amo.STATUS_NOMINATED) self.version.update(needs_human_review=True) self.helper.handler.approve_latest_version() self.addon.reload() self.version.reload() self.file.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert not self.version.needs_human_review def test_nomination_to_public_need_human_review_not_human(self): self.request = None # Not a human review self.setup_data(amo.STATUS_NOMINATED) self.version.update(needs_human_review=True) self.helper.handler.approve_latest_version() self.addon.reload() self.version.reload() self.file.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.version.needs_human_review def test_unlisted_approve_latest_version_need_human_review(self): self.setup_data(amo.STATUS_NULL, channel=amo.RELEASE_CHANNEL_UNLISTED) self.version.update(needs_human_review=True) flags = VersionReviewerFlags.objects.create( version=self.version, needs_human_review_by_mad=True, ) AddonReviewerFlags.objects.create( addon=self.addon, auto_approval_disabled_until_next_approval_unlisted=True ) self.helper.handler.approve_latest_version() self.addon.reload() self.version.reload() self.file.reload() flags.reload() addon_flags = self.addon.reviewerflags.reload() assert self.addon.status == amo.STATUS_NULL assert self.file.status == amo.STATUS_APPROVED assert not self.version.needs_human_review assert not flags.needs_human_review_by_mad assert not addon_flags.auto_approval_disabled_until_next_approval_unlisted def test_unlisted_approve_latest_version_need_human_review_not_human(self): self.request = None # Not a human review self.setup_data(amo.STATUS_NULL, channel=amo.RELEASE_CHANNEL_UNLISTED) self.version.update(needs_human_review=True) flags = VersionReviewerFlags.objects.create( version=self.version, needs_human_review_by_mad=True ) AddonReviewerFlags.objects.create( addon=self.addon, auto_approval_disabled_until_next_approval_unlisted=True ) self.helper.handler.approve_latest_version() self.addon.reload() self.version.reload() self.file.reload() flags.reload() addon_flags = self.addon.reviewerflags.reload() assert self.addon.status == amo.STATUS_NULL assert self.file.status == amo.STATUS_APPROVED assert self.version.needs_human_review assert flags.needs_human_review_by_mad # Not changed this this is not a human approval. assert addon_flags.auto_approval_disabled_until_next_approval_unlisted def test_nomination_to_public_with_version_reviewer_flags(self): flags = VersionReviewerFlags.objects.create( version=self.addon.current_version, needs_human_review_by_mad=True, pending_rejection=datetime.now() + timedelta(days=2), ) assert flags.needs_human_review_by_mad self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() flags.refresh_from_db() assert not flags.needs_human_review_by_mad assert not flags.pending_rejection @patch('olympia.reviewers.utils.sign_file') def test_nomination_to_public(self, sign_mock): sign_mock.reset() self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('%s Approved' % self.preamble) assert 'has been approved' in message.body # AddonApprovalsCounter counter is now at 1 for this addon. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 1 sign_mock.assert_called_with(self.file) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 self._check_score(amo.REVIEWED_ADDON_FULL) @patch('olympia.reviewers.utils.sign_file') def test_old_nomination_to_public_bonus_score(self, sign_mock): sign_mock.reset() self.setup_data(amo.STATUS_NOMINATED) self.version.update(nomination=self.days_ago(9)) self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('%s Approved' % self.preamble) assert 'has been approved' in message.body # AddonApprovalsCounter counter is now at 1 for this addon. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 1 sign_mock.assert_called_with(self.file) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 # Score has bonus points added for reviewing an old add-on. # 2 days over the limit = 4 points self._check_score(amo.REVIEWED_ADDON_FULL, bonus=4) @patch('olympia.reviewers.utils.sign_file') def test_nomination_to_public_no_request(self, sign_mock): self.request = None sign_mock.reset() self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('%s Approved' % self.preamble) assert 'has been approved' in message.body # AddonApprovalsCounter counter is now at 0 for this addon since there # was an automatic approval. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 0 # Since approval counter did not exist for this add-on before, the last # human review field should be empty. assert approval_counter.last_human_review is None sign_mock.assert_called_with(self.file) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 # No request, no user, therefore no score. assert ReviewerScore.objects.count() == 0 @patch('olympia.reviewers.utils.sign_file') def test_public_addon_with_version_awaiting_review_to_public(self, sign_mock): sign_mock.reset() self.addon.current_version.update(created=self.days_ago(1)) self.version = version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, version='3.0.42', file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.preamble = 'Mozilla Add-ons: Delicious Bookmarks 3.0.42' self.file = self.version.files.all()[0] self.setup_data(amo.STATUS_APPROVED) self.create_paths() AddonApprovalsCounter.objects.create( addon=self.addon, counter=1, last_human_review=self.days_ago(42) ) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_AWAITING_REVIEW assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.helper.handler.approve_latest_version() self.addon.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.reload().status == amo.STATUS_APPROVED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('%s Updated' % self.preamble) assert 'has been updated' in message.body # AddonApprovalsCounter counter is now at 2 for this addon since there # was another human review. The last human review date should have been # updated. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 2 self.assertCloseToNow(approval_counter.last_human_review) sign_mock.assert_called_with(self.file) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 self._check_score(amo.REVIEWED_ADDON_UPDATE) self.addon.reviewerflags.reload() assert not self.addon.reviewerflags.auto_approval_disabled_until_next_approval @patch('olympia.reviewers.utils.sign_file') def test_public_addon_with_version_need_human_review_to_public( self, sign_file_mock ): self.old_version = self.addon.current_version self.old_version.update(created=self.days_ago(1), needs_human_review=True) self.version = version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, version='3.0.42', file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.file = self.version.files.all()[0] self.setup_data(amo.STATUS_APPROVED) self.helper.handler.approve_latest_version() self.addon.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.reload().status == amo.STATUS_APPROVED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.old_version.reload() assert not self.old_version.needs_human_review @patch('olympia.reviewers.utils.sign_file') def test_public_addon_with_auto_approval_temporarily_disabled_to_public( self, sign_file_mock ): AddonReviewerFlags.objects.create( addon=self.addon, auto_approval_disabled_until_next_approval=True ) self.version = version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, version='3.0.42', file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.file = self.version.files.all()[0] self.setup_data(amo.STATUS_APPROVED) self.helper.handler.approve_latest_version() self.addon.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.reload().status == amo.STATUS_APPROVED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.addon.reviewerflags.reload() assert not self.addon.reviewerflags.auto_approval_disabled_until_next_approval @patch('olympia.reviewers.utils.sign_file') def test_public_addon_with_version_awaiting_review_to_sandbox(self, sign_mock): sign_mock.reset() self.addon.current_version.update(created=self.days_ago(1)) self.version = version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, version='3.0.42', file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.preamble = 'Mozilla Add-ons: Delicious Bookmarks 3.0.42' self.file = self.version.files.all()[0] self.setup_data(amo.STATUS_APPROVED) self.create_paths() AddonApprovalsCounter.objects.create(addon=self.addon, counter=1) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_AWAITING_REVIEW assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.helper.handler.reject_latest_version() self.addon.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.reload().status == amo.STATUS_DISABLED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ("%s didn't pass review" % self.preamble) assert 'reviewed and did not meet the criteria' in message.body # AddonApprovalsCounter counter is still at 1 for this addon. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 1 assert not sign_mock.called assert storage.exists(self.file.guarded_file_path) assert not storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 1 self._check_score(amo.REVIEWED_ADDON_UPDATE) def test_public_addon_with_version_need_human_review_to_sandbox(self): self.old_version = self.addon.current_version self.old_version.update(created=self.days_ago(1), needs_human_review=True) self.version = version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, version='3.0.42', needs_human_review=True, file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.file = self.version.files.all()[0] self.setup_data(amo.STATUS_APPROVED) self.helper.handler.reject_latest_version() self.addon.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.file.reload().status == amo.STATUS_DISABLED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) # Both version awaiting review and current public version had been # flagged as needing human review. Only the newer version has been # reviewed and rejected, so we leave the flag on past versions (unlike # approvals, we can't be sure the current version is safe now). self.addon.current_version.reload() assert self.addon.current_version.needs_human_review self.version.reload() assert not self.version.needs_human_review def test_public_addon_confirm_auto_approval(self): self.grant_permission(self.request.user, 'Addons:Review') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) summary = AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=151 ) assert summary.confirmed is None self.create_paths() # Safeguards. assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.helper.handler.confirm_auto_approved() summary.reload() assert summary.confirmed is True approvals_counter = AddonApprovalsCounter.objects.get(addon=self.addon) self.assertCloseToNow(approvals_counter.last_human_review) assert self.check_log_count(amo.LOG.APPROVE_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 1 activity = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.CONFIRM_AUTO_APPROVED.id) .get() ) assert activity.arguments == [self.addon, self.version] assert activity.details['comments'] == '' # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_public_with_unreviewed_version_addon_confirm_auto_approval(self): self.grant_permission(self.request.user, 'Addons:Review') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) self.current_version = self.version summary = AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=152 ) self.version = version_factory( addon=self.addon, version='3.0', file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.file = self.version.files.all()[0] self.helper = self.get_helper() # To make it pick up the new version. self.helper.set_data(self.get_data()) # Confirm approval action should be available even if the latest # version is not public, what we care about is the current_version. assert 'confirm_auto_approved' in self.helper.actions self.helper.handler.confirm_auto_approved() summary.reload() assert summary.confirmed is True approvals_counter = AddonApprovalsCounter.objects.get(addon=self.addon) self.assertCloseToNow(approvals_counter.last_human_review) assert self.check_log_count(amo.LOG.APPROVE_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 1 activity = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.CONFIRM_AUTO_APPROVED.id) .get() ) assert activity.arguments == [self.addon, self.current_version] assert activity.details['comments'] == '' # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_public_with_disabled_version_addon_confirm_auto_approval(self): self.grant_permission(self.request.user, 'Addons:Review') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) self.current_version = self.version summary = AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=153 ) self.version = version_factory( addon=self.addon, version='3.0', file_kw={'status': amo.STATUS_DISABLED} ) self.file = self.version.files.all()[0] self.helper = self.get_helper() # To make it pick up the new version. self.helper.set_data(self.get_data()) # Confirm approval action should be available even if the latest # version is not public, what we care about is the current_version. assert 'confirm_auto_approved' in self.helper.actions self.helper.handler.confirm_auto_approved() summary.reload() assert summary.confirmed is True approvals_counter = AddonApprovalsCounter.objects.get(addon=self.addon) self.assertCloseToNow(approvals_counter.last_human_review) assert self.check_log_count(amo.LOG.APPROVE_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 1 activity = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.CONFIRM_AUTO_APPROVED.id) .get() ) assert activity.arguments == [self.addon, self.current_version] assert activity.details['comments'] == '' # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_addon_with_versions_pending_rejection_confirm_auto_approval(self): self.grant_permission(self.request.user, 'Addons:Review') self.grant_permission(self.request.user, 'Reviews:Admin') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) self.version = version_factory( addon=self.addon, version='3.0', file_kw={'status': amo.STATUS_APPROVED} ) self.file = self.version.files.all()[0] summary = AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=153 ) for version in self.addon.versions.all(): VersionReviewerFlags.objects.create( version=version, pending_rejection=datetime.now() + timedelta(days=7) ) self.helper = self.get_helper() # To make it pick up the new version. self.helper.set_data(self.get_data()) # We're an admin, so we can confirm auto approval even if the current # version is pending rejection. assert 'confirm_auto_approved' in self.helper.actions self.helper.handler.confirm_auto_approved() summary.reload() assert summary.confirmed is True approvals_counter = AddonApprovalsCounter.objects.get(addon=self.addon) self.assertCloseToNow(approvals_counter.last_human_review) assert self.check_log_count(amo.LOG.APPROVE_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 1 activity = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.CONFIRM_AUTO_APPROVED.id) .get() ) assert activity.arguments == [self.addon, self.version] assert activity.details['comments'] == '' # None of the versions should be pending rejection anymore. assert not VersionReviewerFlags.objects.filter( version__addon=self.addon, pending_rejection__isnull=False ).exists() # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_addon_with_version_need_human_review_confirm_auto_approval(self): self.addon.current_version.update(needs_human_review=True) self.test_public_addon_confirm_auto_approval() self.addon.current_version.reload() assert self.addon.current_version.needs_human_review is False def test_addon_with_version_and_scanner_flag_confirm_auto_approvals(self): flags = VersionReviewerFlags.objects.create( version=self.addon.current_version, needs_human_review_by_mad=True, ) assert flags.needs_human_review_by_mad self.test_public_addon_confirm_auto_approval() flags.refresh_from_db() assert not flags.needs_human_review_by_mad def test_confirm_multiple_versions_with_version_scanner_flags(self): self.grant_permission(self.request.user, 'Addons:ReviewUnlisted') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) self.version.update(channel=amo.RELEASE_CHANNEL_UNLISTED) flags = VersionReviewerFlags.objects.create( version=self.version, needs_human_review_by_mad=True, ) assert flags.needs_human_review_by_mad helper = self.get_helper() # pick the updated version data = self.get_data().copy() data['versions'] = self.addon.versions.all() helper.set_data(data) helper.handler.confirm_multiple_versions() flags.refresh_from_db() assert not flags.needs_human_review_by_mad def test_unlisted_version_addon_confirm_multiple_versions(self): self.grant_permission(self.request.user, 'Addons:ReviewUnlisted') self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) # This add-on will have 4 versions: # - one listed (the initial one from setup) # - one unlisted we'll confirm approval of (has an AutoApprovalSummary) # - one unlisted we'll confirm approval of (no AutoApprovalSummary) and # flagged by scanners # - one unlisted flagged by scanners we'll leave alone first_unlisted = version_factory( addon=self.addon, version='3.0', channel=amo.RELEASE_CHANNEL_UNLISTED, file_kw={'is_webextension': True}, created=self.days_ago(7), ) summary = AutoApprovalSummary.objects.create( version=first_unlisted, verdict=amo.AUTO_APPROVED ) second_unlisted = version_factory( addon=self.addon, version='4.0', channel=amo.RELEASE_CHANNEL_UNLISTED, file_kw={'is_webextension': True}, needs_human_review=True, created=self.days_ago(6), ) self.version = version_factory( addon=self.addon, version='5.0', channel=amo.RELEASE_CHANNEL_UNLISTED, needs_human_review=True, file_kw={'is_webextension': True}, created=self.days_ago(5), ) self.file = self.version.files.all()[0] self.helper = self.get_helper() # To make it pick up the new version. data = self.get_data().copy() data['versions'] = self.addon.versions.filter( pk__in=(first_unlisted.pk, second_unlisted.pk) ) self.helper.set_data(data) # Confirm multiple versions action should be available since we're # looking at an unlisted version and the reviewer has permission. assert 'confirm_multiple_versions' in self.helper.actions self.helper.handler.confirm_multiple_versions() summary.reload() assert summary.confirmed is True self.version.reload() assert self.version.needs_human_review # Untouched. second_unlisted.reload() assert not second_unlisted.needs_human_review # Cleared. assert ( AddonApprovalsCounter.objects.filter(addon=self.addon).count() == 0 ) # Not incremented since it was unlisted. assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 2 activities = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.CONFIRM_AUTO_APPROVED.id) .order_by('-pk') ) activity = activities[0] assert activity.arguments == [self.addon, first_unlisted] activity = activities[1] assert activity.arguments == [self.addon, second_unlisted] @patch('olympia.reviewers.utils.sign_file') def test_null_to_public_unlisted(self, sign_mock): sign_mock.reset() self.setup_data(amo.STATUS_NULL, channel=amo.RELEASE_CHANNEL_UNLISTED) self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_NULL assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) # AddonApprovalsCounter was not touched since the version we made # public is unlisted. assert not AddonApprovalsCounter.objects.filter(addon=self.addon).exists() assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ('%s signed and ready to download' % self.preamble) assert ( '%s is now signed and ready for you to download' % self.version.version in message.body ) assert 'You received this email because' not in message.body sign_mock.assert_called_with(self.file) assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 @patch('olympia.reviewers.utils.sign_file') def test_nomination_to_public_failed_signing(self, sign_mock): sign_mock.side_effect = Exception sign_mock.reset() self.setup_data(amo.STATUS_NOMINATED) with self.assertRaises(Exception): self.helper.handler.approve_latest_version() # AddonApprovalsCounter was not touched since we failed signing. assert not AddonApprovalsCounter.objects.filter(addon=self.addon).exists() # Status unchanged. assert self.addon.status == amo.STATUS_NOMINATED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_AWAITING_REVIEW ) assert len(mail.outbox) == 0 assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 0 @patch('olympia.reviewers.utils.sign_file') def test_nomination_to_sandbox(self, sign_mock): self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.reject_latest_version() assert self.addon.status == amo.STATUS_NULL assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_DISABLED ) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.subject == ("%s didn't pass review" % self.preamble) assert 'did not meet the criteria' in message.body # AddonApprovalsCounter was not touched since we didn't approve. assert not AddonApprovalsCounter.objects.filter(addon=self.addon).exists() assert not sign_mock.called assert storage.exists(self.file.guarded_file_path) assert not storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 1 def test_email_unicode_monster(self): self.addon.name = 'TaobaoShopping淘宝网导航按钮' self.addon.save() self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.reject_latest_version() message = mail.outbox[0] assert 'TaobaoShopping淘宝网导航按钮' in message.subject def test_nomination_to_super_review(self): self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.process_super_review() assert self.addon.needs_admin_code_review assert self.check_log_count(amo.LOG.REQUEST_ADMIN_REVIEW_CODE.id) == 1 # Make sure we used an activity log that has the special `sanitize` # property so that comments aren't shown to the developer (a generic # message is shown instead) assert getattr(amo.LOG.REQUEST_ADMIN_REVIEW_CODE, 'sanitize', '') def test_auto_approved_admin_code_review(self): self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) self.helper.handler.process_super_review() assert self.addon.needs_admin_code_review assert self.check_log_count(amo.LOG.REQUEST_ADMIN_REVIEW_CODE.id) == 1 def test_auto_approved_admin_content_review(self): self.setup_data( amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True ) AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) self.helper.handler.process_super_review() assert self.addon.needs_admin_content_review assert self.check_log_count(amo.LOG.REQUEST_ADMIN_REVIEW_CONTENT.id) == 1 assert getattr(amo.LOG.REQUEST_ADMIN_REVIEW_CONTENT, 'sanitize', '') def test_auto_approved_admin_theme_review(self): self.setup_data( amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, type=amo.ADDON_STATICTHEME, ) AutoApprovalSummary.objects.create( version=self.addon.current_version, verdict=amo.AUTO_APPROVED ) self.helper.handler.process_super_review() assert self.addon.needs_admin_theme_review assert self.check_log_count(amo.LOG.REQUEST_ADMIN_REVIEW_THEME.id) == 1 assert getattr(amo.LOG.REQUEST_ADMIN_REVIEW_THEME, 'sanitize', '') def test_nomination_to_super_review_and_escalate(self): self.setup_data(amo.STATUS_NOMINATED) self.file.update(status=amo.STATUS_AWAITING_REVIEW) self.helper.handler.process_super_review() assert self.addon.needs_admin_code_review assert self.check_log_count(amo.LOG.REQUEST_ADMIN_REVIEW_CODE.id) == 1 def test_operating_system_present(self): self.setup_data(amo.STATUS_APPROVED) self.helper.handler.reject_latest_version() message = mail.outbox[0] assert 'Tested on osx with Firefox' in message.body def test_operating_system_not_present(self): self.setup_data(amo.STATUS_APPROVED) data = self.get_data().copy() data['operating_systems'] = '' self.helper.set_data(data) self.helper.handler.reject_latest_version() message = mail.outbox[0] assert 'Tested with Firefox' in message.body def test_application_not_present(self): self.setup_data(amo.STATUS_APPROVED) data = self.get_data().copy() data['applications'] = '' self.helper.set_data(data) self.helper.handler.reject_latest_version() message = mail.outbox[0] assert 'Tested on osx' in message.body def test_both_not_present(self): self.setup_data(amo.STATUS_APPROVED) data = self.get_data().copy() data['applications'] = '' data['operating_systems'] = '' self.helper.set_data(data) self.helper.handler.reject_latest_version() message = mail.outbox[0] assert 'Tested' not in message.body def test_pending_to_super_review(self): for status in (amo.STATUS_DISABLED, amo.STATUS_NULL): self.setup_data(status) self.helper.handler.process_super_review() assert self.addon.needs_admin_code_review def test_nominated_review_time_set_version_approve_latest_version(self): self.version.update(reviewed=None) self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert self.version.reload().reviewed def test_nominated_review_time_set_version_reject_latest_version(self): self.version.update(reviewed=None) self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.reject_latest_version() assert self.version.reload().reviewed def test_nominated_review_time_set_file_approve_latest_version(self): self.file.update(reviewed=None) self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert File.objects.get(pk=self.file.pk).reviewed def test_nominated_review_time_set_file_reject_latest_version(self): self.file.update(reviewed=None) self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.reject_latest_version() assert File.objects.get(pk=self.file.pk).reviewed def test_review_unlisted_while_a_listed_version_is_awaiting_review(self): self.make_addon_unlisted(self.addon) self.version.reload() version_factory( addon=self.addon, channel=amo.RELEASE_CHANNEL_LISTED, file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) self.addon.update(status=amo.STATUS_NOMINATED) assert self.get_helper() def test_reject_multiple_versions(self): old_version = self.version self.version = version_factory(addon=self.addon, version='3.0') AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=101 ) # An extra file should not change anything. file_factory(version=self.version) self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.is_public() data = self.get_data().copy() data['versions'] = self.addon.versions.all() self.helper.set_data(data) self.helper.handler.reject_multiple_versions() self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_NULL assert self.addon.current_version is None assert list(self.addon.versions.all()) == [self.version, old_version] assert self.file.status == amo.STATUS_DISABLED assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Delicious Bookmarks has been disabled on ' 'addons.mozilla.org' ) assert 'your add-on Delicious Bookmarks has been disabled' in message.body log_token = ActivityLogToken.objects.get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 2 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 0 logs = ActivityLog.objects.for_addons(self.addon).filter( action=amo.LOG.REJECT_VERSION.id ) assert logs[0].created == logs[1].created # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) # listed auto approvals should be disabled until the next manual approval. flags = self.addon.reviewerflags flags.reload() assert not flags.auto_approval_disabled_until_next_approval_unlisted assert flags.auto_approval_disabled_until_next_approval # The reviewer should have been automatically subscribed to new listed # versions. assert ReviewerSubscription.objects.filter( addon=self.addon, user=self.request.user, channel=self.version.channel ).exists() def test_reject_multiple_versions_with_delay(self): old_version = self.version self.version = version_factory(addon=self.addon, version='3.0') AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=101 ) # An extra file should not change anything. file_factory(version=self.version) self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) in_the_future = datetime.now() + timedelta(days=14) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.is_public() data = self.get_data().copy() data.update( { 'versions': self.addon.versions.all(), 'delayed_rejection': True, 'delayed_rejection_days': 14, } ) self.helper.set_data(data) self.helper.handler.reject_multiple_versions() # File/addon status didn't change. self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.current_version == self.version assert list(self.addon.versions.all()) == [self.version, old_version] assert self.file.status == amo.STATUS_APPROVED # The versions are now pending rejection. for version in self.addon.versions.all(): assert version.pending_rejection self.assertCloseToNow(version.pending_rejection, now=in_the_future) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Delicious Bookmarks will be disabled on ' 'addons.mozilla.org' ) assert 'your add-on Delicious Bookmarks will be disabled' in message.body log_token = ActivityLogToken.objects.get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 0 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.REJECT_CONTENT_DELAYED.id) == 0 assert self.check_log_count(amo.LOG.REJECT_VERSION_DELAYED.id) == 2 logs = ActivityLog.objects.for_addons(self.addon).filter( action=amo.LOG.REJECT_VERSION_DELAYED.id ) assert logs[0].created == logs[1].created # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) # The flag to prevent the authors from being notified several times # about pending rejections should have been reset, and auto approvals # should have been disabled until the next manual approval. flags = self.addon.reviewerflags flags.reload() assert not flags.notified_about_expiring_delayed_rejections assert flags.auto_approval_disabled_until_next_approval # The reviewer should have been automatically subscribed to new listed # versions. assert ReviewerSubscription.objects.filter( addon=self.addon, user=self.request.user, channel=self.version.channel ).exists() def test_reject_multiple_versions_except_latest(self): old_version = self.version extra_version = version_factory(addon=self.addon, version='3.1') # Add yet another version we don't want to reject. self.version = version_factory(addon=self.addon, version='42.0') AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=91 ) self.setup_data(amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.is_public() data = self.get_data().copy() data['versions'] = self.addon.versions.all().exclude(pk=self.version.pk) self.helper.set_data(data) self.helper.handler.reject_multiple_versions() self.addon.reload() self.file.reload() # latest_version is still public so the add-on is still public. assert self.addon.status == amo.STATUS_APPROVED assert self.addon.current_version == self.version assert list(self.addon.versions.all().order_by('-pk')) == [ self.version, extra_version, old_version, ] assert self.file.status == amo.STATUS_DISABLED assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Versions disabled for Delicious Bookmarks' ) assert 'Version(s) affected and disabled:\n3.1, 2.1.072' in message.body log_token = ActivityLogToken.objects.filter(version=self.version).get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 2 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 0 # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_reject_multiple_versions_need_human_review(self): old_version = self.version old_version.update(needs_human_review=True) self.version = version_factory( addon=self.addon, version='3.0', needs_human_review=True ) data = self.get_data().copy() data['versions'] = self.addon.versions.all() self.helper.set_data(data) self.helper.handler.reject_multiple_versions() self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_NULL assert self.addon.current_version is None assert list(self.addon.versions.all()) == [self.version, old_version] # We rejected all versions so there aren't any left that need human # review. assert not self.addon.versions.filter(needs_human_review=True).exists() assert self.file.status == amo.STATUS_DISABLED def test_reject_multiple_versions_content_review(self): self.grant_permission(self.request.user, 'Addons:ContentReview') old_version = self.version self.version = version_factory(addon=self.addon, version='3.0') self.setup_data( amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True ) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.is_public() data = self.get_data().copy() data['versions'] = self.addon.versions.all() self.helper.set_data(data) self.helper.handler.reject_multiple_versions() self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_NULL assert self.addon.current_version is None assert list(self.addon.versions.all()) == [self.version, old_version] assert self.file.status == amo.STATUS_DISABLED assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Delicious Bookmarks has been disabled on ' 'addons.mozilla.org' ) assert 'your add-on Delicious Bookmarks has been disabled' in message.body log_token = ActivityLogToken.objects.get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 0 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 2 # Check points awarded. self._check_score(amo.REVIEWED_CONTENT_REVIEW) def test_reject_multiple_versions_content_review_with_delay(self): self.grant_permission(self.request.user, 'Addons:ContentReview') old_version = self.version self.version = version_factory(addon=self.addon, version='3.0') self.setup_data( amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True ) # Pre-subscribe the user to new listed versions of this add-on, it # shouldn't matter. ReviewerSubscription.objects.create( addon=self.addon, user=self.request.user, channel=self.version.channel ) in_the_future = datetime.now() + timedelta(days=14) # Safeguards. assert isinstance(self.helper.handler, ReviewFiles) assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.is_public() data = self.get_data().copy() data.update( { 'versions': self.addon.versions.all(), 'delayed_rejection': True, 'delayed_rejection_days': 14, } ) self.helper.set_data(data) self.helper.handler.reject_multiple_versions() # File/addon status didn't change. self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.current_version == self.version assert list(self.addon.versions.all()) == [self.version, old_version] assert self.file.status == amo.STATUS_APPROVED # The versions are now pending rejection. for version in self.addon.versions.all(): assert version.pending_rejection self.assertCloseToNow(version.pending_rejection, now=in_the_future) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Delicious Bookmarks will be disabled on ' 'addons.mozilla.org' ) assert 'your add-on Delicious Bookmarks will be disabled' in message.body log_token = ActivityLogToken.objects.get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 0 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 0 assert self.check_log_count(amo.LOG.REJECT_CONTENT_DELAYED.id) == 2 assert self.check_log_count(amo.LOG.REJECT_VERSION_DELAYED.id) == 0 logs = ActivityLog.objects.for_addons(self.addon).filter( action=amo.LOG.REJECT_CONTENT_DELAYED.id ) assert logs[0].created == logs[1].created # Check points awarded. self._check_score(amo.REVIEWED_CONTENT_REVIEW) # The reviewer was already subscribed to new listed versions for this # addon, nothing has changed. assert ReviewerSubscription.objects.filter( addon=self.addon, user=self.request.user, channel=self.version.channel ).exists() def test_reject_multiple_versions_unlisted(self): old_version = self.version self.make_addon_unlisted(self.addon) self.version = version_factory( addon=self.addon, version='3.0', channel=amo.RELEASE_CHANNEL_UNLISTED, file_kw={'status': amo.STATUS_AWAITING_REVIEW}, ) AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED, weight=101 ) # An extra file should not change anything. file_factory(version=self.version) self.setup_data(amo.STATUS_NULL, file_status=amo.STATUS_AWAITING_REVIEW) # Safeguards. assert isinstance(self.helper.handler, ReviewUnlisted) assert self.addon.status == amo.STATUS_NULL assert self.file.status == amo.STATUS_AWAITING_REVIEW data = self.get_data().copy() data['versions'] = self.addon.versions.all() self.helper.set_data(data) self.helper.handler.reject_multiple_versions() self.addon.reload() self.file.reload() assert self.addon.status == amo.STATUS_NULL assert self.addon.current_version is None assert list(self.addon.versions.all()) == [self.version, old_version] assert self.file.status == amo.STATUS_DISABLED # unlisted auto approvals should be disabled until the next manual approval. flags = self.addon.reviewerflags flags.reload() assert not flags.auto_approval_disabled_until_next_approval assert flags.auto_approval_disabled_until_next_approval_unlisted assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.to == [self.addon.authors.all()[0].email] assert message.subject == ( 'Mozilla Add-ons: Versions disabled for Delicious Bookmarks' ) assert ( 'versions of your add-on Delicious Bookmarks have been disabled' in message.body ) log_token = ActivityLogToken.objects.get() assert log_token.uuid.hex in message.reply_to[0] assert self.check_log_count(amo.LOG.REJECT_VERSION.id) == 2 assert self.check_log_count(amo.LOG.REJECT_CONTENT.id) == 0 logs = ActivityLog.objects.for_addons(self.addon).filter( action=amo.LOG.REJECT_VERSION.id ) assert logs[0].created == logs[1].created # Check points awarded. self._check_score(amo.REVIEWED_EXTENSION_MEDIUM_RISK) def test_approve_content_content_review(self): self.grant_permission(self.request.user, 'Addons:ContentReview') self.setup_data( amo.STATUS_APPROVED, file_status=amo.STATUS_APPROVED, content_review=True ) summary = AutoApprovalSummary.objects.create( version=self.version, verdict=amo.AUTO_APPROVED ) self.create_paths() # Safeguards. assert self.addon.status == amo.STATUS_APPROVED assert self.file.status == amo.STATUS_APPROVED assert self.addon.current_version.files.all()[0].status == (amo.STATUS_APPROVED) self.helper.handler.approve_content() summary.reload() assert summary.confirmed is None # unchanged. approvals_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approvals_counter.counter == 0 assert approvals_counter.last_human_review is None self.assertCloseToNow(approvals_counter.last_content_review) assert self.check_log_count(amo.LOG.CONFIRM_AUTO_APPROVED.id) == 0 assert self.check_log_count(amo.LOG.APPROVE_CONTENT.id) == 1 activity = ( ActivityLog.objects.for_addons(self.addon) .filter(action=amo.LOG.APPROVE_CONTENT.id) .get() ) assert activity.arguments == [self.addon, self.version] assert activity.details['comments'] == '' # Check points awarded. self._check_score(amo.REVIEWED_CONTENT_REVIEW) def test_dev_versions_url_in_context(self): self.helper.set_data(self.get_data()) context_data = self.helper.handler.get_context_data() assert context_data['dev_versions_url'] == absolutify( self.addon.get_dev_url('versions') ) self.version.update(channel=amo.RELEASE_CHANNEL_UNLISTED) context_data = self.helper.handler.get_context_data() assert context_data['dev_versions_url'] == absolutify( reverse('devhub.addons.versions', args=[self.addon.id]) ) def test_nominated_to_approved_recommended(self): self.make_addon_promoted(self.addon, RECOMMENDED) assert not self.addon.promoted_group() self.test_nomination_to_public() assert self.addon.current_version.promoted_approvals.filter( group_id=RECOMMENDED.id ).exists() assert self.addon.promoted_group() == RECOMMENDED def test_nominated_to_approved_other_promoted(self): self.make_addon_promoted(self.addon, LINE) assert not self.addon.promoted_group() self.test_nomination_to_public() assert self.addon.current_version.promoted_approvals.filter( group_id=LINE.id ).exists() assert self.addon.promoted_group() == LINE def test_approved_update_recommended(self): self.make_addon_promoted(self.addon, RECOMMENDED) assert not self.addon.promoted_group() self.test_public_addon_with_version_awaiting_review_to_public() assert self.addon.current_version.promoted_approvals.filter( group_id=RECOMMENDED.id ).exists() assert self.addon.promoted_group() == RECOMMENDED def test_approved_update_other_promoted(self): self.make_addon_promoted(self.addon, LINE) assert not self.addon.promoted_group() self.test_public_addon_with_version_awaiting_review_to_public() assert self.addon.current_version.promoted_approvals.filter( group_id=LINE.id ).exists() assert self.addon.promoted_group() == LINE def test_autoapprove_fails_for_promoted(self): self.make_addon_promoted(self.addon, RECOMMENDED) assert not self.addon.promoted_group() self.request.user = UserProfile.objects.get(id=settings.TASK_USER_ID) with self.assertRaises(AssertionError): self.test_nomination_to_public() assert not PromotedApproval.objects.filter( version=self.addon.current_version ).exists() assert not self.addon.promoted_group() # change to other type of promoted; same should happen self.addon.promotedaddon.update(group_id=LINE.id) with self.assertRaises(AssertionError): self.test_nomination_to_public() assert not PromotedApproval.objects.filter( version=self.addon.current_version ).exists() assert not self.addon.promoted_group() # except for a group that doesn't require prereview self.addon.promotedaddon.update(group_id=STRATEGIC.id) assert self.addon.promoted_group() == STRATEGIC self.test_nomination_to_public() # But no promotedapproval though assert not PromotedApproval.objects.filter( version=self.addon.current_version ).exists() assert self.addon.promoted_group() == STRATEGIC def _test_block_multiple_unlisted_versions(self, redirect_url): old_version = self.version self.version = version_factory( addon=self.addon, version='3.0', needs_human_review=True ) # An extra file should not change anything. file_factory(version=self.version) self.setup_data( amo.STATUS_NULL, file_status=amo.STATUS_APPROVED, channel=amo.RELEASE_CHANNEL_UNLISTED, ) # Add a needs_human_review_by_mad flag that should be cleared later. VersionReviewerFlags.objects.create( version=self.version, needs_human_review_by_mad=True ) # Safeguards. assert isinstance(self.helper.handler, ReviewUnlisted) assert self.addon.status == amo.STATUS_NULL assert self.file.status == amo.STATUS_APPROVED data = self.get_data().copy() data['versions'] = self.addon.versions.all() self.helper.set_data(data) self.helper.handler.block_multiple_versions() self.addon.reload() self.file.reload() # Nothing has changed as we change the statuses as part of the Block assert self.addon.status == amo.STATUS_NULL assert self.file.status == amo.STATUS_APPROVED assert self.addon.versions.filter(needs_human_review=True).exists() assert VersionReviewerFlags.objects.filter( version__addon=self.addon, needs_human_review_by_mad=True ).exists() # No mails or logging either assert len(mail.outbox) == 0 assert not ActivityLog.objects.for_addons(self.addon).exists() # We should have set redirect_url to point to the Block admin page if '%s' in redirect_url: redirect_url = redirect_url % (old_version.pk, self.version.pk) assert self.helper.redirect_url == redirect_url def test_pending_blocklistsubmission_multiple_unlisted_versions(self): BlocklistSubmission.objects.create( input_guids=self.addon.guid, updated_by=user_factory() ) redirect_url = ( reverse('admin:blocklist_block_addaddon', args=(self.addon.id,)) + '?min=%s&max=%s' ) assert Block.objects.count() == 0 self._test_block_multiple_unlisted_versions(redirect_url) def test_new_block_multiple_unlisted_versions(self): redirect_url = ( reverse('admin:blocklist_block_addaddon', args=(self.addon.id,)) + '?min=%s&max=%s' ) assert Block.objects.count() == 0 self._test_block_multiple_unlisted_versions(redirect_url) def test_existing_block_multiple_unlisted_versions(self): Block.objects.create(guid=self.addon.guid, updated_by=user_factory()) redirect_url = ( reverse('admin:blocklist_block_addaddon', args=(self.addon.id,)) + '?min=%s&max=%s' ) self._test_block_multiple_unlisted_versions(redirect_url) def test_approve_latest_version_fails_for_blocked_version(self): Block.objects.create(addon=self.addon, updated_by=user_factory()) self.setup_data(amo.STATUS_NOMINATED) del self.addon.block with self.assertRaises(AssertionError): self.helper.handler.approve_latest_version() @override_settings(ENABLE_ADDON_SIGNING=True) class TestReviewHelperSigning(TestReviewHelperBase): """Tests that call signing but don't mock the actual call. Instead tests will have to check the end-result to see if the signing calls succeeded. """ __test__ = True def setUp(self): super().setUp() responses.add_passthru(settings.AUTOGRAPH_CONFIG['server_url']) self.addon = addon_factory( guid='test@local', file_kw={'filename': 'webextension.xpi'}, users=[self.request.user], ) self.version = self.addon.versions.all()[0] self.helper = self.get_helper() self.file = self.version.files.all()[0] def test_nomination_to_public(self): self.setup_data(amo.STATUS_NOMINATED) self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) assert len(mail.outbox) == 1 # AddonApprovalsCounter counter is now at 1 for this addon. approval_counter = AddonApprovalsCounter.objects.get(addon=self.addon) assert approval_counter.counter == 1 assert storage.exists(self.file.file_path) assert self.check_log_count(amo.LOG.APPROVE_VERSION.id) == 1 signature_info, manifest = _get_signature_details(self.file.file_path) subject_info = signature_info.signer_certificate['subject'] assert subject_info['common_name'] == 'test@local' assert manifest.count('Name: ') == 4 assert 'Name: index.js' in manifest assert 'Name: manifest.json' in manifest assert 'Name: META-INF/cose.manifest' in manifest assert 'Name: META-INF/cose.sig' in manifest def test_nominated_to_public_recommended(self): self.setup_data(amo.STATUS_NOMINATED) self.make_addon_promoted(self.addon, RECOMMENDED) assert not self.addon.promoted_group() self.helper.handler.approve_latest_version() assert self.addon.status == amo.STATUS_APPROVED assert self.addon.versions.all()[0].files.all()[0].status == ( amo.STATUS_APPROVED ) assert self.addon.current_version.promoted_approvals.filter( group_id=RECOMMENDED.id ).exists() assert self.addon.promoted_group() == RECOMMENDED signature_info, manifest = _get_signature_details(self.file.file_path) subject_info = signature_info.signer_certificate['subject'] assert subject_info['common_name'] == 'test@local' assert manifest.count('Name: ') == 5 assert 'Name: index.js' in manifest assert 'Name: manifest.json' in manifest assert 'Name: META-INF/cose.manifest' in manifest assert 'Name: META-INF/cose.sig' in manifest assert 'Name: mozilla-recommendation.json' in manifest recommendation_data = _get_recommendation_data(self.file.file_path) assert recommendation_data['addon_id'] == 'test@local' assert sorted(recommendation_data['states']) == [ 'recommended', 'recommended-android', ] def test_send_email_autoescape(): s = 'woo&&<>\'""' # Make sure HTML is not auto-escaped. send_mail( 'Random subject with %s', s, recipient_list=['nobody@mozilla.org'], from_email='nobody@mozilla.org', use_deny_list=False, ) assert len(mail.outbox) == 1 message = mail.outbox[0] assert message.body == s
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 2882, 492, 1683, 199, 504, 2882, 14, 1805, 492, 4420, 12, 3371, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 849, 63, 3494, 465, 4887, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 1208, 492, 7761, 199, 199, 646, 4613, 199, 646, 9320, 199, 199, 504, 312, 590, 311, 4674, 492, 30235, 199, 504, 312, 590, 311, 4674, 14, 8240, 14, 992, 492, 21885, 2445, 12, 21885, 2445, 3264, 199, 504, 312, 590, 311, 4674, 14, 10788, 14, 992, 492, 29366, 12, 29366, 25923, 3643, 11348, 12, 29366, 497, 16645, 6381, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 2853, 393, 935, 1399, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 2219, 492, 334, 272, 7640, 12, 272, 13553, 63, 3702, 12, 272, 570, 63, 3702, 12, 272, 922, 63, 3702, 12, 272, 1015, 63, 3702, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 1208, 492, 3222, 63, 1198, 199, 504, 312, 590, 311, 4674, 14, 1457, 513, 14, 992, 492, 8651, 12, 8651, 513, 2610, 2250, 199, 504, 312, 590, 311, 4674, 14, 5559, 14, 12741, 5731, 492, 334, 272, 13587, 12, 272, 5363, 5378, 25518, 12, 272, 6988, 1387, 21613, 12, 272, 7553, 12649, 948, 12, 272, 6988, 23300, 25517, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 1725, 14, 992, 492, 3814, 199, 504, 312, 590, 311, 4674, 14, 773, 14, 10316, 14, 2219, 14, 396, 63, 23238, 492, 334, 272, 485, 362, 63, 264, 22105, 63, 576, 12, 272, 485, 362, 63, 5233, 63, 5087, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 12741, 5731, 14, 992, 492, 27724, 5731, 25923, 637, 199, 504, 312, 590, 311, 4674, 14, 8578, 1192, 14, 992, 492, 334, 272, 9195, 25923, 637, 10407, 12, 272, 799, 16645, 12642, 12, 272, 799, 16645, 19120, 12, 272, 10935, 6382, 3737, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 8578, 1192, 14, 1208, 492, 334, 272, 26705, 19654, 12, 272, 26705, 5535, 12, 272, 26705, 4433, 12, 272, 26705, 1358, 15023, 12, 272, 10935, 1358, 15023, 2422, 1296, 3186, 12, 272, 2455, 63, 1224, 63, 3702, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 3707, 14, 992, 492, 19037, 199, 504, 312, 590, 311, 4674, 14, 6234, 14, 992, 492, 3394, 497, 16645, 6381, 199, 504, 1134, 1131, 492, 1611, 3227, 465, 29158, 421, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 1176, 63, 697, 421, 199, 907, 12058, 63, 9472, 63, 6305, 654, 275, 334, 4393, 14, 6305, 63, 1282, 2514, 14112, 12, 30235, 14, 6305, 63, 16205, 9, 421, 199, 533, 1379, 2768, 6382, 3737, 3186, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 291, 14, 1224, 275, 2455, 63, 1224, 63, 3702, 8, 2768, 6382, 3737, 9, 4157, 339, 347, 511, 63, 9291, 63, 354, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 2034, 275, 4420, 342, 267, 2034, 14, 928, 63, 1080, 275, 4420, 342, 267, 2034, 14, 928, 63, 1080, 14, 1107, 63, 585, 275, 413, 267, 1962, 14, 9291, 63, 354, 275, 283, 5692, 244, 5573, 103, 5573, 108, 24549, 4197, 240, 29472, 20724, 4197, 97, 4197, 246, 5573, 230, 7, 267, 1962, 14, 9291, 63, 5464, 275, 283, 396, 7, 267, 1962, 14, 7410, 63, 1023, 275, 283, 16, 14, 713, 7, 267, 291, 14, 1224, 14, 409, 63, 1606, 8, 1606, 9, 267, 282, 275, 29158, 8, 277, 14, 1224, 14, 3352, 63, 9291, 63, 354, 8, 1143, 430, 398, 702, 282, 14, 962, 360, 6399, 358, 508, 334, 288, 3837, 360, 8578, 1192, 14, 8578, 297, 1249, 1524, 495, 8, 1143, 14, 9291, 63, 5464, 3948, 267, 776, 267, 702, 282, 14, 505, 342, 508, 283, 5692, 244, 5573, 103, 5573, 108, 24549, 4197, 240, 29472, 20724, 4197, 97, 4197, 246, 5573, 230, 378, 14, 713, 7, 339, 347, 511, 63, 9291, 63, 466, 63, 344, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 9291, 63, 466, 63, 344, 275, 30235, 14, 9732, 615, 63, 15498, 267, 702, 620, 8, 277, 14, 1224, 14, 3352, 63, 9291, 63, 466, 63, 344, 8, 1143, 430, 508, 283, 6382, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 4899, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 1616, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 1616, 627, 5504, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 709, 7609, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 368, 63, 2977, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 413, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 5504, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 5212, 627, 5504, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 17, 5382, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 8419, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 6928, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 5212, 627, 6928, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 1081, 10857, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 827, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 4119, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 2882, 492, 1683, 199, 504, 2882, 14, 1805, 492, 4420, 12, 3371, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 849, 63, 3494, 465, 4887, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 1208, 492, 7761, 199, 199, 646, 4613, 199, 646, 9320, 199, 199, 504, 312, 590, 311, 4674, 492, 30235, 199, 504, 312, 590, 311, 4674, 14, 8240, 14, 992, 492, 21885, 2445, 12, 21885, 2445, 3264, 199, 504, 312, 590, 311, 4674, 14, 10788, 14, 992, 492, 29366, 12, 29366, 25923, 3643, 11348, 12, 29366, 497, 16645, 6381, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 2853, 393, 935, 1399, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 2219, 492, 334, 272, 7640, 12, 272, 13553, 63, 3702, 12, 272, 570, 63, 3702, 12, 272, 922, 63, 3702, 12, 272, 1015, 63, 3702, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 4393, 14, 1208, 492, 3222, 63, 1198, 199, 504, 312, 590, 311, 4674, 14, 1457, 513, 14, 992, 492, 8651, 12, 8651, 513, 2610, 2250, 199, 504, 312, 590, 311, 4674, 14, 5559, 14, 12741, 5731, 492, 334, 272, 13587, 12, 272, 5363, 5378, 25518, 12, 272, 6988, 1387, 21613, 12, 272, 7553, 12649, 948, 12, 272, 6988, 23300, 25517, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 1725, 14, 992, 492, 3814, 199, 504, 312, 590, 311, 4674, 14, 773, 14, 10316, 14, 2219, 14, 396, 63, 23238, 492, 334, 272, 485, 362, 63, 264, 22105, 63, 576, 12, 272, 485, 362, 63, 5233, 63, 5087, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 12741, 5731, 14, 992, 492, 27724, 5731, 25923, 637, 199, 504, 312, 590, 311, 4674, 14, 8578, 1192, 14, 992, 492, 334, 272, 9195, 25923, 637, 10407, 12, 272, 799, 16645, 12642, 12, 272, 799, 16645, 19120, 12, 272, 10935, 6382, 3737, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 8578, 1192, 14, 1208, 492, 334, 272, 26705, 19654, 12, 272, 26705, 5535, 12, 272, 26705, 4433, 12, 272, 26705, 1358, 15023, 12, 272, 10935, 1358, 15023, 2422, 1296, 3186, 12, 272, 2455, 63, 1224, 63, 3702, 12, 199, 9, 199, 504, 312, 590, 311, 4674, 14, 3707, 14, 992, 492, 19037, 199, 504, 312, 590, 311, 4674, 14, 6234, 14, 992, 492, 3394, 497, 16645, 6381, 199, 504, 1134, 1131, 492, 1611, 3227, 465, 29158, 421, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 1176, 63, 697, 421, 199, 907, 12058, 63, 9472, 63, 6305, 654, 275, 334, 4393, 14, 6305, 63, 1282, 2514, 14112, 12, 30235, 14, 6305, 63, 16205, 9, 421, 199, 533, 1379, 2768, 6382, 3737, 3186, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 1252, 5996, 342, 267, 291, 14, 1224, 275, 2455, 63, 1224, 63, 3702, 8, 2768, 6382, 3737, 9, 4157, 339, 347, 511, 63, 9291, 63, 354, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 2034, 275, 4420, 342, 267, 2034, 14, 928, 63, 1080, 275, 4420, 342, 267, 2034, 14, 928, 63, 1080, 14, 1107, 63, 585, 275, 413, 267, 1962, 14, 9291, 63, 354, 275, 283, 5692, 244, 5573, 103, 5573, 108, 24549, 4197, 240, 29472, 20724, 4197, 97, 4197, 246, 5573, 230, 7, 267, 1962, 14, 9291, 63, 5464, 275, 283, 396, 7, 267, 1962, 14, 7410, 63, 1023, 275, 283, 16, 14, 713, 7, 267, 291, 14, 1224, 14, 409, 63, 1606, 8, 1606, 9, 267, 282, 275, 29158, 8, 277, 14, 1224, 14, 3352, 63, 9291, 63, 354, 8, 1143, 430, 398, 702, 282, 14, 962, 360, 6399, 358, 508, 334, 288, 3837, 360, 8578, 1192, 14, 8578, 297, 1249, 1524, 495, 8, 1143, 14, 9291, 63, 5464, 3948, 267, 776, 267, 702, 282, 14, 505, 342, 508, 283, 5692, 244, 5573, 103, 5573, 108, 24549, 4197, 240, 29472, 20724, 4197, 97, 4197, 246, 5573, 230, 378, 14, 713, 7, 339, 347, 511, 63, 9291, 63, 466, 63, 344, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 9291, 63, 466, 63, 344, 275, 30235, 14, 9732, 615, 63, 15498, 267, 702, 620, 8, 277, 14, 1224, 14, 3352, 63, 9291, 63, 466, 63, 344, 8, 1143, 430, 508, 283, 6382, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 4899, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 1616, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 1616, 627, 5504, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 709, 7609, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 368, 63, 2977, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 413, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 5504, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 5212, 627, 5504, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 17, 5382, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 8419, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 6928, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 5212, 627, 6928, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 8, 1143, 9, 508, 283, 1081, 10857, 7, 339, 347, 511, 63, 14093, 63, 521, 63, 262, 63, 827, 8, 277, 304, 267, 1962, 275, 4420, 342, 267, 1962, 14, 14093, 63, 521, 63, 4899, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 8419, 275, 378, 267, 1962, 14, 14093, 63, 521, 63, 827, 275, 4119, 267, 702, 291, 14, 1224, 14, 3352, 63, 14093, 63, 521, 63, 827, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
santiavenda2/griffith
lib/plugins/imp/PersonalVideoDatabase.py
4
8307
# -*- coding: utf-8 -*- __revision__ = '$Id$' # Copyright (c) 2009 # 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. # # 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 Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # You may use and distribute this software under the terms of the # GNU General Public License, version 2 or later from plugins.imp import ImportPlugin as IP import gutils import string from xml.dom import minidom, Node import logging log = logging.getLogger("Griffith") class ImportPlugin(IP): description = 'Personal Video Database (v0.9.9.x)' author = 'Michael Jahn' email = 'griffith@griffith.cc' version = '1.0' file_filters = '*.[xX][mM][lL]' mime_types = None fileversion = None filedom = None items = None itemindex = 0 def initialize(self): if not IP.initialize(self): return False self.edit = False return True def set_source(self, name): IP.set_source(self, name) self.filename = name self.fileversion = self.read_fileversion() if self.fileversion == None: gutils.error(_('The format of the file is not supported.')) return False return True def count_movies(self): """Returns number of movies in file which is about to be imported""" count = 0 if self.filedom: try: xmlElement = self.filedom.getElementsByTagName('xml')[0] for element in xmlElement.childNodes: if element.nodeType == Node.ELEMENT_NODE and element.nodeName == 'viddb': for viddbElement in element.childNodes: if viddbElement.nodeType == Node.ELEMENT_NODE and viddbElement.nodeName == 'movies': count = int(viddbElement.childNodes[0].data.strip()) break break except: log.exception('') else: log.error('Personal Video Database Import: No filedom object.') log.info('Personal Video Database Import: %s movies for import' % count) return count def get_movie_details(self): """Returns dictionary with movie details""" if not self.filedom: self.filedom = minidom.parse(self.filename) if not self.items: xmlElement = self.filedom.getElementsByTagName('xml')[0] viddbElement = self.filedom.getElementsByTagName('viddb')[0] self.items = viddbElement.childNodes self.itemindex = 0 if not self.items or len(self.items) < 1: return None if len(self.items) <= self.itemindex: return None item = self.items[self.itemindex] while not (item.nodeType == Node.ELEMENT_NODE and item.nodeName == 'movie') and len(self.items) > self.itemindex + 1: self.itemindex = self.itemindex + 1 item = self.items[self.itemindex] if len(self.items) <= self.itemindex: return None if not len(item.childNodes): return None details = {} try: for node in item.childNodes: if node.nodeType == Node.ELEMENT_NODE and len(node.childNodes) > 0: if node.nodeName == 'title': details['title'] = node.childNodes[0].data.strip() elif node.nodeName == 'origtitle': details['o_title'] = node.childNodes[0].data.strip() elif node.nodeName == 'year': details['year'] = node.childNodes[0].data.strip() elif node.nodeName == 'genre': details['genre'] = node.childNodes[0].data.strip() elif node.nodeName == 'country': details['country'] = node.childNodes[0].data.strip() elif node.nodeName == 'studio': details['studio'] = node.childNodes[0].data.strip() elif node.nodeName == 'director': details['director'] = node.childNodes[0].data.strip() elif node.nodeName == 'actors': details['cast'] = string.replace(node.childNodes[0].data.strip(), ', ', '\n') elif node.nodeName == 'description': details['plot'] = node.childNodes[0].data.strip() elif node.nodeName == 'length': details['runtime'] = node.childNodes[0].data.strip() elif node.nodeName == 'type': # setting medium_id to string mediumname; mapping is done in base class details['medium_id'] = node.childNodes[0].data.strip() elif node.nodeName == 'count': details['media_num'] = node.childNodes[0].data.strip() elif node.nodeName == 'videocodec': # setting vcodec_id to string codecname; mapping is done in base class details['vcodec_id'] = node.childNodes[0].data elif node.nodeName == 'comment': details['notes'] = node.childNodes[0].data.strip() elif node.nodeName == 'mpaa': details['classification'] = node.childNodes[0].data.strip() elif node.nodeName == 'scenario': details['screenplay'] = node.childNodes[0].data.strip() elif node.nodeName == 'tags': details['tags'] = string.split(node.childNodes[0].data.strip(), ', ') elif node.nodeName == 'url': details['o_site'] = node.childNodes[0].data.strip() elif node.nodeName == 'path': details['trailer'] = node.childNodes[0].data.strip() elif node.nodeName == 'barcode': details['barcode'] = node.childNodes[0].data.strip() elif node.nodeName == 'poster': details['poster'] = node.childNodes[0].data.strip() elif node.nodeName == 'num': details['number'] = node.childNodes[0].data.strip() elif node.nodeName == 'rating': try: details['rating'] = round(float(node.childNodes[0].data.strip().replace(',', '.')), 0) except: pass except EOFError: details = None except Exception, e: log.exception('') details = None self.itemindex = self.itemindex + 1 return details def clear(self): """clear plugin before next source file""" IP.clear(self) if self.filedom: self.filedom.unlink() self.filedom = None self.fileversion = None self.items = None self.itemindex = 0 def destroy(self): """close all resources""" IP.destroy(self) def read_fileversion(self): version = None self.filedom = minidom.parse(self.filename) try: xmlElement = self.filedom.getElementsByTagName('xml')[0] viddbElement = self.filedom.getElementsByTagName('viddb')[0] version = 0.9 except Exception, e: log.error(str(e)) self.filedom.unlink() self.filedom = None log.info('Personal Video Database Import: Found file version %s' % version) return version
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 5792, 363, 275, 4505, 1304, 12913, 199, 199, 3, 1898, 334, 67, 9, 8937, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 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, 11243, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 199, 199, 3, 2047, 1443, 675, 436, 11207, 642, 2032, 1334, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 12, 1015, 499, 503, 2945, 199, 199, 504, 8963, 14, 3236, 492, 3161, 5061, 465, 3531, 199, 646, 486, 1208, 199, 646, 1059, 199, 504, 2748, 14, 4556, 492, 19165, 12, 5013, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 480, 39, 322, 11286, 273, 531, 421, 199, 533, 3161, 5061, 8, 1772, 304, 272, 1369, 221, 275, 283, 7344, 279, 15709, 8692, 334, 86, 16, 14, 25, 14, 25, 14, 88, 3171, 272, 4132, 755, 275, 283, 45, 11781, 1603, 65, 6164, 7, 272, 3031, 263, 275, 283, 7928, 11286, 273, 32, 7928, 11286, 273, 14, 2055, 7, 272, 1015, 420, 275, 283, 17, 14, 16, 7, 272, 570, 63, 4273, 275, 11937, 59, 24110, 1527, 77, 45, 1527, 76, 44, 6616, 272, 6660, 63, 1313, 257, 275, 488, 339, 570, 1023, 221, 275, 488, 272, 570, 4556, 420, 275, 488, 272, 2974, 263, 275, 488, 272, 1242, 1080, 259, 275, 378, 339, 347, 8265, 8, 277, 304, 267, 340, 440, 3531, 14, 8489, 8, 277, 304, 288, 372, 756, 267, 291, 14, 3773, 275, 756, 267, 372, 715, 339, 347, 663, 63, 1365, 8, 277, 12, 536, 304, 267, 3531, 14, 409, 63, 1365, 8, 277, 12, 536, 9, 267, 291, 14, 1501, 275, 536, 267, 291, 14, 493, 1023, 275, 291, 14, 739, 63, 493, 1023, 342, 267, 340, 291, 14, 493, 1023, 508, 488, 26, 288, 486, 1208, 14, 705, 6723, 1918, 1475, 402, 314, 570, 365, 440, 3748, 12459, 288, 372, 756, 267, 372, 715, 339, 347, 2338, 63, 20888, 8, 277, 304, 267, 408, 3407, 1329, 402, 1303, 14484, 315, 570, 1314, 365, 3595, 370, 506, 8439, 624, 267, 2338, 275, 378, 267, 340, 291, 14, 493, 4556, 26, 288, 862, 26, 355, 2748, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 1652, 5832, 16, 61, 355, 367, 1819, 315, 2748, 2162, 14, 10626, 26, 490, 340, 1819, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 1819, 14, 13777, 508, 283, 5017, 697, 356, 717, 367, 27767, 697, 2162, 315, 1819, 14, 10626, 26, 1169, 340, 27767, 697, 2162, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 27767, 697, 2162, 14, 13777, 508, 283, 20888, 356, 1816, 2338, 275, 1109, 8, 5017, 697, 2162, 14, 10626, 59, 16, 1055, 576, 14, 1913, 1012, 1816, 2059, 717, 2059, 288, 871, 26, 355, 943, 14, 1971, 8355, 267, 587, 26, 288, 943, 14, 705, 360, 7344, 279, 15709, 8692, 3161, 26, 3091, 570, 4556, 909, 2659, 267, 943, 14, 815, 360, 7344, 279, 15709, 8692, 3161, 26, 450, 83, 1303, 14484, 367, 492, 7, 450, 2338, 9, 267, 372, 2338, 339, 347, 664, 63, 10888, 63, 5087, 8, 277, 304, 267, 408, 3407, 2600, 543, 14360, 2436, 624, 267, 340, 440, 291, 14, 493, 4556, 26, 288, 291, 14, 493, 4556, 275, 19165, 14, 1122, 8, 277, 14, 1501, 9, 267, 340, 440, 291, 14, 1744, 26, 288, 2748, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 1652, 5832, 16, 61, 288, 27767, 697, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 5017, 697, 5832, 16, 61, 288, 291, 14, 1744, 275, 27767, 697, 2162, 14, 10626, 288, 291, 14, 1053, 1080, 275, 378, 267, 340, 440, 291, 14, 1744, 503, 822, 8, 277, 14, 1744, 9, 665, 413, 26, 288, 372, 488, 267, 340, 822, 8, 277, 14, 1744, 9, 2695, 291, 14, 1053, 1080, 26, 288, 372, 488, 267, 1242, 275, 291, 14, 1744, 59, 277, 14, 1053, 1080, 61, 267, 1830, 440, 334, 1053, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 1242, 14, 13777, 508, 283, 10888, 358, 436, 822, 8, 277, 14, 1744, 9, 690, 291, 14, 1053, 1080, 435, 413, 26, 288, 291, 14, 1053, 1080, 275, 291, 14, 1053, 1080, 435, 413, 288, 1242, 275, 291, 14, 1744, 59, 277, 14, 1053, 1080, 61, 267, 340, 822, 8, 277, 14, 1744, 9, 2695, 291, 14, 1053, 1080, 26, 288, 372, 488, 267, 340, 440, 822, 8, 1053, 14, 10626, 304, 288, 372, 488, 398, 2436, 275, 1052, 267, 862, 26, 288, 367, 1031, 315, 1242, 14, 10626, 26, 355, 340, 1031, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 822, 8, 932, 14, 10626, 9, 690, 378, 26, 490, 340, 1031, 14, 13777, 508, 283, 1213, 356, 717, 2436, 459, 1213, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 2981, 1213, 356, 717, 2436, 459, 79, 63, 1213, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 3403, 356, 717, 2436, 459, 3403, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 23553, 356, 717, 2436, 459, 23553, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 363, 5792, 363, 275, 4505, 1304, 12913, 199, 199, 3, 1898, 334, 67, 9, 8937, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 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, 11243, 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, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 199, 199, 3, 2047, 1443, 675, 436, 11207, 642, 2032, 1334, 314, 2895, 402, 314, 199, 3, 1664, 1696, 1684, 844, 12, 1015, 499, 503, 2945, 199, 199, 504, 8963, 14, 3236, 492, 3161, 5061, 465, 3531, 199, 646, 486, 1208, 199, 646, 1059, 199, 504, 2748, 14, 4556, 492, 19165, 12, 5013, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 480, 39, 322, 11286, 273, 531, 421, 199, 533, 3161, 5061, 8, 1772, 304, 272, 1369, 221, 275, 283, 7344, 279, 15709, 8692, 334, 86, 16, 14, 25, 14, 25, 14, 88, 3171, 272, 4132, 755, 275, 283, 45, 11781, 1603, 65, 6164, 7, 272, 3031, 263, 275, 283, 7928, 11286, 273, 32, 7928, 11286, 273, 14, 2055, 7, 272, 1015, 420, 275, 283, 17, 14, 16, 7, 272, 570, 63, 4273, 275, 11937, 59, 24110, 1527, 77, 45, 1527, 76, 44, 6616, 272, 6660, 63, 1313, 257, 275, 488, 339, 570, 1023, 221, 275, 488, 272, 570, 4556, 420, 275, 488, 272, 2974, 263, 275, 488, 272, 1242, 1080, 259, 275, 378, 339, 347, 8265, 8, 277, 304, 267, 340, 440, 3531, 14, 8489, 8, 277, 304, 288, 372, 756, 267, 291, 14, 3773, 275, 756, 267, 372, 715, 339, 347, 663, 63, 1365, 8, 277, 12, 536, 304, 267, 3531, 14, 409, 63, 1365, 8, 277, 12, 536, 9, 267, 291, 14, 1501, 275, 536, 267, 291, 14, 493, 1023, 275, 291, 14, 739, 63, 493, 1023, 342, 267, 340, 291, 14, 493, 1023, 508, 488, 26, 288, 486, 1208, 14, 705, 6723, 1918, 1475, 402, 314, 570, 365, 440, 3748, 12459, 288, 372, 756, 267, 372, 715, 339, 347, 2338, 63, 20888, 8, 277, 304, 267, 408, 3407, 1329, 402, 1303, 14484, 315, 570, 1314, 365, 3595, 370, 506, 8439, 624, 267, 2338, 275, 378, 267, 340, 291, 14, 493, 4556, 26, 288, 862, 26, 355, 2748, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 1652, 5832, 16, 61, 355, 367, 1819, 315, 2748, 2162, 14, 10626, 26, 490, 340, 1819, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 1819, 14, 13777, 508, 283, 5017, 697, 356, 717, 367, 27767, 697, 2162, 315, 1819, 14, 10626, 26, 1169, 340, 27767, 697, 2162, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 27767, 697, 2162, 14, 13777, 508, 283, 20888, 356, 1816, 2338, 275, 1109, 8, 5017, 697, 2162, 14, 10626, 59, 16, 1055, 576, 14, 1913, 1012, 1816, 2059, 717, 2059, 288, 871, 26, 355, 943, 14, 1971, 8355, 267, 587, 26, 288, 943, 14, 705, 360, 7344, 279, 15709, 8692, 3161, 26, 3091, 570, 4556, 909, 2659, 267, 943, 14, 815, 360, 7344, 279, 15709, 8692, 3161, 26, 450, 83, 1303, 14484, 367, 492, 7, 450, 2338, 9, 267, 372, 2338, 339, 347, 664, 63, 10888, 63, 5087, 8, 277, 304, 267, 408, 3407, 2600, 543, 14360, 2436, 624, 267, 340, 440, 291, 14, 493, 4556, 26, 288, 291, 14, 493, 4556, 275, 19165, 14, 1122, 8, 277, 14, 1501, 9, 267, 340, 440, 291, 14, 1744, 26, 288, 2748, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 1652, 5832, 16, 61, 288, 27767, 697, 2162, 275, 291, 14, 493, 4556, 14, 15045, 360, 5017, 697, 5832, 16, 61, 288, 291, 14, 1744, 275, 27767, 697, 2162, 14, 10626, 288, 291, 14, 1053, 1080, 275, 378, 267, 340, 440, 291, 14, 1744, 503, 822, 8, 277, 14, 1744, 9, 665, 413, 26, 288, 372, 488, 267, 340, 822, 8, 277, 14, 1744, 9, 2695, 291, 14, 1053, 1080, 26, 288, 372, 488, 267, 1242, 275, 291, 14, 1744, 59, 277, 14, 1053, 1080, 61, 267, 1830, 440, 334, 1053, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 1242, 14, 13777, 508, 283, 10888, 358, 436, 822, 8, 277, 14, 1744, 9, 690, 291, 14, 1053, 1080, 435, 413, 26, 288, 291, 14, 1053, 1080, 275, 291, 14, 1053, 1080, 435, 413, 288, 1242, 275, 291, 14, 1744, 59, 277, 14, 1053, 1080, 61, 267, 340, 822, 8, 277, 14, 1744, 9, 2695, 291, 14, 1053, 1080, 26, 288, 372, 488, 267, 340, 440, 822, 8, 1053, 14, 10626, 304, 288, 372, 488, 398, 2436, 275, 1052, 267, 862, 26, 288, 367, 1031, 315, 1242, 14, 10626, 26, 355, 340, 1031, 14, 12412, 508, 5013, 14, 12535, 63, 8063, 436, 822, 8, 932, 14, 10626, 9, 690, 378, 26, 490, 340, 1031, 14, 13777, 508, 283, 1213, 356, 717, 2436, 459, 1213, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 2981, 1213, 356, 717, 2436, 459, 79, 63, 1213, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 3403, 356, 717, 2436, 459, 3403, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 283, 23553, 356, 717, 2436, 459, 23553, 418, 275, 1031, 14, 10626, 59, 16, 1055, 576, 14, 1913, 342, 490, 916, 1031, 14, 13777, 508, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rschnapka/hr
__unported__/hr_resume/__init__.py
28
1047
# -*- encoding: utf-8 -*- ############################################################################### # # OpenERP, Open Source Management Solution # Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.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/>. # ############################################################################### from . import hr_resume from . import report
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 428, 1214, 19142, 13, 667, 3621, 10130, 8642, 1014, 921, 1544, 14, 23374, 19142, 667, 3621, 5135, 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, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 11490, 199, 199, 504, 1275, 492, 16140, 63, 9964, 199, 504, 1275, 492, 3622, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 6171, 428, 1214, 19142, 13, 667, 3621, 10130, 8642, 1014, 921, 1544, 14, 23374, 19142, 667, 3621, 5135, 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, 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, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 11490, 199, 199, 504, 1275, 492, 16140, 63, 9964, 199, 504, 1275, 492, 3622, 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, 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,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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 ]
taiyuanfang/gyp
test/analyzer/gyptest-analyzer.py
8
10850
#!/usr/bin/env python # Copyright (c) 2014 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. """Tests for analyzer """ import json import TestGyp found = 'Found dependency' found_all = 'Found dependency (all)' not_found = 'No dependencies' def _CreateConfigFile(files, targets): """Creates the analyzer conflig file, which is used as the input to analyzer. See description of analyzer.py for description of the arguments.""" f = open('test_file', 'w') to_write = {'files': files, 'targets': targets } json.dump(to_write, f) f.close() def _CreateBogusConfigFile(): f = open('test_file','w') f.write('bogus') f.close() def _ReadOutputFileContents(): f = open('analyzer_output', 'r') result = json.load(f) f.close() return result # NOTE: this would be clearer if it subclassed TestGypCustom, but that trips # over a bug in pylint (E1002). test = TestGyp.TestGypCustom(format='analyzer') def CommonArgs(): return ('-Gconfig_path=test_file', '-Ganalyzer_output_path=analyzer_output') def run_analyzer(*args, **kw): """Runs the test specifying a particular config and output path.""" args += CommonArgs() test.run_gyp('test.gyp', *args, **kw) def run_analyzer2(*args, **kw): """Same as run_analyzer(), but passes in test2.gyp instead of test.gyp.""" args += CommonArgs() test.run_gyp('test2.gyp', *args, **kw) def run_analyzer3(*args, **kw): """Same as run_analyzer(), but passes in test3.gyp instead of test.gyp.""" args += CommonArgs() test.run_gyp('test3.gyp', *args, **kw) def run_analyzer4(*args, **kw): """Same as run_analyzer(), but passes in test3.gyp instead of test.gyp.""" args += CommonArgs() test.run_gyp('test4.gyp', *args, **kw) def EnsureContains(targets=set(), matched=False, build_targets=set()): """Verifies output contains |targets|.""" result = _ReadOutputFileContents() if result.get('error', None): print 'unexpected error', result.get('error') test.fail_test() if result.get('warning', None): print 'unexpected warning', result.get('warning') test.fail_test() actual_targets = set(result['targets']) if actual_targets != targets: print 'actual targets:', actual_targets, '\nexpected targets:', targets test.fail_test() actual_build_targets = set(result['build_targets']) if actual_build_targets != build_targets: print 'actual build_targets:', actual_build_targets, \ '\nexpected build_targets:', build_targets test.fail_test() if matched and result['status'] != found: print 'expected', found, 'got', result['status'] test.fail_test() elif not matched and result['status'] != not_found: print 'expected', not_found, 'got', result['status'] test.fail_test() def EnsureMatchedAll(targets): result = _ReadOutputFileContents() if result.get('error', None): print 'unexpected error', result.get('error') test.fail_test() if result.get('warning', None): print 'unexpected warning', result.get('warning') test.fail_test() if result['status'] != found_all: print 'expected', found_all, 'got', result['status'] test.fail_test() actual_targets = set(result['targets']) if actual_targets != targets: print 'actual targets:', actual_targets, '\nexpected targets:', targets test.fail_test() def EnsureError(expected_error_string): """Verifies output contains the error string.""" result = _ReadOutputFileContents() if result.get('error', '').find(expected_error_string) == -1: print 'actual error:', result.get('error', ''), '\nexpected error:', \ expected_error_string test.fail_test() def EnsureStdoutContains(expected_error_string): if test.stdout().find(expected_error_string) == -1: print 'actual stdout:', test.stdout(), '\nexpected stdout:', \ expected_error_string test.fail_test() def EnsureWarning(expected_warning_string): """Verifies output contains the warning string.""" result = _ReadOutputFileContents() if result.get('warning', '').find(expected_warning_string) == -1: print 'actual warning:', result.get('warning', ''), \ '\nexpected warning:', expected_warning_string test.fail_test() # Verifies config_path must be specified. test.run_gyp('test.gyp') EnsureStdoutContains('Must specify files to analyze via config_path') # Verifies config_path must point to a valid file. test.run_gyp('test.gyp', '-Gconfig_path=bogus_file', '-Ganalyzer_output_path=analyzer_output') EnsureError('Unable to open file bogus_file') # Verify get warning when bad target is specified. _CreateConfigFile(['exe2.c'], ['bad_target']) run_analyzer() EnsureWarning('Unable to find all targets') # Verifies config_path must point to a valid json file. _CreateBogusConfigFile() run_analyzer() EnsureError('Unable to parse config file test_file') # Trivial test of a source. _CreateConfigFile(['foo.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Conditional source that is excluded. _CreateConfigFile(['conditional_source.c'], []) run_analyzer() EnsureContains(matched=False) # Conditional source that is included by way of argument. _CreateConfigFile(['conditional_source.c'], []) run_analyzer('-Dtest_variable=1') EnsureContains(matched=True, build_targets={'exe'}) # Two unknown files. _CreateConfigFile(['unknown1.c', 'unoknow2.cc'], []) run_analyzer() EnsureContains() # Two unknown files. _CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], []) run_analyzer() EnsureContains() # Included dependency _CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe', 'exe3'}) # Included inputs to actions. _CreateConfigFile(['action_input.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Don't consider outputs. _CreateConfigFile(['action_output.c'], []) run_analyzer() EnsureContains(matched=False) # Rule inputs. _CreateConfigFile(['rule_input.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Ignore path specified with PRODUCT_DIR. _CreateConfigFile(['product_dir_input.c'], []) run_analyzer() EnsureContains(matched=False) # Path specified via a variable. _CreateConfigFile(['subdir/subdir_source2.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Verifies paths with // are fixed up correctly. _CreateConfigFile(['parent_source.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe', 'exe3'}) # Verifies relative paths are resolved correctly. _CreateConfigFile(['subdir/subdir_source.h'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Various permutations when passing in targets. _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['exe', 'exe3']) run_analyzer() EnsureContains(matched=True, targets={'exe3'}, build_targets={'exe2', 'exe3'}) _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['exe']) run_analyzer() EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) # Verifies duplicates are ignored. _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['exe', 'exe']) run_analyzer() EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) _CreateConfigFile(['exe2.c'], ['exe']) run_analyzer() EnsureContains(matched=True, build_targets={'exe2'}) _CreateConfigFile(['exe2.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe2'}) _CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) _CreateConfigFile(['subdir/subdir2b_source.c'], ['exe3']) run_analyzer() EnsureContains(matched=True, targets={'exe3'}, build_targets={'exe3'}) _CreateConfigFile(['exe2.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe2'}) _CreateConfigFile(['foo.c'], []) run_analyzer() EnsureContains(matched=True, build_targets={'exe'}) # Assertions when modifying build (gyp/gypi) files, especially when said files # are included. _CreateConfigFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3']) run_analyzer2() EnsureContains(matched=True, targets={'exe', 'foo'}, build_targets={'exe'}) _CreateConfigFile(['subdir2/subdir.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3']) run_analyzer2() EnsureContains(matched=True, targets={'exe', 'foo'}, build_targets={'exe'}) _CreateConfigFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3']) run_analyzer2() EnsureContains(matched=True, targets={'exe', 'foo'}, build_targets={'exe'}) _CreateConfigFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3']) run_analyzer2() EnsureContains(matched=True, targets={'exe', 'exe2', 'exe3'}, build_targets={'exe', 'exe2', 'exe3'}) # Verify modifying a file included makes all targets dirty. _CreateConfigFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3']) run_analyzer2('-Icommon.gypi') EnsureMatchedAll({'exe', 'exe2', 'foo', 'exe3'}) # Assertions from test3.gyp. _CreateConfigFile(['d.c', 'f.c'], ['a']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a', 'b'}) _CreateConfigFile(['f.c'], ['a']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a', 'b'}) _CreateConfigFile(['f.c'], []) run_analyzer3() EnsureContains(matched=True, build_targets={'a', 'b'}) _CreateConfigFile(['c.c', 'e.c'], []) run_analyzer3() EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'e'}) _CreateConfigFile(['d.c'], ['a']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a', 'b'}) _CreateConfigFile(['a.c'], ['a', 'b']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a'}) _CreateConfigFile(['a.c'], ['a', 'b']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a'}) _CreateConfigFile(['d.c'], ['a', 'b']) run_analyzer3() EnsureContains(matched=True, targets={'a', 'b'}, build_targets={'a', 'b'}) _CreateConfigFile(['f.c'], ['a']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a', 'b'}) _CreateConfigFile(['a.c'], ['a']) run_analyzer3() EnsureContains(matched=True, targets={'a'}, build_targets={'a'}) _CreateConfigFile(['a.c'], []) run_analyzer3() EnsureContains(matched=True, build_targets={'a'}) _CreateConfigFile(['d.c'], []) run_analyzer3() EnsureContains(matched=True, build_targets={'a', 'b'}) # Assertions around test4.gyp. _CreateConfigFile(['f.c'], []) run_analyzer4() EnsureContains(matched=True, build_targets={'e', 'f'}) _CreateConfigFile(['d.c'], []) run_analyzer4() EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'd'}) _CreateConfigFile(['i.c'], []) run_analyzer4() EnsureContains(matched=True, build_targets={'h'}) test.pass_test()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6927, 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, 2925, 367, 24608, 199, 624, 199, 199, 646, 2022, 199, 646, 25688, 199, 199, 4214, 275, 283, 3601, 5936, 7, 199, 4214, 63, 452, 275, 283, 3601, 5936, 334, 452, 3171, 199, 1397, 63, 4214, 275, 283, 1944, 5124, 7, 421, 199, 318, 485, 2499, 2028, 1173, 8, 1725, 12, 4545, 304, 523, 408, 10607, 314, 24608, 3743, 17506, 570, 12, 1314, 365, 1202, 465, 314, 1324, 370, 24608, 14, 523, 1666, 1369, 402, 24608, 14, 647, 367, 1369, 402, 314, 2368, 1041, 523, 289, 275, 1551, 360, 396, 63, 493, 297, 283, 87, 358, 523, 370, 63, 952, 275, 791, 1725, 356, 1584, 12, 283, 4684, 356, 4545, 789, 523, 2022, 14, 2724, 8, 475, 63, 952, 12, 289, 9, 523, 289, 14, 1600, 342, 421, 199, 318, 485, 2499, 34, 21670, 2028, 1173, 837, 523, 289, 275, 1551, 360, 396, 63, 493, 1673, 87, 358, 523, 289, 14, 952, 360, 18665, 358, 523, 289, 14, 1600, 342, 421, 199, 318, 485, 3284, 23847, 11383, 837, 523, 289, 275, 1551, 360, 17965, 63, 1199, 297, 283, 82, 358, 523, 754, 275, 2022, 14, 912, 8, 70, 9, 523, 289, 14, 1600, 342, 523, 372, 754, 421, 199, 3, 6944, 26, 642, 3955, 506, 15158, 21462, 340, 652, 1007, 28271, 25688, 7223, 12, 1325, 626, 3229, 1190, 199, 3, 1806, 282, 6519, 315, 4287, 334, 37, 32562, 680, 199, 396, 275, 25688, 14, 774, 13899, 7223, 8, 908, 534, 17965, 358, 199, 199, 318, 13964, 6213, 837, 523, 372, 12291, 39, 888, 63, 515, 29, 396, 63, 493, 297, 1779, 2475, 39, 17965, 63, 1199, 63, 515, 29, 17965, 63, 1199, 358, 421, 199, 318, 1255, 63, 17965, 2031, 589, 12, 1011, 829, 304, 523, 408, 16291, 314, 511, 9176, 282, 6770, 1101, 436, 1072, 931, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 18, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 18, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 18, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 19, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 19, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 19, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 20, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 19, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 20, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 7523, 6906, 8, 4684, 29, 409, 1062, 7838, 29, 797, 12, 1900, 63, 4684, 29, 409, 5109, 523, 408, 21168, 1072, 3509, 1204, 4684, 92, 1041, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 488, 304, 272, 870, 283, 8953, 1125, 297, 754, 14, 362, 360, 705, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 14, 362, 360, 3764, 297, 488, 304, 272, 870, 283, 8953, 5721, 297, 754, 14, 362, 360, 3764, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 4684, 275, 663, 8, 1099, 459, 4684, 1105, 523, 340, 3503, 63, 4684, 1137, 4545, 26, 272, 870, 283, 6514, 4545, 6536, 3503, 63, 4684, 12, 1557, 78, 2062, 4545, 6536, 4545, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 1506, 63, 4684, 275, 663, 8, 1099, 459, 1506, 63, 4684, 1105, 523, 340, 3503, 63, 1506, 63, 4684, 1137, 1900, 63, 4684, 26, 272, 870, 283, 6514, 1900, 63, 4684, 6536, 3503, 63, 1506, 63, 4684, 12, 971, 1779, 1557, 78, 2062, 1900, 63, 4684, 6536, 1900, 63, 4684, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 7838, 436, 754, 459, 1205, 418, 1137, 1911, 26, 272, 870, 283, 2062, 297, 1911, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 523, 916, 440, 7838, 436, 754, 459, 1205, 418, 1137, 440, 63, 4214, 26, 272, 870, 283, 2062, 297, 440, 63, 4214, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 421, 199, 318, 7523, 4486, 379, 2422, 8, 4684, 304, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 488, 304, 272, 870, 283, 8953, 1125, 297, 754, 14, 362, 360, 705, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 14, 362, 360, 3764, 297, 488, 304, 272, 870, 283, 8953, 5721, 297, 754, 14, 362, 360, 3764, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 459, 1205, 418, 1137, 1911, 63, 452, 26, 272, 870, 283, 2062, 297, 1911, 63, 452, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 4684, 275, 663, 8, 1099, 459, 4684, 1105, 523, 340, 3503, 63, 4684, 1137, 4545, 26, 272, 870, 283, 6514, 4545, 6536, 3503, 63, 4684, 12, 1557, 78, 2062, 4545, 6536, 4545, 272, 511, 14, 1633, 63, 396, 342, 421, 199, 318, 7523, 547, 8, 2062, 63, 705, 63, 875, 304, 523, 408, 21168, 1072, 3509, 314, 1125, 1059, 1041, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 12548, 1623, 8, 2062, 63, 705, 63, 875, 9, 508, 446, 17, 26, 272, 870, 283, 6514, 1125, 6536, 754, 14, 362, 360, 705, 297 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6927, 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, 2925, 367, 24608, 199, 624, 199, 199, 646, 2022, 199, 646, 25688, 199, 199, 4214, 275, 283, 3601, 5936, 7, 199, 4214, 63, 452, 275, 283, 3601, 5936, 334, 452, 3171, 199, 1397, 63, 4214, 275, 283, 1944, 5124, 7, 421, 199, 318, 485, 2499, 2028, 1173, 8, 1725, 12, 4545, 304, 523, 408, 10607, 314, 24608, 3743, 17506, 570, 12, 1314, 365, 1202, 465, 314, 1324, 370, 24608, 14, 523, 1666, 1369, 402, 24608, 14, 647, 367, 1369, 402, 314, 2368, 1041, 523, 289, 275, 1551, 360, 396, 63, 493, 297, 283, 87, 358, 523, 370, 63, 952, 275, 791, 1725, 356, 1584, 12, 283, 4684, 356, 4545, 789, 523, 2022, 14, 2724, 8, 475, 63, 952, 12, 289, 9, 523, 289, 14, 1600, 342, 421, 199, 318, 485, 2499, 34, 21670, 2028, 1173, 837, 523, 289, 275, 1551, 360, 396, 63, 493, 1673, 87, 358, 523, 289, 14, 952, 360, 18665, 358, 523, 289, 14, 1600, 342, 421, 199, 318, 485, 3284, 23847, 11383, 837, 523, 289, 275, 1551, 360, 17965, 63, 1199, 297, 283, 82, 358, 523, 754, 275, 2022, 14, 912, 8, 70, 9, 523, 289, 14, 1600, 342, 523, 372, 754, 421, 199, 3, 6944, 26, 642, 3955, 506, 15158, 21462, 340, 652, 1007, 28271, 25688, 7223, 12, 1325, 626, 3229, 1190, 199, 3, 1806, 282, 6519, 315, 4287, 334, 37, 32562, 680, 199, 396, 275, 25688, 14, 774, 13899, 7223, 8, 908, 534, 17965, 358, 199, 199, 318, 13964, 6213, 837, 523, 372, 12291, 39, 888, 63, 515, 29, 396, 63, 493, 297, 1779, 2475, 39, 17965, 63, 1199, 63, 515, 29, 17965, 63, 1199, 358, 421, 199, 318, 1255, 63, 17965, 2031, 589, 12, 1011, 829, 304, 523, 408, 16291, 314, 511, 9176, 282, 6770, 1101, 436, 1072, 931, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 18, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 18, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 18, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 19, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 19, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 19, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 1255, 63, 17965, 20, 2031, 589, 12, 1011, 829, 304, 523, 408, 8479, 465, 1255, 63, 17965, 1062, 1325, 14933, 315, 511, 19, 14, 6179, 3140, 402, 511, 14, 6179, 1041, 523, 1249, 847, 13964, 6213, 342, 523, 511, 14, 1065, 63, 6179, 360, 396, 20, 14, 6179, 297, 627, 589, 12, 1011, 829, 9, 421, 199, 318, 7523, 6906, 8, 4684, 29, 409, 1062, 7838, 29, 797, 12, 1900, 63, 4684, 29, 409, 5109, 523, 408, 21168, 1072, 3509, 1204, 4684, 92, 1041, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 488, 304, 272, 870, 283, 8953, 1125, 297, 754, 14, 362, 360, 705, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 14, 362, 360, 3764, 297, 488, 304, 272, 870, 283, 8953, 5721, 297, 754, 14, 362, 360, 3764, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 4684, 275, 663, 8, 1099, 459, 4684, 1105, 523, 340, 3503, 63, 4684, 1137, 4545, 26, 272, 870, 283, 6514, 4545, 6536, 3503, 63, 4684, 12, 1557, 78, 2062, 4545, 6536, 4545, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 1506, 63, 4684, 275, 663, 8, 1099, 459, 1506, 63, 4684, 1105, 523, 340, 3503, 63, 1506, 63, 4684, 1137, 1900, 63, 4684, 26, 272, 870, 283, 6514, 1900, 63, 4684, 6536, 3503, 63, 1506, 63, 4684, 12, 971, 1779, 1557, 78, 2062, 1900, 63, 4684, 6536, 1900, 63, 4684, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 7838, 436, 754, 459, 1205, 418, 1137, 1911, 26, 272, 870, 283, 2062, 297, 1911, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 523, 916, 440, 7838, 436, 754, 459, 1205, 418, 1137, 440, 63, 4214, 26, 272, 870, 283, 2062, 297, 440, 63, 4214, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 421, 199, 318, 7523, 4486, 379, 2422, 8, 4684, 304, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 488, 304, 272, 870, 283, 8953, 1125, 297, 754, 14, 362, 360, 705, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 14, 362, 360, 3764, 297, 488, 304, 272, 870, 283, 8953, 5721, 297, 754, 14, 362, 360, 3764, 358, 272, 511, 14, 1633, 63, 396, 342, 819, 340, 754, 459, 1205, 418, 1137, 1911, 63, 452, 26, 272, 870, 283, 2062, 297, 1911, 63, 452, 12, 283, 7808, 297, 754, 459, 1205, 418, 272, 511, 14, 1633, 63, 396, 342, 819, 3503, 63, 4684, 275, 663, 8, 1099, 459, 4684, 1105, 523, 340, 3503, 63, 4684, 1137, 4545, 26, 272, 870, 283, 6514, 4545, 6536, 3503, 63, 4684, 12, 1557, 78, 2062, 4545, 6536, 4545, 272, 511, 14, 1633, 63, 396, 342, 421, 199, 318, 7523, 547, 8, 2062, 63, 705, 63, 875, 304, 523, 408, 21168, 1072, 3509, 314, 1125, 1059, 1041, 523, 754, 275, 485, 3284, 23847, 11383, 342, 523, 340, 754, 14, 362, 360, 705, 297, 12548, 1623, 8, 2062, 63, 705, 63, 875, 9, 508, 446, 17, 26, 272, 870, 283, 6514, 1125,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
a4tech/dvbapp2-gui
lib/python/Components/Network.py
10
23686
import re import os from socket import * from Components.Console import Console from Components.PluginComponent import plugins from Plugins.Plugin import PluginDescriptor class Network: def __init__(self): self.ifaces = {} self.configuredNetworkAdapters = [] self.NetworkState = 0 self.DnsState = 0 self.nameservers = [] self.ethtool_bin = "ethtool" self.Console = Console() self.LinkConsole = Console() self.restartConsole = Console() self.deactivateInterfaceConsole = Console() self.activateInterfaceConsole = Console() self.resetNetworkConsole = Console() self.DnsConsole = Console() self.PingConsole = Console() self.config_ready = None self.friendlyNames = {} self.lan_interfaces = [] self.wlan_interfaces = [] self.remoteRootFS = None self.getInterfaces() def onRemoteRootFS(self): if self.remoteRootFS is None: import Harddisk for parts in Harddisk.getProcMounts(): if parts[1] == '/' and parts[2] == 'nfs': self.remoteRootFS = True break else: self.remoteRootFS = False return self.remoteRootFS def isBlacklisted(self, iface): return iface in ('lo', 'wifi0', 'wmaster0', 'sit0', 'tun0') def getInterfaces(self, callback = None): self.configuredInterfaces = [] for device in self.getInstalledAdapters(): self.getAddrInet(device, callback) # helper function def regExpMatch(self, pattern, string): if string is None: return None try: return pattern.search(string).group() except AttributeError: return None # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): return [ int(n) for n in ip.split('.') ] def getAddrInet(self, iface, callback): if not self.Console: self.Console = Console() cmd = "ip -o addr show dev " + iface self.Console.ePopen(cmd, self.IPaddrFinished, [iface,callback]) def IPaddrFinished(self, result, retval, extra_args): (iface, callback ) = extra_args data = { 'up': False, 'dhcp': False, 'preup' : False, 'predown' : False } globalIPpattern = re.compile("scope global") ipRegexp = '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' netRegexp = '[0-9]{1,2}' macRegexp = '[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}' ipLinePattern = re.compile('inet ' + ipRegexp + '/') ipPattern = re.compile(ipRegexp) netmaskLinePattern = re.compile('/' + netRegexp) netmaskPattern = re.compile(netRegexp) bcastLinePattern = re.compile(' brd ' + ipRegexp) upPattern = re.compile('UP') macPattern = re.compile(macRegexp) macLinePattern = re.compile('link/ether ' + macRegexp) for line in result.splitlines(): split = line.strip().split(' ',2) if split[1][:-1] == iface: up = self.regExpMatch(upPattern, split[2]) mac = self.regExpMatch(macPattern, self.regExpMatch(macLinePattern, split[2])) if up is not None: data['up'] = True if iface is not 'lo': self.configuredInterfaces.append(iface) if mac is not None: data['mac'] = mac if split[1] == iface: if re.search(globalIPpattern, split[2]): ip = self.regExpMatch(ipPattern, self.regExpMatch(ipLinePattern, split[2])) netmask = self.calc_netmask(self.regExpMatch(netmaskPattern, self.regExpMatch(netmaskLinePattern, split[2]))) bcast = self.regExpMatch(ipPattern, self.regExpMatch(bcastLinePattern, split[2])) if ip is not None: data['ip'] = self.convertIP(ip) if netmask is not None: data['netmask'] = self.convertIP(netmask) if bcast is not None: data['bcast'] = self.convertIP(bcast) if not data.has_key('ip'): data['dhcp'] = True data['ip'] = [0, 0, 0, 0] data['netmask'] = [0, 0, 0, 0] data['gateway'] = [0, 0, 0, 0] cmd = "route -n | grep " + iface self.Console.ePopen(cmd,self.routeFinished, [iface, data, callback]) def routeFinished(self, result, retval, extra_args): (iface, data, callback) = extra_args ipRegexp = '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ipPattern = re.compile(ipRegexp) ipLinePattern = re.compile(ipRegexp) for line in result.splitlines(): print line[0:7] if line[0:7] == "0.0.0.0": gateway = self.regExpMatch(ipPattern, line[16:31]) if gateway: data['gateway'] = self.convertIP(gateway) self.ifaces[iface] = data self.loadNetworkConfig(iface,callback) def writeNetworkConfig(self): self.configuredInterfaces = [] fp = file('/etc/network/interfaces', 'w') fp.write("# automatically generated by enigma2\n# do NOT change manually!\n\n") fp.write("auto lo\n") fp.write("iface lo inet loopback\n\n") for ifacename, iface in self.ifaces.items(): if iface['up']: fp.write("auto " + ifacename + "\n") self.configuredInterfaces.append(ifacename) if iface['dhcp']: fp.write("iface "+ ifacename +" inet dhcp\n") fp.write(" hostname $(hostname)\n") if not iface['dhcp']: fp.write("iface "+ ifacename +" inet static\n") fp.write(" hostname $(hostname)\n") if iface.has_key('ip'): # print tuple(iface['ip']) fp.write(" address %d.%d.%d.%d\n" % tuple(iface['ip'])) fp.write(" netmask %d.%d.%d.%d\n" % tuple(iface['netmask'])) if iface.has_key('gateway'): fp.write(" gateway %d.%d.%d.%d\n" % tuple(iface['gateway'])) if iface.has_key("configStrings"): fp.write(iface["configStrings"]) if iface["preup"] is not False and not iface.has_key("configStrings"): fp.write(iface["preup"]) if iface["predown"] is not False and not iface.has_key("configStrings"): fp.write(iface["predown"]) fp.write("\n") fp.close() self.configuredNetworkAdapters = self.configuredInterfaces self.writeNameserverConfig() def writeNameserverConfig(self): fp = file('/etc/resolv.conf', 'w') for nameserver in self.nameservers: fp.write("nameserver %d.%d.%d.%d\n" % tuple(nameserver)) fp.close() def loadNetworkConfig(self,iface,callback = None): interfaces = [] # parse the interfaces-file try: fp = file('/etc/network/interfaces', 'r') interfaces = fp.readlines() fp.close() except: print "[Network.py] interfaces - opening failed" ifaces = {} currif = "" for i in interfaces: split = i.strip().split(' ') if split[0] == "iface": currif = split[1] ifaces[currif] = {} if len(split) == 4 and split[3] == "dhcp": ifaces[currif]["dhcp"] = True else: ifaces[currif]["dhcp"] = False if currif == iface: #read information only for available interfaces if split[0] == "address": ifaces[currif]["address"] = map(int, split[1].split('.')) if self.ifaces[currif].has_key("ip"): if self.ifaces[currif]["ip"] != ifaces[currif]["address"] and ifaces[currif]["dhcp"] == False: self.ifaces[currif]["ip"] = map(int, split[1].split('.')) if split[0] == "netmask": ifaces[currif]["netmask"] = map(int, split[1].split('.')) if self.ifaces[currif].has_key("netmask"): if self.ifaces[currif]["netmask"] != ifaces[currif]["netmask"] and ifaces[currif]["dhcp"] == False: self.ifaces[currif]["netmask"] = map(int, split[1].split('.')) if split[0] == "gateway": ifaces[currif]["gateway"] = map(int, split[1].split('.')) if self.ifaces[currif].has_key("gateway"): if self.ifaces[currif]["gateway"] != ifaces[currif]["gateway"] and ifaces[currif]["dhcp"] == False: self.ifaces[currif]["gateway"] = map(int, split[1].split('.')) if split[0] == "pre-up": if self.ifaces[currif].has_key("preup"): self.ifaces[currif]["preup"] = i if split[0] in ("pre-down","post-down"): if self.ifaces[currif].has_key("predown"): self.ifaces[currif]["predown"] = i for ifacename, iface in ifaces.items(): if self.ifaces.has_key(ifacename): self.ifaces[ifacename]["dhcp"] = iface["dhcp"] if self.Console: if len(self.Console.appContainers) == 0: # save configured interfacelist self.configuredNetworkAdapters = self.configuredInterfaces # load ns only once self.loadNameserverConfig() # print "read configured interface:", ifaces # print "self.ifaces after loading:", self.ifaces self.config_ready = True self.msgPlugins() if callback is not None: callback(True) def loadNameserverConfig(self): ipRegexp = "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" nameserverPattern = re.compile("nameserver +" + ipRegexp) ipPattern = re.compile(ipRegexp) resolv = [] try: fp = file('/etc/resolv.conf', 'r') resolv = fp.readlines() fp.close() self.nameservers = [] except: print "[Network.py] resolv.conf - opening failed" for line in resolv: if self.regExpMatch(nameserverPattern, line) is not None: ip = self.regExpMatch(ipPattern, line) if ip: self.nameservers.append(self.convertIP(ip)) # print "nameservers:", self.nameservers def getInstalledAdapters(self): return [x for x in os.listdir('/sys/class/net') if not self.isBlacklisted(x)] def getConfiguredAdapters(self): return self.configuredNetworkAdapters def getNumberOfAdapters(self): return len(self.ifaces) def getFriendlyAdapterName(self, x): if x in self.friendlyNames.keys(): return self.friendlyNames.get(x, x) self.friendlyNames[x] = self.getFriendlyAdapterNaming(x) return self.friendlyNames.get(x, x) # when we have no friendly name, use adapter name def getFriendlyAdapterNaming(self, iface): name = None if self.isWirelessInterface(iface): if iface not in self.wlan_interfaces: name = _("WLAN connection") if len(self.wlan_interfaces): name += " " + str(len(self.wlan_interfaces)+1) self.wlan_interfaces.append(iface) else: if iface not in self.lan_interfaces: name = _("LAN connection") if len(self.lan_interfaces): name += " " + str(len(self.lan_interfaces)+1) self.lan_interfaces.append(iface) return name def getFriendlyAdapterDescription(self, iface): if not self.isWirelessInterface(iface): return _('Ethernet network interface') moduledir = self.getWlanModuleDir(iface) if moduledir: name = os.path.basename(os.path.realpath(moduledir)) if name in ('ath_pci','ath5k'): name = 'Atheros' elif name in ('rt73','rt73usb','rt3070sta'): name = 'Ralink' elif name == 'zd1211b': name = 'Zydas' elif name == 'r871x_usb_drv': name = 'Realtek' else: name = _('Unknown') return name + ' ' + _('wireless network interface') def getAdapterName(self, iface): return iface def getAdapterList(self): return self.ifaces.keys() def getAdapterAttribute(self, iface, attribute): if self.ifaces.has_key(iface): if self.ifaces[iface].has_key(attribute): return self.ifaces[iface][attribute] return None def setAdapterAttribute(self, iface, attribute, value): # print "setting for adapter", iface, "attribute", attribute, " to value", value if self.ifaces.has_key(iface): self.ifaces[iface][attribute] = value def removeAdapterAttribute(self, iface, attribute): if self.ifaces.has_key(iface): if self.ifaces[iface].has_key(attribute): del self.ifaces[iface][attribute] def getNameserverList(self): if len(self.nameservers) == 0: return [[0, 0, 0, 0], [0, 0, 0, 0]] else: return self.nameservers def clearNameservers(self): self.nameservers = [] def addNameserver(self, nameserver): if nameserver not in self.nameservers: self.nameservers.append(nameserver) def removeNameserver(self, nameserver): if nameserver in self.nameservers: self.nameservers.remove(nameserver) def changeNameserver(self, oldnameserver, newnameserver): if oldnameserver in self.nameservers: for i in range(len(self.nameservers)): if self.nameservers[i] == oldnameserver: self.nameservers[i] = newnameserver def resetNetworkConfig(self, mode='lan', callback = None): self.resetNetworkConsole = Console() self.commands = [] self.commands.append("/etc/init.d/avahi-daemon stop") for iface in self.ifaces.keys(): if iface != 'eth0' or not self.onRemoteRootFS(): self.commands.append("ip addr flush dev " + iface) self.commands.append("/etc/init.d/networking stop") self.commands.append("killall -9 udhcpc") self.commands.append("rm /var/run/udhcpc*") self.resetNetworkConsole.eBatch(self.commands, self.resetNetworkFinishedCB, [mode, callback], debug=True) def resetNetworkFinishedCB(self, extra_args): (mode, callback) = extra_args if len(self.resetNetworkConsole.appContainers) == 0: self.writeDefaultNetworkConfig(mode, callback) def writeDefaultNetworkConfig(self,mode='lan', callback = None): fp = file('/etc/network/interfaces', 'w') fp.write("# automatically generated by enigma2\n# do NOT change manually!\n\n") fp.write("auto lo\n") fp.write("iface lo inet loopback\n\n") if mode == 'wlan': fp.write("auto wlan0\n") fp.write("iface wlan0 inet dhcp\n") if mode == 'wlan-mpci': fp.write("auto ath0\n") fp.write("iface ath0 inet dhcp\n") if mode == 'lan': fp.write("auto eth0\n") fp.write("iface eth0 inet dhcp\n") fp.write("\n") fp.close() self.resetNetworkConsole = Console() self.commands = [] if mode == 'wlan': self.commands.append("ifconfig eth0 down") self.commands.append("ifconfig ath0 down") self.commands.append("ifconfig wlan0 up") if mode == 'wlan-mpci': self.commands.append("ifconfig eth0 down") self.commands.append("ifconfig wlan0 down") self.commands.append("ifconfig ath0 up") if mode == 'lan': self.commands.append("ifconfig eth0 up") self.commands.append("ifconfig wlan0 down") self.commands.append("ifconfig ath0 down") self.commands.append("/etc/init.d/avahi-daemon start") self.resetNetworkConsole.eBatch(self.commands, self.resetNetworkFinished, [mode,callback], debug=True) def resetNetworkFinished(self,extra_args): (mode, callback) = extra_args if len(self.resetNetworkConsole.appContainers) == 0: if callback is not None: callback(True,mode) def checkNetworkState(self,statecallback): self.NetworkState = 0 cmd1 = "ping -c 1 www.openpli.org" cmd2 = "ping -c 1 www.google.nl" cmd3 = "ping -c 1 www.google.com" self.PingConsole = Console() self.PingConsole.ePopen(cmd1, self.checkNetworkStateFinished,statecallback) self.PingConsole.ePopen(cmd2, self.checkNetworkStateFinished,statecallback) self.PingConsole.ePopen(cmd3, self.checkNetworkStateFinished,statecallback) def checkNetworkStateFinished(self, result, retval,extra_args): (statecallback) = extra_args if self.PingConsole is not None: if retval == 0: self.PingConsole = None statecallback(self.NetworkState) else: self.NetworkState += 1 if len(self.PingConsole.appContainers) == 0: statecallback(self.NetworkState) def restartNetwork(self,callback = None): self.restartConsole = Console() self.config_ready = False self.msgPlugins() self.commands = [] self.commands.append("/etc/init.d/avahi-daemon stop") for iface in self.ifaces.keys(): if iface != 'eth0' or not self.onRemoteRootFS(): self.commands.append("ifdown " + iface) self.commands.append("ip addr flush dev " + iface) self.commands.append("/etc/init.d/networking stop") self.commands.append("killall -9 udhcpc") self.commands.append("rm /var/run/udhcpc*") self.commands.append("/etc/init.d/networking start") self.commands.append("/etc/init.d/avahi-daemon start") self.restartConsole.eBatch(self.commands, self.restartNetworkFinished, callback, debug=True) def restartNetworkFinished(self,extra_args): ( callback ) = extra_args if callback is not None: callback(True) def getLinkState(self,iface,callback): cmd = self.ethtool_bin + " " + iface self.LinkConsole = Console() self.LinkConsole.ePopen(cmd, self.getLinkStateFinished,callback) def getLinkStateFinished(self, result, retval,extra_args): (callback) = extra_args if self.LinkConsole is not None: if len(self.LinkConsole.appContainers) == 0: callback(result) def stopPingConsole(self): if self.PingConsole is not None: if len(self.PingConsole.appContainers): for name in self.PingConsole.appContainers.keys(): self.PingConsole.kill(name) def stopLinkStateConsole(self): if self.LinkConsole is not None: if len(self.LinkConsole.appContainers): for name in self.LinkConsole.appContainers.keys(): self.LinkConsole.kill(name) def stopDNSConsole(self): if self.DnsConsole is not None: if len(self.DnsConsole.appContainers): for name in self.DnsConsole.appContainers.keys(): self.DnsConsole.kill(name) def stopRestartConsole(self): if self.restartConsole is not None: if len(self.restartConsole.appContainers): for name in self.restartConsole.appContainers.keys(): self.restartConsole.kill(name) def stopGetInterfacesConsole(self): if self.Console is not None: if len(self.Console.appContainers): for name in self.Console.appContainers.keys(): self.Console.kill(name) def stopDeactivateInterfaceConsole(self): if self.deactivateInterfaceConsole is not None: self.deactivateInterfaceConsole.killAll() self.deactivateInterfaceConsole = None def stopActivateInterfaceConsole(self): if self.activateInterfaceConsole is not None: self.activateInterfaceConsole.killAll() self.activateInterfaceConsole = None def checkforInterface(self,iface): if self.getAdapterAttribute(iface, 'up') is True: return True else: ret=os.system("ifconfig " + iface + " up") os.system("ifconfig " + iface + " down") if ret == 0: return True else: return False def checkDNSLookup(self,statecallback): cmd1 = "nslookup www.dream-multimedia-tv.de" cmd2 = "nslookup www.heise.de" cmd3 = "nslookup www.google.de" self.DnsConsole = Console() self.DnsConsole.ePopen(cmd1, self.checkDNSLookupFinished,statecallback) self.DnsConsole.ePopen(cmd2, self.checkDNSLookupFinished,statecallback) self.DnsConsole.ePopen(cmd3, self.checkDNSLookupFinished,statecallback) def checkDNSLookupFinished(self, result, retval,extra_args): (statecallback) = extra_args if self.DnsConsole is not None: if retval == 0: self.DnsConsole = None statecallback(self.DnsState) else: self.DnsState += 1 if len(self.DnsConsole.appContainers) == 0: statecallback(self.DnsState) def deactivateInterface(self,ifaces,callback = None): self.config_ready = False self.msgPlugins() commands = [] def buildCommands(iface): commands.append("ifdown " + iface) commands.append("ip addr flush dev " + iface) #wpa_supplicant sometimes doesn't quit properly on SIGTERM if os.path.exists('/var/run/wpa_supplicant/'+ iface): commands.append("wpa_cli -i" + iface + " terminate") if not self.deactivateInterfaceConsole: self.deactivateInterfaceConsole = Console() if isinstance(ifaces, (list, tuple)): for iface in ifaces: if iface != 'eth0' or not self.onRemoteRootFS(): buildCommands(iface) else: if ifaces == 'eth0' and self.onRemoteRootFS(): if callback is not None: callback(True) return buildCommands(ifaces) self.deactivateInterfaceConsole.eBatch(commands, self.deactivateInterfaceFinished, [ifaces,callback], debug=True) def deactivateInterfaceFinished(self,extra_args): (ifaces, callback) = extra_args def checkCommandResult(iface): if self.deactivateInterfaceConsole and self.deactivateInterfaceConsole.appResults.has_key("ifdown " + iface): result = str(self.deactivateInterfaceConsole.appResults.get("ifdown " + iface)).strip("\n") if result == "ifdown: interface " + iface + " not configured": return False else: return True #ifdown sometimes can't get the interface down. if isinstance(ifaces, (list, tuple)): for iface in ifaces: if checkCommandResult(iface) is False: Console().ePopen(("ifconfig " + iface + " down" )) else: if checkCommandResult(ifaces) is False: Console().ePopen(("ifconfig " + ifaces + " down" )) if self.deactivateInterfaceConsole: if len(self.deactivateInterfaceConsole.appContainers) == 0: if callback is not None: callback(True) def activateInterface(self,iface,callback = None): if self.config_ready: self.config_ready = False self.msgPlugins() if iface == 'eth0' and self.onRemoteRootFS(): if callback is not None: callback(True) return if not self.activateInterfaceConsole: self.activateInterfaceConsole = Console() commands = ["ifup " + iface] self.activateInterfaceConsole.eBatch(commands, self.activateInterfaceFinished, callback, debug=True) def activateInterfaceFinished(self,extra_args): callback = extra_args if self.activateInterfaceConsole: if len(self.activateInterfaceConsole.appContainers) == 0: if callback is not None: callback(True) def sysfsPath(self, iface): return '/sys/class/net/' + iface def isWirelessInterface(self, iface): if iface in self.wlan_interfaces: return True if os.path.isdir(self.sysfsPath(iface) + '/wireless'): return True # r871x_usb_drv on kernel 2.6.12 is not identifiable over /sys/class/net/'ifacename'/wireless so look also inside /proc/net/wireless device = re.compile('[a-z]{2,}[0-9]*:') ifnames = [] fp = open('/proc/net/wireless', 'r') for line in fp: try: ifnames.append(device.search(line).group()[:-1]) except AttributeError: pass fp.close() if iface in ifnames: return True return False def getWlanModuleDir(self, iface = None): devicedir = self.sysfsPath(iface) + '/device' moduledir = devicedir + '/driver/module' if os.path.isdir(moduledir): return moduledir # identification is not possible over default moduledir for x in os.listdir(devicedir): # rt3070 on kernel 2.6.18 registers wireless devices as usb_device (e.g. 1-1.3:1.0) and identification is only possible over /sys/class/net/'ifacename'/device/1-xxx if x.startswith("1-"): moduledir = devicedir + '/' + x + '/driver/module' if os.path.isdir(moduledir): return moduledir # rt73, zd1211b, r871x_usb_drv on kernel 2.6.12 can be identified over /sys/class/net/'ifacename'/device/driver, so look also here moduledir = devicedir + '/driver' if os.path.isdir(moduledir): return moduledir return None def detectWlanModule(self, iface = None): if not self.isWirelessInterface(iface): return None devicedir = self.sysfsPath(iface) + '/device' if os.path.isdir(devicedir + '/ieee80211'): return 'nl80211' moduledir = self.getWlanModuleDir(iface) if moduledir: module = os.path.basename(os.path.realpath(moduledir)) if module in ('ath_pci','ath5k'): return 'madwifi' if module in ('rt73','rt73'): return 'ralink' if module == 'zd1211b': return 'zydas' return 'wext' def calc_netmask(self,nmask): from struct import pack from socket import inet_ntoa mask = 1L<<31 xnet = (1L<<32)-1 cidr_range = range(0, 32) cidr = long(nmask) if cidr not in cidr_range: print 'cidr invalid: %d' % cidr return None else: nm = ((1L<<cidr)-1)<<(32-cidr) netmask = str(inet_ntoa(pack('>L', nm))) return netmask def msgPlugins(self): if self.config_ready is not None: for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKCONFIG_READ): p(reason=self.config_ready) def hotplug(self, event): interface = event['INTERFACE'] if self.isBlacklisted(interface): return action = event['ACTION'] if action == "add": print "[Network] Add new interface:", interface self.getAddrInet(interface, None) elif action == "remove": print "[Network] Removed interface:", interface try: del self.ifaces[interface] except KeyError: pass iNetwork = Network() def InitNetwork(): pass
gpl-2.0
[ 646, 295, 199, 646, 747, 199, 504, 2838, 492, 627, 199, 504, 17823, 14, 9270, 492, 19809, 199, 504, 17823, 14, 5061, 7004, 492, 8963, 199, 504, 30317, 14, 5061, 492, 11349, 4311, 199, 199, 533, 7220, 26, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 73, 4309, 275, 1052, 507, 198, 277, 14, 11786, 4491, 2767, 12552, 275, 942, 507, 198, 277, 14, 4491, 2223, 275, 378, 507, 198, 277, 14, 27664, 2223, 275, 378, 507, 198, 277, 14, 28620, 275, 942, 507, 198, 277, 14, 12391, 3557, 63, 1393, 275, 298, 12391, 3557, 2, 507, 198, 277, 14, 9270, 275, 19809, 342, 507, 198, 277, 14, 3834, 9270, 275, 19809, 342, 507, 198, 277, 14, 10506, 9270, 275, 19809, 342, 507, 198, 277, 14, 24891, 4267, 9270, 275, 19809, 342, 507, 198, 277, 14, 8222, 4267, 9270, 275, 19809, 342, 507, 198, 277, 14, 3958, 4491, 9270, 275, 19809, 342, 507, 198, 277, 14, 27664, 9270, 275, 19809, 342, 507, 198, 277, 14, 22638, 9270, 275, 19809, 342, 507, 198, 277, 14, 888, 63, 2179, 275, 488, 507, 198, 277, 14, 17317, 5866, 275, 1052, 507, 198, 277, 14, 1502, 63, 7436, 275, 942, 507, 198, 277, 14, 87, 1502, 63, 7436, 275, 942, 507, 198, 277, 14, 3846, 6405, 7079, 275, 488, 507, 198, 277, 14, 362, 18680, 342, 421, 198, 318, 641, 6713, 6405, 7079, 8, 277, 304, 507, 198, 692, 291, 14, 3846, 6405, 7079, 365, 488, 26, 686, 198, 646, 22825, 4032, 686, 198, 509, 4184, 315, 22825, 4032, 14, 362, 15019, 24467, 83, 837, 1585, 198, 692, 4184, 59, 17, 61, 508, 7324, 436, 4184, 59, 18, 61, 508, 283, 19591, 356, 1871, 198, 277, 14, 3846, 6405, 7079, 275, 715, 1871, 198, 4785, 686, 198, 2836, 26, 1585, 198, 277, 14, 3846, 6405, 7079, 275, 756, 507, 198, 1107, 291, 14, 3846, 6405, 7079, 421, 198, 318, 365, 23405, 15023, 8, 277, 12, 13395, 304, 507, 198, 1107, 13395, 315, 661, 320, 297, 283, 4326, 16, 297, 283, 87, 4133, 16, 297, 283, 2221, 16, 297, 283, 10032, 16, 358, 421, 198, 318, 664, 18680, 8, 277, 12, 3233, 275, 488, 304, 507, 198, 277, 14, 11786, 18680, 275, 942, 507, 198, 509, 2243, 315, 291, 14, 362, 21268, 2767, 12552, 837, 686, 198, 277, 14, 362, 11404, 14796, 8, 1782, 12, 3233, 9, 421, 198, 3, 5922, 805, 199, 198, 318, 1295, 4527, 4486, 8, 277, 12, 3851, 12, 1059, 304, 507, 198, 692, 1059, 365, 488, 26, 686, 198, 1107, 488, 507, 198, 893, 26, 686, 198, 1107, 3851, 14, 1733, 8, 875, 680, 923, 342, 507, 198, 2590, 4281, 26, 686, 198, 1107, 488, 421, 198, 3, 5922, 805, 370, 3957, 15017, 687, 282, 308, 5985, 370, 282, 769, 402, 14526, 199, 198, 318, 3957, 1772, 8, 277, 12, 3384, 304, 507, 198, 1107, 359, 1109, 8, 78, 9, 367, 302, 315, 3384, 14, 1294, 7563, 1622, 421, 198, 318, 664, 11404, 14796, 8, 277, 12, 13395, 12, 3233, 304, 507, 198, 692, 440, 291, 14, 9270, 26, 686, 198, 277, 14, 9270, 275, 19809, 342, 507, 198, 1760, 275, 298, 711, 446, 79, 5552, 2498, 4866, 298, 435, 13395, 507, 198, 277, 14, 9270, 14, 69, 7942, 8, 1760, 12, 291, 14, 1772, 2697, 13430, 12, 359, 11166, 12, 3058, 566, 421, 198, 318, 3531, 2697, 13430, 8, 277, 12, 754, 12, 9151, 12, 2402, 63, 589, 304, 507, 198, 8, 11166, 12, 3233, 776, 275, 2402, 63, 589, 507, 198, 576, 275, 469, 283, 384, 356, 756, 12, 283, 10801, 356, 756, 12, 283, 657, 384, 7, 520, 756, 12, 283, 5991, 944, 7, 520, 756, 789, 507, 198, 2966, 1772, 3401, 275, 295, 14, 2014, 480, 2645, 2288, 531, 507, 198, 711, 8357, 275, 6730, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 6834, 507, 198, 846, 8357, 275, 6730, 16, 13, 25, 8194, 17, 12, 18, 6834, 507, 198, 3088, 8357, 275, 6730, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 6834, 507, 198, 711, 3049, 9959, 275, 295, 14, 2014, 360, 10811, 283, 435, 3384, 8357, 435, 15107, 507, 198, 711, 9959, 275, 295, 14, 2014, 8, 711, 8357, 9, 507, 198, 14588, 3049, 9959, 275, 295, 14, 2014, 2336, 7, 435, 1851, 8357, 9, 507, 198, 14588, 9959, 275, 295, 14, 2014, 8, 846, 8357, 9, 507, 198, 66, 2931, 3049, 9959, 275, 295, 14, 2014, 360, 330, 6883, 283, 435, 3384, 8357, 9, 507, 198, 384, 9959, 275, 295, 14, 2014, 360, 2160, 358, 507, 198, 3088, 9959, 275, 295, 14, 2014, 8, 3088, 8357, 9, 507, 198, 3088, 3049, 9959, 275, 295, 14, 2014, 360, 1073, 15, 27732, 283, 435, 4497, 8357, 9, 2742, 198, 509, 1004, 315, 754, 14, 7644, 837, 686, 198, 1294, 275, 1004, 14, 1913, 1252, 1294, 360, 1656, 18, 9, 686, 198, 692, 3715, 59, 17, 61, 4439, 17, 61, 508, 13395, 26, 1585, 198, 384, 275, 291, 14, 1135, 4527, 4486, 8, 384, 9959, 12, 3715, 59, 18, 566, 1585, 198, 3088, 275, 291, 14, 1135, 4527, 4486, 8, 3088, 9959, 12, 291, 14, 1135, 4527, 4486, 8, 3088, 3049, 9959, 12, 3715, 59, 18, 2459, 1585, 198, 692, 1536, 365, 440, 488, 26, 1871, 198, 576, 459, 384, 418, 275, 715, 1871, 198, 692, 13395, 365, 440, 283, 320, 356, 4671, 198, 277, 14, 11786, 18680, 14, 740, 8, 11166, 9, 1585, 198, 692, 4497, 365, 440, 488, 26, 1871, 198, 576, 459, 3088, 418, 275, 4497, 686, 198, 692, 3715, 59, 17, 61, 508, 13395, 26, 1585, 198, 692, 295, 14, 1733, 8, 2966, 1772 ]
[ 295, 199, 646, 747, 199, 504, 2838, 492, 627, 199, 504, 17823, 14, 9270, 492, 19809, 199, 504, 17823, 14, 5061, 7004, 492, 8963, 199, 504, 30317, 14, 5061, 492, 11349, 4311, 199, 199, 533, 7220, 26, 199, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 73, 4309, 275, 1052, 507, 198, 277, 14, 11786, 4491, 2767, 12552, 275, 942, 507, 198, 277, 14, 4491, 2223, 275, 378, 507, 198, 277, 14, 27664, 2223, 275, 378, 507, 198, 277, 14, 28620, 275, 942, 507, 198, 277, 14, 12391, 3557, 63, 1393, 275, 298, 12391, 3557, 2, 507, 198, 277, 14, 9270, 275, 19809, 342, 507, 198, 277, 14, 3834, 9270, 275, 19809, 342, 507, 198, 277, 14, 10506, 9270, 275, 19809, 342, 507, 198, 277, 14, 24891, 4267, 9270, 275, 19809, 342, 507, 198, 277, 14, 8222, 4267, 9270, 275, 19809, 342, 507, 198, 277, 14, 3958, 4491, 9270, 275, 19809, 342, 507, 198, 277, 14, 27664, 9270, 275, 19809, 342, 507, 198, 277, 14, 22638, 9270, 275, 19809, 342, 507, 198, 277, 14, 888, 63, 2179, 275, 488, 507, 198, 277, 14, 17317, 5866, 275, 1052, 507, 198, 277, 14, 1502, 63, 7436, 275, 942, 507, 198, 277, 14, 87, 1502, 63, 7436, 275, 942, 507, 198, 277, 14, 3846, 6405, 7079, 275, 488, 507, 198, 277, 14, 362, 18680, 342, 421, 198, 318, 641, 6713, 6405, 7079, 8, 277, 304, 507, 198, 692, 291, 14, 3846, 6405, 7079, 365, 488, 26, 686, 198, 646, 22825, 4032, 686, 198, 509, 4184, 315, 22825, 4032, 14, 362, 15019, 24467, 83, 837, 1585, 198, 692, 4184, 59, 17, 61, 508, 7324, 436, 4184, 59, 18, 61, 508, 283, 19591, 356, 1871, 198, 277, 14, 3846, 6405, 7079, 275, 715, 1871, 198, 4785, 686, 198, 2836, 26, 1585, 198, 277, 14, 3846, 6405, 7079, 275, 756, 507, 198, 1107, 291, 14, 3846, 6405, 7079, 421, 198, 318, 365, 23405, 15023, 8, 277, 12, 13395, 304, 507, 198, 1107, 13395, 315, 661, 320, 297, 283, 4326, 16, 297, 283, 87, 4133, 16, 297, 283, 2221, 16, 297, 283, 10032, 16, 358, 421, 198, 318, 664, 18680, 8, 277, 12, 3233, 275, 488, 304, 507, 198, 277, 14, 11786, 18680, 275, 942, 507, 198, 509, 2243, 315, 291, 14, 362, 21268, 2767, 12552, 837, 686, 198, 277, 14, 362, 11404, 14796, 8, 1782, 12, 3233, 9, 421, 198, 3, 5922, 805, 199, 198, 318, 1295, 4527, 4486, 8, 277, 12, 3851, 12, 1059, 304, 507, 198, 692, 1059, 365, 488, 26, 686, 198, 1107, 488, 507, 198, 893, 26, 686, 198, 1107, 3851, 14, 1733, 8, 875, 680, 923, 342, 507, 198, 2590, 4281, 26, 686, 198, 1107, 488, 421, 198, 3, 5922, 805, 370, 3957, 15017, 687, 282, 308, 5985, 370, 282, 769, 402, 14526, 199, 198, 318, 3957, 1772, 8, 277, 12, 3384, 304, 507, 198, 1107, 359, 1109, 8, 78, 9, 367, 302, 315, 3384, 14, 1294, 7563, 1622, 421, 198, 318, 664, 11404, 14796, 8, 277, 12, 13395, 12, 3233, 304, 507, 198, 692, 440, 291, 14, 9270, 26, 686, 198, 277, 14, 9270, 275, 19809, 342, 507, 198, 1760, 275, 298, 711, 446, 79, 5552, 2498, 4866, 298, 435, 13395, 507, 198, 277, 14, 9270, 14, 69, 7942, 8, 1760, 12, 291, 14, 1772, 2697, 13430, 12, 359, 11166, 12, 3058, 566, 421, 198, 318, 3531, 2697, 13430, 8, 277, 12, 754, 12, 9151, 12, 2402, 63, 589, 304, 507, 198, 8, 11166, 12, 3233, 776, 275, 2402, 63, 589, 507, 198, 576, 275, 469, 283, 384, 356, 756, 12, 283, 10801, 356, 756, 12, 283, 657, 384, 7, 520, 756, 12, 283, 5991, 944, 7, 520, 756, 789, 507, 198, 2966, 1772, 3401, 275, 295, 14, 2014, 480, 2645, 2288, 531, 507, 198, 711, 8357, 275, 6730, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 93, 27658, 16, 13, 25, 8194, 17, 12, 19, 6834, 507, 198, 846, 8357, 275, 6730, 16, 13, 25, 8194, 17, 12, 18, 6834, 507, 198, 3088, 8357, 275, 6730, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 4988, 7766, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 18, 6834, 507, 198, 711, 3049, 9959, 275, 295, 14, 2014, 360, 10811, 283, 435, 3384, 8357, 435, 15107, 507, 198, 711, 9959, 275, 295, 14, 2014, 8, 711, 8357, 9, 507, 198, 14588, 3049, 9959, 275, 295, 14, 2014, 2336, 7, 435, 1851, 8357, 9, 507, 198, 14588, 9959, 275, 295, 14, 2014, 8, 846, 8357, 9, 507, 198, 66, 2931, 3049, 9959, 275, 295, 14, 2014, 360, 330, 6883, 283, 435, 3384, 8357, 9, 507, 198, 384, 9959, 275, 295, 14, 2014, 360, 2160, 358, 507, 198, 3088, 9959, 275, 295, 14, 2014, 8, 3088, 8357, 9, 507, 198, 3088, 3049, 9959, 275, 295, 14, 2014, 360, 1073, 15, 27732, 283, 435, 4497, 8357, 9, 2742, 198, 509, 1004, 315, 754, 14, 7644, 837, 686, 198, 1294, 275, 1004, 14, 1913, 1252, 1294, 360, 1656, 18, 9, 686, 198, 692, 3715, 59, 17, 61, 4439, 17, 61, 508, 13395, 26, 1585, 198, 384, 275, 291, 14, 1135, 4527, 4486, 8, 384, 9959, 12, 3715, 59, 18, 566, 1585, 198, 3088, 275, 291, 14, 1135, 4527, 4486, 8, 3088, 9959, 12, 291, 14, 1135, 4527, 4486, 8, 3088, 3049, 9959, 12, 3715, 59, 18, 2459, 1585, 198, 692, 1536, 365, 440, 488, 26, 1871, 198, 576, 459, 384, 418, 275, 715, 1871, 198, 692, 13395, 365, 440, 283, 320, 356, 4671, 198, 277, 14, 11786, 18680, 14, 740, 8, 11166, 9, 1585, 198, 692, 4497, 365, 440, 488, 26, 1871, 198, 576, 459, 3088, 418, 275, 4497, 686, 198, 692, 3715, 59, 17, 61, 508, 13395, 26, 1585, 198, 692, 295, 14, 1733, 8, 2966, 1772, 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,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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 ]
jerel/readthedocs.org
fabfile-development.py
33
1956
from fabric.api import cd, env, prefix, run, sudo, task # Fill out USER and HOSTS configuration before running env.user = '' env.hosts = [''] env.code_dir = '/home/%s/rtd/checkouts/readthedocs.org' % (env.user) env.virtualenv = '/home/%s/rtd' % (env.user) def install_prerequisites(): """Install prerequisites.""" sudo("apt-get -y install python-dev python-pip git redis-server texlive " "texlive-latex-extra") sudo("pip install virtualenv") def create_virtualenv(): """Create virtualenv.""" run("virtualenv --no-site-packages --distribute rtd") def clone_repository(): """Clone readthedocs repo""" run("mkdir %s/checkouts" % (env.virtualenv)) with cd("%s/checkouts" % env.virtualenv): run("git clone http://github.com/rtfd/readthedocs.org.git") def pip_requirements(): """Install pip requirements""" with cd(env.code_dir): with prefix("source %s/bin/activate" % (env.virtualenv)): run("pip install -r requirements/pip.txt") def build_db(): """Build database""" with prefix("source %s/bin/activate" % (env.virtualenv)): run("%s/readthedocs/manage.py migrate" % (env.code_dir)) def load_testprojects(): """Load test data and update repos""" with prefix("source %s/bin/activate" % (env.virtualenv)): run("%s/readthedocs/manage.py loaddata test_data" % (env.code_dir)) run("%s/readthedocs/manage.py update_repos" % (env.code_dir)) @task(default=True) def install(): """Install readthedocs""" install_prerequisites() create_virtualenv() clone_repository() pip_requirements() build_db() load_testprojects() @task def clean(): """Clean up everything to start over""" sudo("rm -rf %s" % (env.virtualenv)) sudo("pip uninstall virtualenv") sudo("apt-get -y purge python-dev python-pip git redis-server texlive " "texlive-latex-extra") sudo("apt-get -y autoremove --purge")
mit
[ 504, 2630, 14, 1246, 492, 12829, 12, 2589, 12, 2403, 12, 1255, 12, 14682, 12, 2120, 199, 199, 3, 24797, 734, 13044, 436, 25741, 51, 2897, 2544, 3879, 199, 1813, 14, 751, 275, 2125, 199, 1813, 14, 5146, 275, 24506, 199, 199, 1813, 14, 600, 63, 694, 275, 1994, 4219, 3149, 83, 15, 29048, 15, 12891, 83, 15, 25085, 14, 1308, 7, 450, 334, 1813, 14, 751, 9, 199, 1813, 14, 21611, 275, 1994, 4219, 3149, 83, 15, 29048, 7, 450, 334, 1813, 14, 751, 9, 421, 199, 318, 3907, 63, 657, 30140, 837, 272, 408, 8154, 876, 30140, 1041, 272, 14682, 480, 6182, 13, 362, 446, 89, 3907, 2366, 13, 2374, 2366, 13, 9983, 6135, 16967, 13, 1000, 14709, 6442, 298, 268, 298, 3858, 6442, 13, 7572, 13, 2911, 531, 272, 14682, 480, 9983, 3907, 19128, 531, 421, 199, 318, 1218, 63, 21611, 837, 272, 408, 2499, 19128, 1041, 272, 1255, 480, 21611, 1553, 889, 13, 2124, 13, 5154, 1553, 3470, 519, 2076, 531, 421, 199, 318, 7289, 63, 8421, 837, 272, 408, 21222, 1586, 22618, 3831, 624, 272, 1255, 480, 8215, 450, 83, 15, 12891, 83, 2, 450, 334, 1813, 14, 21611, 430, 272, 543, 12829, 3647, 83, 15, 12891, 83, 2, 450, 2589, 14, 21611, 304, 267, 1255, 480, 3187, 7289, 1455, 921, 5031, 14, 957, 15, 2591, 2592, 15, 25085, 14, 1308, 14, 3187, 531, 421, 199, 318, 7305, 63, 7538, 837, 272, 408, 8154, 7305, 9760, 624, 272, 543, 12829, 8, 1813, 14, 600, 63, 694, 304, 267, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 288, 1255, 480, 9983, 3907, 446, 82, 9760, 15, 9983, 14, 2424, 531, 421, 199, 318, 1900, 63, 697, 837, 272, 408, 3425, 3050, 624, 272, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 12810, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 421, 199, 318, 2248, 63, 396, 6776, 837, 272, 408, 6200, 511, 666, 436, 1678, 20416, 624, 272, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 560, 525, 419, 511, 63, 576, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 1678, 63, 11857, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 421, 199, 32, 1765, 8, 885, 29, 549, 9, 199, 318, 3907, 837, 272, 408, 8154, 1586, 22618, 624, 272, 3907, 63, 657, 30140, 342, 272, 1218, 63, 21611, 342, 272, 7289, 63, 8421, 342, 272, 7305, 63, 7538, 342, 272, 1900, 63, 697, 342, 272, 2248, 63, 396, 6776, 342, 421, 199, 32, 1765, 199, 318, 3633, 837, 272, 408, 6580, 1536, 8137, 370, 1343, 1806, 624, 272, 14682, 480, 5682, 446, 3941, 450, 83, 2, 450, 334, 1813, 14, 21611, 430, 272, 14682, 480, 9983, 22199, 19128, 531, 272, 14682, 480, 6182, 13, 362, 446, 89, 18503, 2366, 13, 2374, 2366, 13, 9983, 6135, 16967, 13, 1000, 14709, 6442, 298, 268, 298, 3858, 6442, 13, 7572, 13, 2911, 531, 272, 14682, 480, 6182, 13, 362, 446, 89, 28589, 1185, 1553, 18254, 531, 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 ]
[ 2630, 14, 1246, 492, 12829, 12, 2589, 12, 2403, 12, 1255, 12, 14682, 12, 2120, 199, 199, 3, 24797, 734, 13044, 436, 25741, 51, 2897, 2544, 3879, 199, 1813, 14, 751, 275, 2125, 199, 1813, 14, 5146, 275, 24506, 199, 199, 1813, 14, 600, 63, 694, 275, 1994, 4219, 3149, 83, 15, 29048, 15, 12891, 83, 15, 25085, 14, 1308, 7, 450, 334, 1813, 14, 751, 9, 199, 1813, 14, 21611, 275, 1994, 4219, 3149, 83, 15, 29048, 7, 450, 334, 1813, 14, 751, 9, 421, 199, 318, 3907, 63, 657, 30140, 837, 272, 408, 8154, 876, 30140, 1041, 272, 14682, 480, 6182, 13, 362, 446, 89, 3907, 2366, 13, 2374, 2366, 13, 9983, 6135, 16967, 13, 1000, 14709, 6442, 298, 268, 298, 3858, 6442, 13, 7572, 13, 2911, 531, 272, 14682, 480, 9983, 3907, 19128, 531, 421, 199, 318, 1218, 63, 21611, 837, 272, 408, 2499, 19128, 1041, 272, 1255, 480, 21611, 1553, 889, 13, 2124, 13, 5154, 1553, 3470, 519, 2076, 531, 421, 199, 318, 7289, 63, 8421, 837, 272, 408, 21222, 1586, 22618, 3831, 624, 272, 1255, 480, 8215, 450, 83, 15, 12891, 83, 2, 450, 334, 1813, 14, 21611, 430, 272, 543, 12829, 3647, 83, 15, 12891, 83, 2, 450, 2589, 14, 21611, 304, 267, 1255, 480, 3187, 7289, 1455, 921, 5031, 14, 957, 15, 2591, 2592, 15, 25085, 14, 1308, 14, 3187, 531, 421, 199, 318, 7305, 63, 7538, 837, 272, 408, 8154, 7305, 9760, 624, 272, 543, 12829, 8, 1813, 14, 600, 63, 694, 304, 267, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 288, 1255, 480, 9983, 3907, 446, 82, 9760, 15, 9983, 14, 2424, 531, 421, 199, 318, 1900, 63, 697, 837, 272, 408, 3425, 3050, 624, 272, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 12810, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 421, 199, 318, 2248, 63, 396, 6776, 837, 272, 408, 6200, 511, 666, 436, 1678, 20416, 624, 272, 543, 2403, 480, 1365, 450, 83, 15, 1393, 15, 8222, 2, 450, 334, 1813, 14, 21611, 2298, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 560, 525, 419, 511, 63, 576, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 267, 1255, 3647, 83, 15, 25085, 15, 9053, 14, 647, 1678, 63, 11857, 2, 450, 334, 1813, 14, 600, 63, 694, 430, 421, 199, 32, 1765, 8, 885, 29, 549, 9, 199, 318, 3907, 837, 272, 408, 8154, 1586, 22618, 624, 272, 3907, 63, 657, 30140, 342, 272, 1218, 63, 21611, 342, 272, 7289, 63, 8421, 342, 272, 7305, 63, 7538, 342, 272, 1900, 63, 697, 342, 272, 2248, 63, 396, 6776, 342, 421, 199, 32, 1765, 199, 318, 3633, 837, 272, 408, 6580, 1536, 8137, 370, 1343, 1806, 624, 272, 14682, 480, 5682, 446, 3941, 450, 83, 2, 450, 334, 1813, 14, 21611, 430, 272, 14682, 480, 9983, 22199, 19128, 531, 272, 14682, 480, 6182, 13, 362, 446, 89, 18503, 2366, 13, 2374, 2366, 13, 9983, 6135, 16967, 13, 1000, 14709, 6442, 298, 268, 298, 3858, 6442, 13, 7572, 13, 2911, 531, 272, 14682, 480, 6182, 13, 362, 446, 89, 28589, 1185, 1553, 18254, 531, 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, 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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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 ]
nadley/Sick-Beard
lib/guessit/transfo/guess_movie_title_from_position.py
48
6590
#!/usr/bin/env python # -*- coding: utf-8 -*- # # GuessIt - A library for guessing information from filenames # Copyright (c) 2012 Nicolas Wack <wackou@gmail.com> # # GuessIt is free software; you can redistribute it and/or modify it under # the terms of the Lesser GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GuessIt 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 # Lesser GNU General Public License for more details. # # You should have received a copy of the Lesser GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from __future__ import unicode_literals from guessit import Guess import unicodedata import logging log = logging.getLogger(__name__) def process(mtree): def found_property(node, name, value, confidence): node.guess = Guess({ name: value }, confidence=confidence) log.debug('Found with confidence %.2f: %s' % (confidence, node.guess)) def found_title(node, confidence): found_property(node, 'title', node.clean_value, confidence) basename = mtree.node_at((-2,)) all_valid = lambda leaf: len(leaf.clean_value) > 0 basename_leftover = basename.unidentified_leaves(valid=all_valid) try: folder = mtree.node_at((-3,)) folder_leftover = folder.unidentified_leaves() except ValueError: folder = None folder_leftover = [] log.debug('folder: %s' % folder_leftover) log.debug('basename: %s' % basename_leftover) # specific cases: # if we find the same group both in the folder name and the filename, # it's a good candidate for title if (folder_leftover and basename_leftover and folder_leftover[0].clean_value == basename_leftover[0].clean_value): found_title(folder_leftover[0], confidence=0.8) return # specific cases: # if the basename contains a number first followed by an unidentified # group, and the folder only contains 1 unidentified one, then we have # a series # ex: Millenium Trilogy (2009)/(1)The Girl With The Dragon Tattoo(2009).mkv try: series = folder_leftover[0] filmNumber = basename_leftover[0] title = basename_leftover[1] basename_leaves = basename.leaves() num = int(filmNumber.clean_value) log.debug('series: %s' % series.clean_value) log.debug('title: %s' % title.clean_value) if (series.clean_value != title.clean_value and series.clean_value != filmNumber.clean_value and basename_leaves.index(filmNumber) == 0 and basename_leaves.index(title) == 1): found_title(title, confidence=0.6) found_property(series, 'filmSeries', series.clean_value, confidence=0.6) found_property(filmNumber, 'filmNumber', num, confidence=0.6) return except Exception: pass # specific cases: # - movies/tttttt (yyyy)/tttttt.ccc try: if mtree.node_at((-4, 0)).value.lower() == 'movies': folder = mtree.node_at((-3,)) # Note:too generic, might solve all the unittests as they all # contain 'movies' in their path # #if containing_folder.is_leaf() and not containing_folder.guess: # containing_folder.guess = # Guess({ 'title': clean_string(containing_folder.value) }, # confidence=0.7) year_group = folder.first_leaf_containing('year') groups_before = folder.previous_unidentified_leaves(year_group) found_title(groups_before[0], confidence=0.8) return except Exception: pass # if we have either format or videoCodec in the folder containing the file # or one of its parents, then we should probably look for the title in # there rather than in the basename try: props = mtree.previous_leaves_containing(mtree.children[-2], [ 'videoCodec', 'format', 'language' ]) except IndexError: props = [] if props: group_idx = props[0].node_idx[0] if all(g.node_idx[0] == group_idx for g in props): # if they're all in the same group, take leftover info from there leftover = mtree.node_at((group_idx,)).unidentified_leaves() if leftover: found_title(leftover[0], confidence=0.7) return # look for title in basename if there are some remaining undidentified # groups there if basename_leftover: title_candidate = basename_leftover[0] # if basename is only one word and the containing folder has at least # 3 words in it, we should take the title from the folder name # ex: Movies/Alice in Wonderland DVDRip.XviD-DiAMOND/dmd-aw.avi # ex: Movies/Somewhere.2010.DVDRip.XviD-iLG/i-smwhr.avi <-- TODO: gets caught here? if (title_candidate.clean_value.count(' ') == 0 and folder_leftover and folder_leftover[0].clean_value.count(' ') >= 2): found_title(folder_leftover[0], confidence=0.7) return # if there are only 2 unidentified groups, the first of which is inside # brackets or parentheses, we take the second one for the title: # ex: Movies/[阿维达].Avida.2006.FRENCH.DVDRiP.XViD-PROD.avi if len(basename_leftover) == 2 and basename_leftover[0].is_explicit(): found_title(basename_leftover[1], confidence=0.8) return # if all else fails, take the first remaining unidentified group in the # basename as title found_title(title_candidate, confidence=0.6) return # if there are no leftover groups in the basename, look in the folder name if folder_leftover: found_title(folder_leftover[0], confidence=0.5) return # if nothing worked, look if we have a very small group at the beginning # of the basename basename = mtree.node_at((-2,)) basename_leftover = basename.unidentified_leaves(valid=lambda leaf: True) if basename_leftover: found_title(basename_leftover[0], confidence=0.4) return
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 24570, 7940, 446, 437, 3555, 367, 9519, 316, 2556, 687, 6203, 199, 3, 1898, 334, 67, 9, 6029, 30650, 761, 305, 644, 564, 665, 87, 564, 810, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 24570, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 6401, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24570, 7940, 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, 6401, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 6401, 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, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 19977, 2221, 492, 24570, 199, 646, 23128, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 2112, 8, 7967, 304, 272, 347, 1911, 63, 1829, 8, 932, 12, 536, 12, 574, 12, 15197, 304, 267, 1031, 14, 11636, 275, 24570, 2561, 536, 26, 574, 1660, 2574, 15197, 29, 13969, 9, 267, 943, 14, 1757, 360, 3601, 543, 15197, 10536, 18, 70, 26, 450, 83, 7, 450, 334, 13969, 12, 1031, 14, 11636, 430, 339, 347, 1911, 63, 1213, 8, 932, 12, 15197, 304, 267, 1911, 63, 1829, 8, 932, 12, 283, 1213, 297, 1031, 14, 3118, 63, 585, 12, 15197, 9, 339, 9593, 275, 333, 2350, 14, 932, 63, 292, 18138, 18, 4641, 272, 1006, 63, 1078, 275, 2400, 11747, 26, 822, 8, 8914, 14, 3118, 63, 585, 9, 690, 378, 272, 9593, 63, 21491, 25084, 275, 9593, 14, 5411, 848, 8981, 63, 16554, 8, 1078, 29, 452, 63, 1078, 9, 339, 862, 26, 267, 4922, 275, 333, 2350, 14, 932, 63, 292, 18138, 19, 4641, 267, 4922, 63, 21491, 25084, 275, 4922, 14, 5411, 848, 8981, 63, 16554, 342, 272, 871, 1722, 26, 267, 4922, 275, 488, 267, 4922, 63, 21491, 25084, 275, 942, 339, 943, 14, 1757, 360, 3741, 26, 450, 83, 7, 450, 4922, 63, 21491, 25084, 9, 272, 943, 14, 1757, 360, 4846, 26, 450, 83, 7, 450, 9593, 63, 21491, 25084, 9, 339, 327, 2488, 5560, 26, 272, 327, 340, 781, 2342, 314, 2011, 1572, 3865, 315, 314, 4922, 536, 436, 314, 1788, 12, 272, 327, 652, 1159, 282, 6954, 7627, 367, 2538, 272, 340, 334, 3741, 63, 21491, 25084, 436, 9593, 63, 21491, 25084, 436, 267, 4922, 63, 21491, 25084, 59, 16, 1055, 3118, 63, 585, 508, 9593, 63, 21491, 25084, 59, 16, 1055, 3118, 63, 585, 304, 398, 1911, 63, 1213, 8, 3741, 63, 21491, 25084, 59, 16, 467, 15197, 29, 16, 14, 24, 9, 267, 372, 339, 327, 2488, 5560, 26, 272, 327, 340, 314, 9593, 3509, 282, 1329, 1642, 9437, 701, 376, 625, 9281, 8981, 272, 327, 1572, 12, 436, 314, 4922, 1454, 3509, 413, 625, 9281, 8981, 1373, 12, 2066, 781, 1172, 272, 327, 282, 6779, 272, 327, 444, 26, 603, 382, 9465, 12480, 4956, 334, 8664, 15136, 17, 9, 1918, 598, 723, 76, 8777, 710, 577, 2527, 265, 377, 292, 7354, 8, 8664, 680, 30420, 272, 862, 26, 267, 6779, 275, 4922, 63, 21491, 25084, 59, 16, 61, 267, 1794, 77, 3259, 275, 9593, 63, 21491, 25084, 59, 16, 61, 267, 2538, 275, 9593, 63, 21491, 25084, 59, 17, 61, 398, 9593, 63, 16554, 275, 9593, 14, 16554, 342, 398, 1967, 275, 1109, 8, 1289, 77, 3259, 14, 3118, 63, 585, 9, 398, 943, 14, 1757, 360, 5602, 26, 450, 83, 7, 450, 6779, 14, 3118, 63, 585, 9, 267, 943, 14, 1757, 360, 1213, 26, 450, 83, 7, 450, 2538, 14, 3118, 63, 585, 9, 267, 340, 334, 5602, 14, 3118, 63, 585, 1137, 2538, 14, 3118, 63, 585, 436, 288, 6779, 14, 3118, 63, 585, 1137, 1794, 77, 3259, 14, 3118, 63, 585, 436, 288, 9593, 63, 16554, 14, 1080, 8, 1289, 77, 3259, 9, 508, 378, 436, 288, 9593, 63, 16554, 14, 1080, 8, 1213, 9, 508, 413, 304, 953, 1911, 63, 1213, 8, 1213, 12, 15197, 29, 16, 14, 22, 9, 288, 1911, 63, 1829, 8, 5602, 12, 283, 1289, 77, 9641, 297, 2574, 6779, 14, 3118, 63, 585, 12, 15197, 29, 16, 14, 22, 9, 288, 1911, 63, 1829, 8, 1289, 77, 3259, 12, 283, 1289, 77, 3259, 297, 2574, 1967, 12, 15197, 29, 16, 14, 22, 9, 267, 372, 272, 871, 2186, 26, 267, 986, 339, 327, 2488, 5560, 26, 272, 327, 221, 446, 1303, 14484, 15, 6215, 6215, 6215, 334, 18322, 2447, 6215, 6215, 6215, 14, 19504, 272, 862, 26, 267, 340, 333, 2350, 14, 932, 63, 292, 18138, 20, 12, 378, 4992, 585, 14, 2325, 342, 508, 283, 20888, 356, 288, 4922, 275, 333, 2350, 14, 932, 63, 292, 18138, 19, 4641, 953, 327, 3390, 26, 7354, 7809, 12, 5594, 14241, 1006, 314, 2882, 83, 465, 2985, 1006, 288, 327, 1395, 283, 20888, 7, 315, 3932, 931, 288, 327, 288, 327, 692, 3035, 63, 3741, 14, 374, 63, 8914, 342, 436, 440, 3035, 63, 3741, 14, 11636, 26, 288, 327, 259, 3035, 63, 3741, 14, 11636, 275, 288, 327, 263, 24570, 2561, 283, 1213, 356, 3633, 63, 875, 8, 16133, 63, 3741, 14, 585, 9, 1660, 288, 327, 4519, 15197, 29, 16, 14, 23, 9, 953, 5361, 63, 923, 275, 4922, 14, 2246, 63, 8914, 63, 16133, 360, 3403, 358, 288, 4652, 63, 5182, 275, 4922, 14, 6352, 63, 5411, 848, 8981, 63, 16554, 8, 3403, 63, 923, 9, 953, 1911, 63, 1213, 8, 2634, 63, 5182, 59, 16, 467, 15197, 29, 16, 14, 24, 9, 288, 372 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 24570, 7940, 446, 437, 3555, 367, 9519, 316, 2556, 687, 6203, 199, 3, 1898, 334, 67, 9, 6029, 30650, 761, 305, 644, 564, 665, 87, 564, 810, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 24570, 7940, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 6401, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 24570, 7940, 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, 6401, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 6401, 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, 3, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 19977, 2221, 492, 24570, 199, 646, 23128, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 2112, 8, 7967, 304, 272, 347, 1911, 63, 1829, 8, 932, 12, 536, 12, 574, 12, 15197, 304, 267, 1031, 14, 11636, 275, 24570, 2561, 536, 26, 574, 1660, 2574, 15197, 29, 13969, 9, 267, 943, 14, 1757, 360, 3601, 543, 15197, 10536, 18, 70, 26, 450, 83, 7, 450, 334, 13969, 12, 1031, 14, 11636, 430, 339, 347, 1911, 63, 1213, 8, 932, 12, 15197, 304, 267, 1911, 63, 1829, 8, 932, 12, 283, 1213, 297, 1031, 14, 3118, 63, 585, 12, 15197, 9, 339, 9593, 275, 333, 2350, 14, 932, 63, 292, 18138, 18, 4641, 272, 1006, 63, 1078, 275, 2400, 11747, 26, 822, 8, 8914, 14, 3118, 63, 585, 9, 690, 378, 272, 9593, 63, 21491, 25084, 275, 9593, 14, 5411, 848, 8981, 63, 16554, 8, 1078, 29, 452, 63, 1078, 9, 339, 862, 26, 267, 4922, 275, 333, 2350, 14, 932, 63, 292, 18138, 19, 4641, 267, 4922, 63, 21491, 25084, 275, 4922, 14, 5411, 848, 8981, 63, 16554, 342, 272, 871, 1722, 26, 267, 4922, 275, 488, 267, 4922, 63, 21491, 25084, 275, 942, 339, 943, 14, 1757, 360, 3741, 26, 450, 83, 7, 450, 4922, 63, 21491, 25084, 9, 272, 943, 14, 1757, 360, 4846, 26, 450, 83, 7, 450, 9593, 63, 21491, 25084, 9, 339, 327, 2488, 5560, 26, 272, 327, 340, 781, 2342, 314, 2011, 1572, 3865, 315, 314, 4922, 536, 436, 314, 1788, 12, 272, 327, 652, 1159, 282, 6954, 7627, 367, 2538, 272, 340, 334, 3741, 63, 21491, 25084, 436, 9593, 63, 21491, 25084, 436, 267, 4922, 63, 21491, 25084, 59, 16, 1055, 3118, 63, 585, 508, 9593, 63, 21491, 25084, 59, 16, 1055, 3118, 63, 585, 304, 398, 1911, 63, 1213, 8, 3741, 63, 21491, 25084, 59, 16, 467, 15197, 29, 16, 14, 24, 9, 267, 372, 339, 327, 2488, 5560, 26, 272, 327, 340, 314, 9593, 3509, 282, 1329, 1642, 9437, 701, 376, 625, 9281, 8981, 272, 327, 1572, 12, 436, 314, 4922, 1454, 3509, 413, 625, 9281, 8981, 1373, 12, 2066, 781, 1172, 272, 327, 282, 6779, 272, 327, 444, 26, 603, 382, 9465, 12480, 4956, 334, 8664, 15136, 17, 9, 1918, 598, 723, 76, 8777, 710, 577, 2527, 265, 377, 292, 7354, 8, 8664, 680, 30420, 272, 862, 26, 267, 6779, 275, 4922, 63, 21491, 25084, 59, 16, 61, 267, 1794, 77, 3259, 275, 9593, 63, 21491, 25084, 59, 16, 61, 267, 2538, 275, 9593, 63, 21491, 25084, 59, 17, 61, 398, 9593, 63, 16554, 275, 9593, 14, 16554, 342, 398, 1967, 275, 1109, 8, 1289, 77, 3259, 14, 3118, 63, 585, 9, 398, 943, 14, 1757, 360, 5602, 26, 450, 83, 7, 450, 6779, 14, 3118, 63, 585, 9, 267, 943, 14, 1757, 360, 1213, 26, 450, 83, 7, 450, 2538, 14, 3118, 63, 585, 9, 267, 340, 334, 5602, 14, 3118, 63, 585, 1137, 2538, 14, 3118, 63, 585, 436, 288, 6779, 14, 3118, 63, 585, 1137, 1794, 77, 3259, 14, 3118, 63, 585, 436, 288, 9593, 63, 16554, 14, 1080, 8, 1289, 77, 3259, 9, 508, 378, 436, 288, 9593, 63, 16554, 14, 1080, 8, 1213, 9, 508, 413, 304, 953, 1911, 63, 1213, 8, 1213, 12, 15197, 29, 16, 14, 22, 9, 288, 1911, 63, 1829, 8, 5602, 12, 283, 1289, 77, 9641, 297, 2574, 6779, 14, 3118, 63, 585, 12, 15197, 29, 16, 14, 22, 9, 288, 1911, 63, 1829, 8, 1289, 77, 3259, 12, 283, 1289, 77, 3259, 297, 2574, 1967, 12, 15197, 29, 16, 14, 22, 9, 267, 372, 272, 871, 2186, 26, 267, 986, 339, 327, 2488, 5560, 26, 272, 327, 221, 446, 1303, 14484, 15, 6215, 6215, 6215, 334, 18322, 2447, 6215, 6215, 6215, 14, 19504, 272, 862, 26, 267, 340, 333, 2350, 14, 932, 63, 292, 18138, 20, 12, 378, 4992, 585, 14, 2325, 342, 508, 283, 20888, 356, 288, 4922, 275, 333, 2350, 14, 932, 63, 292, 18138, 19, 4641, 953, 327, 3390, 26, 7354, 7809, 12, 5594, 14241, 1006, 314, 2882, 83, 465, 2985, 1006, 288, 327, 1395, 283, 20888, 7, 315, 3932, 931, 288, 327, 288, 327, 692, 3035, 63, 3741, 14, 374, 63, 8914, 342, 436, 440, 3035, 63, 3741, 14, 11636, 26, 288, 327, 259, 3035, 63, 3741, 14, 11636, 275, 288, 327, 263, 24570, 2561, 283, 1213, 356, 3633, 63, 875, 8, 16133, 63, 3741, 14, 585, 9, 1660, 288, 327, 4519, 15197, 29, 16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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 ]
foohooboo/graphql-cookiecutter
config/settings/production.py
1
7200
""" Production Configurations - Use Amazon's S3 for storing static files and uploaded media - Use mailgun to send emails - Use Redis for cache """ from boto.s3.connection import OrdinaryCallingFormat from .base import * # noqa # SECRET CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ SECRET_KEY = env('DJANGO_SECRET_KEY') # This ensures that Django will be able to detect a secure connection # properly on Heroku. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # SECURITY CONFIGURATION # ------------------------------------------------------------------------------ # See https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.security # and https://docs.djangoproject.com/en/dev/howto/deployment/checklist/#run-manage-py-check-deploy # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool( 'DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS', default=True) SECURE_CONTENT_TYPE_NOSNIFF = env.bool( 'DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True) SECURE_BROWSER_XSS_FILTER = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_HTTPONLY = True SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True) CSRF_COOKIE_SECURE = True CSRF_COOKIE_HTTPONLY = True X_FRAME_OPTIONS = 'DENY' # SITE CONFIGURATION # ------------------------------------------------------------------------------ # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['example.com', ]) # END SITE CONFIGURATION INSTALLED_APPS += ['gunicorn', ] # STORAGE CONFIGURATION # ------------------------------------------------------------------------------ # Uploaded Media Files # ------------------------ # See: http://django-storages.readthedocs.io/en/latest/index.html INSTALLED_APPS += ['storages', ] AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID', default='') AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY', default='') AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME', default='') AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIRY = 60 * 60 * 24 * 7 # TODO See: https://github.com/jschneier/django-storages/issues/47 # Revert the following and use str after the above-mentioned bug is fixed in # either django-storage-redux or boto control = 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIRY, AWS_EXPIRY) AWS_HEADERS = { 'Cache-Control': bytes(control).encode('latin-1') } # See: http://stackoverflow.com/questions/10390244/ DEFAULT_FILE_STORAGE = 'config.settings.s3utils.MediaRootS3BotoStorage' MEDIA_URL = 'https://%s.s3.amazonaws.com/media/' % AWS_STORAGE_BUCKET_NAME # Static Assets # ------------------------ STATICFILES_STORAGE = 'config.settings.s3utils.StaticRootS3BotoStorage' STATIC_URL = 'https://%s.s3.amazonaws.com/static/' % AWS_STORAGE_BUCKET_NAME # See: https://github.com/antonagestam/collectfast # For Django 1.7+, 'collectfast' should come before # 'django.contrib.staticfiles' AWS_PRELOAD_METADATA = True INSTALLED_APPS = ['collectfast', ] + INSTALLED_APPS # EMAIL # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', default='graphql cookiecutter <noreply@example.com>') EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[graphql cookiecutter]') SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) # Anymail with Mailgun INSTALLED_APPS += ['anymail', ] ANYMAIL = { 'MAILGUN_API_KEY': env('DJANGO_MAILGUN_API_KEY', default=''), 'MAILGUN_SENDER_DOMAIN': env('MAILGUN_SENDER_DOMAIN', default='') } EMAIL_BACKEND = 'anymail.backends.mailgun.MailgunBackend' # TEMPLATE CONFIGURATION # ------------------------------------------------------------------------------ # See: # https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader TEMPLATES[0]['OPTIONS']['loaders'] = [ ('django.template.loaders.cached.Loader', [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]), ] # DATABASE CONFIGURATION # ------------------------------------------------------------------------------ # Use the Heroku-style specification # Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ DATABASES['default'] = env.db('DATABASE_URL') # CACHING # ------------------------------------------------------------------------------ REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://127.0.0.1:6379'), 0) CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': REDIS_LOCATION, 'OPTIONS': { 'CLIENT_CLASS': 'django_redis.client.DefaultClient', 'IGNORE_EXCEPTIONS': True, # mimics memcache behavior. # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior } } } # LOGGING CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See https://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s ' '%(process)d %(thread)d %(message)s' }, }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false', ], 'class': 'django.utils.log.AdminEmailHandler' }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose', }, }, 'loggers': { 'django.request': { 'handlers': ['mail_admins', ], 'level': 'ERROR', 'propagate': True }, 'django.security.DisallowedHost': { 'level': 'ERROR', 'handlers': ['console', 'mail_admins', ], 'propagate': True } } } # Custom Admin URL, use {% url 'admin:index' %} ADMIN_URL = env('DJANGO_ADMIN_URL', default='/admin') # Your production stuff: Below this line define 3rd party library settings # ------------------------------------------------------------------------------
mit
[ 624, 199, 26432, 4094, 6556, 199, 199, 13, 3645, 14347, 1159, 428, 19, 367, 16915, 2955, 1584, 436, 14238, 5898, 199, 13, 3645, 6016, 17924, 370, 3222, 14931, 199, 13, 3645, 25496, 367, 2581, 199, 199, 624, 199, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 4236, 68, 5354, 23796, 3484, 421, 199, 504, 1275, 1095, 492, 627, 221, 327, 8151, 199, 199, 3, 5795, 11771, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 26, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 4731, 13, 498, 199, 3, 6218, 11897, 1919, 340, 577, 42, 18822, 63, 12961, 63, 3078, 440, 315, 747, 14, 2314, 199, 12961, 63, 3078, 275, 2589, 360, 22848, 63, 12961, 63, 3078, 358, 421, 199, 3, 961, 15620, 626, 5634, 911, 506, 7688, 370, 9696, 282, 11153, 1950, 199, 3, 7684, 641, 18769, 745, 85, 14, 199, 20696, 63, 20026, 63, 5413, 63, 7311, 275, 661, 2856, 63, 56, 63, 22371, 8280, 63, 7459, 297, 283, 2859, 358, 199, 199, 3, 24143, 32712, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5754, 12645, 578, 13, 1176, 14, 5754, 14, 4416, 199, 3, 436, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 21232, 15, 13605, 15, 1074, 513, 12645, 1065, 13, 9053, 13, 647, 13, 1074, 13, 11060, 199, 199, 3, 663, 642, 370, 5212, 4696, 436, 2066, 370, 959, 1085, 5303, 1380, 1265, 883, 557, 432, 652, 5419, 199, 20696, 63, 40, 840, 51, 63, 23319, 275, 5212, 199, 20696, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 275, 2589, 14, 2245, 8, 272, 283, 22848, 63, 20696, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 297, 849, 29, 549, 9, 199, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 275, 2589, 14, 2245, 8, 272, 283, 22848, 63, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 297, 849, 29, 549, 9, 199, 20696, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 275, 715, 199, 12763, 63, 13665, 63, 20696, 275, 715, 199, 12763, 63, 13665, 63, 2856, 10452, 275, 715, 199, 20696, 63, 5413, 63, 19747, 275, 2589, 14, 2245, 360, 22848, 63, 20696, 63, 5413, 63, 19747, 297, 849, 29, 549, 9, 199, 26405, 63, 13665, 63, 20696, 275, 715, 199, 26405, 63, 13665, 63, 2856, 10452, 275, 715, 199, 56, 63, 12683, 63, 8808, 275, 283, 23282, 57, 7, 199, 199, 3, 428, 4427, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 10891, 83, 15, 2261, 1561, 626, 787, 1686, 367, 642, 4770, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 6541, 13, 5146, 199, 17350, 63, 23775, 275, 2589, 14, 513, 360, 22848, 63, 17350, 63, 23775, 297, 849, 2968, 2694, 14, 957, 297, 4794, 199, 3, 7729, 428, 4427, 15869, 15301, 199, 199, 15942, 63, 14219, 847, 788, 71, 29067, 297, 1622, 421, 199, 3, 4384, 726, 2962, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 4949, 4591, 12300, 16920, 199, 3, 10652, 518, 199, 3, 1666, 26, 1455, 921, 1176, 13, 3494, 83, 14, 25085, 14, 2308, 15, 287, 15, 7410, 15, 1080, 14, 1360, 199, 15942, 63, 14219, 847, 788, 3494, 83, 297, 1622, 199, 199, 13226, 63, 11074, 63, 3078, 63, 998, 275, 2589, 360, 22848, 63, 13226, 63, 11074, 63, 3078, 63, 998, 297, 849, 13275, 199, 13226, 63, 12961, 63, 11074, 63, 3078, 275, 2589, 360, 22848, 63, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 849, 13275, 199, 13226, 63, 17467, 63, 20156, 63, 2339, 275, 2589, 360, 22848, 63, 13226, 63, 17467, 63, 20156, 63, 2339, 297, 849, 13275, 199, 13226, 63, 13883, 63, 8366, 63, 20156, 275, 715, 199, 13226, 63, 11938, 5353, 63, 5580, 275, 756, 199, 13226, 63, 51, 19, 63, 11978, 1206, 63, 4807, 275, 4236, 68, 5354, 23796, 3484, 342, 199, 199, 3, 10168, 2581, 2202, 12, 2793, 1133, 1570, 7444, 1265, 5715, 4052, 1265, 3984, 9689, 26, 199, 13226, 63, 25632, 5782, 275, 5212, 627, 5212, 627, 5504, 627, 1520, 199, 199, 3, 3254, 1666, 26, 4178, 921, 5031, 14, 957, 15, 3596, 335, 685, 4446, 15, 1176, 13, 3494, 83, 15, 10115, 15, 2417, 199, 3, 799, 1884, 314, 2569, 436, 675, 620, 2410, 314, 3432, 13, 32016, 379, 6519, 365, 6317, 315, 199, 3, 1902, 1639, 13, 3494, 13, 581, 2521, 503, 6055, 199, 2785, 275, 283, 988, 13, 474, 2458, 68, 12, 308, 13, 988, 474, 2458, 68, 12, 1471, 13, 264, 3502, 7, 450, 334, 13226, 63, 25632, 5782, 12, 10168, 63, 25632, 5782, 9, 199, 13226, 63, 21178, 275, 469, 272, 283, 4437, 13, 3717, 356, 2783, 8, 2785, 680, 2143, 360, 10378, 13, 17, 358, 199, 93, 199, 199, 3, 221, 1666, 26, 1455, 921, 23153, 14, 957, 15, 16069, 15, 709, 1355, 996, 1602, 15, 199, 3472, 63, 3817, 63, 17467, 275, 283, 888, 14, 1751, 14, 83, 19, 1208, 14, 11398, 6405, 51, 19, 20380, 6408, 7, 199, 13669, 63, 2632, 275, 283, 2859, 13827, 83, 14, 83, 19, 14, 21442, 14, 957, 15, 4603, 4805, 450, 10168, 63, 17467, 63, 20156, 63, 2339, 199, 199, 3, 13599, 3709, 2193, 199, 3, 10652, 518, 199, 10449, 9472, 63, 17467, 275, 283, 888, 14, 1751, 14, 83, 19, 1208, 14, 9278, 6405, 51, 19, 20380, 6408, 7, 199, 10449, 63, 2632, 275, 283, 2859, 13827, 83, 14, 83, 19, 14, 21442, 14, 957, 15, 1986, 4805, 450, 10168, 63, 17467, 63, 20156, 63, 2339, 421, 199, 3, 1666, 26, 4178, 921, 5031, 14, 957, 15, 867, 265, 474, 270, 455, 15, 7112, 7015, 199, 3, 2104, 5634, 413, 14, 23, 28061, 283, 7112, 7015, 7, 1077, 11492, 2544, 199, 3, 283, 1176, 14, 2828, 14, 18373, 7, 199, 13226, 63, 4225, 7405, 63, 8314, 275, 715, 199, 15942, 63, 14219, 275, 788, 7112, 7015, 297, 1622, 435, 31061, 63, 14219, 421, 199, 3, 32320, 199, 3, 5620, 10965, 199, 3472, 63, 12491, 63, 10089, 275, 2589, 360, 22848, 63 ]
[ 199, 26432, 4094, 6556, 199, 199, 13, 3645, 14347, 1159, 428, 19, 367, 16915, 2955, 1584, 436, 14238, 5898, 199, 13, 3645, 6016, 17924, 370, 3222, 14931, 199, 13, 3645, 25496, 367, 2581, 199, 199, 624, 199, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 4236, 68, 5354, 23796, 3484, 421, 199, 504, 1275, 1095, 492, 627, 221, 327, 8151, 199, 199, 3, 5795, 11771, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 26, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 4731, 13, 498, 199, 3, 6218, 11897, 1919, 340, 577, 42, 18822, 63, 12961, 63, 3078, 440, 315, 747, 14, 2314, 199, 12961, 63, 3078, 275, 2589, 360, 22848, 63, 12961, 63, 3078, 358, 421, 199, 3, 961, 15620, 626, 5634, 911, 506, 7688, 370, 9696, 282, 11153, 1950, 199, 3, 7684, 641, 18769, 745, 85, 14, 199, 20696, 63, 20026, 63, 5413, 63, 7311, 275, 661, 2856, 63, 56, 63, 22371, 8280, 63, 7459, 297, 283, 2859, 358, 199, 199, 3, 24143, 32712, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5754, 12645, 578, 13, 1176, 14, 5754, 14, 4416, 199, 3, 436, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 21232, 15, 13605, 15, 1074, 513, 12645, 1065, 13, 9053, 13, 647, 13, 1074, 13, 11060, 199, 199, 3, 663, 642, 370, 5212, 4696, 436, 2066, 370, 959, 1085, 5303, 1380, 1265, 883, 557, 432, 652, 5419, 199, 20696, 63, 40, 840, 51, 63, 23319, 275, 5212, 199, 20696, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 275, 2589, 14, 2245, 8, 272, 283, 22848, 63, 20696, 63, 40, 840, 51, 63, 18171, 63, 6348, 7378, 51, 297, 849, 29, 549, 9, 199, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 275, 2589, 14, 2245, 8, 272, 283, 22848, 63, 20696, 63, 9663, 63, 2711, 63, 2826, 8199, 24150, 297, 849, 29, 549, 9, 199, 20696, 63, 31956, 3279, 63, 56, 2300, 63, 9905, 275, 715, 199, 12763, 63, 13665, 63, 20696, 275, 715, 199, 12763, 63, 13665, 63, 2856, 10452, 275, 715, 199, 20696, 63, 5413, 63, 19747, 275, 2589, 14, 2245, 360, 22848, 63, 20696, 63, 5413, 63, 19747, 297, 849, 29, 549, 9, 199, 26405, 63, 13665, 63, 20696, 275, 715, 199, 26405, 63, 13665, 63, 2856, 10452, 275, 715, 199, 56, 63, 12683, 63, 8808, 275, 283, 23282, 57, 7, 199, 199, 3, 428, 4427, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 10891, 83, 15, 2261, 1561, 626, 787, 1686, 367, 642, 4770, 199, 3, 1666, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 6541, 13, 5146, 199, 17350, 63, 23775, 275, 2589, 14, 513, 360, 22848, 63, 17350, 63, 23775, 297, 849, 2968, 2694, 14, 957, 297, 4794, 199, 3, 7729, 428, 4427, 15869, 15301, 199, 199, 15942, 63, 14219, 847, 788, 71, 29067, 297, 1622, 421, 199, 3, 4384, 726, 2962, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 4949, 4591, 12300, 16920, 199, 3, 10652, 518, 199, 3, 1666, 26, 1455, 921, 1176, 13, 3494, 83, 14, 25085, 14, 2308, 15, 287, 15, 7410, 15, 1080, 14, 1360, 199, 15942, 63, 14219, 847, 788, 3494, 83, 297, 1622, 199, 199, 13226, 63, 11074, 63, 3078, 63, 998, 275, 2589, 360, 22848, 63, 13226, 63, 11074, 63, 3078, 63, 998, 297, 849, 13275, 199, 13226, 63, 12961, 63, 11074, 63, 3078, 275, 2589, 360, 22848, 63, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 849, 13275, 199, 13226, 63, 17467, 63, 20156, 63, 2339, 275, 2589, 360, 22848, 63, 13226, 63, 17467, 63, 20156, 63, 2339, 297, 849, 13275, 199, 13226, 63, 13883, 63, 8366, 63, 20156, 275, 715, 199, 13226, 63, 11938, 5353, 63, 5580, 275, 756, 199, 13226, 63, 51, 19, 63, 11978, 1206, 63, 4807, 275, 4236, 68, 5354, 23796, 3484, 342, 199, 199, 3, 10168, 2581, 2202, 12, 2793, 1133, 1570, 7444, 1265, 5715, 4052, 1265, 3984, 9689, 26, 199, 13226, 63, 25632, 5782, 275, 5212, 627, 5212, 627, 5504, 627, 1520, 199, 199, 3, 3254, 1666, 26, 4178, 921, 5031, 14, 957, 15, 3596, 335, 685, 4446, 15, 1176, 13, 3494, 83, 15, 10115, 15, 2417, 199, 3, 799, 1884, 314, 2569, 436, 675, 620, 2410, 314, 3432, 13, 32016, 379, 6519, 365, 6317, 315, 199, 3, 1902, 1639, 13, 3494, 13, 581, 2521, 503, 6055, 199, 2785, 275, 283, 988, 13, 474, 2458, 68, 12, 308, 13, 988, 474, 2458, 68, 12, 1471, 13, 264, 3502, 7, 450, 334, 13226, 63, 25632, 5782, 12, 10168, 63, 25632, 5782, 9, 199, 13226, 63, 21178, 275, 469, 272, 283, 4437, 13, 3717, 356, 2783, 8, 2785, 680, 2143, 360, 10378, 13, 17, 358, 199, 93, 199, 199, 3, 221, 1666, 26, 1455, 921, 23153, 14, 957, 15, 16069, 15, 709, 1355, 996, 1602, 15, 199, 3472, 63, 3817, 63, 17467, 275, 283, 888, 14, 1751, 14, 83, 19, 1208, 14, 11398, 6405, 51, 19, 20380, 6408, 7, 199, 13669, 63, 2632, 275, 283, 2859, 13827, 83, 14, 83, 19, 14, 21442, 14, 957, 15, 4603, 4805, 450, 10168, 63, 17467, 63, 20156, 63, 2339, 199, 199, 3, 13599, 3709, 2193, 199, 3, 10652, 518, 199, 10449, 9472, 63, 17467, 275, 283, 888, 14, 1751, 14, 83, 19, 1208, 14, 9278, 6405, 51, 19, 20380, 6408, 7, 199, 10449, 63, 2632, 275, 283, 2859, 13827, 83, 14, 83, 19, 14, 21442, 14, 957, 15, 1986, 4805, 450, 10168, 63, 17467, 63, 20156, 63, 2339, 421, 199, 3, 1666, 26, 4178, 921, 5031, 14, 957, 15, 867, 265, 474, 270, 455, 15, 7112, 7015, 199, 3, 2104, 5634, 413, 14, 23, 28061, 283, 7112, 7015, 7, 1077, 11492, 2544, 199, 3, 283, 1176, 14, 2828, 14,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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 ]
EiNSTeiN-/idapython
pywraps/py_ua.py
1
21392
#<pycode(py_ua)> # ----------------------------------------------------------------------- class op_t(py_clinked_object_t): """Class representing operands""" def __init__(self, lnk = None): py_clinked_object_t.__init__(self, lnk) def _create_clink(self): return _idaapi.op_t_create() def _del_clink(self, lnk): return _idaapi.op_t_destroy(lnk) def assign(self, other): """Copies the contents of 'other' to 'self'""" return _idaapi.op_t_assign(self, other) def __eq__(self, other): """Checks if two register operands are equal by checking the register number and its dtype""" return (self.reg == other.reg) and (self.dtyp == other.dtyp) def is_reg(self, r): """Checks if the register operand is the given processor register""" return self.type == o_reg and self.reg == r def has_reg(self, r): """Checks if the operand accesses the given processor register""" return self.reg == r.reg # # Autogenerated # def __get_n__(self): return _idaapi.op_t_get_n(self) def __set_n__(self, v): _idaapi.op_t_set_n(self, v) def __get_type__(self): return _idaapi.op_t_get_type(self) def __set_type__(self, v): _idaapi.op_t_set_type(self, v) def __get_offb__(self): return _idaapi.op_t_get_offb(self) def __set_offb__(self, v): _idaapi.op_t_set_offb(self, v) def __get_offo__(self): return _idaapi.op_t_get_offo(self) def __set_offo__(self, v): _idaapi.op_t_set_offo(self, v) def __get_flags__(self): return _idaapi.op_t_get_flags(self) def __set_flags__(self, v): _idaapi.op_t_set_flags(self, v) def __get_dtyp__(self): return _idaapi.op_t_get_dtyp(self) def __set_dtyp__(self, v): _idaapi.op_t_set_dtyp(self, v) def __get_reg_phrase__(self): return _idaapi.op_t_get_reg_phrase(self) def __set_reg_phrase__(self, v): _idaapi.op_t_set_reg_phrase(self, v) def __get_value__(self): return _idaapi.op_t_get_value(self) def __set_value__(self, v): _idaapi.op_t_set_value(self, v) def __get_addr__(self): return _idaapi.op_t_get_addr(self) def __set_addr__(self, v): _idaapi.op_t_set_addr(self, v) def __get_specval__(self): return _idaapi.op_t_get_specval(self) def __set_specval__(self, v): _idaapi.op_t_set_specval(self, v) def __get_specflag1__(self): return _idaapi.op_t_get_specflag1(self) def __set_specflag1__(self, v): _idaapi.op_t_set_specflag1(self, v) def __get_specflag2__(self): return _idaapi.op_t_get_specflag2(self) def __set_specflag2__(self, v): _idaapi.op_t_set_specflag2(self, v) def __get_specflag3__(self): return _idaapi.op_t_get_specflag3(self) def __set_specflag3__(self, v): _idaapi.op_t_set_specflag3(self, v) def __get_specflag4__(self): return _idaapi.op_t_get_specflag4(self) def __set_specflag4__(self, v): _idaapi.op_t_set_specflag4(self, v) n = property(__get_n__, __set_n__) type = property(__get_type__, __set_type__) offb = property(__get_offb__, __set_offb__) offo = property(__get_offo__, __set_offo__) flags = property(__get_flags__, __set_flags__) dtyp = property(__get_dtyp__, __set_dtyp__) reg = property(__get_reg_phrase__, __set_reg_phrase__) phrase = property(__get_reg_phrase__, __set_reg_phrase__) value = property(__get_value__, __set_value__) addr = property(__get_addr__, __set_addr__) specval = property(__get_specval__, __set_specval__) specflag1 = property(__get_specflag1__, __set_specflag1__) specflag2 = property(__get_specflag2__, __set_specflag2__) specflag3 = property(__get_specflag3__, __set_specflag3__) specflag4 = property(__get_specflag4__, __set_specflag4__) # ----------------------------------------------------------------------- class insn_t(py_clinked_object_t): """Class representing instructions""" def __init__(self, lnk = None): py_clinked_object_t.__init__(self, lnk) # Create linked operands self.Operands = [] for i in xrange(0, UA_MAXOP): self.Operands.append(op_t(insn_t_get_op_link(self.clink, i))) # Convenience operand reference objects self.Op1 = self.Operands[0] self.Op2 = self.Operands[1] self.Op3 = self.Operands[2] self.Op4 = self.Operands[3] self.Op5 = self.Operands[4] self.Op6 = self.Operands[5] def assign(self, other): """Copies the contents of 'other' to 'self'""" return _idaapi.insn_t_assign(self, other) #<pydoc> # def copy(self): # """Returns a new copy of this class""" # pass #</pydoc> def _create_clink(self): return _idaapi.insn_t_create() def _del_clink(self, lnk): return _idaapi.insn_t_destroy(lnk) def __iter__(self): return (self.Operands[idx] for idx in xrange(0, UA_MAXOP)) def __getitem__(self, idx): """ Operands can be accessed directly as indexes @return op_t: Returns an operand of type op_t """ if idx >= UA_MAXOP: raise KeyError else: return self.Operands[idx] def is_macro(self): return self.flags & INSN_MACRO != 0 def is_canon_insn(self): return _idaapi.insn_t_is_canon_insn(self.itype) def get_canon_feature(self): return _idaapi.insn_t_get_canon_feature(self.itype) def get_canon_mnem(self): return _idaapi.insn_t_get_canon_mnem(self.itype) # # Autogenerated # def __get_cs__(self): return _idaapi.insn_t_get_cs(self) def __set_cs__(self, v): _idaapi.insn_t_set_cs(self, v) def __get_ip__(self): return _idaapi.insn_t_get_ip(self) def __set_ip__(self, v): _idaapi.insn_t_set_ip(self, v) def __get_ea__(self): return _idaapi.insn_t_get_ea(self) def __set_ea__(self, v): _idaapi.insn_t_set_ea(self, v) def __get_itype__(self): return _idaapi.insn_t_get_itype(self) def __set_itype__(self, v): _idaapi.insn_t_set_itype(self, v) def __get_size__(self): return _idaapi.insn_t_get_size(self) def __set_size__(self, v): _idaapi.insn_t_set_size(self, v) def __get_auxpref__(self): return _idaapi.insn_t_get_auxpref(self) def __set_auxpref__(self, v): _idaapi.insn_t_set_auxpref(self, v) def __get_segpref__(self): return _idaapi.insn_t_get_segpref(self) def __set_segpref__(self, v): _idaapi.insn_t_set_segpref(self, v) def __get_insnpref__(self): return _idaapi.insn_t_get_insnpref(self) def __set_insnpref__(self, v): _idaapi.insn_t_set_insnpref(self, v) def __get_flags__(self): return _idaapi.insn_t_get_flags(self) def __set_flags__(self, v): _idaapi.insn_t_set_flags(self, v) cs = property(__get_cs__, __set_cs__) ip = property(__get_ip__, __set_ip__) ea = property(__get_ea__, __set_ea__) itype = property(__get_itype__, __set_itype__) size = property(__get_size__, __set_size__) auxpref = property(__get_auxpref__, __set_auxpref__) segpref = property(__get_segpref__, __set_segpref__) insnpref = property(__get_insnpref__, __set_insnpref__) flags = property(__get_flags__, __set_flags__) #---------------------------------------------------------------------------- # P R O C E S S O R M O D U L E S C O N S T A N T S #---------------------------------------------------------------------------- # ---------------------------------------------------------------------- # processor_t related constants CUSTOM_CMD_ITYPE = 0x8000 REG_SPOIL = 0x80000000 REAL_ERROR_FORMAT = -1 # not supported format for current .idp REAL_ERROR_RANGE = -2 # number too big (small) for store (mem NOT modifyed) REAL_ERROR_BADDATA = -3 # illegal real data for load (IEEE data not filled) # # Check whether the operand is relative to stack pointer or frame pointer. # This function is used to determine how to output a stack variable # This function may be absent. If it is absent, then all operands # are sp based by default. # Define this function only if some stack references use frame pointer # instead of stack pointer. # returns flags: OP_FP_BASED = 0x00000000 # operand is FP based OP_SP_BASED = 0x00000001 # operand is SP based OP_SP_ADD = 0x00000000 # operand value is added to the pointer OP_SP_SUB = 0x00000002 # operand value is substracted from the pointer # processor_t.id PLFM_386 = 0 # Intel 80x86 PLFM_Z80 = 1 # 8085, Z80 PLFM_I860 = 2 # Intel 860 PLFM_8051 = 3 # 8051 PLFM_TMS = 4 # Texas Instruments TMS320C5x PLFM_6502 = 5 # 6502 PLFM_PDP = 6 # PDP11 PLFM_68K = 7 # Motoroal 680x0 PLFM_JAVA = 8 # Java PLFM_6800 = 9 # Motorola 68xx PLFM_ST7 = 10 # SGS-Thomson ST7 PLFM_MC6812 = 11 # Motorola 68HC12 PLFM_MIPS = 12 # MIPS PLFM_ARM = 13 # Advanced RISC Machines PLFM_TMSC6 = 14 # Texas Instruments TMS320C6x PLFM_PPC = 15 # PowerPC PLFM_80196 = 16 # Intel 80196 PLFM_Z8 = 17 # Z8 PLFM_SH = 18 # Renesas (formerly Hitachi) SuperH PLFM_NET = 19 # Microsoft Visual Studio.Net PLFM_AVR = 20 # Atmel 8-bit RISC processor(s) PLFM_H8 = 21 # Hitachi H8/300, H8/2000 PLFM_PIC = 22 # Microchip's PIC PLFM_SPARC = 23 # SPARC PLFM_ALPHA = 24 # DEC Alpha PLFM_HPPA = 25 # Hewlett-Packard PA-RISC PLFM_H8500 = 26 # Hitachi H8/500 PLFM_TRICORE = 27 # Tasking Tricore PLFM_DSP56K = 28 # Motorola DSP5600x PLFM_C166 = 29 # Siemens C166 family PLFM_ST20 = 30 # SGS-Thomson ST20 PLFM_IA64 = 31 # Intel Itanium IA64 PLFM_I960 = 32 # Intel 960 PLFM_F2MC = 33 # Fujistu F2MC-16 PLFM_TMS320C54 = 34 # Texas Instruments TMS320C54xx PLFM_TMS320C55 = 35 # Texas Instruments TMS320C55xx PLFM_TRIMEDIA = 36 # Trimedia PLFM_M32R = 37 # Mitsubishi 32bit RISC PLFM_NEC_78K0 = 38 # NEC 78K0 PLFM_NEC_78K0S = 39 # NEC 78K0S PLFM_M740 = 40 # Mitsubishi 8bit PLFM_M7700 = 41 # Mitsubishi 16bit PLFM_ST9 = 42 # ST9+ PLFM_FR = 43 # Fujitsu FR Family PLFM_MC6816 = 44 # Motorola 68HC16 PLFM_M7900 = 45 # Mitsubishi 7900 PLFM_TMS320C3 = 46 # Texas Instruments TMS320C3 PLFM_KR1878 = 47 # Angstrem KR1878 PLFM_AD218X = 48 # Analog Devices ADSP 218X PLFM_OAKDSP = 49 # Atmel OAK DSP PLFM_TLCS900 = 50 # Toshiba TLCS-900 PLFM_C39 = 51 # Rockwell C39 PLFM_CR16 = 52 # NSC CR16 PLFM_MN102L00 = 53 # Panasonic MN10200 PLFM_TMS320C1X = 54 # Texas Instruments TMS320C1x PLFM_NEC_V850X = 55 # NEC V850 and V850ES/E1/E2 PLFM_SCR_ADPT = 56 # Processor module adapter for processor modules written in scripting languages PLFM_EBC = 57 # EFI Bytecode PLFM_MSP430 = 58 # Texas Instruments MSP430 PLFM_SPU = 59 # Cell Broadband Engine Synergistic Processor Unit # # processor_t.flag # PR_SEGS = 0x000001 # has segment registers? PR_USE32 = 0x000002 # supports 32-bit addressing? PR_DEFSEG32 = 0x000004 # segments are 32-bit by default PR_RNAMESOK = 0x000008 # allow to user register names for location names PR_ADJSEGS = 0x000020 # IDA may adjust segments moving their starting/ending addresses. PR_DEFNUM = 0x0000C0 # default number representation: PRN_HEX = 0x000000 # hex PRN_OCT = 0x000040 # octal PRN_DEC = 0x000080 # decimal PRN_BIN = 0x0000C0 # binary PR_WORD_INS = 0x000100 # instruction codes are grouped 2bytes in binrary line prefix PR_NOCHANGE = 0x000200 # The user can't change segments and code/data attributes (display only) PR_ASSEMBLE = 0x000400 # Module has a built-in assembler and understands IDP_ASSEMBLE PR_ALIGN = 0x000800 # All data items should be aligned properly PR_TYPEINFO = 0x001000 # the processor module supports # type information callbacks # ALL OF THEM SHOULD BE IMPLEMENTED! # (the ones >= decorate_name) PR_USE64 = 0x002000 # supports 64-bit addressing? PR_SGROTHER = 0x004000 # the segment registers don't contain # the segment selectors, something else PR_STACK_UP = 0x008000 # the stack grows up PR_BINMEM = 0x010000 # the processor module provides correct # segmentation for binary files # (i.e. it creates additional segments) # The kernel will not ask the user # to specify the RAM/ROM sizes PR_SEGTRANS = 0x020000 # the processor module supports # the segment translation feature # (it means it calculates the code # addresses using the codeSeg() function) PR_CHK_XREF = 0x040000 # don't allow near xrefs between segments # with different bases PR_NO_SEGMOVE = 0x080000 # the processor module doesn't support move_segm() # (i.e. the user can't move segments) PR_FULL_HIFXP = 0x100000 # REF_VHIGH operand value contains full operand # not only the high bits. Meaningful if ph.high_fixup_bits PR_USE_ARG_TYPES = 0x200000 # use ph.use_arg_types callback PR_SCALE_STKVARS = 0x400000 # use ph.get_stkvar_scale callback PR_DELAYED = 0x800000 # has delayed jumps and calls PR_ALIGN_INSN = 0x1000000 # allow ida to create alignment instructions # arbirtrarily. Since these instructions # might lead to other wrong instructions # and spoil the listing, IDA does not create # them by default anymore PR_PURGING = 0x2000000 # there are calling conventions which may # purge bytes from the stack PR_CNDINSNS = 0x4000000 # has conditional instructions PR_USE_TBYTE = 0x8000000 # BTMT_SPECFLT means _TBYTE type PR_DEFSEG64 = 0x10000000 # segments are 64-bit by default # ---------------------------------------------------------------------- # # Misc constants # UA_MAXOP = 6 """The maximum number of operands in the insn_t structure""" # Create 'cmd' into the global scope cmd = insn_t(_idaapi.py_get_global_cmd_link()) """cmd is a global variable of type insn_t. It is contains information about the last decoded instruction. This variable is also filled by processor modules when they decode instructions.""" # ---------------------------------------------------------------------- # instruc_t related constants # # instruc_t.feature # CF_STOP = 0x00001 # Instruction doesn't pass execution to the next instruction CF_CALL = 0x00002 # CALL instruction (should make a procedure here) CF_CHG1 = 0x00004 # The instruction modifies the first operand CF_CHG2 = 0x00008 # The instruction modifies the second operand CF_CHG3 = 0x00010 # The instruction modifies the third operand CF_CHG4 = 0x00020 # The instruction modifies 4 operand CF_CHG5 = 0x00040 # The instruction modifies 5 operand CF_CHG6 = 0x00080 # The instruction modifies 6 operand CF_USE1 = 0x00100 # The instruction uses value of the first operand CF_USE2 = 0x00200 # The instruction uses value of the second operand CF_USE3 = 0x00400 # The instruction uses value of the third operand CF_USE4 = 0x00800 # The instruction uses value of the 4 operand CF_USE5 = 0x01000 # The instruction uses value of the 5 operand CF_USE6 = 0x02000 # The instruction uses value of the 6 operand CF_JUMP = 0x04000 # The instruction passes execution using indirect jump or call (thus needs additional analysis) CF_SHFT = 0x08000 # Bit-shift instruction (shl,shr...) CF_HLL = 0x10000 # Instruction may be present in a high level language function. # ---------------------------------------------------------------------- # op_t related constants # # op_t.type # Description Data field o_void = 0 # No Operand ---------- o_reg = 1 # General Register (al,ax,es,ds...) reg o_mem = 2 # Direct Memory Reference (DATA) addr o_phrase = 3 # Memory Ref [Base Reg + Index Reg] phrase o_displ = 4 # Memory Reg [Base Reg + Index Reg + Displacement] phrase+addr o_imm = 5 # Immediate Value value o_far = 6 # Immediate Far Address (CODE) addr o_near = 7 # Immediate Near Address (CODE) addr o_idpspec0 = 8 # IDP specific type o_idpspec1 = 9 # IDP specific type o_idpspec2 = 10 # IDP specific type o_idpspec3 = 11 # IDP specific type o_idpspec4 = 12 # IDP specific type o_idpspec5 = 13 # IDP specific type o_last = 14 # first unused type # # op_t.dtyp # dt_byte = 0 # 8 bit dt_word = 1 # 16 bit dt_dword = 2 # 32 bit dt_float = 3 # 4 byte dt_double = 4 # 8 byte dt_tbyte = 5 # variable size (ph.tbyte_size) dt_packreal = 6 # packed real format for mc68040 dt_qword = 7 # 64 bit dt_byte16 = 8 # 128 bit dt_code = 9 # ptr to code (not used?) dt_void = 10 # none dt_fword = 11 # 48 bit dt_bitfild = 12 # bit field (mc680x0) dt_string = 13 # pointer to asciiz string dt_unicode = 14 # pointer to unicode string dt_3byte = 15 # 3-byte data dt_ldbl = 16 # long double (which may be different from tbyte) dt_byte32 = 17 # 256 bit dt_byte64 = 18 # 512 bit # # op_t.flags # OF_NO_BASE_DISP = 0x80 # o_displ: base displacement doesn't exist meaningful only for o_displ type if set, base displacement (x.addr) doesn't exist. OF_OUTER_DISP = 0x40 # o_displ: outer displacement exists meaningful only for o_displ type if set, outer displacement (x.value) exists. PACK_FORM_DEF = 0x20 # !o_reg + dt_packreal: packed factor defined OF_NUMBER = 0x10 # can be output as number only if set, the operand can be converted to a number only OF_SHOW = 0x08 # should the operand be displayed? if clear, the operand is hidden and should not be displayed # # insn_t.flags # INSN_MACRO = 0x01 # macro instruction INSN_MODMAC = 0x02 # macros: may modify the database to make room for the macro insn # # Set IDP options constants # IDPOPT_STR = 1 # string constant IDPOPT_NUM = 2 # number IDPOPT_BIT = 3 # bit, yes/no IDPOPT_FLT = 4 # float IDPOPT_I64 = 5 # 64bit number IDPOPT_OK = 0 # ok IDPOPT_BADKEY = 1 # illegal keyword IDPOPT_BADTYPE = 2 # illegal type of value IDPOPT_BADVALUE = 3 # illegal value (bad range, for example) # ---------------------------------------------------------------------- class processor_t(pyidc_opaque_object_t): """Base class for all processor module scripts""" def __init__(self): # Take a reference to 'cmd' self.cmd = cmd def get_idpdesc(self): """ This function must be present and should return the list of short processor names similar to the one in ph.psnames. This method can be overridden to return to the kernel a different IDP description. """ return self.plnames[0] + ':' + ':'.join(self.psnames) def get_uFlag(self): """Use this utility function to retrieve the 'uFlag' global variable""" return _idaapi.cvar.uFlag def get_auxpref(self): """This function returns cmd.auxpref value""" return self.cmd.auxpref # ---------------------------------------------------------------------- class __ph(object): id = property(lambda self: ph_get_id()) cnbits = property(lambda self: ph_get_cnbits()) dnbits = property(lambda self: ph_get_dnbits()) flag = property(lambda self: ph_get_flag()) high_fixup_bits = property(lambda self: ph_get_high_fixup_bits()) icode_return = property(lambda self: ph_get_icode_return()) instruc = property(lambda self: ph_get_instruc()) instruc_end = property(lambda self: ph_get_instruc_end()) instruc_start = property(lambda self: ph_get_instruc_start()) regCodeSreg = property(lambda self: ph_get_regCodeSreg()) regDataSreg = property(lambda self: ph_get_regDataSreg()) regFirstSreg = property(lambda self: ph_get_regFirstSreg()) regLastSreg = property(lambda self: ph_get_regLastSreg()) regnames = property(lambda self: ph_get_regnames()) segreg_size = property(lambda self: ph_get_segreg_size()) tbyte_size = property(lambda self: ph_get_tbyte_size()) version = property(lambda self: ph_get_version()) ph = __ph() #</pycode(py_ua)>
bsd-3-clause
[ 3, 28, 647, 600, 8, 647, 63, 1458, 13032, 199, 199, 3, 5620, 12797, 199, 533, 1687, 63, 84, 8, 647, 63, 429, 2292, 379, 63, 785, 63, 84, 304, 272, 408, 2543, 6144, 15163, 624, 272, 347, 636, 826, 721, 277, 12, 10359, 75, 275, 488, 304, 267, 1134, 63, 429, 2292, 379, 63, 785, 63, 84, 855, 826, 721, 277, 12, 10359, 75, 9, 339, 347, 485, 981, 63, 429, 2292, 8, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 981, 342, 339, 347, 485, 2264, 63, 429, 2292, 8, 277, 12, 10359, 75, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 7237, 8, 6066, 75, 9, 339, 347, 5090, 8, 277, 12, 1163, 304, 267, 408, 29042, 314, 4072, 402, 283, 1848, 7, 370, 283, 277, 26555, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 5038, 8, 277, 12, 1163, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 11834, 340, 2877, 2274, 15163, 787, 4472, 701, 7907, 314, 2274, 1329, 436, 2399, 2152, 624, 267, 372, 334, 277, 14, 1135, 508, 1163, 14, 1135, 9, 436, 334, 277, 14, 68, 9749, 508, 1163, 14, 68, 9749, 9, 339, 347, 365, 63, 1135, 8, 277, 12, 519, 304, 267, 408, 11834, 340, 314, 2274, 14888, 365, 314, 1627, 12495, 2274, 624, 267, 372, 291, 14, 466, 508, 312, 63, 1135, 436, 291, 14, 1135, 508, 519, 339, 347, 965, 63, 1135, 8, 277, 12, 519, 304, 267, 408, 11834, 340, 314, 14888, 1066, 5804, 314, 1627, 12495, 2274, 624, 267, 372, 291, 14, 1135, 508, 519, 14, 1135, 339, 327, 272, 327, 27722, 16741, 272, 327, 272, 347, 636, 362, 63, 78, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 78, 8, 277, 9, 272, 347, 636, 409, 63, 78, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 78, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 466, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 466, 8, 277, 9, 272, 347, 636, 409, 63, 466, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 466, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1997, 66, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1997, 66, 8, 277, 9, 272, 347, 636, 409, 63, 1997, 66, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1997, 66, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1618, 545, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1618, 545, 8, 277, 9, 272, 347, 636, 409, 63, 1618, 545, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1618, 545, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 2469, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 2469, 8, 277, 9, 272, 347, 636, 409, 63, 2469, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 2469, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 68, 9749, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 68, 9749, 8, 277, 9, 272, 347, 636, 409, 63, 68, 9749, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 68, 9749, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1135, 63, 10906, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1135, 63, 10906, 8, 277, 9, 272, 347, 636, 409, 63, 1135, 63, 10906, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1135, 63, 10906, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 585, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 585, 8, 277, 9, 272, 347, 636, 409, 63, 585, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 585, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 2697, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 2697, 8, 277, 9, 272, 347, 636, 409, 63, 2697, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 2697, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 637, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 637, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 637, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 637, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 17, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 17, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 17, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 17, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 18, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 18, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 18, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 18, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 19, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 19, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 19, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 19, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650 ]
[ 28, 647, 600, 8, 647, 63, 1458, 13032, 199, 199, 3, 5620, 12797, 199, 533, 1687, 63, 84, 8, 647, 63, 429, 2292, 379, 63, 785, 63, 84, 304, 272, 408, 2543, 6144, 15163, 624, 272, 347, 636, 826, 721, 277, 12, 10359, 75, 275, 488, 304, 267, 1134, 63, 429, 2292, 379, 63, 785, 63, 84, 855, 826, 721, 277, 12, 10359, 75, 9, 339, 347, 485, 981, 63, 429, 2292, 8, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 981, 342, 339, 347, 485, 2264, 63, 429, 2292, 8, 277, 12, 10359, 75, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 7237, 8, 6066, 75, 9, 339, 347, 5090, 8, 277, 12, 1163, 304, 267, 408, 29042, 314, 4072, 402, 283, 1848, 7, 370, 283, 277, 26555, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 5038, 8, 277, 12, 1163, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 11834, 340, 2877, 2274, 15163, 787, 4472, 701, 7907, 314, 2274, 1329, 436, 2399, 2152, 624, 267, 372, 334, 277, 14, 1135, 508, 1163, 14, 1135, 9, 436, 334, 277, 14, 68, 9749, 508, 1163, 14, 68, 9749, 9, 339, 347, 365, 63, 1135, 8, 277, 12, 519, 304, 267, 408, 11834, 340, 314, 2274, 14888, 365, 314, 1627, 12495, 2274, 624, 267, 372, 291, 14, 466, 508, 312, 63, 1135, 436, 291, 14, 1135, 508, 519, 339, 347, 965, 63, 1135, 8, 277, 12, 519, 304, 267, 408, 11834, 340, 314, 14888, 1066, 5804, 314, 1627, 12495, 2274, 624, 267, 372, 291, 14, 1135, 508, 519, 14, 1135, 339, 327, 272, 327, 27722, 16741, 272, 327, 272, 347, 636, 362, 63, 78, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 78, 8, 277, 9, 272, 347, 636, 409, 63, 78, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 78, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 466, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 466, 8, 277, 9, 272, 347, 636, 409, 63, 466, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 466, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1997, 66, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1997, 66, 8, 277, 9, 272, 347, 636, 409, 63, 1997, 66, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1997, 66, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1618, 545, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1618, 545, 8, 277, 9, 272, 347, 636, 409, 63, 1618, 545, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1618, 545, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 2469, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 2469, 8, 277, 9, 272, 347, 636, 409, 63, 2469, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 2469, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 68, 9749, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 68, 9749, 8, 277, 9, 272, 347, 636, 409, 63, 68, 9749, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 68, 9749, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1135, 63, 10906, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1135, 63, 10906, 8, 277, 9, 272, 347, 636, 409, 63, 1135, 63, 10906, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1135, 63, 10906, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 585, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 585, 8, 277, 9, 272, 347, 636, 409, 63, 585, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 585, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 2697, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 2697, 8, 277, 9, 272, 347, 636, 409, 63, 2697, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 2697, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 637, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 637, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 637, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 637, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 17, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 17, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 17, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 17, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 18, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 18, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 18, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 18, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 4173, 19, 721, 277, 304, 267, 372, 485, 29132, 1246, 14, 411, 63, 84, 63, 362, 63, 1650, 4173, 19, 8, 277, 9, 272, 347, 636, 409, 63, 1650, 4173, 19, 721, 277, 12, 373, 304, 267, 485, 29132, 1246, 14, 411, 63, 84, 63, 409, 63, 1650, 4173, 19, 8, 277, 12, 373, 9, 272, 347, 636, 362, 63, 1650, 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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source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * 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. # * 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 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 OWNER 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. """ Implementation of stream filters for PDF. """ __author__ = "Mathieu Fenniak" __author_email__ = "biziqe@mathieu.fenniak.net" from utils import PdfReadError try: from cStringIO import StringIO except ImportError: from StringIO import StringIO try: import zlib def decompress(data): return zlib.decompress(data) def compress(data): return zlib.compress(data) except ImportError: # Unable to import zlib. Attempt to use the System.IO.Compression # library from the .NET framework. (IronPython only) import System from System import IO, Collections, Array def _string_to_bytearr(buf): retval = Array.CreateInstance(System.Byte, len(buf)) for i in range(len(buf)): retval[i] = ord(buf[i]) return retval def _bytearr_to_string(bytes): retval = "" for i in range(bytes.Length): retval += chr(bytes[i]) return retval def _read_bytes(stream): ms = IO.MemoryStream() buf = Array.CreateInstance(System.Byte, 2048) while True: bytes = stream.Read(buf, 0, buf.Length) if bytes == 0: break else: ms.Write(buf, 0, bytes) retval = ms.ToArray() ms.Close() return retval def decompress(data): bytes = _string_to_bytearr(data) ms = IO.MemoryStream() ms.Write(bytes, 0, bytes.Length) ms.Position = 0 # fseek 0 gz = IO.Compression.DeflateStream(ms, IO.Compression.CompressionMode.Decompress) bytes = _read_bytes(gz) retval = _bytearr_to_string(bytes) gz.Close() return retval def compress(data): bytes = _string_to_bytearr(data) ms = IO.MemoryStream() gz = IO.Compression.DeflateStream(ms, IO.Compression.CompressionMode.Compress, True) gz.Write(bytes, 0, bytes.Length) gz.Close() ms.Position = 0 # fseek 0 bytes = ms.ToArray() retval = _bytearr_to_string(bytes) ms.Close() return retval class FlateDecode(object): def decode(data, decodeParms): data = decompress(data) predictor = 1 if decodeParms: predictor = decodeParms.get("/Predictor", 1) # predictor 1 == no predictor if predictor != 1: columns = decodeParms["/Columns"] # PNG prediction: if predictor >= 10 and predictor <= 15: output = StringIO() # PNG prediction can vary from row to row rowlength = columns + 1 assert len(data) % rowlength == 0 prev_rowdata = (0,) * rowlength for row in xrange(len(data) / rowlength): rowdata = [ord(x) for x in data[(row*rowlength):((row+1)*rowlength)]] filterByte = rowdata[0] if filterByte == 0: pass elif filterByte == 1: for i in range(2, rowlength): rowdata[i] = (rowdata[i] + rowdata[i-1]) % 256 elif filterByte == 2: for i in range(1, rowlength): rowdata[i] = (rowdata[i] + prev_rowdata[i]) % 256 else: # unsupported PNG filter raise PdfReadError("Unsupported PNG filter %r" % filterByte) prev_rowdata = rowdata output.write(''.join([chr(x) for x in rowdata[1:]])) data = output.getvalue() else: # unsupported predictor raise PdfReadError("Unsupported flatedecode predictor %r" % predictor) return data decode = staticmethod(decode) def encode(data): return compress(data) encode = staticmethod(encode) class ASCIIHexDecode(object): def decode(data, decodeParms=None): retval = "" char = "" x = 0 while True: c = data[x] if c == ">": break elif c.isspace(): x += 1 continue char += c if len(char) == 2: retval += chr(int(char, base=16)) char = "" x += 1 assert char == "" return retval decode = staticmethod(decode) class ASCII85Decode(object): def decode(data, decodeParms=None): retval = "" group = [] x = 0 hitEod = False # remove all whitespace from data data = [y for y in data if not (y in ' \n\r\t')] while not hitEod: c = data[x] if len(retval) == 0 and c == "<" and data[x+1] == "~": x += 2 continue #elif c.isspace(): # x += 1 # continue elif c == 'z': assert len(group) == 0 retval += '\x00\x00\x00\x00' continue elif c == "~" and data[x+1] == ">": if len(group) != 0: # cannot have a final group of just 1 char assert len(group) > 1 cnt = len(group) - 1 group += [ 85, 85, 85 ] hitEod = cnt else: break else: c = ord(c) - 33 assert c >= 0 and c < 85 group += [ c ] if len(group) >= 5: b = group[0] * (85**4) + \ group[1] * (85**3) + \ group[2] * (85**2) + \ group[3] * 85 + \ group[4] assert b < (2**32 - 1) c4 = chr((b >> 0) % 256) c3 = chr((b >> 8) % 256) c2 = chr((b >> 16) % 256) c1 = chr(b >> 24) retval += (c1 + c2 + c3 + c4) if hitEod: retval = retval[:-4+hitEod] group = [] x += 1 return retval decode = staticmethod(decode) def decodeStreamData(stream): from generic import NameObject filters = stream.get("/Filter", ()) if len(filters) and not isinstance(filters[0], NameObject): # we have a single filter instance filters = (filters,) data = stream._data for filterType in filters: if filterType == "/FlateDecode": data = FlateDecode.decode(data, stream.get("/DecodeParms")) elif filterType == "/ASCIIHexDecode": data = ASCIIHexDecode.decode(data) elif filterType == "/ASCII85Decode": data = ASCII85Decode.decode(data) elif filterType == "/Crypt": decodeParams = stream.get("/DecodeParams", {}) if "/Name" not in decodeParams and "/Type" not in decodeParams: pass else: raise NotImplementedError("/Crypt filter with /Name or /Type not supported yet") else: # unsupported filter raise NotImplementedError("unsupported filter %s" % filterType) return data if __name__ == "__main__": assert "abc" == ASCIIHexDecode.decode('61\n626\n3>') ascii85Test = """ <~9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKF<GL>Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!, O<DJ+*.@<*K0@<6L(Df-\\0Ec5e;DffZ(EZee.Bl.9pF"AGXBPCsi+DGm>@3BB/F*&OCAfu2/AKY i(DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIa l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G >uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c~> """ ascii85_originalText="Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure." assert ASCII85Decode.decode(ascii85Test) == ascii85_originalText
mit
[ 3, 6695, 26, 5584, 29, 20, 26, 10379, 26, 14011, 765, 29, 4211, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8315, 12, 21066, 29364, 481, 287, 8445, 1151, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 202, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 202, 199, 3, 7647, 26, 202, 199, 3, 202, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 202, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 202, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 202, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 202, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 202, 199, 3, 627, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 202, 199, 3, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 202, 199, 3, 202, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 202, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 202, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 202, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 202, 199, 3, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 202, 199, 3, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 202, 199, 3, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 202, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 202, 199, 3, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 202, 199, 3, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 202, 199, 3, 9726, 1634, 9712, 9784, 14, 8065, 199, 624, 202, 199, 7921, 402, 2547, 4766, 367, 15537, 14, 202, 199, 624, 202, 199, 363, 2502, 363, 275, 298, 18568, 29364, 481, 287, 8445, 1151, 2, 202, 199, 363, 2502, 63, 2123, 363, 275, 298, 66, 565, 9962, 69, 32, 3442, 29364, 14, 70, 287, 8445, 1151, 14, 846, 2, 2999, 199, 504, 3778, 492, 510, 1587, 3284, 547, 202, 199, 893, 26, 1128, 687, 15073, 492, 5228, 202, 199, 2590, 3545, 26, 1128, 687, 5228, 492, 5228, 2999, 199, 893, 26, 1128, 492, 12472, 1128, 347, 24733, 8, 576, 304, 1039, 372, 12472, 14, 14954, 8, 576, 9, 1128, 347, 11029, 8, 576, 304, 1039, 372, 12472, 14, 6447, 8, 576, 9, 202, 199, 2590, 3545, 26, 1128, 327, 30849, 370, 492, 12472, 14, 221, 23115, 370, 675, 314, 6187, 14, 2090, 14, 25551, 1128, 327, 3555, 687, 314, 1275, 7278, 10059, 14, 334, 41, 2641, 4718, 1454, 9, 1128, 492, 6187, 1128, 687, 6187, 492, 5004, 12, 18003, 83, 12, 8725, 1128, 347, 485, 875, 63, 475, 63, 4414, 5250, 8, 1436, 304, 1039, 9151, 275, 8725, 14, 2499, 3244, 8, 3989, 14, 4861, 12, 822, 8, 1436, 430, 1039, 367, 284, 315, 1425, 8, 552, 8, 1436, 2298, 1675, 9151, 59, 73, 61, 275, 6206, 8, 1436, 59, 73, 566, 1039, 372, 9151, 1128, 347, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 304, 1039, 9151, 275, 3087, 1039, 367, 284, 315, 1425, 8, 2394, 14, 4625, 304, 1675, 9151, 847, 8678, 8, 2394, 59, 73, 566, 1039, 372, 9151, 1128, 347, 485, 739, 63, 2394, 8, 1745, 304, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 4123, 275, 8725, 14, 2499, 3244, 8, 3989, 14, 4861, 12, 18427, 9, 1039, 1830, 715, 26, 1675, 2783, 275, 2547, 14, 3284, 8, 1436, 12, 378, 12, 4123, 14, 4625, 9, 1675, 340, 2783, 508, 378, 26, 2628, 2059, 1675, 587, 26, 2628, 6605, 14, 3534, 8, 1436, 12, 378, 12, 2783, 9, 1039, 9151, 275, 6605, 14, 1378, 3836, 342, 1039, 6605, 14, 4724, 342, 1039, 372, 9151, 1128, 347, 24733, 8, 576, 304, 1039, 2783, 275, 485, 875, 63, 475, 63, 4414, 5250, 8, 576, 9, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 6605, 14, 3534, 8, 2394, 12, 378, 12, 2783, 14, 4625, 9, 1039, 6605, 14, 5625, 275, 378, 221, 327, 289, 5507, 378, 1039, 486, 90, 275, 5004, 14, 25551, 14, 6172, 750, 3296, 8, 706, 12, 5004, 14, 25551, 14, 25551, 1385, 14, 872, 6447, 9, 1039, 2783, 275, 485, 739, 63, 2394, 8, 6838, 9, 1039, 9151, 275, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 9, 1039, 486, 90, 14, 4724, 342, 1039, 372, 9151, 1128, 347, 11029, 8, 576, 304, 1039, 2783, 275, 485, 875, 63, 475, 63, 4414, 5250, 8, 576, 9, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 486, 90, 275, 5004, 14, 25551, 14, 6172, 750, 3296, 8, 706, 12, 5004, 14, 25551, 14, 25551, 1385, 14, 2404, 753, 12, 715, 9, 1039, 486, 90, 14, 3534, 8, 2394, 12, 378, 12, 2783, 14, 4625, 9, 1039, 486, 90, 14, 4724, 342, 1039, 6605, 14, 5625, 275, 378, 327, 289, 5507, 378, 1039, 2783, 275, 6605, 14, 1378, 3836, 342, 1039, 9151, 275, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 9, 1039, 6605, 14, 4724, 342, 1039, 372, 9151, 8065, 199, 533, 481, 750, 9400, 8, 785, 304, 1128, 347, 4849, 8, 576, 12, 4849, 1262, 706, 304, 1039, 666, 275, 24733, 8, 576, 9, 1039, 4557, 630, 275, 413, 1039, 340, 4849, 1262, 706, 26, 1675, 4557, 630, 275, 4849, 1262, 706, 14, 362, 4769, 14730, 630, 401, 413, 9, 1039, 327, 4557, 630, 413, 508, 949, 4557, 630, 1039, 340, 4557, 630, 1137, 413, 26, 1675, 4362, 275, 4849, 1262, 706, 905, 15, 15086, 937, 1675, 327, 26951, 12044, 26, 1675, 340, 4557, 630, 2356, 1616, 436, 4557, 630, 2695, 4114, 26, 2628, 1072, 275, 5228, 342, 2628, 327, 26951, 12044, 883 ]
[ 6695, 26, 5584, 29, 20, 26, 10379, 26, 14011, 765, 29, 4211, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 8315, 12, 21066, 29364, 481, 287, 8445, 1151, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 202, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 202, 199, 3, 7647, 26, 202, 199, 3, 202, 199, 3, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 202, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 202, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 202, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 202, 199, 3, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 202, 199, 3, 627, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 202, 199, 3, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 202, 199, 3, 202, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 202, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 202, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 202, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 6483, 6262, 202, 199, 3, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 202, 199, 3, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 202, 199, 3, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 202, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 202, 199, 3, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 202, 199, 3, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 202, 199, 3, 9726, 1634, 9712, 9784, 14, 8065, 199, 624, 202, 199, 7921, 402, 2547, 4766, 367, 15537, 14, 202, 199, 624, 202, 199, 363, 2502, 363, 275, 298, 18568, 29364, 481, 287, 8445, 1151, 2, 202, 199, 363, 2502, 63, 2123, 363, 275, 298, 66, 565, 9962, 69, 32, 3442, 29364, 14, 70, 287, 8445, 1151, 14, 846, 2, 2999, 199, 504, 3778, 492, 510, 1587, 3284, 547, 202, 199, 893, 26, 1128, 687, 15073, 492, 5228, 202, 199, 2590, 3545, 26, 1128, 687, 5228, 492, 5228, 2999, 199, 893, 26, 1128, 492, 12472, 1128, 347, 24733, 8, 576, 304, 1039, 372, 12472, 14, 14954, 8, 576, 9, 1128, 347, 11029, 8, 576, 304, 1039, 372, 12472, 14, 6447, 8, 576, 9, 202, 199, 2590, 3545, 26, 1128, 327, 30849, 370, 492, 12472, 14, 221, 23115, 370, 675, 314, 6187, 14, 2090, 14, 25551, 1128, 327, 3555, 687, 314, 1275, 7278, 10059, 14, 334, 41, 2641, 4718, 1454, 9, 1128, 492, 6187, 1128, 687, 6187, 492, 5004, 12, 18003, 83, 12, 8725, 1128, 347, 485, 875, 63, 475, 63, 4414, 5250, 8, 1436, 304, 1039, 9151, 275, 8725, 14, 2499, 3244, 8, 3989, 14, 4861, 12, 822, 8, 1436, 430, 1039, 367, 284, 315, 1425, 8, 552, 8, 1436, 2298, 1675, 9151, 59, 73, 61, 275, 6206, 8, 1436, 59, 73, 566, 1039, 372, 9151, 1128, 347, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 304, 1039, 9151, 275, 3087, 1039, 367, 284, 315, 1425, 8, 2394, 14, 4625, 304, 1675, 9151, 847, 8678, 8, 2394, 59, 73, 566, 1039, 372, 9151, 1128, 347, 485, 739, 63, 2394, 8, 1745, 304, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 4123, 275, 8725, 14, 2499, 3244, 8, 3989, 14, 4861, 12, 18427, 9, 1039, 1830, 715, 26, 1675, 2783, 275, 2547, 14, 3284, 8, 1436, 12, 378, 12, 4123, 14, 4625, 9, 1675, 340, 2783, 508, 378, 26, 2628, 2059, 1675, 587, 26, 2628, 6605, 14, 3534, 8, 1436, 12, 378, 12, 2783, 9, 1039, 9151, 275, 6605, 14, 1378, 3836, 342, 1039, 6605, 14, 4724, 342, 1039, 372, 9151, 1128, 347, 24733, 8, 576, 304, 1039, 2783, 275, 485, 875, 63, 475, 63, 4414, 5250, 8, 576, 9, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 6605, 14, 3534, 8, 2394, 12, 378, 12, 2783, 14, 4625, 9, 1039, 6605, 14, 5625, 275, 378, 221, 327, 289, 5507, 378, 1039, 486, 90, 275, 5004, 14, 25551, 14, 6172, 750, 3296, 8, 706, 12, 5004, 14, 25551, 14, 25551, 1385, 14, 872, 6447, 9, 1039, 2783, 275, 485, 739, 63, 2394, 8, 6838, 9, 1039, 9151, 275, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 9, 1039, 486, 90, 14, 4724, 342, 1039, 372, 9151, 1128, 347, 11029, 8, 576, 304, 1039, 2783, 275, 485, 875, 63, 475, 63, 4414, 5250, 8, 576, 9, 1039, 6605, 275, 5004, 14, 8628, 3296, 342, 1039, 486, 90, 275, 5004, 14, 25551, 14, 6172, 750, 3296, 8, 706, 12, 5004, 14, 25551, 14, 25551, 1385, 14, 2404, 753, 12, 715, 9, 1039, 486, 90, 14, 3534, 8, 2394, 12, 378, 12, 2783, 14, 4625, 9, 1039, 486, 90, 14, 4724, 342, 1039, 6605, 14, 5625, 275, 378, 327, 289, 5507, 378, 1039, 2783, 275, 6605, 14, 1378, 3836, 342, 1039, 9151, 275, 485, 4414, 5250, 63, 475, 63, 875, 8, 2394, 9, 1039, 6605, 14, 4724, 342, 1039, 372, 9151, 8065, 199, 533, 481, 750, 9400, 8, 785, 304, 1128, 347, 4849, 8, 576, 12, 4849, 1262, 706, 304, 1039, 666, 275, 24733, 8, 576, 9, 1039, 4557, 630, 275, 413, 1039, 340, 4849, 1262, 706, 26, 1675, 4557, 630, 275, 4849, 1262, 706, 14, 362, 4769, 14730, 630, 401, 413, 9, 1039, 327, 4557, 630, 413, 508, 949, 4557, 630, 1039, 340, 4557, 630, 1137, 413, 26, 1675, 4362, 275, 4849, 1262, 706, 905, 15, 15086, 937, 1675, 327, 26951, 12044, 26, 1675, 340, 4557, 630, 2356, 1616, 436, 4557, 630, 2695, 4114, 26, 2628, 1072, 275, 5228, 342, 2628, 327, 26951, 12044, 883, 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,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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 ]
MangoMangoDevelopment/neptune
lib/ros_comm-1.12.0/test/test_rospy/test/unit/test_gensrv_py.py
1
3000
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2008, Willow Garage, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * 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. # * Neither the name of Willow Garage, Inc. 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 OWNER 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. import os import sys import struct import unittest try: from cStringIO import StringIO except ImportError: from io import StringIO import time import random import math from genpy import SerializationError class TestGensrvPy(unittest.TestCase): ## Utility for testing roundtrip serialization ## @param orig Message to test roundtrip serialization of ## @param blank Uninitialized instance of message to deserialize into ## @param float bool: if True, use almostEquals instead of equals ## comparison. This variant assumes only data field is named ## 'data' def _test_ser_deser(self, orig, blank, float=False): b = StringIO() orig.serialize(b) blank.deserialize(b.getvalue()) if not float: self.assertEquals(orig, blank, str(orig)+" != "+str(blank)) else: self.assertAlmostEquals(orig.data, blank.data, 5) ## #2133/2139 def test_test_rospy_TransitiveImport(self): from test_rospy.srv import TransitiveSrvRequest m = TransitiveSrvRequest() # invoking serialize should be enough to expose issue. The bug # was that genmsg_py was failing to include the imports of # embedded messages. Because messages are flattened, this # causes ImportErrors. self._test_ser_deser(m, TransitiveSrvRequest())
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2290, 844, 28629, 334, 15400, 844, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 9079, 12, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 259, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 259, 543, 314, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 259, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2702, 199, 646, 2882, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5890, 492, 5228, 199, 646, 900, 199, 646, 2196, 199, 646, 3473, 199, 199, 504, 3805, 647, 492, 11973, 2072, 547, 268, 199, 533, 1379, 8168, 15165, 2713, 8, 2796, 14, 1746, 304, 339, 925, 20511, 367, 5343, 6168, 7254, 16953, 272, 925, 768, 635, 2306, 6430, 370, 511, 6168, 7254, 16953, 402, 272, 925, 768, 635, 4596, 1910, 12486, 1256, 402, 1245, 370, 22920, 1901, 272, 925, 768, 635, 2069, 2155, 26, 340, 715, 12, 675, 18871, 13317, 3140, 402, 18527, 272, 925, 9132, 14, 961, 9854, 15194, 1454, 666, 901, 365, 4310, 272, 925, 283, 576, 7, 272, 347, 485, 396, 63, 332, 63, 271, 332, 8, 277, 12, 2306, 12, 4596, 12, 2069, 29, 797, 304, 267, 330, 275, 5228, 342, 267, 2306, 14, 3549, 8, 66, 9, 267, 4596, 14, 11143, 8, 66, 14, 7150, 1012, 267, 340, 440, 2069, 26, 288, 291, 14, 2947, 8, 2981, 12, 4596, 12, 620, 8, 2981, 18663, 1137, 7210, 495, 8, 2500, 430, 267, 587, 26, 288, 291, 14, 7904, 83, 8, 2981, 14, 576, 12, 4596, 14, 576, 12, 959, 9, 339, 925, 327, 18, 10456, 15, 18, 7491, 272, 347, 511, 63, 396, 63, 4796, 647, 63, 14612, 3013, 6295, 8, 277, 304, 267, 687, 511, 63, 4796, 647, 14, 15165, 492, 19894, 3013, 51, 6310, 2017, 267, 333, 275, 19894, 3013, 51, 6310, 2017, 342, 267, 327, 26750, 8437, 1077, 506, 8321, 370, 23705, 4976, 14, 710, 6519, 267, 327, 1990, 626, 3805, 1328, 63, 647, 1990, 18648, 370, 2387, 314, 8925, 402, 267, 327, 12169, 3788, 14, 13821, 3788, 787, 18767, 12, 642, 267, 327, 14486, 3545, 83, 14, 267, 291, 423, 396, 63, 332, 63, 271, 332, 8, 77, 12, 19894, 3013, 51, 6310, 2017, 1012, 260, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2290, 844, 28629, 334, 15400, 844, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 9079, 12, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 199, 3, 221, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 259, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 199, 3, 259, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 199, 3, 259, 543, 314, 4084, 14, 199, 3, 221, 627, 11443, 314, 536, 402, 644, 382, 674, 598, 285, 474, 12, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 199, 3, 259, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 199, 3, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 5877, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 3, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 199, 3, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 199, 3, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2702, 199, 646, 2882, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5890, 492, 5228, 199, 646, 900, 199, 646, 2196, 199, 646, 3473, 199, 199, 504, 3805, 647, 492, 11973, 2072, 547, 268, 199, 533, 1379, 8168, 15165, 2713, 8, 2796, 14, 1746, 304, 339, 925, 20511, 367, 5343, 6168, 7254, 16953, 272, 925, 768, 635, 2306, 6430, 370, 511, 6168, 7254, 16953, 402, 272, 925, 768, 635, 4596, 1910, 12486, 1256, 402, 1245, 370, 22920, 1901, 272, 925, 768, 635, 2069, 2155, 26, 340, 715, 12, 675, 18871, 13317, 3140, 402, 18527, 272, 925, 9132, 14, 961, 9854, 15194, 1454, 666, 901, 365, 4310, 272, 925, 283, 576, 7, 272, 347, 485, 396, 63, 332, 63, 271, 332, 8, 277, 12, 2306, 12, 4596, 12, 2069, 29, 797, 304, 267, 330, 275, 5228, 342, 267, 2306, 14, 3549, 8, 66, 9, 267, 4596, 14, 11143, 8, 66, 14, 7150, 1012, 267, 340, 440, 2069, 26, 288, 291, 14, 2947, 8, 2981, 12, 4596, 12, 620, 8, 2981, 18663, 1137, 7210, 495, 8, 2500, 430, 267, 587, 26, 288, 291, 14, 7904, 83, 8, 2981, 14, 576, 12, 4596, 14, 576, 12, 959, 9, 339, 925, 327, 18, 10456, 15, 18, 7491, 272, 347, 511, 63, 396, 63, 4796, 647, 63, 14612, 3013, 6295, 8, 277, 304, 267, 687, 511, 63, 4796, 647, 14, 15165, 492, 19894, 3013, 51, 6310, 2017, 267, 333, 275, 19894, 3013, 51, 6310, 2017, 342, 267, 327, 26750, 8437, 1077, 506, 8321, 370, 23705, 4976, 14, 710, 6519, 267, 327, 1990, 626, 3805, 1328, 63, 647, 1990, 18648, 370, 2387, 314, 8925, 402, 267, 327, 12169, 3788, 14, 13821, 3788, 787, 18767, 12, 642, 267, 327, 14486, 3545, 83, 14, 267, 291, 423, 396, 63, 332, 63, 271, 332, 8, 77, 12, 19894, 3013, 51, 6310, 2017, 1012, 260, 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, 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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 ]
KAMI911/loec
examples/Sharpen/binaries-windows-python26/GimpGradientFile.py
3
3348
# # Python Imaging Library # $Id: GimpGradientFile.py 2134 2004-10-06 08:55:20Z fredrik $ # # stuff to read (and render) GIMP gradient files # # History: # 97-08-23 fl Created # # Copyright (c) Secret Labs AB 1997. # Copyright (c) Fredrik Lundh 1997. # # See the README file for information on usage and redistribution. # from math import pi, log, sin, sqrt import string # -------------------------------------------------------------------- # Stuff to translate curve segments to palette values (derived from # the corresponding code in GIMP, written by Federico Mena Quintero. # See the GIMP distribution for more information.) # EPSILON = 1e-10 def linear(middle, pos): if pos <= middle: if middle < EPSILON: return 0.0 else: return 0.5 * pos / middle else: pos = pos - middle middle = 1.0 - middle if middle < EPSILON: return 1.0 else: return 0.5 + 0.5 * pos / middle def curved(middle, pos): return pos ** (log(0.5) / log(max(middle, EPSILON))) def sine(middle, pos): return (sin((-pi / 2.0) + pi * linear(middle, pos)) + 1.0) / 2.0 def sphere_increasing(middle, pos): return sqrt(1.0 - (linear(middle, pos) - 1.0) ** 2) def sphere_decreasing(middle, pos): return 1.0 - sqrt(1.0 - linear(middle, pos) ** 2) SEGMENTS = [ linear, curved, sine, sphere_increasing, sphere_decreasing ] class GradientFile: gradient = None def getpalette(self, entries = 256): palette = [] ix = 0 x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix] for i in range(entries): x = i / float(entries-1) while x1 < x: ix = ix + 1 x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix] w = x1 - x0 if w < EPSILON: scale = segment(0.5, 0.5) else: scale = segment((xm - x0) / w, (x - x0) / w) # expand to RGBA r = chr(int(255 * ((rgb1[0] - rgb0[0]) * scale + rgb0[0]) + 0.5)) g = chr(int(255 * ((rgb1[1] - rgb0[1]) * scale + rgb0[1]) + 0.5)) b = chr(int(255 * ((rgb1[2] - rgb0[2]) * scale + rgb0[2]) + 0.5)) a = chr(int(255 * ((rgb1[3] - rgb0[3]) * scale + rgb0[3]) + 0.5)) # add to palette palette.append(r + g + b + a) return string.join(palette, ""), "RGBA" ## # File handler for GIMP's gradient format. class GimpGradientFile(GradientFile): def __init__(self, fp): if fp.readline()[:13] != "GIMP Gradient": raise SyntaxError, "not a GIMP gradient file" count = int(fp.readline()) gradient = [] for i in range(count): s = string.split(fp.readline()) w = map(float, s[:11]) x0, x1 = w[0], w[2] xm = w[1] rgb0 = w[3:7] rgb1 = w[7:11] segment = SEGMENTS[int(s[11])] cspace = int(s[12]) if cspace != 0: raise IOError, "cannot handle HSV colour space" gradient.append((x0, x1, xm, rgb0, rgb1, segment)) self.gradient = gradient
gpl-3.0
[ 3, 202, 199, 3, 2018, 473, 391, 1540, 11243, 202, 199, 3, 2672, 1304, 26, 598, 3236, 9942, 1173, 14, 647, 499, 7582, 8353, 13, 709, 13, 1690, 19363, 26, 1229, 26, 1165, 58, 289, 581, 25844, 2672, 202, 199, 3, 202, 199, 3, 8292, 370, 1586, 334, 460, 3795, 9, 598, 8947, 6709, 1584, 202, 199, 3, 202, 199, 3, 27829, 26, 202, 199, 3, 755, 15997, 13, 2036, 13, 1789, 2717, 258, 18208, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 9013, 23, 14, 202, 199, 3, 1898, 334, 67, 9, 481, 581, 25844, 491, 725, 72, 9013, 23, 14, 202, 199, 3, 202, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 202, 199, 3, 2999, 199, 504, 3473, 492, 6682, 12, 943, 12, 9829, 12, 7452, 202, 199, 646, 1059, 2999, 199, 3, 23567, 202, 199, 3, 1933, 3043, 370, 9028, 15318, 11998, 370, 17986, 1338, 334, 19588, 687, 202, 199, 3, 314, 5226, 1233, 315, 598, 8947, 12, 5313, 701, 7949, 9910, 331, 603, 287, 65, 5843, 5707, 293, 14, 202, 199, 3, 1666, 314, 598, 8947, 4084, 367, 1655, 2556, 4959, 202, 199, 3, 2999, 199, 37, 20725, 275, 413, 69, 13, 709, 2999, 199, 318, 7798, 8, 14885, 12, 2086, 304, 1128, 340, 2086, 2695, 12180, 26, 1039, 340, 12180, 665, 662, 20725, 26, 1675, 372, 378, 14, 16, 1039, 587, 26, 1675, 372, 378, 14, 21, 627, 2086, 1182, 12180, 1128, 587, 26, 1039, 2086, 275, 2086, 446, 12180, 1039, 12180, 275, 413, 14, 16, 446, 12180, 1039, 340, 12180, 665, 662, 20725, 26, 1675, 372, 413, 14, 16, 1039, 587, 26, 1675, 372, 378, 14, 21, 435, 378, 14, 21, 627, 2086, 1182, 12180, 2999, 199, 318, 1094, 1354, 8, 14885, 12, 2086, 304, 1128, 372, 2086, 1011, 334, 793, 8, 16, 14, 21, 9, 1182, 943, 8, 988, 8, 14885, 12, 662, 20725, 1724, 2999, 199, 318, 308, 1132, 8, 14885, 12, 2086, 304, 1128, 372, 334, 5911, 18138, 1038, 1182, 499, 14, 16, 9, 435, 6682, 627, 7798, 8, 14885, 12, 2086, 430, 435, 413, 14, 16, 9, 1182, 499, 14, 16, 2999, 199, 318, 26941, 63, 262, 19877, 8, 14885, 12, 2086, 304, 1128, 372, 7452, 8, 17, 14, 16, 446, 334, 6676, 8, 14885, 12, 2086, 9, 446, 413, 14, 16, 9, 1011, 499, 9, 2999, 199, 318, 26941, 63, 271, 19877, 8, 14885, 12, 2086, 304, 1128, 372, 413, 14, 16, 446, 7452, 8, 17, 14, 16, 446, 7798, 8, 14885, 12, 2086, 9, 1011, 499, 9, 2999, 199, 21981, 20967, 275, 359, 7798, 12, 1094, 1354, 12, 308, 1132, 12, 26941, 63, 262, 19877, 12, 26941, 63, 271, 19877, 1622, 2999, 199, 533, 19603, 1173, 26, 2958, 6709, 275, 488, 2958, 347, 664, 16506, 8, 277, 12, 4811, 275, 7633, 304, 4341, 17986, 275, 942, 4341, 20593, 275, 378, 1039, 671, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 275, 291, 14, 7490, 59, 1148, 61, 4341, 367, 284, 315, 1425, 8, 3189, 304, 11556, 671, 275, 284, 1182, 2069, 8, 3189, 13, 17, 9, 11556, 1830, 671, 17, 665, 671, 26, 2628, 20593, 275, 20593, 435, 413, 2628, 671, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 275, 291, 14, 7490, 59, 1148, 61, 11556, 336, 275, 671, 17, 446, 671, 16, 11556, 340, 336, 665, 662, 20725, 26, 2628, 4666, 275, 8135, 8, 16, 14, 21, 12, 378, 14, 21, 9, 1675, 587, 26, 2628, 4666, 275, 8135, 1332, 10198, 446, 671, 16, 9, 1182, 336, 12, 334, 88, 446, 671, 16, 9, 1182, 336, 9, 11556, 327, 6544, 370, 820, 39, 4134, 1675, 519, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 16, 61, 446, 15180, 16, 59, 16, 566, 627, 4666, 435, 15180, 16, 59, 16, 566, 435, 378, 14, 21, 430, 1675, 486, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 17, 61, 446, 15180, 16, 59, 17, 566, 627, 4666, 435, 15180, 16, 59, 17, 566, 435, 378, 14, 21, 430, 1675, 330, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 18, 61, 446, 15180, 16, 59, 18, 566, 627, 4666, 435, 15180, 16, 59, 18, 566, 435, 378, 14, 21, 430, 1675, 282, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 19, 61, 446, 15180, 16, 59, 19, 566, 627, 4666, 435, 15180, 16, 59, 19, 566, 435, 378, 14, 21, 430, 11556, 327, 1050, 370, 17986, 1675, 17986, 14, 740, 8, 82, 435, 486, 435, 330, 435, 282, 9, 4341, 372, 1059, 14, 904, 8, 16506, 12, 16241, 298, 21631, 2, 2999, 199, 309, 202, 199, 3, 3814, 3016, 367, 598, 8947, 1159, 6709, 1475, 14, 2999, 199, 533, 598, 3236, 9942, 1173, 8, 9942, 1173, 304, 2958, 347, 636, 826, 721, 277, 12, 4090, 304, 4341, 340, 4090, 14, 6407, 20523, 969, 61, 1137, 298, 39, 8947, 19603, 582, 1675, 746, 12053, 12, 298, 1397, 282, 598, 8947, 6709, 570, 2, 4341, 2338, 275, 1109, 8, 3997, 14, 6407, 1012, 4341, 6709, 275, 942, 4341, 367, 284, 315, 1425, 8, 835, 304, 11556, 308, 275, 1059, 14, 1294, 8, 3997, 14, 6407, 1012, 1675, 336, 275, 2341, 8, 1609, 12, 308, 1491, 845, 566, 11556, 671, 16, 12, 671, 17, 221, 275, 336, 59, 16, 467, 336, 59, 18, 61, 1675, 17725, 420, 275, 336, 59, 17, 61, 1675, 15180, 16, 259, 275, 336, 59, 19, 26, 23, 61, 1675, 15180, 17, 259, 275, 336, 59, 23, 26, 845, 61, 11556, 8135, 275, 428, 4680, 20967, 59, 442, 8, 83, 59, 845, 12457, 1675, 286, 2638, 221, 275, 1109, 8, 83, 59, 713, 566, 11556, 340, 286, 2638, 1137, 378, 26, 2628, 746, 5925, 12, 298, 11250, 2429, 869, 4985, 15706, 4601, 2, 11556, 6709, 14, 740, 1332, 88, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 430, 4341, 291, 14, 7490, 275, 6709, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 202, 199, 3, 2018, 473, 391, 1540, 11243, 202, 199, 3, 2672, 1304, 26, 598, 3236, 9942, 1173, 14, 647, 499, 7582, 8353, 13, 709, 13, 1690, 19363, 26, 1229, 26, 1165, 58, 289, 581, 25844, 2672, 202, 199, 3, 202, 199, 3, 8292, 370, 1586, 334, 460, 3795, 9, 598, 8947, 6709, 1584, 202, 199, 3, 202, 199, 3, 27829, 26, 202, 199, 3, 755, 15997, 13, 2036, 13, 1789, 2717, 258, 18208, 202, 199, 3, 202, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 9013, 23, 14, 202, 199, 3, 1898, 334, 67, 9, 481, 581, 25844, 491, 725, 72, 9013, 23, 14, 202, 199, 3, 202, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 202, 199, 3, 2999, 199, 504, 3473, 492, 6682, 12, 943, 12, 9829, 12, 7452, 202, 199, 646, 1059, 2999, 199, 3, 23567, 202, 199, 3, 1933, 3043, 370, 9028, 15318, 11998, 370, 17986, 1338, 334, 19588, 687, 202, 199, 3, 314, 5226, 1233, 315, 598, 8947, 12, 5313, 701, 7949, 9910, 331, 603, 287, 65, 5843, 5707, 293, 14, 202, 199, 3, 1666, 314, 598, 8947, 4084, 367, 1655, 2556, 4959, 202, 199, 3, 2999, 199, 37, 20725, 275, 413, 69, 13, 709, 2999, 199, 318, 7798, 8, 14885, 12, 2086, 304, 1128, 340, 2086, 2695, 12180, 26, 1039, 340, 12180, 665, 662, 20725, 26, 1675, 372, 378, 14, 16, 1039, 587, 26, 1675, 372, 378, 14, 21, 627, 2086, 1182, 12180, 1128, 587, 26, 1039, 2086, 275, 2086, 446, 12180, 1039, 12180, 275, 413, 14, 16, 446, 12180, 1039, 340, 12180, 665, 662, 20725, 26, 1675, 372, 413, 14, 16, 1039, 587, 26, 1675, 372, 378, 14, 21, 435, 378, 14, 21, 627, 2086, 1182, 12180, 2999, 199, 318, 1094, 1354, 8, 14885, 12, 2086, 304, 1128, 372, 2086, 1011, 334, 793, 8, 16, 14, 21, 9, 1182, 943, 8, 988, 8, 14885, 12, 662, 20725, 1724, 2999, 199, 318, 308, 1132, 8, 14885, 12, 2086, 304, 1128, 372, 334, 5911, 18138, 1038, 1182, 499, 14, 16, 9, 435, 6682, 627, 7798, 8, 14885, 12, 2086, 430, 435, 413, 14, 16, 9, 1182, 499, 14, 16, 2999, 199, 318, 26941, 63, 262, 19877, 8, 14885, 12, 2086, 304, 1128, 372, 7452, 8, 17, 14, 16, 446, 334, 6676, 8, 14885, 12, 2086, 9, 446, 413, 14, 16, 9, 1011, 499, 9, 2999, 199, 318, 26941, 63, 271, 19877, 8, 14885, 12, 2086, 304, 1128, 372, 413, 14, 16, 446, 7452, 8, 17, 14, 16, 446, 7798, 8, 14885, 12, 2086, 9, 1011, 499, 9, 2999, 199, 21981, 20967, 275, 359, 7798, 12, 1094, 1354, 12, 308, 1132, 12, 26941, 63, 262, 19877, 12, 26941, 63, 271, 19877, 1622, 2999, 199, 533, 19603, 1173, 26, 2958, 6709, 275, 488, 2958, 347, 664, 16506, 8, 277, 12, 4811, 275, 7633, 304, 4341, 17986, 275, 942, 4341, 20593, 275, 378, 1039, 671, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 275, 291, 14, 7490, 59, 1148, 61, 4341, 367, 284, 315, 1425, 8, 3189, 304, 11556, 671, 275, 284, 1182, 2069, 8, 3189, 13, 17, 9, 11556, 1830, 671, 17, 665, 671, 26, 2628, 20593, 275, 20593, 435, 413, 2628, 671, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 275, 291, 14, 7490, 59, 1148, 61, 11556, 336, 275, 671, 17, 446, 671, 16, 11556, 340, 336, 665, 662, 20725, 26, 2628, 4666, 275, 8135, 8, 16, 14, 21, 12, 378, 14, 21, 9, 1675, 587, 26, 2628, 4666, 275, 8135, 1332, 10198, 446, 671, 16, 9, 1182, 336, 12, 334, 88, 446, 671, 16, 9, 1182, 336, 9, 11556, 327, 6544, 370, 820, 39, 4134, 1675, 519, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 16, 61, 446, 15180, 16, 59, 16, 566, 627, 4666, 435, 15180, 16, 59, 16, 566, 435, 378, 14, 21, 430, 1675, 486, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 17, 61, 446, 15180, 16, 59, 17, 566, 627, 4666, 435, 15180, 16, 59, 17, 566, 435, 378, 14, 21, 430, 1675, 330, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 18, 61, 446, 15180, 16, 59, 18, 566, 627, 4666, 435, 15180, 16, 59, 18, 566, 435, 378, 14, 21, 430, 1675, 282, 275, 8678, 8, 442, 8, 2299, 627, 3666, 10090, 17, 59, 19, 61, 446, 15180, 16, 59, 19, 566, 627, 4666, 435, 15180, 16, 59, 19, 566, 435, 378, 14, 21, 430, 11556, 327, 1050, 370, 17986, 1675, 17986, 14, 740, 8, 82, 435, 486, 435, 330, 435, 282, 9, 4341, 372, 1059, 14, 904, 8, 16506, 12, 16241, 298, 21631, 2, 2999, 199, 309, 202, 199, 3, 3814, 3016, 367, 598, 8947, 1159, 6709, 1475, 14, 2999, 199, 533, 598, 3236, 9942, 1173, 8, 9942, 1173, 304, 2958, 347, 636, 826, 721, 277, 12, 4090, 304, 4341, 340, 4090, 14, 6407, 20523, 969, 61, 1137, 298, 39, 8947, 19603, 582, 1675, 746, 12053, 12, 298, 1397, 282, 598, 8947, 6709, 570, 2, 4341, 2338, 275, 1109, 8, 3997, 14, 6407, 1012, 4341, 6709, 275, 942, 4341, 367, 284, 315, 1425, 8, 835, 304, 11556, 308, 275, 1059, 14, 1294, 8, 3997, 14, 6407, 1012, 1675, 336, 275, 2341, 8, 1609, 12, 308, 1491, 845, 566, 11556, 671, 16, 12, 671, 17, 221, 275, 336, 59, 16, 467, 336, 59, 18, 61, 1675, 17725, 420, 275, 336, 59, 17, 61, 1675, 15180, 16, 259, 275, 336, 59, 19, 26, 23, 61, 1675, 15180, 17, 259, 275, 336, 59, 23, 26, 845, 61, 11556, 8135, 275, 428, 4680, 20967, 59, 442, 8, 83, 59, 845, 12457, 1675, 286, 2638, 221, 275, 1109, 8, 83, 59, 713, 566, 11556, 340, 286, 2638, 1137, 378, 26, 2628, 746, 5925, 12, 298, 11250, 2429, 869, 4985, 15706, 4601, 2, 11556, 6709, 14, 740, 1332, 88, 16, 12, 671, 17, 12, 17725, 12, 15180, 16, 12, 15180, 17, 12, 8135, 430, 4341, 291, 14, 7490, 275, 6709, 1223, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Nrikolo/X8_AutoPilot
fsm/scripts/Utility.py
1
10399
#!/usr/bin/env python# # A set of utility functions for converting msgs to numpy arrays, computing distance metrics import rospy import ros import numpy import math from geometry_msgs.msg import Pose, Point, Quaternion, PoseStamped class switch(object): """ python switch statement adapted from : http://code.activestate.com/recipes/410692-readable-switch-construction-without-lambdas-or-di/ """ def __init__(self, value): self.value = value self.fall = False def __iter__(self): """Return the match method once, then stop""" yield self.match raise StopIteration def match(self, *args): """Indicate whether or not to enter a case suite""" if self.fall or not args: return True elif self.value in args: self.fall = True return True else: return False def PoseMsg2NumpyArray(pose_msg): """ :param: pose_msg: A ros/geometry_msgs/Pose type msg :return: A numpy array size [7,1] holds [x,y,z,q1,q2,q3,q0] where q0 is the quaternion scalar Converts ros/geometry_msgs/Pose to a numpy array """ #print "PoseMsg2NumpyArray : ", pose_msg v = numpy.array([pose_msg.position.x, pose_msg.position.y, pose_msg.position.z, pose_msg.orientation.x, pose_msg.orientation.y, pose_msg.orientation.z, pose_msg.orientation.w]) return v def PoseMsg2NumpyArrayPosition(pose_msg): """ :param pose_msg: A ros/geometry_msgs/Pose type msg :return: A numpy array size [3,1] holds [x,y,z] Converts ros/geometry_msgs/Pose to a numpy array """ #print "PoseMsg2NumpyArrayPosition: " , pose_msg v = PoseMsg2NumpyArray(pose_msg) v = v[0:3] return v def PointMsg2NumpyArrayPosition(point_msg): """ :param point_msg: A ros/geometry_msgs/Point type msg :return: A numpy array size [3,1] holds [x,y,z] Converts ros/geometry_msgs/Pose.position to a numpy array """ v = numpy.array([point_msg.x, point_msg.y, point_msg.z]) return v def Distance(str_metric, array_1, array_2, dim): """ :param str_metric: A string naming the type of metric to be used :param array_1 : A numpy array :param array_2 : A numpy array :param dim : An integer numpy array :return: A float measuring the distance in dimension dim between the two arrays according to the metric Computed the distance metric specified in str_metric between two numpy arrays """ if numpy.size(array_1) != numpy.size(array_2): print ("Arrays are not of equal size") return numpy.inf else: if str_metric is 'Manhatten': return ManhattenPlanarDistance(array_1, array_2,dim) else: return EuclideanPlanarDistance(array_1, array_2,dim) def EuclideanPlanarDistance( array_1, array_2,dim): """ :param array_1 : A numpy array :param array_2 : A numpy array :param dim : An integer numpy array :return: A float measuring the Euclidean distance two arrays Computed the Euclidean metric of the first dim dimesions between two numpy arrays""" ## print "\narray_1:", array_1 ## print "\narray_2:", array_2 diff = array_1[0:dim]-array_2[0:dim] ## print "\ndifference between arrays", diff return numpy.linalg.norm(diff,2) def ManhattenPlanarDistance( array_1, array_2, dim=3): """ :param array_1 : A numpy array :param array_2 : A numpy array :param dim : An integer numpy array :return: A float measuring the Manhatten distance two arrays Computed the Manhatten metric of the first dim dimesions between two numpy arrays""" diff = array_1[0:dim]-array_2[0:dim] return numpy.linalg.norm(diff,1) def getTrajectoryAltitudeProfile(currentPoseStamped, TargetPose, tolerance): #Function should be formulated as a motion planner wrapped as a service """ :param currentPoseStamped: A ros/geometry_msgs/PoseStamped message :param TargetPose : A ros/geometry_msgs/Pose message indicating target pose :param tolerance : A float indicating maximal tolerance between sigamoid an actual height :return: An array of ros/geometry_msgs/PoseStamped messages Generates an altitude proflie for TAKEOFF/LAND based on a sigamoid """ #Ref signal frequency frequency = 100 #[Hz] #Use current position [x,y] constant and current z as lower asymptote of sigamoid x = currentPoseStamped.pose.position.x y = currentPoseStamped.pose.position.y z_init = currentPoseStamped.pose.position.z z_final = TargetPose.position.z quat = Quaternion(0.0, 0.0, 0.0, 1.0) v_max = abs(z_final-z_init)/2.0 #[meters\second] Should be a function of the time horizon and the change in altitude i.e : v_max = abs(z_final-z_init)/horizon print (abs(z_init-z_final)/tolerance) - 1 delay = math.log((abs(z_init-z_final)/tolerance) - 1)/v_max #Loop to populate trajectory with StampedPoses instances trajectory = [] # z = z_init + (z_final - z_init)./(1+exp(-v_max*(t-delay-tNOW)))); print ("\nGenereting an altitude profile from z = {} [m] -->> z = {} [m]".format(z_init , z_final)) i=0 while True: #no more than 10 sec StampedPose = PoseStamped() #Construct a StampedPose MSG StampedPose.header.frame_id = "/world" #Frame of ref that the trajectory is formualted in t = rospy.Duration(float(i)/frequency) #create a time instance z = z_init + (z_final - z_init)/(1+math.exp(-v_max*(t.to_sec()-delay))); #compute its height #print("Test traj : At time {} z value is {}".format(t.to_sec(),z)) #Populate the StampedPose object StampedPose.header.stamp = t StampedPose.pose = Pose(Point(x, y, z),quat) #The pose # Append the time staped pose to the trajectory to follow trajectory.append(StampedPose) i += 1 if abs(z-z_final) < tolerance: #print ("trajectory length is {}".format(i)) break print ("\nTrajectory start is: {}".format(trajectory[0].pose.position)) print ("\nTrajectory end is: {}".format(trajectory[-1].pose.position)) return trajectory def getTrajectory(currentPose, TargetPose , tolerance = 0.01): #Function should be formulated as a motion planner wrapped as a service """ :param currentPoseStamped: A ros/geometry_msgs/PoseStamped message :param TargetPose : A ros/geometry_msgs/Pose message indicating target pose :param tolerance : A float indicating maximal tolerance between sigamoid an actual height :return: An array of ros/geometry_msgs/PoseStamped messages Generates a trajectory the vehicle to follow (sigamoid based) """ trajectory = [] distance_to_target = Distance('Euclidean', PoseMsg2NumpyArrayPosition( currentPose ), PoseMsg2NumpyArrayPosition( TargetPose ), 3) ## print "Euclidean Distance to Target: " , distance_to_target if distance_to_target < tolerance : print "Basically at target already" StampedPose = PoseStamped() #Construct a StampedPose MSG StampedPose.header.frame_id = "/world" #Frame of ref that the trajectory is formualted in StampedPose.header.stamp = rospy.Time.now() StampedPose.pose = currentPose #The pose trajectory.append(StampedPose) return trajectory #Ref signal frequency frequency = 100 #[Hz] #Use current position [x,y] constant and current z as lower asymptote of sigamoid x_init = currentPose.position.x y_init = currentPose.position.y z_init = currentPose.position.z x_final = TargetPose.position.x y_final = TargetPose.position.y z_final = TargetPose.position.z quat = Quaternion(0.0, 0.0, 0.0, 1.0) delta = numpy.amax([abs(z_final-z_init),abs(z_final-z_init),abs(z_final-z_init)]) if delta<tolerance: v_max = 1.0 #[meters\second] Should be a function of the time horizon and the change in altitude i.e : v_max = abs(z_final-z_init)/horizon delay = 0.0 else: v_max = delta/2.0 #[meters\second] Should be a function of the time horizon and the change in altitude i.e : v_max = abs(z_final-z_init)/horizon delay = math.log(delta/tolerance - 1)/v_max #Loop to populate trajectory with StampedPoses instances #print ("\nGenereting a trajectory from z = {} [m] -->> z = {} [m]".format(z_init , z_final)) i=0 while True: StampedPose = PoseStamped() #Construct a StampedPose MSG StampedPose.header.frame_id = "/world" #Frame of ref that the trajectory is formualted in t = rospy.Duration(float(i)/frequency) #create a time instance den = math.pow((1+math.exp(-v_max*(t.to_sec()-delay))),1) x = x_init + (x_final - x_init)/den #compute its height y = y_init + (y_final - y_init)/den z = z_init + (z_final - z_init)/den ## print("Test traj : At time {} x value is {}".format(t.to_sec(),x)) #Populate the StampedPose object StampedPose.header.stamp = t StampedPose.pose = Pose(Point(x, y, z),quat) #The pose # Append the time staped pose to the trajectory to follow trajectory.append(StampedPose) i += 1 bool = numpy.array([abs(x-x_final),abs(y-y_final),abs(z-z_final)])<tolerance #print bool if bool.all(): ## print ("Trajectory length is {}".format(i)) break ## print "\nTrajectory generated." print ("\nTrajectory start is:\n {}".format(trajectory[0].pose.position)) print ("\nTrajectory end is:\n {}".format(trajectory[-1].pose.position)) return trajectory
gpl-2.0
[ 327, 1, 15, 2647, 15, 1393, 15, 1813, 2366, 3, 199, 3, 437, 663, 402, 11420, 3423, 367, 13806, 17599, 370, 2680, 6572, 12, 17226, 6033, 7186, 9948, 199, 646, 21848, 199, 646, 882, 83, 199, 646, 2680, 199, 646, 3473, 199, 504, 3400, 63, 13429, 14, 1328, 492, 510, 3362, 12, 7584, 12, 1413, 4767, 11641, 1636, 12, 510, 3362, 16649, 379, 199, 199, 533, 6258, 8, 785, 304, 272, 408, 272, 2366, 6258, 5164, 26266, 687, 520, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 24781, 27041, 13, 11875, 13, 5656, 13, 12708, 13, 7395, 13, 416, 887, 24315, 13, 269, 13, 328, 15, 272, 408, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 70, 452, 275, 756, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 1767, 314, 1336, 1083, 5403, 12, 2066, 3631, 624, 267, 1995, 291, 14, 1431, 267, 746, 10852, 2286, 347, 1336, 8, 277, 12, 627, 589, 304, 267, 408, 607, 10188, 3775, 503, 440, 370, 9509, 282, 1930, 5241, 624, 267, 340, 291, 14, 70, 452, 503, 440, 1249, 26, 288, 372, 715, 267, 916, 291, 14, 585, 315, 1249, 26, 7205, 291, 14, 70, 452, 275, 715, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 318, 510, 3362, 6173, 18, 25218, 3836, 8, 4070, 63, 1328, 304, 272, 408, 272, 520, 635, 26, 1115, 261, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 23, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 12, 81, 17, 12, 81, 18, 12, 81, 19, 12, 81, 16, 61, 2382, 1894, 16, 365, 314, 2173, 28945, 6917, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 370, 282, 2680, 1625, 272, 408, 272, 327, 1361, 298, 1575, 261, 6173, 18, 25218, 3836, 520, 3872, 1115, 261, 63, 1328, 272, 373, 275, 221, 2680, 14, 1144, 779, 4070, 63, 1328, 14, 3124, 14, 88, 12, 490, 1115, 261, 63, 1328, 14, 3124, 14, 89, 12, 490, 1115, 261, 63, 1328, 14, 3124, 14, 90, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 88, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 89, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 90, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 87, 566, 272, 372, 373, 199, 199, 318, 510, 3362, 6173, 18, 25218, 3836, 5625, 8, 4070, 63, 1328, 304, 272, 408, 272, 520, 635, 1115, 261, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 19, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 61, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 370, 282, 2680, 1625, 272, 408, 272, 327, 1361, 298, 1575, 261, 6173, 18, 25218, 3836, 5625, 26, 298, 2360, 1115, 261, 63, 1328, 272, 373, 275, 510, 3362, 6173, 18, 25218, 3836, 8, 4070, 63, 1328, 9, 272, 373, 275, 373, 59, 16, 26, 19, 61, 272, 372, 373, 199, 199, 318, 7584, 6173, 18, 25218, 3836, 5625, 8, 1403, 63, 1328, 304, 272, 408, 272, 520, 635, 2376, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 3428, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 19, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 61, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 14, 3124, 370, 282, 2680, 1625, 272, 408, 339, 373, 275, 221, 2680, 14, 1144, 779, 1403, 63, 1328, 14, 88, 12, 2151, 2376, 63, 1328, 14, 89, 12, 2151, 2376, 63, 1328, 14, 90, 566, 23855, 372, 373, 199, 199, 318, 21892, 8, 495, 63, 5165, 12, 1625, 63, 17, 12, 1625, 63, 18, 12, 8134, 304, 272, 408, 272, 520, 635, 620, 63, 5165, 26, 437, 1059, 19720, 314, 730, 402, 6370, 370, 506, 1202, 272, 520, 635, 1625, 63, 17, 520, 437, 2680, 1625, 272, 520, 635, 1625, 63, 18, 520, 437, 2680, 1625, 272, 520, 635, 8134, 520, 1626, 3000, 221, 2680, 1625, 272, 520, 1107, 26, 437, 2069, 17616, 4039, 314, 6033, 315, 6240, 8134, 3382, 314, 2877, 6572, 7182, 370, 314, 6370, 221, 2286, 3599, 4241, 314, 6033, 6370, 2013, 315, 620, 63, 5165, 3382, 2877, 2680, 6572, 272, 408, 2378, 340, 2680, 14, 890, 8, 1144, 63, 17, 9, 1137, 2680, 14, 890, 8, 1144, 63, 18, 304, 267, 870, 1689, 29033, 787, 440, 402, 4472, 1568, 531, 267, 372, 2680, 14, 4904, 272, 587, 26, 3777, 267, 340, 620, 63, 5165, 365, 283, 2395, 72, 4867, 356, 288, 372, 4688, 72, 4867, 13375, 285, 10076, 8, 1144, 63, 17, 12, 1625, 63, 18, 12, 3572, 9, 267, 587, 26, 288, 372, 662, 24941, 13375, 285, 10076, 8, 1144, 63, 17, 12, 1625, 63, 18, 12, 3572, 9, 199, 199, 318, 662, 24941, 13375, 285, 10076, 8, 1625, 63, 17, 12, 1625, 63, 18, 12, 3572, 304, 272, 408, 272, 520, 635, 1625, 63, 17, 520, 437, 2680, 1625, 272, 520, 635, 1625, 63, 18, 520, 437, 2680, 1625, 272, 520, 635, 8134, 520, 1626, 3000, 221, 2680, 1625, 272, 520, 1107, 26, 437, 2069, 17616, 4039, 314, 662, 24941, 6033, 2877, 6572, 2286, 3599, 4241, 314, 662, 24941, 6370, 402, 314, 1642, 8134, 221, 487, 278, 1356, 3382, 2877, 2680, 6572, 624, 199, 309, 259, 870, 1867, 78, 1144, 63, 17, 6783, 1625, 63, 17, 199, 309, 259, 870, 1867, 78, 1144, 63, 18, 6783, 1625, 63, 18, 272, 3915, 275, 1625, 63, 17, 59, 16, 26, 3572, 11285, 1144, 63, 18, 59, 16, 26, 3572, 61, 258, 199, 309, 259, 870, 1867, 78, 9196, 3382, 6572, 401, 3915, 272, 372, 2680, 14, 10096, 14, 4791, 8, 3028, 12, 18, 9, 421, 199, 318, 4688, 72, 4867, 13375, 285, 10076, 8, 1625, 63, 17, 12, 1625, 63, 18, 12, 8134, 29, 19, 304, 272, 408, 272, 520, 635, 1625, 63, 17, 520, 437, 2680, 1625, 272, 520, 635, 1625, 63, 18, 520, 437, 2680 ]
[ 1, 15, 2647, 15, 1393, 15, 1813, 2366, 3, 199, 3, 437, 663, 402, 11420, 3423, 367, 13806, 17599, 370, 2680, 6572, 12, 17226, 6033, 7186, 9948, 199, 646, 21848, 199, 646, 882, 83, 199, 646, 2680, 199, 646, 3473, 199, 504, 3400, 63, 13429, 14, 1328, 492, 510, 3362, 12, 7584, 12, 1413, 4767, 11641, 1636, 12, 510, 3362, 16649, 379, 199, 199, 533, 6258, 8, 785, 304, 272, 408, 272, 2366, 6258, 5164, 26266, 687, 520, 1455, 921, 600, 14, 32595, 14, 957, 15, 25200, 15, 24781, 27041, 13, 11875, 13, 5656, 13, 12708, 13, 7395, 13, 416, 887, 24315, 13, 269, 13, 328, 15, 272, 408, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 70, 452, 275, 756, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 1767, 314, 1336, 1083, 5403, 12, 2066, 3631, 624, 267, 1995, 291, 14, 1431, 267, 746, 10852, 2286, 347, 1336, 8, 277, 12, 627, 589, 304, 267, 408, 607, 10188, 3775, 503, 440, 370, 9509, 282, 1930, 5241, 624, 267, 340, 291, 14, 70, 452, 503, 440, 1249, 26, 288, 372, 715, 267, 916, 291, 14, 585, 315, 1249, 26, 7205, 291, 14, 70, 452, 275, 715, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 318, 510, 3362, 6173, 18, 25218, 3836, 8, 4070, 63, 1328, 304, 272, 408, 272, 520, 635, 26, 1115, 261, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 23, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 12, 81, 17, 12, 81, 18, 12, 81, 19, 12, 81, 16, 61, 2382, 1894, 16, 365, 314, 2173, 28945, 6917, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 370, 282, 2680, 1625, 272, 408, 272, 327, 1361, 298, 1575, 261, 6173, 18, 25218, 3836, 520, 3872, 1115, 261, 63, 1328, 272, 373, 275, 221, 2680, 14, 1144, 779, 4070, 63, 1328, 14, 3124, 14, 88, 12, 490, 1115, 261, 63, 1328, 14, 3124, 14, 89, 12, 490, 1115, 261, 63, 1328, 14, 3124, 14, 90, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 88, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 89, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 90, 12, 490, 1115, 261, 63, 1328, 14, 17001, 14, 87, 566, 272, 372, 373, 199, 199, 318, 510, 3362, 6173, 18, 25218, 3836, 5625, 8, 4070, 63, 1328, 304, 272, 408, 272, 520, 635, 1115, 261, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 19, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 61, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 370, 282, 2680, 1625, 272, 408, 272, 327, 1361, 298, 1575, 261, 6173, 18, 25218, 3836, 5625, 26, 298, 2360, 1115, 261, 63, 1328, 272, 373, 275, 510, 3362, 6173, 18, 25218, 3836, 8, 4070, 63, 1328, 9, 272, 373, 275, 373, 59, 16, 26, 19, 61, 272, 372, 373, 199, 199, 318, 7584, 6173, 18, 25218, 3836, 5625, 8, 1403, 63, 1328, 304, 272, 408, 272, 520, 635, 2376, 63, 1328, 26, 437, 882, 83, 15, 7660, 63, 13429, 15, 3428, 730, 1499, 272, 520, 1107, 26, 437, 2680, 1625, 1568, 359, 19, 12, 17, 61, 15164, 359, 88, 12, 89, 12, 90, 61, 2286, 19107, 882, 83, 15, 7660, 63, 13429, 15, 1575, 261, 14, 3124, 370, 282, 2680, 1625, 272, 408, 339, 373, 275, 221, 2680, 14, 1144, 779, 1403, 63, 1328, 14, 88, 12, 2151, 2376, 63, 1328, 14, 89, 12, 2151, 2376, 63, 1328, 14, 90, 566, 23855, 372, 373, 199, 199, 318, 21892, 8, 495, 63, 5165, 12, 1625, 63, 17, 12, 1625, 63, 18, 12, 8134, 304, 272, 408, 272, 520, 635, 620, 63, 5165, 26, 437, 1059, 19720, 314, 730, 402, 6370, 370, 506, 1202, 272, 520, 635, 1625, 63, 17, 520, 437, 2680, 1625, 272, 520, 635, 1625, 63, 18, 520, 437, 2680, 1625, 272, 520, 635, 8134, 520, 1626, 3000, 221, 2680, 1625, 272, 520, 1107, 26, 437, 2069, 17616, 4039, 314, 6033, 315, 6240, 8134, 3382, 314, 2877, 6572, 7182, 370, 314, 6370, 221, 2286, 3599, 4241, 314, 6033, 6370, 2013, 315, 620, 63, 5165, 3382, 2877, 2680, 6572, 272, 408, 2378, 340, 2680, 14, 890, 8, 1144, 63, 17, 9, 1137, 2680, 14, 890, 8, 1144, 63, 18, 304, 267, 870, 1689, 29033, 787, 440, 402, 4472, 1568, 531, 267, 372, 2680, 14, 4904, 272, 587, 26, 3777, 267, 340, 620, 63, 5165, 365, 283, 2395, 72, 4867, 356, 288, 372, 4688, 72, 4867, 13375, 285, 10076, 8, 1144, 63, 17, 12, 1625, 63, 18, 12, 3572, 9, 267, 587, 26, 288, 372, 662, 24941, 13375, 285, 10076, 8, 1144, 63, 17, 12, 1625, 63, 18, 12, 3572, 9, 199, 199, 318, 662, 24941, 13375, 285, 10076, 8, 1625, 63, 17, 12, 1625, 63, 18, 12, 3572, 304, 272, 408, 272, 520, 635, 1625, 63, 17, 520, 437, 2680, 1625, 272, 520, 635, 1625, 63, 18, 520, 437, 2680, 1625, 272, 520, 635, 8134, 520, 1626, 3000, 221, 2680, 1625, 272, 520, 1107, 26, 437, 2069, 17616, 4039, 314, 662, 24941, 6033, 2877, 6572, 2286, 3599, 4241, 314, 662, 24941, 6370, 402, 314, 1642, 8134, 221, 487, 278, 1356, 3382, 2877, 2680, 6572, 624, 199, 309, 259, 870, 1867, 78, 1144, 63, 17, 6783, 1625, 63, 17, 199, 309, 259, 870, 1867, 78, 1144, 63, 18, 6783, 1625, 63, 18, 272, 3915, 275, 1625, 63, 17, 59, 16, 26, 3572, 11285, 1144, 63, 18, 59, 16, 26, 3572, 61, 258, 199, 309, 259, 870, 1867, 78, 9196, 3382, 6572, 401, 3915, 272, 372, 2680, 14, 10096, 14, 4791, 8, 3028, 12, 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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 ]
Micronaet/micronaet-mx8
stock_assigned_quantity/__init__.py
1
1035
# -*- coding: utf-8 -*- ############################################################################### # # Copyright (C) 2001-2014 Micronaet SRL (<http://www.micronaet.it>). # # 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/>. # ############################################################################### from . import stock # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 11490, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 12521, 13, 7280, 603, 530, 2641, 65, 386, 428, 2431, 8642, 1014, 921, 1544, 14, 15003, 2641, 65, 386, 14, 390, 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, 3267, 199, 3, 259, 701, 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, 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, 11490, 199, 504, 1275, 492, 10952, 421, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 11490, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 12521, 13, 7280, 603, 530, 2641, 65, 386, 428, 2431, 8642, 1014, 921, 1544, 14, 15003, 2641, 65, 386, 14, 390, 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, 3267, 199, 3, 259, 701, 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, 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, 11490, 199, 504, 1275, 492, 10952, 421, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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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 ]
cyb0/volatility
vol.py
44
6142
#!/usr/bin/env python # -*- mode: python; -*- # # Volatility # Copyright (C) 2007-2013 Volatility Foundation # # This file is part of Volatility. # # Volatility 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. # # Volatility 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 Volatility. If not, see <http://www.gnu.org/licenses/>. # """ @author: AAron Walters @license: GNU General Public License 2.0 @contact: awalters@4tphi.net @organization: Volatility Foundation """ #pylint: disable-msg=C0111 import sys if sys.version_info < (2, 6, 0): sys.stderr.write("Volatility requires python version 2.6, please upgrade your python installation.") sys.exit(1) try: import psyco #pylint: disable-msg=W0611,F0401 except ImportError: pass if False: # Include a fake import for things like pyinstaller to hit # since this is a dependency of the malware plugins import yara import textwrap import volatility.conf as conf config = conf.ConfObject() import volatility.constants as constants import volatility.registry as registry import volatility.exceptions as exceptions import volatility.obj as obj import volatility.debug as debug import volatility.addrspace as addrspace import volatility.commands as commands import volatility.scan as scan config.add_option("INFO", default = None, action = "store_true", cache_invalidator = False, help = "Print information about all registered objects") def list_plugins(): result = "\n\tSupported Plugin Commands:\n\n" cmds = registry.get_plugin_classes(commands.Command, lower = True) profs = registry.get_plugin_classes(obj.Profile) if config.PROFILE not in profs: raise BaseException("Invalid profile " + config.PROFILE + " selected") profile = profs[config.PROFILE]() wrongprofile = "" for cmdname in sorted(cmds): command = cmds[cmdname] helpline = command.help() or '' ## Just put the title line (First non empty line) in this ## abbreviated display for line in helpline.splitlines(): if line: helpline = line break if command.is_valid_profile(profile): result += "\t\t{0:15}\t{1}\n".format(cmdname, helpline) else: wrongprofile += "\t\t{0:15}\t{1}\n".format(cmdname, helpline) if wrongprofile and config.VERBOSE: result += "\n\tPlugins requiring a different profile:\n\n" result += wrongprofile return result def command_help(command): result = textwrap.dedent(""" --------------------------------- Module {0} ---------------------------------\n""".format(command.__class__.__name__)) return result + command.help() + "\n\n" def print_info(): """ Returns the results """ categories = {addrspace.BaseAddressSpace: 'Address Spaces', commands.Command : 'Plugins', obj.Profile: 'Profiles', scan.ScannerCheck: 'Scanner Checks'} for c, n in sorted(categories.items()): lower = (c == commands.Command) plugins = registry.get_plugin_classes(c, lower = lower) print "\n" print "{0}".format(n) print "-" * len(n) result = [] max_length = 0 for clsname, cls in sorted(plugins.items()): try: doc = cls.__doc__.strip().splitlines()[0] except AttributeError: doc = 'No docs' result.append((clsname, doc)) max_length = max(len(clsname), max_length) for (name, doc) in result: print "{0:{2}} - {1:15}".format(name, doc, max_length) def main(): # Get the version information on every output from the beginning # Exceptionally useful for debugging/telling people what's going on sys.stderr.write("Volatility Foundation Volatility Framework {0}\n".format(constants.VERSION)) sys.stderr.flush() # Setup the debugging format debug.setup() # Load up modules in case they set config options registry.PluginImporter() ## Register all register_options for the various classes registry.register_global_options(config, addrspace.BaseAddressSpace) registry.register_global_options(config, commands.Command) if config.INFO: print_info() sys.exit(0) ## Parse all the options now config.parse_options(False) # Reset the logging level now we know whether debug is set or not debug.setup(config.DEBUG) module = None ## Try to find the first thing that looks like a module name cmds = registry.get_plugin_classes(commands.Command, lower = True) for m in config.args: if m in cmds.keys(): module = m break if not module: config.parse_options() debug.error("You must specify something to do (try -h)") try: if module in cmds.keys(): command = cmds[module](config) ## Register the help cb from the command itself config.set_help_hook(obj.Curry(command_help, command)) config.parse_options() if not config.LOCATION: debug.error("Please specify a location (-l) or filename (-f)") command.execute() except exceptions.VolatilityException, e: print e if __name__ == "__main__": config.set_usage(usage = "Volatility - A memory forensics analysis platform.") config.add_help_hook(list_plugins) try: main() except Exception, ex: if config.DEBUG: debug.post_mortem() else: raise except KeyboardInterrupt: print "Interrupted"
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 221, 1882, 818, 26, 2366, 27, 1882, 199, 3, 199, 3, 28367, 199, 3, 1898, 334, 35, 9, 10219, 13, 6965, 28367, 2752, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28367, 14, 199, 3, 199, 3, 28367, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28367, 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, 28367, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 199, 32, 2502, 26, 755, 437, 1596, 265, 644, 31185, 199, 32, 1682, 26, 420, 1664, 1696, 1684, 844, 499, 14, 16, 199, 32, 7811, 26, 420, 282, 20877, 878, 32, 20, 683, 5812, 14, 846, 199, 32, 9071, 26, 28367, 2752, 199, 624, 199, 199, 3, 26324, 26, 3507, 13, 1328, 29, 35, 28107, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1227, 12, 378, 304, 272, 984, 14, 3083, 14, 952, 480, 16969, 18783, 5074, 2366, 1015, 499, 14, 22, 12, 8749, 10754, 2195, 2366, 12096, 2685, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 893, 26, 272, 492, 14177, 331, 327, 26324, 26, 3507, 13, 1328, 29, 55, 1690, 845, 12, 38, 28025, 199, 2590, 3545, 26, 272, 986, 199, 199, 692, 756, 26, 272, 327, 15783, 282, 4026, 492, 367, 7645, 2839, 1134, 17047, 370, 9793, 272, 327, 3967, 642, 365, 282, 5936, 402, 314, 333, 279, 1068, 8963, 272, 492, 612, 17956, 199, 199, 646, 13390, 199, 646, 5236, 18783, 14, 2190, 465, 3743, 199, 888, 275, 3743, 14, 8930, 1692, 342, 199, 646, 5236, 18783, 14, 5559, 465, 5262, 199, 646, 5236, 18783, 14, 5189, 465, 7086, 199, 646, 5236, 18783, 14, 3924, 465, 4967, 199, 646, 5236, 18783, 14, 1113, 465, 1559, 199, 646, 5236, 18783, 14, 1757, 465, 3105, 199, 199, 646, 5236, 18783, 14, 18942, 1142, 465, 29259, 1142, 199, 646, 5236, 18783, 14, 4405, 465, 3718, 199, 646, 5236, 18783, 14, 6282, 465, 8000, 199, 199, 888, 14, 525, 63, 1422, 480, 4531, 401, 849, 275, 488, 12, 1595, 275, 298, 1617, 63, 2052, 401, 2116, 2581, 63, 3197, 707, 275, 756, 12, 2116, 1720, 275, 298, 5375, 2556, 3595, 1006, 7264, 2251, 531, 199, 199, 318, 769, 63, 5265, 837, 272, 754, 275, 1867, 78, 60, 84, 10682, 11349, 5817, 83, 3427, 78, 60, 78, 2, 272, 11465, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 4405, 14, 3110, 12, 5117, 275, 715, 9, 272, 557, 2319, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 1113, 14, 5736, 9, 272, 340, 1101, 14, 16632, 440, 315, 557, 2319, 26, 267, 746, 25416, 480, 3364, 4690, 298, 435, 1101, 14, 16632, 435, 298, 4895, 531, 272, 4690, 275, 557, 2319, 59, 888, 14, 16632, 32702, 272, 6835, 2913, 275, 3087, 272, 367, 2088, 354, 315, 3355, 8, 12975, 304, 267, 1414, 275, 11465, 59, 1760, 354, 61, 267, 1720, 604, 275, 1414, 14, 3437, 342, 503, 2125, 267, 925, 13870, 5324, 314, 2538, 1004, 334, 7147, 2222, 2701, 1004, 9, 315, 642, 267, 925, 2236, 23988, 972, 2929, 267, 367, 1004, 315, 1720, 604, 14, 7644, 837, 288, 340, 1004, 26, 355, 1720, 604, 275, 1004, 355, 2059, 267, 340, 1414, 14, 374, 63, 1078, 63, 2913, 8, 2913, 304, 288, 754, 847, 1867, 84, 60, 84, 91, 16, 26, 1046, 4988, 84, 91, 17, 4988, 78, 1674, 908, 8, 1760, 354, 12, 1720, 604, 9, 267, 587, 26, 288, 6835, 2913, 847, 1867, 84, 60, 84, 91, 16, 26, 1046, 4988, 84, 91, 17, 4988, 78, 1674, 908, 8, 1760, 354, 12, 1720, 604, 9, 339, 340, 6835, 2913, 436, 1101, 14, 16075, 26, 267, 754, 847, 1867, 78, 60, 84, 19330, 29963, 282, 3365, 4690, 3427, 78, 60, 78, 2, 267, 754, 847, 6835, 2913, 339, 372, 754, 199, 199, 318, 1414, 63, 3437, 8, 1531, 304, 272, 754, 275, 13390, 14, 14674, 4852, 272, 11016, 13, 272, 5673, 469, 16, 93, 272, 11016, 2696, 78, 23045, 908, 8, 1531, 855, 533, 4914, 354, 8964, 339, 372, 754, 435, 1414, 14, 3437, 342, 435, 1867, 78, 60, 78, 2, 199, 199, 318, 870, 63, 815, 837, 272, 408, 1803, 314, 2058, 408, 272, 9695, 275, 469, 18942, 1142, 14, 20189, 7643, 26, 283, 1476, 428, 4285, 297, 2116, 3718, 14, 3110, 520, 283, 19330, 297, 2116, 1559, 14, 5736, 26, 283, 30208, 297, 2116, 8000, 14, 20843, 1799, 26, 283, 20843, 13813, 936, 272, 367, 286, 12, 302, 315, 3355, 8, 8906, 14, 1744, 5109, 267, 5117, 275, 334, 67, 508, 3718, 14, 3110, 9, 267, 8963, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 67, 12, 5117, 275, 5117, 9, 267, 870, 1867, 78, 2, 267, 870, 5310, 16, 5469, 908, 8, 78, 9, 267, 870, 17155, 627, 822, 8, 78, 9, 398, 754, 275, 942, 267, 1390, 63, 1267, 275, 378, 267, 367, 843, 354, 12, 843, 315, 3355, 8, 5265, 14, 1744, 5109, 288, 862, 26, 355, 1382, 275, 843, 855, 1301, 4343, 1913, 1252, 7644, 3430, 16, 61, 288, 871, 4281, 26, 355, 1382, 275, 283, 1944, 9149, 7, 288, 754, 14, 740, 1332, 1886, 354, 12, 1382, 430, 288, 1390, 63, 1267, 275, 1390, 8, 552, 8, 1886, 354, 395, 1390, 63, 1267, 9, 398, 367, 334, 354, 12, 1382, 9, 315, 754, 26, 288, 870, 5310, 16, 14534, 18, 4863, 446, 469, 17, 26, 1046, 5469, 908, 8, 354 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 221, 1882, 818, 26, 2366, 27, 1882, 199, 3, 199, 3, 28367, 199, 3, 1898, 334, 35, 9, 10219, 13, 6965, 28367, 2752, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28367, 14, 199, 3, 199, 3, 28367, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28367, 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, 28367, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 624, 199, 32, 2502, 26, 755, 437, 1596, 265, 644, 31185, 199, 32, 1682, 26, 420, 1664, 1696, 1684, 844, 499, 14, 16, 199, 32, 7811, 26, 420, 282, 20877, 878, 32, 20, 683, 5812, 14, 846, 199, 32, 9071, 26, 28367, 2752, 199, 624, 199, 199, 3, 26324, 26, 3507, 13, 1328, 29, 35, 28107, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1227, 12, 378, 304, 272, 984, 14, 3083, 14, 952, 480, 16969, 18783, 5074, 2366, 1015, 499, 14, 22, 12, 8749, 10754, 2195, 2366, 12096, 2685, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 893, 26, 272, 492, 14177, 331, 327, 26324, 26, 3507, 13, 1328, 29, 55, 1690, 845, 12, 38, 28025, 199, 2590, 3545, 26, 272, 986, 199, 199, 692, 756, 26, 272, 327, 15783, 282, 4026, 492, 367, 7645, 2839, 1134, 17047, 370, 9793, 272, 327, 3967, 642, 365, 282, 5936, 402, 314, 333, 279, 1068, 8963, 272, 492, 612, 17956, 199, 199, 646, 13390, 199, 646, 5236, 18783, 14, 2190, 465, 3743, 199, 888, 275, 3743, 14, 8930, 1692, 342, 199, 646, 5236, 18783, 14, 5559, 465, 5262, 199, 646, 5236, 18783, 14, 5189, 465, 7086, 199, 646, 5236, 18783, 14, 3924, 465, 4967, 199, 646, 5236, 18783, 14, 1113, 465, 1559, 199, 646, 5236, 18783, 14, 1757, 465, 3105, 199, 199, 646, 5236, 18783, 14, 18942, 1142, 465, 29259, 1142, 199, 646, 5236, 18783, 14, 4405, 465, 3718, 199, 646, 5236, 18783, 14, 6282, 465, 8000, 199, 199, 888, 14, 525, 63, 1422, 480, 4531, 401, 849, 275, 488, 12, 1595, 275, 298, 1617, 63, 2052, 401, 2116, 2581, 63, 3197, 707, 275, 756, 12, 2116, 1720, 275, 298, 5375, 2556, 3595, 1006, 7264, 2251, 531, 199, 199, 318, 769, 63, 5265, 837, 272, 754, 275, 1867, 78, 60, 84, 10682, 11349, 5817, 83, 3427, 78, 60, 78, 2, 272, 11465, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 4405, 14, 3110, 12, 5117, 275, 715, 9, 272, 557, 2319, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 1113, 14, 5736, 9, 272, 340, 1101, 14, 16632, 440, 315, 557, 2319, 26, 267, 746, 25416, 480, 3364, 4690, 298, 435, 1101, 14, 16632, 435, 298, 4895, 531, 272, 4690, 275, 557, 2319, 59, 888, 14, 16632, 32702, 272, 6835, 2913, 275, 3087, 272, 367, 2088, 354, 315, 3355, 8, 12975, 304, 267, 1414, 275, 11465, 59, 1760, 354, 61, 267, 1720, 604, 275, 1414, 14, 3437, 342, 503, 2125, 267, 925, 13870, 5324, 314, 2538, 1004, 334, 7147, 2222, 2701, 1004, 9, 315, 642, 267, 925, 2236, 23988, 972, 2929, 267, 367, 1004, 315, 1720, 604, 14, 7644, 837, 288, 340, 1004, 26, 355, 1720, 604, 275, 1004, 355, 2059, 267, 340, 1414, 14, 374, 63, 1078, 63, 2913, 8, 2913, 304, 288, 754, 847, 1867, 84, 60, 84, 91, 16, 26, 1046, 4988, 84, 91, 17, 4988, 78, 1674, 908, 8, 1760, 354, 12, 1720, 604, 9, 267, 587, 26, 288, 6835, 2913, 847, 1867, 84, 60, 84, 91, 16, 26, 1046, 4988, 84, 91, 17, 4988, 78, 1674, 908, 8, 1760, 354, 12, 1720, 604, 9, 339, 340, 6835, 2913, 436, 1101, 14, 16075, 26, 267, 754, 847, 1867, 78, 60, 84, 19330, 29963, 282, 3365, 4690, 3427, 78, 60, 78, 2, 267, 754, 847, 6835, 2913, 339, 372, 754, 199, 199, 318, 1414, 63, 3437, 8, 1531, 304, 272, 754, 275, 13390, 14, 14674, 4852, 272, 11016, 13, 272, 5673, 469, 16, 93, 272, 11016, 2696, 78, 23045, 908, 8, 1531, 855, 533, 4914, 354, 8964, 339, 372, 754, 435, 1414, 14, 3437, 342, 435, 1867, 78, 60, 78, 2, 199, 199, 318, 870, 63, 815, 837, 272, 408, 1803, 314, 2058, 408, 272, 9695, 275, 469, 18942, 1142, 14, 20189, 7643, 26, 283, 1476, 428, 4285, 297, 2116, 3718, 14, 3110, 520, 283, 19330, 297, 2116, 1559, 14, 5736, 26, 283, 30208, 297, 2116, 8000, 14, 20843, 1799, 26, 283, 20843, 13813, 936, 272, 367, 286, 12, 302, 315, 3355, 8, 8906, 14, 1744, 5109, 267, 5117, 275, 334, 67, 508, 3718, 14, 3110, 9, 267, 8963, 275, 7086, 14, 362, 63, 2718, 63, 2888, 8, 67, 12, 5117, 275, 5117, 9, 267, 870, 1867, 78, 2, 267, 870, 5310, 16, 5469, 908, 8, 78, 9, 267, 870, 17155, 627, 822, 8, 78, 9, 398, 754, 275, 942, 267, 1390, 63, 1267, 275, 378, 267, 367, 843, 354, 12, 843, 315, 3355, 8, 5265, 14, 1744, 5109, 288, 862, 26, 355, 1382, 275, 843, 855, 1301, 4343, 1913, 1252, 7644, 3430, 16, 61, 288, 871, 4281, 26, 355, 1382, 275, 283, 1944, 9149, 7, 288, 754, 14, 740, 1332, 1886, 354, 12, 1382, 430, 288, 1390, 63, 1267, 275, 1390, 8, 552, 8, 1886, 354, 395, 1390, 63, 1267, 9, 398, 367, 334, 354, 12, 1382, 9, 315, 754, 26, 288, 870, 5310, 16, 14534, 18, 4863, 446, 469, 17, 26, 1046, 5469, 908, 8, 354, 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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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, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mhbu50/erpnext
erpnext/patches/v11_0/inter_state_field_for_gst.py
3
3206
from __future__ import unicode_literals import frappe from erpnext.regional.india.setup import make_custom_fields def execute(): company = frappe.get_all('Company', filters = {'country': 'India'}) if not company: return frappe.reload_doc("Payroll", "doctype", "Employee Tax Exemption Declaration") frappe.reload_doc("Payroll", "doctype", "Employee Tax Exemption Proof Submission") frappe.reload_doc("hr", "doctype", "Employee Grade") frappe.reload_doc("hr", "doctype", "Leave Policy") frappe.reload_doc("accounts", "doctype", "Bank Account") frappe.reload_doc("accounts", "doctype", "Tax Withholding Category") frappe.reload_doc("accounts", "doctype", "Allowed To Transact With") frappe.reload_doc("accounts", "doctype", "Finance Book") frappe.reload_doc("accounts", "doctype", "Loyalty Program") frappe.reload_doc("stock", "doctype", "Item Barcode") make_custom_fields() frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges") frappe.reload_doc("accounts", "doctype", "purchase_taxes_and_charges") frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges_template") frappe.reload_doc("accounts", "doctype", "purchase_taxes_and_charges_template") # set is_inter_state in Taxes And Charges Templates if frappe.db.has_column("Sales Taxes and Charges Template", "is_inter_state") and\ frappe.db.has_column("Purchase Taxes and Charges Template", "is_inter_state"): igst_accounts = set(frappe.db.sql_list('''SELECT igst_account from `tabGST Account` WHERE parent = "GST Settings"''')) cgst_accounts = set(frappe.db.sql_list('''SELECT cgst_account FROM `tabGST Account` WHERE parenttype = "GST Settings"''')) when_then_sales = get_formatted_data("Sales Taxes and Charges", igst_accounts, cgst_accounts) when_then_purchase = get_formatted_data("Purchase Taxes and Charges", igst_accounts, cgst_accounts) if when_then_sales: frappe.db.sql('''update `tabSales Taxes and Charges Template` set is_inter_state = Case {when_then} Else 0 End '''.format(when_then=" ".join(when_then_sales))) if when_then_purchase: frappe.db.sql('''update `tabPurchase Taxes and Charges Template` set is_inter_state = Case {when_then} Else 0 End '''.format(when_then=" ".join(when_then_purchase))) def get_formatted_data(doctype, igst_accounts, cgst_accounts): # fetch all the rows data from child table all_details = frappe.db.sql(''' select parent, account_head from `tab{doctype}` where parenttype="{doctype} Template"'''.format(doctype=doctype), as_dict=True) # group the data in the form "parent: [list of accounts]"" group_detail = {} for i in all_details: if not i['parent'] in group_detail: group_detail[i['parent']] = [] for j in all_details: if i['parent']==j['parent']: group_detail[i['parent']].append(j['account_head']) # form when_then condition based on - if list of accounts for a document # matches any account in igst_accounts list and not matches any in cgst_accounts list when_then = [] for i in group_detail: temp = set(group_detail[i]) if not temp.isdisjoint(igst_accounts) and temp.isdisjoint(cgst_accounts): when_then.append('''When name='{name}' Then 1'''.format(name=i)) return when_then
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 29106, 14, 4551, 279, 14, 262, 2391, 14, 2758, 221, 492, 1852, 63, 4229, 63, 955, 199, 199, 318, 5341, 837, 199, 198, 4627, 275, 6950, 14, 362, 63, 452, 360, 16063, 297, 4766, 275, 791, 6063, 356, 283, 607, 2391, 3071, 199, 198, 692, 440, 7233, 26, 507, 198, 1107, 199, 198, 9098, 14, 9233, 63, 1301, 480, 10517, 2827, 401, 298, 6356, 401, 298, 22635, 30174, 1316, 2109, 296, 1487, 7456, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 10517, 2827, 401, 298, 6356, 401, 298, 22635, 30174, 1316, 2109, 296, 2165, 1618, 4804, 2250, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 6271, 401, 298, 6356, 401, 298, 22635, 10268, 271, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 6271, 401, 298, 6356, 401, 298, 23679, 18141, 531, 421, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 14814, 9973, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 26019, 8777, 72, 13122, 13573, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16070, 4005, 6266, 2442, 8777, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 8694, 554, 8944, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 2041, 89, 13248, 18841, 531, 421, 198, 9098, 14, 9233, 63, 1301, 480, 6088, 401, 298, 6356, 401, 298, 2081, 12377, 600, 531, 421, 198, 1875, 63, 4229, 63, 955, 342, 421, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16175, 63, 22272, 63, 460, 63, 1560, 3389, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 9533, 63, 22272, 63, 460, 63, 1560, 3389, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16175, 63, 22272, 63, 460, 63, 1560, 3389, 63, 1160, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 9533, 63, 22272, 63, 460, 63, 1560, 3389, 63, 1160, 531, 421, 198, 3, 663, 365, 63, 1058, 63, 929, 315, 377, 6402, 6061, 6659, 3389, 31273, 199, 198, 692, 6950, 14, 697, 14, 1989, 63, 2301, 480, 18220, 377, 6402, 436, 6659, 3389, 5458, 401, 298, 374, 63, 1058, 63, 929, 531, 436, 60, 507, 198, 9098, 14, 697, 14, 1989, 63, 2301, 480, 20486, 377, 6402, 436, 6659, 3389, 5458, 401, 298, 374, 63, 1058, 63, 929, 2349, 2742, 198, 528, 270, 63, 8370, 275, 663, 8, 9098, 14, 697, 14, 3009, 63, 513, 10505, 4859, 284, 23908, 63, 2048, 687, 658, 2902, 39, 840, 9973, 64, 6038, 1676, 275, 298, 39, 840, 13303, 2, 891, 1333, 507, 198, 12595, 270, 63, 8370, 275, 663, 8, 9098, 14, 697, 14, 3009, 63, 513, 10505, 4859, 19711, 270, 63, 2048, 4442, 658, 2902, 39, 840, 9973, 64, 6038, 1676, 466, 275, 298, 39, 840, 13303, 2, 891, 1333, 2742, 198, 6526, 63, 12726, 63, 16175, 275, 664, 63, 15317, 63, 576, 480, 18220, 377, 6402, 436, 6659, 3389, 401, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 9, 507, 198, 6526, 63, 12726, 63, 9533, 275, 664, 63, 15317, 63, 576, 480, 20486, 377, 6402, 436, 6659, 3389, 401, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 9, 2742, 198, 692, 1380, 63, 12726, 63, 16175, 26, 686, 198, 9098, 14, 697, 14, 3009, 10505, 873, 658, 2902, 18220, 377, 6402, 436, 6659, 3389, 5458, 64, 1585, 198, 409, 365, 63, 1058, 63, 929, 275, 12425, 469, 6526, 63, 12726, 93, 19524, 378, 9599, 686, 198, 891, 1370, 908, 8, 6526, 63, 12726, 628, 3680, 904, 8, 6526, 63, 12726, 63, 16175, 1724, 2742, 198, 692, 1380, 63, 12726, 63, 9533, 26, 686, 198, 9098, 14, 697, 14, 3009, 10505, 873, 658, 2902, 20486, 377, 6402, 436, 6659, 3389, 5458, 64, 1585, 198, 409, 365, 63, 1058, 63, 929, 275, 12425, 469, 6526, 63, 12726, 93, 19524, 378, 9599, 686, 198, 891, 1370, 908, 8, 6526, 63, 12726, 628, 3680, 904, 8, 6526, 63, 12726, 63, 9533, 1724, 199, 199, 318, 664, 63, 15317, 63, 576, 8, 6356, 12, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 304, 199, 198, 3, 5267, 1006, 314, 4730, 666, 687, 1982, 1817, 199, 198, 452, 63, 5087, 275, 6950, 14, 697, 14, 3009, 10505, 507, 198, 2416, 1676, 12, 2933, 63, 2993, 687, 658, 2902, 91, 6356, 23485, 507, 198, 4509, 1676, 466, 18448, 6356, 93, 5458, 2, 891, 1370, 908, 8, 6356, 29, 6356, 395, 465, 63, 807, 29, 549, 9, 421, 198, 3, 1572, 314, 666, 315, 314, 1824, 298, 1708, 26, 359, 513, 402, 12639, 61, 341, 199, 198, 923, 63, 5506, 275, 1052, 199, 198, 509, 284, 315, 1006, 63, 5087, 26, 507, 198, 692, 221, 440, 284, 459, 1708, 418, 315, 1572, 63, 5506, 26, 1572, 63, 5506, 59, 73, 459, 1708, 6538, 275, 942, 507, 198, 509, 1335, 315, 1006, 63, 5087, 26, 686, 198, 692, 284, 459, 1708, 418, 389, 74, 459, 1708, 2565, 1585, 198, 923, 63, 5506, 59, 73, 459, 1708, 418, 1055, 740, 8, 74, 459, 2048, 63, 2993, 1105, 421, 198, 3, 1824, 1380, 63, 12726, 5558, 4079, 641, 446, 340, 769, 402, 12639, 367, 282, 2213, 199, 198, 3, 4450, 1263, 2933, 315, 284, 23908, 63, 8370, 769, 436, 440, 4450, 1263, 315, 19711, 270, 63, 8370, 769, 199, 198, 6526, 63, 12726, 275, 942, 199, 198, 509, 284, 315, 1572, 63, 5506, 26, 507, 198, 808, 275, 663, 8, 923, 63, 5506, 59, 73, 566, 507, 198, 692, 440, 2388, 14, 374, 31880, 8, 528, 270, 63, 8370, 9, 436, 2388, 14, 374, 31880, 8, 12595, 270, 63, 8370, 304, 686, 198, 6526, 63, 12726, 14, 740, 10505, 11423, 536, 32134, 354, 6834, 9442, 413, 891, 1370, 908, 8, 354, 29, 73, 430, 421, 198, 1107, 1380, 63, 12726, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 504, 29106, 14, 4551, 279, 14, 262, 2391, 14, 2758, 221, 492, 1852, 63, 4229, 63, 955, 199, 199, 318, 5341, 837, 199, 198, 4627, 275, 6950, 14, 362, 63, 452, 360, 16063, 297, 4766, 275, 791, 6063, 356, 283, 607, 2391, 3071, 199, 198, 692, 440, 7233, 26, 507, 198, 1107, 199, 198, 9098, 14, 9233, 63, 1301, 480, 10517, 2827, 401, 298, 6356, 401, 298, 22635, 30174, 1316, 2109, 296, 1487, 7456, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 10517, 2827, 401, 298, 6356, 401, 298, 22635, 30174, 1316, 2109, 296, 2165, 1618, 4804, 2250, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 6271, 401, 298, 6356, 401, 298, 22635, 10268, 271, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 6271, 401, 298, 6356, 401, 298, 23679, 18141, 531, 421, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 14814, 9973, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 26019, 8777, 72, 13122, 13573, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16070, 4005, 6266, 2442, 8777, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 8694, 554, 8944, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 2041, 89, 13248, 18841, 531, 421, 198, 9098, 14, 9233, 63, 1301, 480, 6088, 401, 298, 6356, 401, 298, 2081, 12377, 600, 531, 421, 198, 1875, 63, 4229, 63, 955, 342, 421, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16175, 63, 22272, 63, 460, 63, 1560, 3389, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 9533, 63, 22272, 63, 460, 63, 1560, 3389, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 16175, 63, 22272, 63, 460, 63, 1560, 3389, 63, 1160, 531, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 9533, 63, 22272, 63, 460, 63, 1560, 3389, 63, 1160, 531, 421, 198, 3, 663, 365, 63, 1058, 63, 929, 315, 377, 6402, 6061, 6659, 3389, 31273, 199, 198, 692, 6950, 14, 697, 14, 1989, 63, 2301, 480, 18220, 377, 6402, 436, 6659, 3389, 5458, 401, 298, 374, 63, 1058, 63, 929, 531, 436, 60, 507, 198, 9098, 14, 697, 14, 1989, 63, 2301, 480, 20486, 377, 6402, 436, 6659, 3389, 5458, 401, 298, 374, 63, 1058, 63, 929, 2349, 2742, 198, 528, 270, 63, 8370, 275, 663, 8, 9098, 14, 697, 14, 3009, 63, 513, 10505, 4859, 284, 23908, 63, 2048, 687, 658, 2902, 39, 840, 9973, 64, 6038, 1676, 275, 298, 39, 840, 13303, 2, 891, 1333, 507, 198, 12595, 270, 63, 8370, 275, 663, 8, 9098, 14, 697, 14, 3009, 63, 513, 10505, 4859, 19711, 270, 63, 2048, 4442, 658, 2902, 39, 840, 9973, 64, 6038, 1676, 466, 275, 298, 39, 840, 13303, 2, 891, 1333, 2742, 198, 6526, 63, 12726, 63, 16175, 275, 664, 63, 15317, 63, 576, 480, 18220, 377, 6402, 436, 6659, 3389, 401, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 9, 507, 198, 6526, 63, 12726, 63, 9533, 275, 664, 63, 15317, 63, 576, 480, 20486, 377, 6402, 436, 6659, 3389, 401, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 9, 2742, 198, 692, 1380, 63, 12726, 63, 16175, 26, 686, 198, 9098, 14, 697, 14, 3009, 10505, 873, 658, 2902, 18220, 377, 6402, 436, 6659, 3389, 5458, 64, 1585, 198, 409, 365, 63, 1058, 63, 929, 275, 12425, 469, 6526, 63, 12726, 93, 19524, 378, 9599, 686, 198, 891, 1370, 908, 8, 6526, 63, 12726, 628, 3680, 904, 8, 6526, 63, 12726, 63, 16175, 1724, 2742, 198, 692, 1380, 63, 12726, 63, 9533, 26, 686, 198, 9098, 14, 697, 14, 3009, 10505, 873, 658, 2902, 20486, 377, 6402, 436, 6659, 3389, 5458, 64, 1585, 198, 409, 365, 63, 1058, 63, 929, 275, 12425, 469, 6526, 63, 12726, 93, 19524, 378, 9599, 686, 198, 891, 1370, 908, 8, 6526, 63, 12726, 628, 3680, 904, 8, 6526, 63, 12726, 63, 9533, 1724, 199, 199, 318, 664, 63, 15317, 63, 576, 8, 6356, 12, 284, 23908, 63, 8370, 12, 19711, 270, 63, 8370, 304, 199, 198, 3, 5267, 1006, 314, 4730, 666, 687, 1982, 1817, 199, 198, 452, 63, 5087, 275, 6950, 14, 697, 14, 3009, 10505, 507, 198, 2416, 1676, 12, 2933, 63, 2993, 687, 658, 2902, 91, 6356, 23485, 507, 198, 4509, 1676, 466, 18448, 6356, 93, 5458, 2, 891, 1370, 908, 8, 6356, 29, 6356, 395, 465, 63, 807, 29, 549, 9, 421, 198, 3, 1572, 314, 666, 315, 314, 1824, 298, 1708, 26, 359, 513, 402, 12639, 61, 341, 199, 198, 923, 63, 5506, 275, 1052, 199, 198, 509, 284, 315, 1006, 63, 5087, 26, 507, 198, 692, 221, 440, 284, 459, 1708, 418, 315, 1572, 63, 5506, 26, 1572, 63, 5506, 59, 73, 459, 1708, 6538, 275, 942, 507, 198, 509, 1335, 315, 1006, 63, 5087, 26, 686, 198, 692, 284, 459, 1708, 418, 389, 74, 459, 1708, 2565, 1585, 198, 923, 63, 5506, 59, 73, 459, 1708, 418, 1055, 740, 8, 74, 459, 2048, 63, 2993, 1105, 421, 198, 3, 1824, 1380, 63, 12726, 5558, 4079, 641, 446, 340, 769, 402, 12639, 367, 282, 2213, 199, 198, 3, 4450, 1263, 2933, 315, 284, 23908, 63, 8370, 769, 436, 440, 4450, 1263, 315, 19711, 270, 63, 8370, 769, 199, 198, 6526, 63, 12726, 275, 942, 199, 198, 509, 284, 315, 1572, 63, 5506, 26, 507, 198, 808, 275, 663, 8, 923, 63, 5506, 59, 73, 566, 507, 198, 692, 440, 2388, 14, 374, 31880, 8, 528, 270, 63, 8370, 9, 436, 2388, 14, 374, 31880, 8, 12595, 270, 63, 8370, 304, 686, 198, 6526, 63, 12726, 14, 740, 10505, 11423, 536, 32134, 354, 6834, 9442, 413, 891, 1370, 908, 8, 354, 29, 73, 430, 421, 198, 1107, 1380, 63, 12726, 199, 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 ]
mcdeoliveira/beaglebone
pyctrl/flask/server.py
3
17472
from flask import Flask, request, render_template, jsonify, make_response, redirect, flash, url_for from functools import wraps import re import pyctrl from pyctrl.block import Logger import warnings import importlib import traceback, sys, io from pyctrl.flask import JSONEncoder, JSONDecoder encoder = JSONEncoder(sort_keys = True, indent = 4) decoder = JSONDecoder() # decorators # decode def decode_value(f): @wraps(f) def wrapper(label, value, *args, **kwargs): return f(label, decoder.decode(value), *args, **kwargs) return wrapper # decode_kwargs_aux def decode_kwargs_aux(e): if len(e) == 1: return decoder.decode(e[0]) elif len(e) > 1: return [decoder.decode(v) for v in e] else: return None # decode_kwargs def decode_kwargs(f): @wraps(f) def wrapper(*args, **kwargs): try: kwargs.update({k: decode_kwargs_aux(request.args.getlist(k)) for k in request.args.keys()}) except: raise Exception("Arguments '{}' are not json compatible".format(request.args)) #print('>>> kwargs = {}'.format(kwargs)) return f(*args, **kwargs) return wrapper # json_response def json_response(f): @wraps(f) def wrapper(*args, **kwargs): try: retval = f(*args, **kwargs) if retval is None: retval = { 'status': 'success' } except Exception as e: message = io.StringIO() traceback.print_exc(file=message) retval = { 'status': 'error', 'message': message.getvalue() } next = request.args.get('next', None) if next: if 'status' in retval and retval['status'] == 'error': flash(retval['message']) return redirect(url_for(next)) else: return jsonify(retval) return wrapper # Server class class Server(Flask): def __init__(self, *args, **kwargs): self.controller = None self.base_url = '' # call super super().__init__(*args, **kwargs) # change json_encoder self.json_encoder = JSONEncoder # set api entry points # index, info and scope self.add_url_rule(self.base_url + '/', view_func = self.index) self.add_url_rule(self.base_url + '/info', view_func = self.info) self.add_url_rule(self.base_url + '/scope/<path:label>', view_func = self.scope) # download controller self.add_url_rule(self.base_url + '/download', view_func = self.download) # upload controller self.add_url_rule(self.base_url + '/upload', methods=['GET', 'POST'], view_func = self.upload) # reset self.add_url_rule(self.base_url + '/reset', view_func = self.reset) # set controller self.add_url_rule(self.base_url + '/set/controller/<module>/<pyctrl_class>', view_func = self.reset_controller) # start and stop self.add_url_rule(self.base_url + '/start', view_func = self.start) self.add_url_rule(self.base_url + '/stop', view_func = self.stop) # signals self.add_url_rule(self.base_url + '/add/signal/<path:label>', view_func = self.add_signal) self.add_url_rule(self.base_url + '/remove/signal/<path:label>', view_func = self.remove_signal) self.add_url_rule(self.base_url + '/get/signal/<path:label>', view_func = self.get_signal) self.add_url_rule(self.base_url + '/set/signal/<path:label>/<value>', view_func = self.set_signal) self.add_url_rule(self.base_url + '/list/signals', view_func = self.list_signals) # sources self.add_url_rule(self.base_url + '/add/source/<path:label>/<module_name>/<class_name>', view_func = self.add_source) self.add_url_rule(self.base_url + '/remove/source/<path:label>', view_func = self.remove_source) self.add_url_rule(self.base_url + '/get/source/<path:label>', view_func = self.get_source) self.add_url_rule(self.base_url + '/set/source/<path:label>', view_func = self.set_source) self.add_url_rule(self.base_url + '/html/source/<path:label>', view_func = self.html_source) # filters self.add_url_rule(self.base_url + '/add/filter/<path:label>/<module_name>/<class_name>', view_func = self.add_filter) self.add_url_rule(self.base_url + '/remove/filter/<path:label>', view_func = self.remove_filter) self.add_url_rule(self.base_url + '/get/filter/<path:label>', view_func = self.get_filter) self.add_url_rule(self.base_url + '/set/filter/<path:label>', view_func = self.set_filter) self.add_url_rule(self.base_url + '/html/filter/<path:label>', view_func = self.html_filter) # sinks self.add_url_rule(self.base_url + '/add/sink/<path:label>/<module_name>/<class_name>', view_func = self.add_sink) self.add_url_rule(self.base_url + '/remove/sink/<path:label>', view_func = self.remove_sink) self.add_url_rule(self.base_url + '/get/sink/<path:label>', view_func = self.get_sink) self.add_url_rule(self.base_url + '/set/sink/<path:label>', view_func = self.set_sink) self.add_url_rule(self.base_url + '/html/sink/<path:label>', view_func = self.html_sink) # timers self.add_url_rule(self.base_url + '/add/timer/<path:label>/<module_name>/<class_name>', view_func = self.add_timer) self.add_url_rule(self.base_url + '/remove/timer/<path:label>', view_func = self.remove_timer) self.add_url_rule(self.base_url + '/get/timer/<path:label>', view_func = self.get_timer) self.add_url_rule(self.base_url + '/set/timer/<path:label>', view_func = self.set_timer) self.add_url_rule(self.base_url + '/html/timer/<path:label>', view_func = self.html_timer) def set_controller(self, **kwargs): # Create new controller? if 'module' in kwargs or 'pyctrl_class' in kwargs: module = kwargs.pop('module', 'pyctrl') pyctrl_class = kwargs.pop('pyctrl_class', 'Controller') ckwargs = kwargs.pop('kwargs', {}) if len(kwargs) > 0: raise Exception("webserver.reset():: Unknown parameter(s) '{}'".format(', '.join(str(k) for k in kwargs.keys()))) try: if True: warnings.warn("> Installing new instance of '{}.{}({})' as controller".format(module, pyctrl_class, ckwargs)) obj_class = getattr(importlib.import_module(module), pyctrl_class) controller = obj_class(**ckwargs) # print('obj_class = {}'.format(obj_class)) # print('_controller = {}'.format(_controller)) # Make sure it is an instance of pyctrl.Controller if not isinstance(controller, pyctrl.Controller): raise Exception("Object '{}.{}' is not and instance of pyctrl.Controller".format(module, pyctrl_class)) self.controller = controller except Exception as e: raise Exception("Error resetting controller: {}".format(e)) elif 'controller' in kwargs: controller = kwargs.pop('controller') # Make sure it is an instance of pyctrl.Controller if not isinstance(controller, pyctrl.Controller): raise Exception("Object '{}.{}' is not and instance of pyctrl.Controller".format(module, pyctrl_class)) self.controller = controller # auxiliary def get_keys(self, method, type_name, label, **kwargs): # get keys keys = kwargs.get('keys', '') if keys and not isinstance(keys, (list,tuple)): keys = [keys] print('keys = {}'.format(keys)) # get container (container,label) = self.controller.resolve_label(label) if keys: # return attributes if len(keys) > 1: return method(label, *keys) else: return {keys[0]: method(label, *keys)} else: # return container return {label: getattr(container, type_name)[label]['block']} # handlers def index(self): sinks = [ {'label': k, 'is_logger': isinstance(v['block'], Logger)} for (k,v) in self.controller.sinks.items() ] return render_template('index.html', baseurl = self.base_url, class_name = self.controller.info('class'), signals = sorted(self.controller.list_signals()), sources = self.controller.list_sources(), filters = self.controller.list_filters(), sinks = sinks, timers = self.controller.list_timers(), is_running = self.controller.get_signal('is_running')) def info(self): return self.controller.html() def scope(self, label, *args, **kwargs): return render_template('scope.html', baseurl = self.base_url, logger = label) def download(self): response = make_response(jsonify(self.controller)) response.headers["Content-Disposition"] \ = "attachment; filename=controller.json" return response def upload(self, **kwargs): # post? if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash("Form has no field 'part'") else: # has file file = request.files['file'] # empty filename? if not file or file.filename == '': flash('No file selected') else: # there is a file try: controller = decoder.decode(file.read().decode('utf-8')) # print('controller = {}'.format(controller)) self.set_controller(controller = controller) flash('New controller succesfully loaded.') except Exception as e: message = io.StringIO() traceback.print_exc(file=message) flash('Could not load controller.') flash(message.getvalue()) return redirect(self.base_url + '/') @json_response @decode_kwargs def reset(self, **kwargs): return self.controller.reset(**kwargs) @decode_kwargs def reset_controller(self, **kwargs): # set new controller self.set_controller(**kwargs) # redirect to base return redirect(self.base_url + '/') @json_response def start(self): return self.controller.start() @json_response def stop(self): return self.controller.stop() @json_response def add_signal(self, *args, **kwargs): return self.controller.add_signal(*args, **kwargs) @json_response def remove_signal(self, *args, **kwargs): return self.controller.remove_signal(*args, **kwargs) @json_response def get_signal(self, label, *args, **kwargs): return {label: self.controller.get_signal(label, *args, **kwargs)} @json_response @decode_value def set_signal(self, *args, **kwargs): return self.controller.set_signal(*args, **kwargs) @json_response def list_signals(self): return self.controller.list_signals() # sources @json_response @decode_kwargs def add_source(self, label, module_name, class_name, **kwargs): return self.controller.add_source(label, (module_name, class_name), **kwargs) @json_response def remove_source(self, *args, **kwargs): return self.controller.remove_source(*args, **kwargs) @json_response @decode_kwargs def get_source(self, label, *args, **kwargs): return self.get_keys(self.controller.get_source, 'sources', label, *args, **kwargs) @json_response @decode_kwargs def set_source(self, *args, **kwargs): return self.controller.set_source(*args, **kwargs) @decode_kwargs def html_source(self, label, *args, **kwargs): # get container (container,label) = self.controller.resolve_label(label) return self.controller.sources[label]['block'].html(); # filters @json_response @decode_kwargs def add_filter(self, label, module_name, class_name, **kwargs): return self.controller.add_filter(label, (module_name, class_name), **kwargs) @json_response def remove_filter(self, *args, **kwargs): return self.controller.remove_filter(*args, **kwargs) @json_response @decode_kwargs def get_filter(self, label, *args, **kwargs): return self.get_keys(self.controller.get_filter, 'filters', label, *args, **kwargs) @json_response @decode_kwargs def set_filter(self, *args, **kwargs): return self.controller.set_filter(*args, **kwargs) @decode_kwargs def html_filter(self, label, *args, **kwargs): # get container (container,label) = self.controller.resolve_label(label) return self.controller.filters[label]['block'].html(); # sinks @json_response @decode_kwargs def add_sink(self, label, module_name, class_name, **kwargs): return self.controller.add_sink(label, (module_name, class_name), **kwargs) @json_response def remove_sink(self, *args, **kwargs): return self.controller.remove_sink(*args, **kwargs) @json_response @decode_kwargs def get_sink(self, label, *args, **kwargs): return self.get_keys(self.controller.get_sink, 'sinks', label, *args, **kwargs) @json_response @decode_kwargs def set_sink(self, *args, **kwargs): return self.controller.set_sink(*args, **kwargs) @decode_kwargs def html_sink(self, label, *args, **kwargs): # get container (container,label) = self.controller.resolve_label(label) return self.controller.sinks[label]['block'].html(); # timers @json_response @decode_kwargs def add_timer(self, label, module_name, class_name, **kwargs): return self.controller.add_timer(label, (module_name, class_name), **kwargs) @json_response def remove_timer(self, *args, **kwargs): return self.controller.remove_timer(*args, **kwargs) @json_response @decode_kwargs def get_timer(self, label, *args, **kwargs): return self.get_keys(self.controller.get_timer, 'timers', label, *args, **kwargs) @json_response @decode_kwargs def set_timer(self, *args, **kwargs): return self.controller.set_timer(*args, **kwargs) @decode_kwargs def html_timer(self, label, *args, **kwargs): # get container (container,label) = self.controller.resolve_label(label) return self.controller.timers[label]['block'].html(); if __name__ == "__main__": try: import os os.environ['RCPY_NO_HANDLERS'] = 't' from pyctrl.rc import Controller debug = False RCPY = True except: from pyctrl.timer import Controller debug = True RCPY = False try: app = Server(__name__) app.config['SECRET_KEY'] = 'secret!' # initialize controller app.set_controller(controller = Controller(period = .01)) # run app app.run(host='0.0.0.0', debug = debug) except: pass finally: sys.exit(0)
apache-2.0
[ 504, 7209, 492, 16704, 12, 1056, 12, 3795, 63, 1160, 12, 23819, 12, 1852, 63, 1310, 12, 4660, 12, 14775, 12, 1166, 63, 509, 199, 504, 9143, 492, 14018, 199, 646, 295, 199, 199, 646, 1134, 12476, 199, 504, 1134, 12476, 14, 1457, 492, 15996, 199, 646, 3598, 199, 646, 14802, 199, 646, 5190, 12, 984, 12, 5890, 199, 199, 504, 1134, 12476, 14, 15720, 492, 4840, 6679, 12, 4840, 8326, 199, 199, 9347, 275, 4840, 6679, 8, 3191, 63, 1612, 275, 715, 12, 4363, 275, 841, 9, 199, 8813, 275, 4840, 8326, 342, 199, 199, 3, 20419, 199, 199, 3, 4849, 199, 318, 4849, 63, 585, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 8, 1302, 12, 574, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 289, 8, 1302, 12, 10334, 14, 2708, 8, 585, 395, 627, 589, 12, 1011, 958, 9, 339, 372, 4975, 199, 199, 3, 4849, 63, 958, 63, 10962, 199, 318, 4849, 63, 958, 63, 10962, 8, 69, 304, 272, 340, 822, 8, 69, 9, 508, 413, 26, 267, 372, 10334, 14, 2708, 8, 69, 59, 16, 566, 272, 916, 822, 8, 69, 9, 690, 413, 26, 267, 372, 359, 8813, 14, 2708, 8, 86, 9, 367, 373, 315, 325, 61, 272, 587, 26, 267, 372, 488, 1362, 199, 3, 4849, 63, 958, 199, 318, 4849, 63, 958, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 2074, 14, 873, 2561, 75, 26, 4849, 63, 958, 63, 10962, 8, 1069, 14, 589, 14, 21343, 8, 75, 430, 2574, 367, 1022, 315, 1056, 14, 589, 14, 1612, 22804, 267, 871, 26, 288, 746, 2186, 480, 14517, 19574, 787, 440, 2022, 9025, 1674, 908, 8, 1069, 14, 589, 430, 267, 327, 1361, 360, 6071, 2074, 275, 9499, 908, 8, 958, 430, 267, 372, 289, 2031, 589, 12, 1011, 958, 9, 339, 372, 4975, 199, 199, 3, 2022, 63, 1310, 199, 318, 2022, 63, 1310, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 9151, 275, 289, 2031, 589, 12, 1011, 958, 9, 288, 340, 9151, 365, 488, 26, 355, 9151, 275, 469, 283, 1205, 356, 283, 3742, 7, 789, 267, 871, 2186, 465, 325, 26, 288, 1245, 275, 5890, 14, 6424, 342, 288, 5190, 14, 1361, 63, 2804, 8, 493, 29, 1188, 9, 288, 9151, 275, 469, 283, 1205, 356, 283, 705, 297, 2432, 283, 1188, 356, 1245, 14, 7150, 342, 789, 10631, 2163, 275, 1056, 14, 589, 14, 362, 360, 2184, 297, 488, 9, 267, 340, 2163, 26, 288, 340, 283, 1205, 7, 315, 9151, 436, 9151, 459, 1205, 418, 508, 283, 705, 356, 355, 14775, 8, 18476, 459, 1188, 1105, 288, 372, 4660, 8, 633, 63, 509, 8, 2184, 430, 267, 587, 26, 288, 372, 23819, 8, 18476, 9, 5493, 372, 4975, 199, 199, 3, 7146, 1021, 199, 199, 533, 7146, 8, 14182, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 398, 291, 14, 5538, 275, 488, 267, 291, 14, 1095, 63, 633, 275, 2125, 398, 327, 1240, 1613, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 1570, 2022, 63, 9347, 267, 291, 14, 1001, 63, 9347, 275, 4840, 6679, 398, 327, 663, 2986, 2397, 4501, 10631, 327, 1478, 12, 2256, 436, 4194, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 17220, 2079, 2455, 63, 1532, 275, 291, 14, 1080, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 815, 297, 2079, 2455, 63, 1532, 275, 291, 14, 815, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2645, 8316, 515, 26, 1302, 4206, 2079, 2455, 63, 1532, 275, 291, 14, 2645, 9, 2728, 327, 5235, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 4249, 297, 2079, 2455, 63, 1532, 275, 291, 14, 4249, 9, 2728, 327, 5802, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 5064, 297, 2079, 3102, 2968, 2970, 297, 283, 4030, 995, 2079, 2455, 63, 1532, 275, 291, 14, 5064, 9, 2728, 327, 5305, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 3958, 297, 2079, 2455, 63, 1532, 275, 291, 14, 3958, 9, 398, 327, 663, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 409, 15, 5538, 8316, 578, 23220, 647, 12476, 63, 533, 4206, 2079, 2455, 63, 1532, 275, 291, 14, 3958, 63, 5538, 9, 2728, 327, 1343, 436, 3631, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 928, 297, 586, 2455, 63, 1532, 275, 291, 14, 928, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2379, 297, 586, 2455, 63, 1532, 275, 291, 14, 2379, 9, 2728, 327, 10166, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 525, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 525, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2168, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 2168, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 362, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 362, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 409, 15, 4653, 8316, 515, 26, 1302, 23220, 585, 4206, 586, 2455, 63, 1532, 275, 291, 14, 409, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 513, 15, 10458, 297, 586, 2455, 63, 1532, 275, 291 ]
[ 7209, 492, 16704, 12, 1056, 12, 3795, 63, 1160, 12, 23819, 12, 1852, 63, 1310, 12, 4660, 12, 14775, 12, 1166, 63, 509, 199, 504, 9143, 492, 14018, 199, 646, 295, 199, 199, 646, 1134, 12476, 199, 504, 1134, 12476, 14, 1457, 492, 15996, 199, 646, 3598, 199, 646, 14802, 199, 646, 5190, 12, 984, 12, 5890, 199, 199, 504, 1134, 12476, 14, 15720, 492, 4840, 6679, 12, 4840, 8326, 199, 199, 9347, 275, 4840, 6679, 8, 3191, 63, 1612, 275, 715, 12, 4363, 275, 841, 9, 199, 8813, 275, 4840, 8326, 342, 199, 199, 3, 20419, 199, 199, 3, 4849, 199, 318, 4849, 63, 585, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 8, 1302, 12, 574, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 289, 8, 1302, 12, 10334, 14, 2708, 8, 585, 395, 627, 589, 12, 1011, 958, 9, 339, 372, 4975, 199, 199, 3, 4849, 63, 958, 63, 10962, 199, 318, 4849, 63, 958, 63, 10962, 8, 69, 304, 272, 340, 822, 8, 69, 9, 508, 413, 26, 267, 372, 10334, 14, 2708, 8, 69, 59, 16, 566, 272, 916, 822, 8, 69, 9, 690, 413, 26, 267, 372, 359, 8813, 14, 2708, 8, 86, 9, 367, 373, 315, 325, 61, 272, 587, 26, 267, 372, 488, 1362, 199, 3, 4849, 63, 958, 199, 318, 4849, 63, 958, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 2074, 14, 873, 2561, 75, 26, 4849, 63, 958, 63, 10962, 8, 1069, 14, 589, 14, 21343, 8, 75, 430, 2574, 367, 1022, 315, 1056, 14, 589, 14, 1612, 22804, 267, 871, 26, 288, 746, 2186, 480, 14517, 19574, 787, 440, 2022, 9025, 1674, 908, 8, 1069, 14, 589, 430, 267, 327, 1361, 360, 6071, 2074, 275, 9499, 908, 8, 958, 430, 267, 372, 289, 2031, 589, 12, 1011, 958, 9, 339, 372, 4975, 199, 199, 3, 2022, 63, 1310, 199, 318, 2022, 63, 1310, 8, 70, 304, 2286, 768, 13582, 8, 70, 9, 272, 347, 4975, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 9151, 275, 289, 2031, 589, 12, 1011, 958, 9, 288, 340, 9151, 365, 488, 26, 355, 9151, 275, 469, 283, 1205, 356, 283, 3742, 7, 789, 267, 871, 2186, 465, 325, 26, 288, 1245, 275, 5890, 14, 6424, 342, 288, 5190, 14, 1361, 63, 2804, 8, 493, 29, 1188, 9, 288, 9151, 275, 469, 283, 1205, 356, 283, 705, 297, 2432, 283, 1188, 356, 1245, 14, 7150, 342, 789, 10631, 2163, 275, 1056, 14, 589, 14, 362, 360, 2184, 297, 488, 9, 267, 340, 2163, 26, 288, 340, 283, 1205, 7, 315, 9151, 436, 9151, 459, 1205, 418, 508, 283, 705, 356, 355, 14775, 8, 18476, 459, 1188, 1105, 288, 372, 4660, 8, 633, 63, 509, 8, 2184, 430, 267, 587, 26, 288, 372, 23819, 8, 18476, 9, 5493, 372, 4975, 199, 199, 3, 7146, 1021, 199, 199, 533, 7146, 8, 14182, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 398, 291, 14, 5538, 275, 488, 267, 291, 14, 1095, 63, 633, 275, 2125, 398, 327, 1240, 1613, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 1570, 2022, 63, 9347, 267, 291, 14, 1001, 63, 9347, 275, 4840, 6679, 398, 327, 663, 2986, 2397, 4501, 10631, 327, 1478, 12, 2256, 436, 4194, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 17220, 2079, 2455, 63, 1532, 275, 291, 14, 1080, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 815, 297, 2079, 2455, 63, 1532, 275, 291, 14, 815, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2645, 8316, 515, 26, 1302, 4206, 2079, 2455, 63, 1532, 275, 291, 14, 2645, 9, 2728, 327, 5235, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 4249, 297, 2079, 2455, 63, 1532, 275, 291, 14, 4249, 9, 2728, 327, 5802, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 5064, 297, 2079, 3102, 2968, 2970, 297, 283, 4030, 995, 2079, 2455, 63, 1532, 275, 291, 14, 5064, 9, 2728, 327, 5305, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 3958, 297, 2079, 2455, 63, 1532, 275, 291, 14, 3958, 9, 398, 327, 663, 7614, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 409, 15, 5538, 8316, 578, 23220, 647, 12476, 63, 533, 4206, 2079, 2455, 63, 1532, 275, 291, 14, 3958, 63, 5538, 9, 2728, 327, 1343, 436, 3631, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 928, 297, 586, 2455, 63, 1532, 275, 291, 14, 928, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2379, 297, 586, 2455, 63, 1532, 275, 291, 14, 2379, 9, 2728, 327, 10166, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 525, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 525, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 2168, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 2168, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 362, 15, 4653, 8316, 515, 26, 1302, 4206, 586, 2455, 63, 1532, 275, 291, 14, 362, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 409, 15, 4653, 8316, 515, 26, 1302, 23220, 585, 4206, 586, 2455, 63, 1532, 275, 291, 14, 409, 63, 4653, 9, 267, 291, 14, 525, 63, 633, 63, 2200, 8, 277, 14, 1095, 63, 633, 435, 1994, 513, 15, 10458, 297, 586, 2455, 63, 1532, 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, 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 ]
car3oon/saleor
saleor/discount/migrations/0003_auto_20160207_0534.py
15
2317
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-02-07 11:34 from __future__ import unicode_literals import datetime from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('discount', '0002_voucher'), ] operations = [ migrations.AlterField( model_name='sale', name='type', field=models.CharField(choices=[('fixed', 'USD'), ('percentage', '%')], default='fixed', max_length=10), ), migrations.AlterField( model_name='voucher', name='code', field=models.CharField(db_index=True, max_length=12, unique=True, verbose_name='code'), ), migrations.AlterField( model_name='voucher', name='discount_value', field=models.DecimalField(decimal_places=2, max_digits=12, verbose_name='discount value'), ), migrations.AlterField( model_name='voucher', name='discount_value_type', field=models.CharField(choices=[('fixed', 'USD'), ('percentage', '%')], default='fixed', max_length=10, verbose_name='discount type'), ), migrations.AlterField( model_name='voucher', name='end_date', field=models.DateField(blank=True, null=True, verbose_name='end date'), ), migrations.AlterField( model_name='voucher', name='name', field=models.CharField(blank=True, max_length=255, null=True, verbose_name='name'), ), migrations.AlterField( model_name='voucher', name='start_date', field=models.DateField(default=datetime.date.today, verbose_name='start date'), ), migrations.AlterField( model_name='voucher', name='type', field=models.CharField(choices=[('value', 'All purchases'), ('product', 'One product'), ('category', 'A category of products'), ('shipping', 'Shipping')], default='value', max_length=20, verbose_name='discount for'), ), migrations.AlterField( model_name='voucher', name='usage_limit', field=models.PositiveIntegerField(blank=True, null=True, verbose_name='usage limit'), ), ]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 25, 14, 17, 641, 7800, 13, 996, 13, 1780, 4119, 26, 1082, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 15446, 297, 283, 9425, 63, 16637, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 8515, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 5964, 297, 283, 1668, 36, 659, 661, 14200, 297, 1543, 2665, 849, 534, 5964, 297, 1390, 63, 1267, 29, 709, 395, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 600, 297, 288, 901, 29, 992, 14, 2183, 8, 697, 63, 1080, 29, 549, 12, 1390, 63, 1267, 29, 713, 12, 3747, 29, 549, 12, 3376, 63, 354, 534, 600, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 15446, 63, 585, 297, 288, 901, 29, 992, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 713, 12, 3376, 63, 354, 534, 15446, 574, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 15446, 63, 585, 63, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 5964, 297, 283, 1668, 36, 659, 661, 14200, 297, 1543, 2665, 849, 534, 5964, 297, 1390, 63, 1267, 29, 709, 12, 3376, 63, 354, 534, 15446, 730, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 500, 63, 602, 297, 288, 901, 29, 992, 14, 14071, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 500, 1434, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 354, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 928, 63, 602, 297, 288, 901, 29, 992, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 12, 3376, 63, 354, 534, 928, 1434, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 585, 297, 283, 2422, 5861, 335, 3274, 659, 661, 2558, 297, 283, 4395, 3336, 659, 661, 3710, 297, 283, 33, 4637, 402, 7585, 659, 661, 17801, 297, 283, 30707, 4073, 2665, 849, 534, 585, 297, 1390, 63, 1267, 29, 1165, 12, 3376, 63, 354, 534, 15446, 367, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 3807, 63, 3097, 297, 288, 901, 29, 992, 14, 8591, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 3807, 2304, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 25, 14, 17, 641, 7800, 13, 996, 13, 1780, 4119, 26, 1082, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 15446, 297, 283, 9425, 63, 16637, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 8515, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 5964, 297, 283, 1668, 36, 659, 661, 14200, 297, 1543, 2665, 849, 534, 5964, 297, 1390, 63, 1267, 29, 709, 395, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 600, 297, 288, 901, 29, 992, 14, 2183, 8, 697, 63, 1080, 29, 549, 12, 1390, 63, 1267, 29, 713, 12, 3747, 29, 549, 12, 3376, 63, 354, 534, 600, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 15446, 63, 585, 297, 288, 901, 29, 992, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 713, 12, 3376, 63, 354, 534, 15446, 574, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 15446, 63, 585, 63, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 5964, 297, 283, 1668, 36, 659, 661, 14200, 297, 1543, 2665, 849, 534, 5964, 297, 1390, 63, 1267, 29, 709, 12, 3376, 63, 354, 534, 15446, 730, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 500, 63, 602, 297, 288, 901, 29, 992, 14, 14071, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 500, 1434, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 354, 297, 288, 901, 29, 992, 14, 2183, 8, 2500, 29, 549, 12, 1390, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 354, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 928, 63, 602, 297, 288, 901, 29, 992, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 12, 3376, 63, 354, 534, 928, 1434, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 466, 297, 288, 901, 29, 992, 14, 2183, 8, 4577, 11699, 585, 297, 283, 2422, 5861, 335, 3274, 659, 661, 2558, 297, 283, 4395, 3336, 659, 661, 3710, 297, 283, 33, 4637, 402, 7585, 659, 661, 17801, 297, 283, 30707, 4073, 2665, 849, 534, 585, 297, 1390, 63, 1267, 29, 1165, 12, 3376, 63, 354, 534, 15446, 367, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 16637, 297, 288, 536, 534, 3807, 63, 3097, 297, 288, 901, 29, 992, 14, 8591, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 3807, 2304, 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, 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,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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 ]
bkaradzic/SwiftShader
third_party/subzero/pydir/szbuild_spec2k.py
3
2991
#!/usr/bin/env python2 import argparse import os import sys import szbuild from utils import FindBaseNaCl, shellcmd def main(): """Build native gcc-style executables for one or all Spec2K components. Afterwards, the executables can be run from the native_client/tests/spec2k/ directory as: './run_all.sh RunBenchmarks SetupGccX8632Opt {train|ref} ...' -- or -- './run_all.sh RunBenchmarks SetupPnaclX8632Opt {train|ref} ...' -- or -- './run_all.sh RunBenchmarks SetupNonsfiX8632Opt {train|ref} ...' """ nacl_root = FindBaseNaCl() # Use the same default ordering as spec2k/run_all.sh. components = [ '177.mesa', '179.art', '183.equake', '188.ammp', '164.gzip', '175.vpr', '176.gcc', '181.mcf', '186.crafty', '197.parser', '253.perlbmk', '254.gap', '255.vortex', '256.bzip2', '300.twolf', '252.eon' ] argparser = argparse.ArgumentParser(description=main.__doc__) szbuild.AddOptionalArgs(argparser) argparser.add_argument('--run', dest='run', action='store_true', help='Run after building') argparser.add_argument('comps', nargs='*', default=components) args = argparser.parse_args() bad = set(args.comps) - set(components) if bad: print 'Unknown component{s}: '.format(s='s' if len(bad) > 1 else '') + \ ' '.join(x for x in bad) sys.exit(1) # Fix up Subzero target strings for the run_all.sh script. target_map = { 'arm32':'arm', 'x8632':'x8632', 'x8664':'x8664' } run_all_target = target_map[args.target] # fail if target not listed above suffix = ( 'pnacl.opt.{target}' if args.sandbox else 'nonsfi.opt.{target}' if args.nonsfi else 'gcc.opt.{target}').format( target=run_all_target); for comp in args.comps: name = os.path.splitext(comp)[1] or comp if name[0] == '.': name = name[1:] szbuild.ProcessPexe(args, ('{root}/tests/spec2k/{comp}/' + '{name}.opt.stripped.pexe' ).format(root=nacl_root, comp=comp, name=name), ('{root}/tests/spec2k/{comp}/' + '{name}.{suffix}' ).format(root=nacl_root, comp=comp, name=name, suffix=suffix)) if args.run: os.chdir('{root}/tests/spec2k'.format(root=FindBaseNaCl())) setup = 'Setup' + ('Pnacl' if args.sandbox else 'Nonsfi' if args.nonsfi else 'Gcc') + { 'arm32': 'Arm', 'x8632': 'X8632', 'x8664': 'X8664'}[args.target] + 'Opt' shellcmd(['./run_all.sh', 'RunTimedBenchmarks', setup, 'train'] + args.comps) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 646, 17176, 1506, 199, 199, 504, 3778, 492, 6668, 1563, 8565, 1968, 12, 5218, 1760, 199, 199, 318, 2446, 837, 272, 408, 3425, 5438, 19443, 13, 2487, 31172, 367, 1373, 503, 1006, 31511, 18, 43, 7323, 14, 339, 12836, 4751, 12, 314, 31172, 883, 506, 1255, 687, 314, 272, 5438, 63, 1258, 15, 2219, 15, 1650, 18, 75, 15, 2082, 465, 26, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 39, 2055, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 1553, 503, 1553, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 48, 7745, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 1553, 503, 1553, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 46, 4654, 329, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 408, 272, 302, 5853, 63, 1231, 275, 6668, 1563, 8565, 1968, 342, 272, 327, 3645, 314, 2011, 849, 7794, 465, 3158, 18, 75, 15, 1065, 63, 452, 14, 609, 14, 272, 7323, 275, 359, 283, 8881, 14, 27871, 297, 283, 10699, 14, 580, 297, 283, 12363, 14, 15788, 1728, 297, 283, 11501, 14, 455, 311, 297, 283, 8982, 14, 12256, 297, 673, 283, 10848, 14, 86, 2700, 297, 283, 10216, 14, 13112, 297, 283, 12851, 14, 77, 2177, 297, 283, 11656, 14, 67, 345, 70, 369, 297, 283, 11165, 14, 2087, 297, 673, 283, 3781, 14, 529, 6374, 3880, 297, 283, 8306, 14, 15046, 297, 283, 2299, 14, 14419, 3858, 297, 283, 3912, 14, 66, 3065, 18, 297, 673, 283, 5863, 14, 5601, 276, 297, 283, 6390, 14, 69, 265, 7, 1622, 339, 1680, 2087, 275, 7534, 14, 10730, 8, 1802, 29, 973, 855, 1301, 3368, 272, 17176, 1506, 14, 1123, 7012, 6213, 8, 1273, 2087, 9, 272, 1680, 2087, 14, 525, 63, 2094, 4517, 1065, 297, 2053, 534, 1065, 297, 1595, 534, 1617, 63, 2052, 297, 2574, 1720, 534, 2540, 2410, 10015, 358, 272, 1680, 2087, 14, 525, 63, 2094, 360, 24344, 297, 9237, 534, 7693, 849, 29, 4608, 9, 272, 1249, 275, 1680, 2087, 14, 1122, 63, 589, 342, 272, 4875, 275, 663, 8, 589, 14, 24344, 9, 446, 663, 8, 4608, 9, 272, 340, 4875, 26, 267, 870, 283, 5912, 3931, 91, 83, 9160, 1987, 908, 8, 83, 534, 83, 7, 340, 822, 8, 4087, 9, 690, 413, 587, 4074, 435, 971, 288, 283, 1987, 904, 8, 88, 367, 671, 315, 4875, 9, 267, 984, 14, 2224, 8, 17, 9, 339, 327, 14811, 1536, 4804, 4262, 1347, 3326, 367, 314, 1255, 63, 452, 14, 609, 2884, 14, 272, 1347, 63, 1130, 275, 469, 268, 283, 5362, 708, 5242, 5362, 297, 268, 283, 88, 1184, 708, 5242, 88, 1184, 708, 297, 268, 283, 88, 1184, 772, 5242, 88, 1184, 772, 7, 268, 789, 272, 1255, 63, 452, 63, 1375, 275, 1347, 63, 1130, 59, 589, 14, 1375, 61, 327, 2449, 340, 1347, 440, 10532, 3432, 339, 4739, 275, 334, 267, 283, 80, 7745, 14, 2992, 23379, 1375, 6834, 340, 1249, 14, 16647, 587, 267, 283, 2865, 83, 329, 14, 2992, 23379, 1375, 6834, 340, 1249, 14, 2865, 83, 329, 587, 267, 283, 13112, 14, 2992, 23379, 1375, 93, 1959, 908, 8, 1467, 1347, 29, 1065, 63, 452, 63, 1375, 2736, 272, 367, 1013, 315, 1249, 14, 24344, 26, 267, 536, 275, 747, 14, 515, 14, 7973, 8, 863, 2788, 17, 61, 503, 1013, 267, 340, 536, 59, 16, 61, 508, 26351, 288, 536, 275, 536, 59, 17, 2938, 267, 17176, 1506, 14, 3498, 48, 5803, 8, 589, 12, 1169, 661, 91, 1231, 5995, 2219, 15, 1650, 18, 75, 5321, 863, 93, 4805, 435, 2490, 5041, 354, 5565, 2992, 14, 25382, 14, 321, 1845, 7, 2490, 7092, 908, 8, 1231, 29, 7745, 63, 1231, 12, 1013, 29, 863, 12, 536, 29, 354, 395, 1169, 661, 91, 1231, 5995, 2219, 15, 1650, 18, 75, 5321, 863, 93, 4805, 435, 2490, 5041, 354, 26944, 4511, 6834, 2490, 7092, 908, 8, 1231, 29, 7745, 63, 1231, 12, 1013, 29, 863, 12, 536, 29, 354, 12, 4228, 4739, 29, 4511, 430, 272, 340, 1249, 14, 1065, 26, 267, 747, 14, 8563, 11117, 1231, 5995, 2219, 15, 1650, 18, 75, 1370, 908, 8, 1231, 29, 6591, 1563, 8565, 1968, 4059, 267, 3272, 275, 283, 8555, 7, 435, 661, 48, 7745, 7, 340, 1249, 14, 16647, 587, 2574, 283, 46, 4654, 329, 7, 340, 1249, 14, 2865, 83, 329, 587, 2574, 283, 39, 2055, 358, 435, 469, 288, 283, 5362, 708, 356, 283, 1596, 77, 297, 288, 283, 88, 1184, 708, 356, 283, 56, 1184, 708, 297, 288, 283, 88, 1184, 772, 356, 283, 56, 1184, 772, 936, 59, 589, 14, 1375, 61, 435, 283, 9985, 7, 267, 5218, 1760, 2941, 13186, 1065, 63, 452, 14, 609, 297, 2116, 283, 2540, 28682, 18644, 83, 297, 2116, 3272, 12, 2116, 283, 2834, 418, 435, 1249, 14, 24344, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 646, 7534, 199, 646, 747, 199, 646, 984, 199, 199, 646, 17176, 1506, 199, 199, 504, 3778, 492, 6668, 1563, 8565, 1968, 12, 5218, 1760, 199, 199, 318, 2446, 837, 272, 408, 3425, 5438, 19443, 13, 2487, 31172, 367, 1373, 503, 1006, 31511, 18, 43, 7323, 14, 339, 12836, 4751, 12, 314, 31172, 883, 506, 1255, 687, 314, 272, 5438, 63, 1258, 15, 2219, 15, 1650, 18, 75, 15, 2082, 465, 26, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 39, 2055, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 1553, 503, 1553, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 48, 7745, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 1553, 503, 1553, 272, 21526, 1065, 63, 452, 14, 609, 3378, 18644, 83, 12439, 46, 4654, 329, 56, 1184, 708, 9985, 469, 2834, 92, 1121, 93, 2263, 7, 272, 408, 272, 302, 5853, 63, 1231, 275, 6668, 1563, 8565, 1968, 342, 272, 327, 3645, 314, 2011, 849, 7794, 465, 3158, 18, 75, 15, 1065, 63, 452, 14, 609, 14, 272, 7323, 275, 359, 283, 8881, 14, 27871, 297, 283, 10699, 14, 580, 297, 283, 12363, 14, 15788, 1728, 297, 283, 11501, 14, 455, 311, 297, 283, 8982, 14, 12256, 297, 673, 283, 10848, 14, 86, 2700, 297, 283, 10216, 14, 13112, 297, 283, 12851, 14, 77, 2177, 297, 283, 11656, 14, 67, 345, 70, 369, 297, 283, 11165, 14, 2087, 297, 673, 283, 3781, 14, 529, 6374, 3880, 297, 283, 8306, 14, 15046, 297, 283, 2299, 14, 14419, 3858, 297, 283, 3912, 14, 66, 3065, 18, 297, 673, 283, 5863, 14, 5601, 276, 297, 283, 6390, 14, 69, 265, 7, 1622, 339, 1680, 2087, 275, 7534, 14, 10730, 8, 1802, 29, 973, 855, 1301, 3368, 272, 17176, 1506, 14, 1123, 7012, 6213, 8, 1273, 2087, 9, 272, 1680, 2087, 14, 525, 63, 2094, 4517, 1065, 297, 2053, 534, 1065, 297, 1595, 534, 1617, 63, 2052, 297, 2574, 1720, 534, 2540, 2410, 10015, 358, 272, 1680, 2087, 14, 525, 63, 2094, 360, 24344, 297, 9237, 534, 7693, 849, 29, 4608, 9, 272, 1249, 275, 1680, 2087, 14, 1122, 63, 589, 342, 272, 4875, 275, 663, 8, 589, 14, 24344, 9, 446, 663, 8, 4608, 9, 272, 340, 4875, 26, 267, 870, 283, 5912, 3931, 91, 83, 9160, 1987, 908, 8, 83, 534, 83, 7, 340, 822, 8, 4087, 9, 690, 413, 587, 4074, 435, 971, 288, 283, 1987, 904, 8, 88, 367, 671, 315, 4875, 9, 267, 984, 14, 2224, 8, 17, 9, 339, 327, 14811, 1536, 4804, 4262, 1347, 3326, 367, 314, 1255, 63, 452, 14, 609, 2884, 14, 272, 1347, 63, 1130, 275, 469, 268, 283, 5362, 708, 5242, 5362, 297, 268, 283, 88, 1184, 708, 5242, 88, 1184, 708, 297, 268, 283, 88, 1184, 772, 5242, 88, 1184, 772, 7, 268, 789, 272, 1255, 63, 452, 63, 1375, 275, 1347, 63, 1130, 59, 589, 14, 1375, 61, 327, 2449, 340, 1347, 440, 10532, 3432, 339, 4739, 275, 334, 267, 283, 80, 7745, 14, 2992, 23379, 1375, 6834, 340, 1249, 14, 16647, 587, 267, 283, 2865, 83, 329, 14, 2992, 23379, 1375, 6834, 340, 1249, 14, 2865, 83, 329, 587, 267, 283, 13112, 14, 2992, 23379, 1375, 93, 1959, 908, 8, 1467, 1347, 29, 1065, 63, 452, 63, 1375, 2736, 272, 367, 1013, 315, 1249, 14, 24344, 26, 267, 536, 275, 747, 14, 515, 14, 7973, 8, 863, 2788, 17, 61, 503, 1013, 267, 340, 536, 59, 16, 61, 508, 26351, 288, 536, 275, 536, 59, 17, 2938, 267, 17176, 1506, 14, 3498, 48, 5803, 8, 589, 12, 1169, 661, 91, 1231, 5995, 2219, 15, 1650, 18, 75, 5321, 863, 93, 4805, 435, 2490, 5041, 354, 5565, 2992, 14, 25382, 14, 321, 1845, 7, 2490, 7092, 908, 8, 1231, 29, 7745, 63, 1231, 12, 1013, 29, 863, 12, 536, 29, 354, 395, 1169, 661, 91, 1231, 5995, 2219, 15, 1650, 18, 75, 5321, 863, 93, 4805, 435, 2490, 5041, 354, 26944, 4511, 6834, 2490, 7092, 908, 8, 1231, 29, 7745, 63, 1231, 12, 1013, 29, 863, 12, 536, 29, 354, 12, 4228, 4739, 29, 4511, 430, 272, 340, 1249, 14, 1065, 26, 267, 747, 14, 8563, 11117, 1231, 5995, 2219, 15, 1650, 18, 75, 1370, 908, 8, 1231, 29, 6591, 1563, 8565, 1968, 4059, 267, 3272, 275, 283, 8555, 7, 435, 661, 48, 7745, 7, 340, 1249, 14, 16647, 587, 2574, 283, 46, 4654, 329, 7, 340, 1249, 14, 2865, 83, 329, 587, 2574, 283, 39, 2055, 358, 435, 469, 288, 283, 5362, 708, 356, 283, 1596, 77, 297, 288, 283, 88, 1184, 708, 356, 283, 56, 1184, 708, 297, 288, 283, 88, 1184, 772, 356, 283, 56, 1184, 772, 936, 59, 589, 14, 1375, 61, 435, 283, 9985, 7, 267, 5218, 1760, 2941, 13186, 1065, 63, 452, 14, 609, 297, 2116, 283, 2540, 28682, 18644, 83, 297, 2116, 3272, 12, 2116, 283, 2834, 418, 435, 1249, 14, 24344, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
baoboa/pyqt5
examples/designer/plugins/widgets/counterlabel.py
3
5180
#!/usr/bin/env python """ counterlabel.py A PyQt custom widget example for Qt Designer. Copyright (C) 2006 David Boddie <david@boddie.org.uk> Copyright (C) 2005-2006 Trolltech ASA. All rights reserved. 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. 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QRectF, QSize, Qt from PyQt5.QtGui import QFont, QFontMetricsF, QPainter from PyQt5.QtWidgets import QApplication, QWidget class CounterLabel(QWidget): """CounterLabel(QWidget) Provides a custom label widget to be used as a counter, with signals similar to those provided by QAbstractSlider subclasses and properties similar to those provided by QLabel. """ # We define two signals that are used to indicate changes to the status # of the widget. valueChanged = pyqtSignal((int, ), (str, )) def __init__(self, parent=None): super(CounterLabel, self).__init__(parent) self.setAutoFillBackground(False) self._font = QFont() self._minimum = 1 self._maximum = 1 self._value = 1 self._offset = 0 self.rescale() self.reposition() def paintEvent(self, event): p = QPainter() p.begin(self) p.setRenderHint(QPainter.Antialiasing) p.setFont(self._font) p.translate(self.width()/2.0, self.height()/2.0) p.scale(self._scale, self._scale) p.drawText(self._xpos, self._ypos, str(self._value)) p.end() def sizeHint(self): return QSize(32, 32) def rescale(self): fm = QFontMetricsF(self._font, self) maxRect = fm.boundingRect(QRectF(self.rect()), Qt.AlignCenter, str(self._maximum)) xscale = float(self.width())/maxRect.width() yscale = float(self.height())/maxRect.height() self._scale = min(xscale, yscale) def reposition(self): fm = QFontMetricsF(self._font, self) rect = fm.boundingRect(QRectF(self.rect()), Qt.AlignCenter, str(self._value)) self._xpos = -rect.width()/2.0 self._ypos = rect.height()/2.0 - fm.descent() self.update() # Provide getter and setter methods for the font property. def getFont(self): return self._font def setFont(self, font): self._font = font self.rescale() self.reposition() font = pyqtProperty(QFont, getFont, setFont) # Provide getter and setter methods for the minimum and maximum properties. def getMinimum(self): return self._minimum def setMinimum(self, value): self._minimum = value if self._minimum > self._maximum: self.setMaximum(self._minimum) if self._minimum > self._value: self.setValue(self._minimum) minimum = pyqtProperty(int, getMinimum, setMinimum) def getMaximum(self): return self._maximum def setMaximum(self, value): self._maximum = value self._minimum = min(self._minimum, self._maximum) if self._maximum < self._value: self.setValue(self._maximum) self.rescale() self.reposition() maximum = pyqtProperty(int, getMaximum, setMaximum) # We provide an offset property to allow the value shown to differ from # the internal value held by the widget. def getOffset(self): return self._offset def setOffset(self, value): self._offset = value offset = pyqtProperty(int, getOffset, setOffset) # The value property is implemented using the getValue() and setValue() # methods. def getValue(self): return self._value # The setter method for the value property can also be used as a slot. @pyqtSlot(int) def setValue(self, value): if not self._minimum <= value <= self._maximum: return self._value = value self.valueChanged[int].emit(value + self._offset) self.valueChanged[str].emit(str(value + self._offset)) self.reposition() value = pyqtProperty(int, getValue, setValue) # Like QAbstractSpinBox, we provide stepUp() and stepDown() slots to # enable the value to be incremented and decremented. @pyqtSlot() def stepUp(self): self.setValue(self._value + 1) @pyqtSlot() def stepDown(self): self.setValue(self._value - 1) if __name__ == "__main__": import sys app = QApplication(sys.argv) widget = CounterLabel() widget.setValue(123) widget.show() sys.exit(app.exec_())
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 5337, 1302, 14, 647, 199, 199, 33, 14084, 3537, 3938, 2893, 367, 3959, 1487, 25399, 14, 199, 199, 7384, 334, 35, 9, 8315, 20232, 699, 364, 15130, 665, 983, 5017, 32, 66, 364, 15130, 14, 1308, 14, 3210, 30, 199, 7384, 334, 35, 9, 11811, 13, 7968, 377, 2827, 15970, 437, 4251, 14, 2900, 4481, 4644, 14, 199, 199, 2765, 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, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 624, 199, 199, 504, 14084, 21, 14, 10901, 492, 27149, 3697, 12, 27149, 11274, 12, 27149, 15183, 12, 1413, 8252, 38, 12, 1413, 2320, 12, 3959, 199, 504, 14084, 21, 14, 10604, 492, 1413, 6986, 12, 1413, 6986, 17213, 38, 12, 1413, 31169, 199, 504, 14084, 21, 14, 29081, 492, 29469, 12, 1413, 3339, 421, 199, 533, 14427, 4314, 8, 23894, 304, 272, 408, 11348, 4314, 8, 23894, 9, 339, 21552, 282, 3537, 1768, 3938, 370, 506, 1202, 465, 282, 7055, 12, 543, 10166, 272, 8545, 370, 5204, 2741, 701, 1413, 8458, 21074, 9180, 436, 4382, 272, 8545, 370, 5204, 2741, 701, 1413, 4314, 14, 272, 408, 339, 327, 2136, 5627, 2877, 10166, 626, 787, 1202, 370, 6623, 4493, 370, 314, 2004, 272, 327, 402, 314, 3938, 14, 272, 574, 6970, 275, 27149, 11274, 1332, 442, 12, 2318, 334, 495, 12, 5082, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 398, 1613, 8, 11348, 4314, 12, 291, 2843, 826, 721, 1708, 9, 398, 291, 14, 409, 3358, 12914, 14148, 8, 797, 9, 398, 291, 423, 4246, 275, 1413, 6986, 342, 267, 291, 423, 10700, 275, 413, 267, 291, 423, 11555, 275, 413, 267, 291, 423, 585, 275, 413, 267, 291, 423, 2743, 275, 378, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 347, 32055, 2390, 8, 277, 12, 1566, 304, 398, 299, 275, 1413, 31169, 342, 267, 299, 14, 5037, 8, 277, 9, 267, 299, 14, 409, 9216, 20891, 8, 49, 31169, 14, 2493, 1009, 2241, 316, 9, 267, 299, 14, 24432, 8, 277, 423, 4246, 9, 267, 299, 14, 5275, 8, 277, 14, 2063, 29728, 18, 14, 16, 12, 291, 14, 3333, 29728, 18, 14, 16, 9, 267, 299, 14, 3467, 8, 277, 423, 3467, 12, 291, 423, 3467, 9, 267, 299, 14, 5485, 1872, 8, 277, 423, 88, 1712, 12, 291, 423, 89, 1712, 12, 620, 8, 277, 423, 585, 430, 267, 299, 14, 500, 342, 339, 347, 1568, 20891, 8, 277, 304, 267, 372, 1413, 2320, 8, 708, 12, 4337, 9, 339, 347, 522, 2357, 8, 277, 304, 398, 20831, 275, 1413, 6986, 17213, 38, 8, 277, 423, 4246, 12, 291, 9, 267, 1390, 8252, 275, 20831, 14, 24511, 8252, 8, 30197, 38, 8, 277, 14, 1201, 4000, 3959, 14, 9497, 13551, 12, 355, 620, 8, 277, 423, 11555, 430, 267, 671, 3467, 275, 2069, 8, 277, 14, 2063, 1012, 15, 988, 8252, 14, 2063, 342, 267, 612, 3467, 275, 2069, 8, 277, 14, 3333, 1012, 15, 988, 8252, 14, 3333, 342, 267, 291, 423, 3467, 275, 1748, 8, 88, 3467, 12, 612, 3467, 9, 339, 347, 295, 3124, 8, 277, 304, 398, 20831, 275, 1413, 6986, 17213, 38, 8, 277, 423, 4246, 12, 291, 9, 267, 8626, 275, 20831, 14, 24511, 8252, 8, 30197, 38, 8, 277, 14, 1201, 4000, 3959, 14, 9497, 13551, 12, 355, 620, 8, 277, 423, 585, 430, 267, 291, 423, 88, 1712, 275, 446, 1201, 14, 2063, 29728, 18, 14, 16, 267, 291, 423, 89, 1712, 275, 8626, 14, 3333, 29728, 18, 14, 16, 446, 20831, 14, 26269, 342, 267, 291, 14, 873, 342, 339, 327, 22896, 15917, 436, 18743, 3102, 367, 314, 5023, 3324, 14, 339, 347, 664, 6986, 8, 277, 304, 267, 372, 291, 423, 4246, 339, 347, 663, 6986, 8, 277, 12, 5023, 304, 267, 291, 423, 4246, 275, 5023, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 5023, 275, 27149, 3697, 8, 49, 6986, 12, 664, 6986, 12, 663, 6986, 9, 339, 327, 22896, 15917, 436, 18743, 3102, 367, 314, 7481, 436, 5696, 4382, 14, 339, 347, 664, 12092, 8, 277, 304, 267, 372, 291, 423, 10700, 339, 347, 663, 12092, 8, 277, 12, 574, 304, 267, 291, 423, 10700, 275, 574, 267, 340, 291, 423, 10700, 690, 291, 423, 11555, 26, 288, 291, 14, 409, 10915, 8, 277, 423, 10700, 9, 267, 340, 291, 423, 10700, 690, 291, 423, 585, 26, 288, 291, 14, 14733, 8, 277, 423, 10700, 9, 339, 7481, 275, 27149, 3697, 8, 442, 12, 664, 12092, 12, 663, 12092, 9, 339, 347, 664, 10915, 8, 277, 304, 267, 372, 291, 423, 11555, 339, 347, 663, 10915, 8, 277, 12, 574, 304, 267, 291, 423, 11555, 275, 574, 267, 291, 423, 10700, 275, 1748, 8, 277, 423, 10700, 12, 291, 423, 11555, 9, 267, 340, 291, 423, 11555, 665, 291, 423, 585, 26, 288, 291, 14, 14733, 8, 277, 423, 11555, 9, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 5696, 275, 27149, 3697, 8, 442, 12, 664, 10915, 12, 663, 10915, 9, 339, 327, 2136, 5647, 376, 3268, 3324, 370, 2040, 314, 574, 9164, 370, 14460, 687, 272, 327, 314, 5007, 574, 23608, 701, 314, 3938, 14, 339, 347, 664, 6397, 8, 277, 304, 267, 372, 291, 423 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 5337, 1302, 14, 647, 199, 199, 33, 14084, 3537, 3938, 2893, 367, 3959, 1487, 25399, 14, 199, 199, 7384, 334, 35, 9, 8315, 20232, 699, 364, 15130, 665, 983, 5017, 32, 66, 364, 15130, 14, 1308, 14, 3210, 30, 199, 7384, 334, 35, 9, 11811, 13, 7968, 377, 2827, 15970, 437, 4251, 14, 2900, 4481, 4644, 14, 199, 199, 2765, 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, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 624, 199, 199, 504, 14084, 21, 14, 10901, 492, 27149, 3697, 12, 27149, 11274, 12, 27149, 15183, 12, 1413, 8252, 38, 12, 1413, 2320, 12, 3959, 199, 504, 14084, 21, 14, 10604, 492, 1413, 6986, 12, 1413, 6986, 17213, 38, 12, 1413, 31169, 199, 504, 14084, 21, 14, 29081, 492, 29469, 12, 1413, 3339, 421, 199, 533, 14427, 4314, 8, 23894, 304, 272, 408, 11348, 4314, 8, 23894, 9, 339, 21552, 282, 3537, 1768, 3938, 370, 506, 1202, 465, 282, 7055, 12, 543, 10166, 272, 8545, 370, 5204, 2741, 701, 1413, 8458, 21074, 9180, 436, 4382, 272, 8545, 370, 5204, 2741, 701, 1413, 4314, 14, 272, 408, 339, 327, 2136, 5627, 2877, 10166, 626, 787, 1202, 370, 6623, 4493, 370, 314, 2004, 272, 327, 402, 314, 3938, 14, 272, 574, 6970, 275, 27149, 11274, 1332, 442, 12, 2318, 334, 495, 12, 5082, 339, 347, 636, 826, 721, 277, 12, 1676, 29, 403, 304, 398, 1613, 8, 11348, 4314, 12, 291, 2843, 826, 721, 1708, 9, 398, 291, 14, 409, 3358, 12914, 14148, 8, 797, 9, 398, 291, 423, 4246, 275, 1413, 6986, 342, 267, 291, 423, 10700, 275, 413, 267, 291, 423, 11555, 275, 413, 267, 291, 423, 585, 275, 413, 267, 291, 423, 2743, 275, 378, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 347, 32055, 2390, 8, 277, 12, 1566, 304, 398, 299, 275, 1413, 31169, 342, 267, 299, 14, 5037, 8, 277, 9, 267, 299, 14, 409, 9216, 20891, 8, 49, 31169, 14, 2493, 1009, 2241, 316, 9, 267, 299, 14, 24432, 8, 277, 423, 4246, 9, 267, 299, 14, 5275, 8, 277, 14, 2063, 29728, 18, 14, 16, 12, 291, 14, 3333, 29728, 18, 14, 16, 9, 267, 299, 14, 3467, 8, 277, 423, 3467, 12, 291, 423, 3467, 9, 267, 299, 14, 5485, 1872, 8, 277, 423, 88, 1712, 12, 291, 423, 89, 1712, 12, 620, 8, 277, 423, 585, 430, 267, 299, 14, 500, 342, 339, 347, 1568, 20891, 8, 277, 304, 267, 372, 1413, 2320, 8, 708, 12, 4337, 9, 339, 347, 522, 2357, 8, 277, 304, 398, 20831, 275, 1413, 6986, 17213, 38, 8, 277, 423, 4246, 12, 291, 9, 267, 1390, 8252, 275, 20831, 14, 24511, 8252, 8, 30197, 38, 8, 277, 14, 1201, 4000, 3959, 14, 9497, 13551, 12, 355, 620, 8, 277, 423, 11555, 430, 267, 671, 3467, 275, 2069, 8, 277, 14, 2063, 1012, 15, 988, 8252, 14, 2063, 342, 267, 612, 3467, 275, 2069, 8, 277, 14, 3333, 1012, 15, 988, 8252, 14, 3333, 342, 267, 291, 423, 3467, 275, 1748, 8, 88, 3467, 12, 612, 3467, 9, 339, 347, 295, 3124, 8, 277, 304, 398, 20831, 275, 1413, 6986, 17213, 38, 8, 277, 423, 4246, 12, 291, 9, 267, 8626, 275, 20831, 14, 24511, 8252, 8, 30197, 38, 8, 277, 14, 1201, 4000, 3959, 14, 9497, 13551, 12, 355, 620, 8, 277, 423, 585, 430, 267, 291, 423, 88, 1712, 275, 446, 1201, 14, 2063, 29728, 18, 14, 16, 267, 291, 423, 89, 1712, 275, 8626, 14, 3333, 29728, 18, 14, 16, 446, 20831, 14, 26269, 342, 267, 291, 14, 873, 342, 339, 327, 22896, 15917, 436, 18743, 3102, 367, 314, 5023, 3324, 14, 339, 347, 664, 6986, 8, 277, 304, 267, 372, 291, 423, 4246, 339, 347, 663, 6986, 8, 277, 12, 5023, 304, 267, 291, 423, 4246, 275, 5023, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 5023, 275, 27149, 3697, 8, 49, 6986, 12, 664, 6986, 12, 663, 6986, 9, 339, 327, 22896, 15917, 436, 18743, 3102, 367, 314, 7481, 436, 5696, 4382, 14, 339, 347, 664, 12092, 8, 277, 304, 267, 372, 291, 423, 10700, 339, 347, 663, 12092, 8, 277, 12, 574, 304, 267, 291, 423, 10700, 275, 574, 267, 340, 291, 423, 10700, 690, 291, 423, 11555, 26, 288, 291, 14, 409, 10915, 8, 277, 423, 10700, 9, 267, 340, 291, 423, 10700, 690, 291, 423, 585, 26, 288, 291, 14, 14733, 8, 277, 423, 10700, 9, 339, 7481, 275, 27149, 3697, 8, 442, 12, 664, 12092, 12, 663, 12092, 9, 339, 347, 664, 10915, 8, 277, 304, 267, 372, 291, 423, 11555, 339, 347, 663, 10915, 8, 277, 12, 574, 304, 267, 291, 423, 11555, 275, 574, 267, 291, 423, 10700, 275, 1748, 8, 277, 423, 10700, 12, 291, 423, 11555, 9, 267, 340, 291, 423, 11555, 665, 291, 423, 585, 26, 288, 291, 14, 14733, 8, 277, 423, 11555, 9, 267, 291, 14, 470, 2357, 342, 267, 291, 14, 264, 3124, 342, 339, 5696, 275, 27149, 3697, 8, 442, 12, 664, 10915, 12, 663, 10915, 9, 339, 327, 2136, 5647, 376, 3268, 3324, 370, 2040, 314, 574, 9164, 370, 14460, 687, 272, 327, 314, 5007, 574, 23608, 701, 314, 3938, 14, 339, 347, 664, 6397, 8, 277, 304, 267, 372, 291, 423, 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,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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 ]
HewlettPackard/oneview-ansible
test/test_oneview_ethernet_network.py
1
15111
#!/usr/bin/python # -*- coding: utf-8 -*- ### # Copyright (2016-2020) Hewlett Packard Enterprise Development LP # # 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 mock import pytest import yaml from hpe_test_utils import OneViewBaseTest from oneview_module_loader import EthernetNetworkModule FAKE_MSG_ERROR = 'Fake message error' DEFAULT_ETHERNET_NAME = 'Test Ethernet Network' RENAMED_ETHERNET = 'Renamed Ethernet Network' DEFAULT_ENET_TEMPLATE = dict( name=DEFAULT_ETHERNET_NAME, vlanId=200, ethernetNetworkType="Tagged", purpose="General", smartLink=False, privateNetwork=False, connectionTemplateUri=None ) PARAMS_FOR_PRESENT = dict( config='config.json', state='present', data=dict(name=DEFAULT_ETHERNET_NAME) ) PARAMS_TO_RENAME = dict( config='config.json', state='present', data=dict(name=DEFAULT_ETHERNET_NAME, newName=RENAMED_ETHERNET) ) YAML_PARAMS_WITH_CHANGES = """ config: "config.json" state: present data: name: 'Test Ethernet Network' purpose: Management connectionTemplateUri: ~ bandwidth: maximumBandwidth: 3000 typicalBandwidth: 2000 """ YAML_RESET_CONNECTION_TEMPLATE = """ config: "{{ config }}" state: default_bandwidth_reset data: name: 'network name' """ PARAMS_FOR_SCOPES_SET = dict( config='config.json', state='present', data=dict(name=DEFAULT_ETHERNET_NAME) ) PARAMS_FOR_ABSENT = dict( config='config.json', state='absent', data=dict(name=DEFAULT_ETHERNET_NAME) ) PARAMS_FOR_BULK_CREATED = dict( config='config.json', state='present', data=dict(namePrefix="TestNetwork", vlanIdRange="1-2,5,9-10") ) DEFAULT_BULK_ENET_TEMPLATE = [ {'name': 'TestNetwork_1', 'vlanId': 1}, {'name': 'TestNetwork_2', 'vlanId': 2}, {'name': 'TestNetwork_5', 'vlanId': 5}, {'name': 'TestNetwork_9', 'vlanId': 9}, {'name': 'TestNetwork_10', 'vlanId': 10}, ] DICT_PARAMS_WITH_CHANGES = yaml.load(YAML_PARAMS_WITH_CHANGES)["data"] @pytest.mark.resource(TestEthernetNetworkModule='ethernet_networks') class TestEthernetNetworkModule(OneViewBaseTest): """ OneViewBaseTestCase provides the mocks used in this test case """ def test_should_create_new_ethernet_network(self): self.resource.get_by_name.return_value = None self.resource.create.return_value = self.resource self.resource.data = DEFAULT_ENET_TEMPLATE self.mock_ansible_module.params = PARAMS_FOR_PRESENT EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_CREATED, ansible_facts=dict(ethernet_network=DEFAULT_ENET_TEMPLATE) ) def test_should_not_update_when_data_is_equals(self): self.resource.data = DEFAULT_ENET_TEMPLATE self.mock_ansible_module.params = PARAMS_FOR_PRESENT EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, msg=EthernetNetworkModule.MSG_ALREADY_PRESENT, ansible_facts=dict(ethernet_network=DEFAULT_ENET_TEMPLATE) ) def test_update_when_data_has_modified_attributes(self): self.resource.data = DEFAULT_ENET_TEMPLATE obj = mock.Mock() obj.data = {"uri": "uri"} self.mock_ov_client.connection_templates.get.return_value = obj self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_UPDATED, ansible_facts=dict(ethernet_network=DEFAULT_ENET_TEMPLATE) ) def test_update_when_only_bandwidth_has_modified_attributes(self): self.resource.data = DICT_PARAMS_WITH_CHANGES obj = mock.Mock() obj.data = {"uri": "uri"} self.mock_ov_client.connection_templates.get_by_uri.return_value = obj self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_UPDATED, ansible_facts=dict(ethernet_network=DICT_PARAMS_WITH_CHANGES) ) def test_update_when_data_has_modified_attributes_but_bandwidth_is_equal(self): self.resource.data = DEFAULT_ENET_TEMPLATE obj = mock.Mock() obj.data = {"bandwidth": DICT_PARAMS_WITH_CHANGES['bandwidth']} self.mock_ov_client.connection_templates.get_by_uri.return_value = obj self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_UPDATED, ansible_facts=dict(ethernet_network=DEFAULT_ENET_TEMPLATE) ) def test_update_successfully_even_when_connection_template_uri_not_exists(self): self.resource.data = DEFAULT_ENET_TEMPLATE.copy() del self.resource.data["connectionTemplateUri"] self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_UPDATED, ansible_facts=dict(ethernet_network=self.resource.data) ) def test_rename_when_resource_exists(self): data_merged = DEFAULT_ENET_TEMPLATE.copy() data_merged['name'] = RENAMED_ETHERNET params_to_rename = PARAMS_TO_RENAME.copy() self.resource.data = DEFAULT_ENET_TEMPLATE self.mock_ansible_module.params = params_to_rename EthernetNetworkModule().run() self.resource.update.assert_called_once_with(data_merged) def test_create_with_new_name_when_resource_not_exists(self): data_merged = DEFAULT_ENET_TEMPLATE.copy() data_merged['name'] = RENAMED_ETHERNET params_to_rename = PARAMS_TO_RENAME.copy() self.resource.get_by_name.return_value = None self.resource.create.return_value = self.resource self.resource.data = DEFAULT_ENET_TEMPLATE self.mock_ansible_module.params = params_to_rename EthernetNetworkModule().run() self.resource.create.assert_called_once_with(PARAMS_TO_RENAME['data']) def test_should_remove_ethernet_network(self): self.resource.data = DEFAULT_ENET_TEMPLATE self.mock_ansible_module.params = PARAMS_FOR_ABSENT EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_DELETED ) def test_should_do_nothing_when_ethernet_network_not_exist(self): self.resource.get_by_name.return_value = None self.mock_ansible_module.params = PARAMS_FOR_ABSENT EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, msg=EthernetNetworkModule.MSG_ALREADY_ABSENT ) def test_should_create_all_ethernet_networks(self): self.resource.get_range.return_value = [] self.resource.create_bulk.return_value = DEFAULT_BULK_ENET_TEMPLATE self.mock_ansible_module.params = PARAMS_FOR_BULK_CREATED EthernetNetworkModule().run() self.resource.create_bulk.assert_called_once_with( dict(namePrefix="TestNetwork", vlanIdRange="1-2,5,9-10")) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_BULK_CREATED, ansible_facts=dict(ethernet_network_bulk=DEFAULT_BULK_ENET_TEMPLATE)) def test_should_create_missing_ethernet_networks(self): enet_get_range_return = [ {'name': 'TestNetwork_1', 'vlanId': 1}, {'name': 'TestNetwork_2', 'vlanId': 2}, ] self.resource.get_range.side_effect = [enet_get_range_return, DEFAULT_BULK_ENET_TEMPLATE] self.resource.dissociate_values_or_ranges.return_value = [1, 2, 5, 9, 10] self.mock_ansible_module.params = PARAMS_FOR_BULK_CREATED EthernetNetworkModule().run() self.resource.create_bulk.assert_called_once_with( dict(namePrefix="TestNetwork", vlanIdRange="5,9,10")) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_MISSING_BULK_CREATED, ansible_facts=dict(ethernet_network_bulk=DEFAULT_BULK_ENET_TEMPLATE)) def test_should_delete_bulk_ethernet_networks(self): networkUris = [ "/rest/ethernet-networks/e2f0031b-52bd-4223-9ac1-d91cb519d548", "/rest/ethernet-networks/f2f0031b-52bd-4223-9ac1-d91cb519d549", "/rest/ethernet-networks/02f0031b-52bd-4223-9ac1-d91cb519d54a" ] PARAMS_FOR_BULK_DELETED = dict( config='config.json', state='absent', data=dict(networkUris=[ "/rest/ethernet-networks/e2f0031b-52bd-4223-9ac1-d91cb519d548", "/rest/ethernet-networks/f2f0031b-52bd-4223-9ac1-d91cb519d549", "/rest/ethernet-networks/02f0031b-52bd-4223-9ac1-d91cb519d54a" ]) ) self.resource.delete_bulk.return_value = None self.mock_ansible_module.params = PARAMS_FOR_BULK_DELETED EthernetNetworkModule().run() self.resource.delete_bulk.assert_called_once_with({'networkUris': networkUris}) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_BULK_DELETED, ansible_facts=dict(ethernet_network_bulk_delete=None)) def test_should_create_missing_ethernet_networks_with_just_one_difference(self): enet_get_range_return = [ {'name': 'TestNetwork_1', 'vlanId': 1}, {'name': 'TestNetwork_2', 'vlanId': 2}, ] self.resource.get_range.side_effect = [enet_get_range_return, DEFAULT_BULK_ENET_TEMPLATE] self.resource.dissociate_values_or_ranges.return_value = [1, 2, 5] self.mock_ansible_module.params = PARAMS_FOR_BULK_CREATED EthernetNetworkModule().run() self.resource.create_bulk.assert_called_once_with({'vlanIdRange': '5-5', 'namePrefix': 'TestNetwork'}) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_MISSING_BULK_CREATED, ansible_facts=dict(ethernet_network_bulk=DEFAULT_BULK_ENET_TEMPLATE)) def test_should_do_nothing_when_ethernet_networks_already_exist(self): self.resource.get_range.return_value = DEFAULT_BULK_ENET_TEMPLATE self.resource.dissociate_values_or_ranges.return_value = [1, 2, 5, 9, 10] self.mock_ansible_module.params = PARAMS_FOR_BULK_CREATED EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, msg=EthernetNetworkModule.MSG_BULK_ALREADY_EXIST, ansible_facts=dict(ethernet_network_bulk=DEFAULT_BULK_ENET_TEMPLATE)) def test_reset_successfully(self): self.resource.data = DICT_PARAMS_WITH_CHANGES obj = mock.Mock() obj.data = {"bandwidth": DICT_PARAMS_WITH_CHANGES['bandwidth']} self.mock_ov_client.connection_templates.get_by_uri.return_value = obj self.mock_ov_client.connection_templates.get_default.return_value = {"bandwidth": { "max": 1 }} self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE) EthernetNetworkModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, msg=EthernetNetworkModule.MSG_CONNECTION_TEMPLATE_RESET, ansible_facts=dict(ethernet_network_connection_template=obj.data)) def test_should_fail_when_reset_not_existing_ethernet_network(self): self.resource.get_by_name.return_value = None self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE) EthernetNetworkModule().run() self.mock_ansible_module.fail_json.assert_called_once_with( exception=mock.ANY, msg=EthernetNetworkModule.MSG_ETHERNET_NETWORK_NOT_FOUND) def test_update_scopes_when_different(self): params_to_scope = PARAMS_FOR_PRESENT.copy() params_to_scope['data']['scopeUris'] = ['test'] self.mock_ansible_module.params = params_to_scope resource_data = DEFAULT_ENET_TEMPLATE.copy() resource_data['scopeUris'] = ['fake'] resource_data['uri'] = 'rest/ethernet/fake' self.resource.data = resource_data self.resource.get_by_name.return_value = self.resource patch_return = resource_data.copy() patch_return['scopeUris'] = ['test'] obj = mock.Mock() obj.data = patch_return self.resource.patch.return_value = obj EthernetNetworkModule().run() self.resource.patch.assert_called_once_with(operation='replace', path='/scopeUris', value=['test']) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, ansible_facts=dict(ethernet_network=patch_return), msg=EthernetNetworkModule.MSG_UPDATED ) def test_should_do_nothing_when_scopes_are_the_same(self): params_to_scope = PARAMS_FOR_PRESENT.copy() params_to_scope['data']['scopeUris'] = ['test'] self.mock_ansible_module.params = params_to_scope resource_data = DEFAULT_ENET_TEMPLATE.copy() resource_data['scopeUris'] = ['test'] self.resource.data = resource_data self.mock_ansible_module.params = PARAMS_FOR_PRESENT EthernetNetworkModule().run() self.resource.patch.not_been_called() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(ethernet_network=resource_data), msg=EthernetNetworkModule.MSG_ALREADY_PRESENT ) if __name__ == '__main__': pytest.main([__file__])
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5680, 199, 3, 1898, 334, 9261, 13, 13934, 9, 27849, 9954, 1005, 29949, 15290, 21738, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 2047, 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, 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, 5680, 199, 199, 646, 1683, 199, 646, 4613, 199, 646, 8864, 199, 199, 504, 394, 321, 63, 396, 63, 1208, 492, 7309, 2768, 23170, 199, 504, 1373, 1345, 63, 578, 63, 3422, 492, 26125, 4491, 2377, 199, 199, 14623, 63, 9740, 63, 3170, 275, 283, 8249, 1245, 1125, 7, 199, 3472, 63, 6919, 7278, 63, 2339, 275, 283, 774, 26125, 7220, 7, 199, 50, 742, 1156, 1149, 63, 6919, 7278, 275, 283, 16843, 68, 26125, 7220, 7, 199, 199, 3472, 63, 742, 775, 63, 7433, 275, 1211, 8, 272, 536, 29, 3472, 63, 6919, 7278, 63, 2339, 12, 272, 10119, 1304, 29, 1840, 12, 272, 21944, 4491, 804, 628, 26403, 401, 272, 12016, 628, 14109, 401, 272, 11179, 3834, 29, 797, 12, 272, 5726, 4491, 29, 797, 12, 272, 1950, 4231, 14014, 29, 403, 199, 9, 199, 199, 17978, 63, 2707, 63, 19743, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2566, 63, 50, 11536, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 12, 1598, 892, 985, 29, 50, 742, 1156, 1149, 63, 6919, 7278, 9, 199, 9, 199, 199, 23103, 63, 17978, 63, 9139, 63, 17858, 654, 275, 408, 272, 1101, 26, 298, 888, 14, 1001, 2, 272, 1174, 26, 3451, 272, 666, 26, 489, 536, 26, 283, 774, 26125, 7220, 7, 489, 12016, 26, 8259, 489, 1950, 4231, 14014, 26, 6146, 489, 20434, 26, 881, 5696, 25859, 26, 29664, 881, 25780, 25859, 26, 12293, 199, 624, 199, 199, 23103, 63, 18066, 63, 18389, 63, 7433, 275, 408, 267, 1101, 26, 7370, 1101, 7820, 267, 1174, 26, 849, 63, 18358, 63, 3958, 267, 666, 26, 881, 536, 26, 283, 1200, 536, 7, 199, 624, 199, 199, 17978, 63, 2707, 63, 15901, 48, 654, 63, 3597, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2707, 63, 27851, 1309, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 5575, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2707, 63, 34, 1293, 43, 63, 26561, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 4793, 628, 774, 4491, 401, 10119, 1304, 4709, 628, 17, 13, 18, 12, 21, 12, 25, 13, 709, 531, 199, 9, 199, 199, 3472, 63, 34, 1293, 43, 63, 742, 775, 63, 7433, 275, 359, 272, 791, 354, 356, 283, 774, 4491, 63, 17, 297, 283, 7175, 1304, 356, 413, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 18, 297, 283, 7175, 1304, 356, 499, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 21, 297, 283, 7175, 1304, 356, 959, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 25, 297, 283, 7175, 1304, 356, 1749, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 709, 297, 283, 7175, 1304, 356, 1616, 1386, 199, 61, 199, 199, 12511, 63, 17978, 63, 9139, 63, 17858, 654, 275, 8864, 14, 912, 8, 23103, 63, 17978, 63, 9139, 63, 17858, 654, 26332, 576, 937, 421, 199, 32, 4462, 14, 1657, 14, 1927, 8, 774, 22056, 4491, 2377, 534, 20354, 63, 7642, 358, 199, 533, 1379, 22056, 4491, 2377, 8, 4395, 2768, 23170, 304, 272, 408, 272, 7309, 2768, 20760, 6571, 314, 26500, 1202, 315, 642, 511, 1930, 272, 408, 339, 347, 511, 63, 5626, 63, 981, 63, 1222, 63, 20354, 63, 1200, 8, 277, 304, 267, 291, 14, 1927, 14, 362, 63, 991, 63, 354, 14, 1107, 63, 585, 275, 488, 267, 291, 14, 1927, 14, 981, 14, 1107, 63, 585, 275, 291, 14, 1927, 267, 291, 14, 1927, 14, 576, 275, 6186, 63, 742, 775, 63, 7433, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 1162, 275, 16565, 51, 63, 2707, 63, 19743, 398, 26125, 4491, 2377, 1252, 1065, 342, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 2224, 63, 1001, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 2896, 29, 549, 12, 288, 1499, 29, 22056, 4491, 2377, 14, 9740, 63, 26561, 12, 288, 3242, 63, 5047, 29, 807, 8, 20354, 63, 1200, 29, 3472, 63, 742, 775, 63, 7433, 9, 267, 776, 339, 347, 511, 63, 5626, 63, 1397, 63, 873, 63, 6526, 63, 576, 63, 374, 63, 11332, 8, 277, 304, 267, 291, 14, 1927, 14, 576, 275, 6186, 63, 742, 775, 63, 7433, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 1162, 275, 16565, 51, 63, 2707, 63, 19743, 398, 26125, 4491, 2377, 1252, 1065, 342, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 2224, 63, 1001, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 2896, 29, 797, 12, 288, 1499, 29, 22056, 4491, 2377, 14, 9740, 63, 32687, 63, 19743, 12, 288, 3242, 63 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 5680, 199, 3, 1898, 334, 9261, 13, 13934, 9, 27849, 9954, 1005, 29949, 15290, 21738, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 2047, 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, 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, 5680, 199, 199, 646, 1683, 199, 646, 4613, 199, 646, 8864, 199, 199, 504, 394, 321, 63, 396, 63, 1208, 492, 7309, 2768, 23170, 199, 504, 1373, 1345, 63, 578, 63, 3422, 492, 26125, 4491, 2377, 199, 199, 14623, 63, 9740, 63, 3170, 275, 283, 8249, 1245, 1125, 7, 199, 3472, 63, 6919, 7278, 63, 2339, 275, 283, 774, 26125, 7220, 7, 199, 50, 742, 1156, 1149, 63, 6919, 7278, 275, 283, 16843, 68, 26125, 7220, 7, 199, 199, 3472, 63, 742, 775, 63, 7433, 275, 1211, 8, 272, 536, 29, 3472, 63, 6919, 7278, 63, 2339, 12, 272, 10119, 1304, 29, 1840, 12, 272, 21944, 4491, 804, 628, 26403, 401, 272, 12016, 628, 14109, 401, 272, 11179, 3834, 29, 797, 12, 272, 5726, 4491, 29, 797, 12, 272, 1950, 4231, 14014, 29, 403, 199, 9, 199, 199, 17978, 63, 2707, 63, 19743, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2566, 63, 50, 11536, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 12, 1598, 892, 985, 29, 50, 742, 1156, 1149, 63, 6919, 7278, 9, 199, 9, 199, 199, 23103, 63, 17978, 63, 9139, 63, 17858, 654, 275, 408, 272, 1101, 26, 298, 888, 14, 1001, 2, 272, 1174, 26, 3451, 272, 666, 26, 489, 536, 26, 283, 774, 26125, 7220, 7, 489, 12016, 26, 8259, 489, 1950, 4231, 14014, 26, 6146, 489, 20434, 26, 881, 5696, 25859, 26, 29664, 881, 25780, 25859, 26, 12293, 199, 624, 199, 199, 23103, 63, 18066, 63, 18389, 63, 7433, 275, 408, 267, 1101, 26, 7370, 1101, 7820, 267, 1174, 26, 849, 63, 18358, 63, 3958, 267, 666, 26, 881, 536, 26, 283, 1200, 536, 7, 199, 624, 199, 199, 17978, 63, 2707, 63, 15901, 48, 654, 63, 3597, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2707, 63, 27851, 1309, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 5575, 297, 272, 666, 29, 807, 8, 354, 29, 3472, 63, 6919, 7278, 63, 2339, 9, 199, 9, 199, 199, 17978, 63, 2707, 63, 34, 1293, 43, 63, 26561, 275, 1211, 8, 272, 1101, 534, 888, 14, 1001, 297, 272, 1174, 534, 1881, 297, 272, 666, 29, 807, 8, 354, 4793, 628, 774, 4491, 401, 10119, 1304, 4709, 628, 17, 13, 18, 12, 21, 12, 25, 13, 709, 531, 199, 9, 199, 199, 3472, 63, 34, 1293, 43, 63, 742, 775, 63, 7433, 275, 359, 272, 791, 354, 356, 283, 774, 4491, 63, 17, 297, 283, 7175, 1304, 356, 413, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 18, 297, 283, 7175, 1304, 356, 499, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 21, 297, 283, 7175, 1304, 356, 959, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 25, 297, 283, 7175, 1304, 356, 1749, 1386, 272, 791, 354, 356, 283, 774, 4491, 63, 709, 297, 283, 7175, 1304, 356, 1616, 1386, 199, 61, 199, 199, 12511, 63, 17978, 63, 9139, 63, 17858, 654, 275, 8864, 14, 912, 8, 23103, 63, 17978, 63, 9139, 63, 17858, 654, 26332, 576, 937, 421, 199, 32, 4462, 14, 1657, 14, 1927, 8, 774, 22056, 4491, 2377, 534, 20354, 63, 7642, 358, 199, 533, 1379, 22056, 4491, 2377, 8, 4395, 2768, 23170, 304, 272, 408, 272, 7309, 2768, 20760, 6571, 314, 26500, 1202, 315, 642, 511, 1930, 272, 408, 339, 347, 511, 63, 5626, 63, 981, 63, 1222, 63, 20354, 63, 1200, 8, 277, 304, 267, 291, 14, 1927, 14, 362, 63, 991, 63, 354, 14, 1107, 63, 585, 275, 488, 267, 291, 14, 1927, 14, 981, 14, 1107, 63, 585, 275, 291, 14, 1927, 267, 291, 14, 1927, 14, 576, 275, 6186, 63, 742, 775, 63, 7433, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 1162, 275, 16565, 51, 63, 2707, 63, 19743, 398, 26125, 4491, 2377, 1252, 1065, 342, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 2224, 63, 1001, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 2896, 29, 549, 12, 288, 1499, 29, 22056, 4491, 2377, 14, 9740, 63, 26561, 12, 288, 3242, 63, 5047, 29, 807, 8, 20354, 63, 1200, 29, 3472, 63, 742, 775, 63, 7433, 9, 267, 776, 339, 347, 511, 63, 5626, 63, 1397, 63, 873, 63, 6526, 63, 576, 63, 374, 63, 11332, 8, 277, 304, 267, 291, 14, 1927, 14, 576, 275, 6186, 63, 742, 775, 63, 7433, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 1162, 275, 16565, 51, 63, 2707, 63, 19743, 398, 26125, 4491, 2377, 1252, 1065, 342, 398, 291, 14, 1805, 63, 4853, 63, 578, 14, 2224, 63, 1001, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 288, 2896, 29, 797, 12, 288, 1499, 29, 22056, 4491, 2377, 14, 9740, 63, 32687, 63, 19743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, 1, 1, 1, 1, 1, 1, 1 ]
AndroidOpenDevelopment/android_external_chromium_org
native_client_sdk/src/doc/conf.py
103
6018
# Copyright (c) 2014 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. # -*- coding: utf-8 -*- # # Native Client documentation build configuration file, created by # sphinx-quickstart on Thu Aug 15 11:31:06 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # Where we keep our extensions... sys.path.insert(0, os.path.abspath('_sphinxext')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['devsite_builder', 'chromesite_builder'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Native Client' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '31' # The full version, including alpha/beta/rc tags. release = '31' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build', '**/.#*'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'NativeClientdoc' linkcheck_ignore = [ # General links not worth checking r'http://localhost.*', r'about:.*', r'chrome:.*', r'.*local_extensions\.css', # # Specific known bad cases go here. # # linkcheck's anchor checker can't check these because they are # server-generated and don't actually appear in the HTML of the page. r'https://code.google.com.*browse#svn.*', ]
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6927, 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, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 653, 1905, 6810, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 25298, 4114, 4119, 26, 2192, 26, 1690, 6171, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 17685, 781, 4215, 4154, 5478, 1396, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 6412, 8008, 832, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 2374, 2124, 63, 5649, 297, 283, 9887, 2124, 63, 5649, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 19675, 6810, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 2192, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 2192, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 297, 23940, 8083, 15002, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654 ]
[ 1898, 334, 67, 9, 6927, 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, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 653, 1905, 6810, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 25298, 4114, 4119, 26, 2192, 26, 1690, 6171, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 17685, 781, 4215, 4154, 5478, 1396, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 6412, 8008, 832, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 2374, 2124, 63, 5649, 297, 283, 9887, 2124, 63, 5649, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 19675, 6810, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 2192, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 2192, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 297, 23940, 8083, 15002, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 975, 503, 4337, 88, 708, 199, 3, 11094, 7031, 14, 199, 3, 1360, 63, 22229, 275, 488, 199, 199, 3, 2654, 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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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 ]
nozuono/calibre-webserver
src/calibre/gui2/preferences/keyboard.py
9
1418
#!/usr/bin/env python # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __docformat__ = 'restructuredtext en' from PyQt4.Qt import QVBoxLayout from calibre.gui2.preferences import (ConfigWidgetBase, test_widget) from calibre.gui2.keyboard import ShortcutConfig class ConfigWidget(ConfigWidgetBase): def genesis(self, gui): self.gui = gui self.conf_widget = ShortcutConfig(self) self.conf_widget.changed_signal.connect(self.changed_signal) self._layout = l = QVBoxLayout() self.setLayout(l) l.addWidget(self.conf_widget) def initialize(self): ConfigWidgetBase.initialize(self) self.conf_widget.initialize(self.gui.keyboard) def restore_defaults(self): ConfigWidgetBase.restore_defaults(self) self.conf_widget.restore_defaults() def commit(self): self.conf_widget.commit() return ConfigWidgetBase.commit(self) def refresh_gui(self, gui): gui.keyboard.finalize() def highlight_group(self, group_name): self.conf_widget.highlight_group(group_name) if __name__ == '__main__': from PyQt4.Qt import QApplication app = QApplication([]) test_widget('Advanced', 'Keyboard')
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 6542, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 504, 14084, 20, 14, 4238, 492, 1413, 54, 18536, 199, 199, 504, 19238, 14, 5885, 18, 14, 18063, 492, 334, 2028, 3339, 1563, 12, 511, 63, 3440, 9, 199, 504, 19238, 14, 5885, 18, 14, 19553, 492, 20124, 5919, 2028, 199, 199, 533, 4094, 3339, 8, 2028, 3339, 1563, 304, 339, 347, 15599, 2316, 8, 277, 12, 11621, 304, 267, 291, 14, 5885, 275, 11621, 267, 291, 14, 2190, 63, 3440, 275, 20124, 5919, 2028, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 2489, 63, 4653, 14, 2242, 8, 277, 14, 2489, 63, 4653, 9, 267, 291, 423, 4209, 275, 634, 275, 1413, 54, 18536, 342, 267, 291, 14, 409, 4798, 8, 76, 9, 267, 634, 14, 9475, 8, 277, 14, 2190, 63, 3440, 9, 339, 347, 8265, 8, 277, 304, 267, 4094, 3339, 1563, 14, 8489, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 8489, 8, 277, 14, 5885, 14, 19553, 9, 339, 347, 9066, 63, 4322, 8, 277, 304, 267, 4094, 3339, 1563, 14, 8011, 63, 4322, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 8011, 63, 4322, 342, 339, 347, 5532, 8, 277, 304, 267, 291, 14, 2190, 63, 3440, 14, 3543, 342, 267, 372, 4094, 3339, 1563, 14, 3543, 8, 277, 9, 339, 347, 9236, 63, 5885, 8, 277, 12, 11621, 304, 267, 11621, 14, 19553, 14, 14450, 342, 339, 347, 11850, 63, 923, 8, 277, 12, 1572, 63, 354, 304, 267, 291, 14, 2190, 63, 3440, 14, 14337, 63, 923, 8, 923, 63, 354, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 14084, 20, 14, 4238, 492, 29469, 272, 1145, 275, 29469, 4157, 272, 511, 63, 3440, 360, 23613, 297, 283, 28377, 358, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 493, 2991, 29, 6610, 13, 24, 26, 1086, 29, 20, 26, 3519, 29, 20, 26, 1207, 26, 386, 26, 10329, 29, 20, 26, 5789, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 257, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 6542, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 32, 7697, 5017, 1939, 31876, 14, 846, 3524, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 199, 199, 504, 14084, 20, 14, 4238, 492, 1413, 54, 18536, 199, 199, 504, 19238, 14, 5885, 18, 14, 18063, 492, 334, 2028, 3339, 1563, 12, 511, 63, 3440, 9, 199, 504, 19238, 14, 5885, 18, 14, 19553, 492, 20124, 5919, 2028, 199, 199, 533, 4094, 3339, 8, 2028, 3339, 1563, 304, 339, 347, 15599, 2316, 8, 277, 12, 11621, 304, 267, 291, 14, 5885, 275, 11621, 267, 291, 14, 2190, 63, 3440, 275, 20124, 5919, 2028, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 2489, 63, 4653, 14, 2242, 8, 277, 14, 2489, 63, 4653, 9, 267, 291, 423, 4209, 275, 634, 275, 1413, 54, 18536, 342, 267, 291, 14, 409, 4798, 8, 76, 9, 267, 634, 14, 9475, 8, 277, 14, 2190, 63, 3440, 9, 339, 347, 8265, 8, 277, 304, 267, 4094, 3339, 1563, 14, 8489, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 8489, 8, 277, 14, 5885, 14, 19553, 9, 339, 347, 9066, 63, 4322, 8, 277, 304, 267, 4094, 3339, 1563, 14, 8011, 63, 4322, 8, 277, 9, 267, 291, 14, 2190, 63, 3440, 14, 8011, 63, 4322, 342, 339, 347, 5532, 8, 277, 304, 267, 291, 14, 2190, 63, 3440, 14, 3543, 342, 267, 372, 4094, 3339, 1563, 14, 3543, 8, 277, 9, 339, 347, 9236, 63, 5885, 8, 277, 12, 11621, 304, 267, 11621, 14, 19553, 14, 14450, 342, 339, 347, 11850, 63, 923, 8, 277, 12, 1572, 63, 354, 304, 267, 291, 14, 2190, 63, 3440, 14, 14337, 63, 923, 8, 923, 63, 354, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 687, 14084, 20, 14, 4238, 492, 29469, 272, 1145, 275, 29469, 4157, 272, 511, 63, 3440, 360, 23613, 297, 283, 28377, 358, 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, 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, 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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 ]
le9i0nx/ansible
contrib/inventory/vmware.py
92
18476
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' VMware Inventory Script ======================= Retrieve information about virtual machines from a vCenter server or standalone ESX host. When `group_by=false` (in the INI file), host systems are also returned in addition to VMs. This script will attempt to read configuration from an INI file with the same base filename if present, or `vmware.ini` if not. It is possible to create symlinks to the inventory script to support multiple configurations, e.g.: * `vmware.py` (this script) * `vmware.ini` (default configuration, will be read by `vmware.py`) * `vmware_test.py` (symlink to `vmware.py`) * `vmware_test.ini` (test configuration, will be read by `vmware_test.py`) * `vmware_other.py` (symlink to `vmware.py`, will read `vmware.ini` since no `vmware_other.ini` exists) The path to an INI file may also be specified via the `VMWARE_INI` environment variable, in which case the filename matching rules above will not apply. Host and authentication parameters may be specified via the `VMWARE_HOST`, `VMWARE_USER` and `VMWARE_PASSWORD` environment variables; these options will take precedence over options present in the INI file. An INI file is not required if these options are specified using environment variables. ''' from __future__ import print_function import collections import json import logging import optparse import os import ssl import sys import time from six import integer_types, text_type, string_types from six.moves import configparser # Disable logging message trigged by pSphere/suds. try: from logging import NullHandler except ImportError: from logging import Handler class NullHandler(Handler): def emit(self, record): pass logging.getLogger('psphere').addHandler(NullHandler()) logging.getLogger('suds').addHandler(NullHandler()) from psphere.client import Client from psphere.errors import ObjectNotFoundError from psphere.managedobjects import HostSystem, VirtualMachine, ManagedObject, Network, ClusterComputeResource from suds.sudsobject import Object as SudsObject class VMwareInventory(object): def __init__(self, guests_only=None): self.config = configparser.SafeConfigParser() if os.environ.get('VMWARE_INI', ''): config_files = [os.environ['VMWARE_INI']] else: config_files = [os.path.abspath(sys.argv[0]).rstrip('.py') + '.ini', 'vmware.ini'] for config_file in config_files: if os.path.exists(config_file): self.config.read(config_file) break # Retrieve only guest VMs, or include host systems? if guests_only is not None: self.guests_only = guests_only elif self.config.has_option('defaults', 'guests_only'): self.guests_only = self.config.getboolean('defaults', 'guests_only') else: self.guests_only = True # Read authentication information from VMware environment variables # (if set), otherwise from INI file. auth_host = os.environ.get('VMWARE_HOST') if not auth_host and self.config.has_option('auth', 'host'): auth_host = self.config.get('auth', 'host') auth_user = os.environ.get('VMWARE_USER') if not auth_user and self.config.has_option('auth', 'user'): auth_user = self.config.get('auth', 'user') auth_password = os.environ.get('VMWARE_PASSWORD') if not auth_password and self.config.has_option('auth', 'password'): auth_password = self.config.get('auth', 'password') sslcheck = os.environ.get('VMWARE_SSLCHECK') if not sslcheck and self.config.has_option('auth', 'sslcheck'): sslcheck = self.config.get('auth', 'sslcheck') if not sslcheck: sslcheck = True else: if sslcheck.lower() in ['no', 'false']: sslcheck = False else: sslcheck = True # Limit the clusters being scanned self.filter_clusters = os.environ.get('VMWARE_CLUSTERS') if not self.filter_clusters and self.config.has_option('defaults', 'clusters'): self.filter_clusters = self.config.get('defaults', 'clusters') if self.filter_clusters: self.filter_clusters = [x.strip() for x in self.filter_clusters.split(',') if x.strip()] # Override certificate checks if not sslcheck: if hasattr(ssl, '_create_unverified_context'): ssl._create_default_https_context = ssl._create_unverified_context # Create the VMware client connection. self.client = Client(auth_host, auth_user, auth_password) def _put_cache(self, name, value): ''' Saves the value to cache with the name given. ''' if self.config.has_option('defaults', 'cache_dir'): cache_dir = os.path.expanduser(self.config.get('defaults', 'cache_dir')) if not os.path.exists(cache_dir): os.makedirs(cache_dir) cache_file = os.path.join(cache_dir, name) with open(cache_file, 'w') as cache: json.dump(value, cache) def _get_cache(self, name, default=None): ''' Retrieves the value from cache for the given name. ''' if self.config.has_option('defaults', 'cache_dir'): cache_dir = self.config.get('defaults', 'cache_dir') cache_file = os.path.join(cache_dir, name) if os.path.exists(cache_file): if self.config.has_option('defaults', 'cache_max_age'): cache_max_age = self.config.getint('defaults', 'cache_max_age') else: cache_max_age = 0 cache_stat = os.stat(cache_file) if (cache_stat.st_mtime + cache_max_age) >= time.time(): with open(cache_file) as cache: return json.load(cache) return default def _flatten_dict(self, d, parent_key='', sep='_'): ''' Flatten nested dicts by combining keys with a separator. Lists with only string items are included as is; any other lists are discarded. ''' items = [] for k, v in d.items(): if k.startswith('_'): continue new_key = parent_key + sep + k if parent_key else k if isinstance(v, collections.MutableMapping): items.extend(self._flatten_dict(v, new_key, sep).items()) elif isinstance(v, (list, tuple)): if all([isinstance(x, string_types) for x in v]): items.append((new_key, v)) else: items.append((new_key, v)) return dict(items) def _get_obj_info(self, obj, depth=99, seen=None): ''' Recursively build a data structure for the given pSphere object (depth only applies to ManagedObject instances). ''' seen = seen or set() if isinstance(obj, ManagedObject): try: obj_unicode = text_type(getattr(obj, 'name')) except AttributeError: obj_unicode = () if obj in seen: return obj_unicode seen.add(obj) if depth <= 0: return obj_unicode d = {} for attr in dir(obj): if attr.startswith('_'): continue try: val = getattr(obj, attr) obj_info = self._get_obj_info(val, depth - 1, seen) if obj_info != (): d[attr] = obj_info except Exception as e: pass return d elif isinstance(obj, SudsObject): d = {} for key, val in iter(obj): obj_info = self._get_obj_info(val, depth, seen) if obj_info != (): d[key] = obj_info return d elif isinstance(obj, (list, tuple)): l = [] for val in iter(obj): obj_info = self._get_obj_info(val, depth, seen) if obj_info != (): l.append(obj_info) return l elif isinstance(obj, (type(None), bool, float) + string_types + integer_types): return obj else: return () def _get_host_info(self, host, prefix='vmware'): ''' Return a flattened dict with info about the given host system. ''' host_info = { 'name': host.name, } for attr in ('datastore', 'network', 'vm'): try: value = getattr(host, attr) host_info['%ss' % attr] = self._get_obj_info(value, depth=0) except AttributeError: host_info['%ss' % attr] = [] for k, v in self._get_obj_info(host.summary, depth=0).items(): if isinstance(v, collections.MutableMapping): for k2, v2 in v.items(): host_info[k2] = v2 elif k != 'host': host_info[k] = v try: host_info['ipAddress'] = host.config.network.vnic[0].spec.ip.ipAddress except Exception as e: print(e, file=sys.stderr) host_info = self._flatten_dict(host_info, prefix) if ('%s_ipAddress' % prefix) in host_info: host_info['ansible_ssh_host'] = host_info['%s_ipAddress' % prefix] return host_info def _get_vm_info(self, vm, prefix='vmware'): ''' Return a flattened dict with info about the given virtual machine. ''' vm_info = { 'name': vm.name, } for attr in ('datastore', 'network'): try: value = getattr(vm, attr) vm_info['%ss' % attr] = self._get_obj_info(value, depth=0) except AttributeError: vm_info['%ss' % attr] = [] try: vm_info['resourcePool'] = self._get_obj_info(vm.resourcePool, depth=0) except AttributeError: vm_info['resourcePool'] = '' try: vm_info['guestState'] = vm.guest.guestState except AttributeError: vm_info['guestState'] = '' for k, v in self._get_obj_info(vm.summary, depth=0).items(): if isinstance(v, collections.MutableMapping): for k2, v2 in v.items(): if k2 == 'host': k2 = 'hostSystem' vm_info[k2] = v2 elif k != 'vm': vm_info[k] = v vm_info = self._flatten_dict(vm_info, prefix) if ('%s_ipAddress' % prefix) in vm_info: vm_info['ansible_ssh_host'] = vm_info['%s_ipAddress' % prefix] return vm_info def _add_host(self, inv, parent_group, host_name): ''' Add the host to the parent group in the given inventory. ''' p_group = inv.setdefault(parent_group, []) if isinstance(p_group, dict): group_hosts = p_group.setdefault('hosts', []) else: group_hosts = p_group if host_name not in group_hosts: group_hosts.append(host_name) def _add_child(self, inv, parent_group, child_group): ''' Add a child group to a parent group in the given inventory. ''' if parent_group != 'all': p_group = inv.setdefault(parent_group, {}) if not isinstance(p_group, dict): inv[parent_group] = {'hosts': p_group} p_group = inv[parent_group] group_children = p_group.setdefault('children', []) if child_group not in group_children: group_children.append(child_group) inv.setdefault(child_group, []) def get_inventory(self, meta_hostvars=True): ''' Reads the inventory from cache or VMware API via pSphere. ''' # Use different cache names for guests only vs. all hosts. if self.guests_only: cache_name = '__inventory_guests__' else: cache_name = '__inventory_all__' inv = self._get_cache(cache_name, None) if inv is not None: return inv inv = {'all': {'hosts': []}} if meta_hostvars: inv['_meta'] = {'hostvars': {}} default_group = os.path.basename(sys.argv[0]).rstrip('.py') if not self.guests_only: if self.config.has_option('defaults', 'hw_group'): hw_group = self.config.get('defaults', 'hw_group') else: hw_group = default_group + '_hw' if self.config.has_option('defaults', 'vm_group'): vm_group = self.config.get('defaults', 'vm_group') else: vm_group = default_group + '_vm' if self.config.has_option('defaults', 'prefix_filter'): prefix_filter = self.config.get('defaults', 'prefix_filter') else: prefix_filter = None if self.filter_clusters: # Loop through clusters and find hosts: hosts = [] for cluster in ClusterComputeResource.all(self.client): if cluster.name in self.filter_clusters: for host in cluster.host: hosts.append(host) else: # Get list of all physical hosts hosts = HostSystem.all(self.client) # Loop through physical hosts: for host in hosts: if not self.guests_only: self._add_host(inv, 'all', host.name) self._add_host(inv, hw_group, host.name) host_info = self._get_host_info(host) if meta_hostvars: inv['_meta']['hostvars'][host.name] = host_info self._put_cache(host.name, host_info) # Loop through all VMs on physical host. for vm in host.vm: if prefix_filter: if vm.name.startswith(prefix_filter): continue self._add_host(inv, 'all', vm.name) self._add_host(inv, vm_group, vm.name) vm_info = self._get_vm_info(vm) if meta_hostvars: inv['_meta']['hostvars'][vm.name] = vm_info self._put_cache(vm.name, vm_info) # Group by resource pool. vm_resourcePool = vm_info.get('vmware_resourcePool', None) if vm_resourcePool: self._add_child(inv, vm_group, 'resource_pools') self._add_child(inv, 'resource_pools', vm_resourcePool) self._add_host(inv, vm_resourcePool, vm.name) # Group by datastore. for vm_datastore in vm_info.get('vmware_datastores', []): self._add_child(inv, vm_group, 'datastores') self._add_child(inv, 'datastores', vm_datastore) self._add_host(inv, vm_datastore, vm.name) # Group by network. for vm_network in vm_info.get('vmware_networks', []): self._add_child(inv, vm_group, 'networks') self._add_child(inv, 'networks', vm_network) self._add_host(inv, vm_network, vm.name) # Group by guest OS. vm_guestId = vm_info.get('vmware_guestId', None) if vm_guestId: self._add_child(inv, vm_group, 'guests') self._add_child(inv, 'guests', vm_guestId) self._add_host(inv, vm_guestId, vm.name) # Group all VM templates. vm_template = vm_info.get('vmware_template', False) if vm_template: self._add_child(inv, vm_group, 'templates') self._add_host(inv, 'templates', vm.name) self._put_cache(cache_name, inv) return inv def get_host(self, hostname): ''' Read info about a specific host or VM from cache or VMware API. ''' inv = self._get_cache(hostname, None) if inv is not None: return inv if not self.guests_only: try: host = HostSystem.get(self.client, name=hostname) inv = self._get_host_info(host) except ObjectNotFoundError: pass if inv is None: try: vm = VirtualMachine.get(self.client, name=hostname) inv = self._get_vm_info(vm) except ObjectNotFoundError: pass if inv is not None: self._put_cache(hostname, inv) return inv or {} def main(): parser = optparse.OptionParser() parser.add_option('--list', action='store_true', dest='list', default=False, help='Output inventory groups and hosts') parser.add_option('--host', dest='host', default=None, metavar='HOST', help='Output variables only for the given hostname') # Additional options for use when running the script standalone, but never # used by Ansible. parser.add_option('--pretty', action='store_true', dest='pretty', default=False, help='Output nicely-formatted JSON') parser.add_option('--include-host-systems', action='store_true', dest='include_host_systems', default=False, help='Include host systems in addition to VMs') parser.add_option('--no-meta-hostvars', action='store_false', dest='meta_hostvars', default=True, help='Exclude [\'_meta\'][\'hostvars\'] with --list') options, args = parser.parse_args() if options.include_host_systems: vmware_inventory = VMwareInventory(guests_only=False) else: vmware_inventory = VMwareInventory() if options.host is not None: inventory = vmware_inventory.get_host(options.host) else: inventory = vmware_inventory.get_inventory(options.meta_hostvars) json_kwargs = {} if options.pretty: json_kwargs.update({'indent': 4, 'sort_keys': True}) json.dump(inventory, sys.stdout, **json_kwargs) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 6849, 1068, 19337, 14914, 199, 1280, 18673, 199, 199, 15310, 2556, 3595, 5791, 20601, 687, 282, 373, 13551, 1654, 503, 199, 20323, 10427, 56, 1591, 14, 221, 3979, 658, 923, 63, 991, 29, 3910, 64, 334, 262, 314, 1621, 41, 570, 395, 1591, 10460, 199, 1530, 2597, 2138, 315, 10234, 370, 30641, 14, 199, 199, 2765, 2884, 911, 7427, 370, 1586, 2897, 687, 376, 1621, 41, 570, 543, 314, 2011, 199, 1095, 1788, 340, 3451, 12, 503, 658, 18970, 14, 2730, 64, 340, 440, 14, 221, 2779, 365, 3962, 370, 1218, 199, 19522, 370, 314, 8200, 2884, 370, 2291, 3663, 13422, 12, 325, 14, 71, 16781, 199, 199, 10, 658, 18970, 14, 647, 64, 334, 3749, 2884, 9, 199, 10, 658, 18970, 14, 2730, 64, 334, 885, 2897, 12, 911, 506, 1586, 701, 658, 18970, 14, 647, 10522, 199, 10, 658, 18970, 63, 396, 14, 647, 64, 334, 13380, 370, 658, 18970, 14, 647, 10522, 199, 10, 658, 18970, 63, 396, 14, 2730, 64, 334, 396, 2897, 12, 911, 506, 1586, 701, 658, 18970, 63, 396, 14, 647, 10522, 199, 10, 658, 18970, 63, 1848, 14, 647, 64, 334, 13380, 370, 658, 18970, 14, 647, 3559, 911, 1586, 658, 18970, 14, 2730, 64, 3967, 949, 523, 658, 18970, 63, 1848, 14, 2730, 64, 3495, 9, 199, 199, 1918, 931, 370, 376, 1621, 41, 570, 1443, 2597, 506, 2013, 4799, 314, 658, 6849, 3695, 63, 568, 41, 64, 3734, 199, 1975, 12, 315, 1314, 1930, 314, 1788, 4877, 4713, 3432, 911, 440, 4838, 14, 199, 199, 4965, 436, 6299, 2633, 1443, 506, 2013, 4799, 314, 658, 6849, 3695, 63, 5449, 3559, 199, 64, 6849, 3695, 63, 3791, 64, 436, 658, 6849, 3695, 63, 9032, 64, 3734, 2860, 27, 3520, 1511, 911, 199, 11066, 13823, 1806, 1511, 3451, 315, 314, 1621, 41, 570, 14, 221, 1626, 1621, 41, 570, 365, 440, 199, 2427, 340, 3520, 1511, 787, 2013, 1808, 3734, 2860, 14, 199, 2344, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5055, 199, 646, 2022, 199, 646, 2050, 199, 646, 8691, 199, 646, 747, 199, 646, 6149, 199, 646, 984, 199, 646, 900, 199, 199, 504, 3816, 492, 3000, 63, 1313, 12, 1318, 63, 466, 12, 1059, 63, 1313, 199, 504, 3816, 14, 4912, 492, 21230, 199, 199, 3, 17534, 2050, 1245, 3229, 71, 3046, 701, 299, 22385, 15, 9648, 795, 14, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 687, 2050, 492, 18599, 339, 1021, 12119, 2461, 8, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 4806, 14, 5572, 360, 80, 14980, 1959, 18826, 8, 8849, 2461, 1012, 199, 4806, 14, 5572, 360, 9648, 795, 1959, 18826, 8, 8849, 2461, 1012, 199, 199, 504, 299, 14980, 14, 1258, 492, 6810, 199, 504, 299, 14980, 14, 2550, 492, 6935, 10870, 199, 504, 299, 14980, 14, 11122, 1462, 492, 10891, 3989, 12, 13311, 8412, 12, 4688, 6028, 1692, 12, 7220, 12, 16454, 8564, 4031, 199, 504, 30713, 14, 9648, 795, 785, 492, 6935, 465, 428, 14577, 1692, 421, 199, 533, 27391, 19304, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 13980, 83, 63, 2118, 29, 403, 304, 267, 291, 14, 888, 275, 21230, 14, 11090, 15218, 342, 267, 340, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 568, 41, 297, 21019, 288, 1101, 63, 1725, 275, 359, 736, 14, 2314, 459, 6849, 3695, 63, 568, 41, 6538, 267, 587, 26, 288, 1101, 63, 1725, 275, 359, 736, 14, 515, 14, 4832, 8, 1274, 14, 3020, 59, 16, 6575, 6735, 5175, 647, 358, 435, 1987, 2730, 297, 283, 18970, 14, 2730, 418, 267, 367, 1101, 63, 493, 315, 1101, 63, 1725, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 888, 63, 493, 304, 355, 291, 14, 888, 14, 739, 8, 888, 63, 493, 9, 355, 2059, 398, 327, 13939, 1454, 13980, 30641, 12, 503, 2387, 1591, 10460, 31, 267, 340, 13980, 83, 63, 2118, 365, 440, 488, 26, 288, 291, 14, 10409, 83, 63, 2118, 275, 13980, 83, 63, 2118, 267, 916, 291, 14, 888, 14, 1989, 63, 1422, 360, 4322, 297, 283, 10409, 83, 63, 2118, 735, 288, 291, 14, 10409, 83, 63, 2118, 275, 291, 14, 888, 14, 30356, 360, 4322, 297, 283, 10409, 83, 63, 2118, 358, 267, 587, 26, 288, 291, 14, 10409, 83, 63, 2118, 275, 715, 398, 327, 5574, 6299, 2556, 687, 27391, 3734, 2860, 267, 327, 334, 692, 663, 395, 4257, 687, 1621, 41, 570, 14, 267, 1790, 63, 1102, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 5449, 358, 267, 340, 440, 1790, 63, 1102, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 1102, 735, 288, 1790, 63, 1102, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 1102, 358, 267, 1790, 63, 751, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 3791, 358, 267, 340, 440, 1790, 63, 751, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 751, 735, 288, 1790, 63, 751, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 751, 358, 267, 1790, 63, 2060, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 9032, 358, 267, 340, 440, 1790, 63, 2060, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 2060, 735, 288, 1790, 63, 2060, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 2060, 358, 267, 6149, 1074, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 5413, 8936, 358, 267, 340, 440, 6149, 1074, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 4266, 1074, 735, 288, 6149, 1074, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 4266, 1074, 358, 267, 340, 440, 6149, 1074, 26, 288, 6149, 1074, 275, 715, 267, 587, 26, 288, 340, 6149, 1074, 14, 2325, 342, 315, 788, 889, 297, 283, 3910, 2565, 355, 6149, 1074, 275, 756, 288, 587, 26, 355, 6149, 1074, 275, 715, 398, 327, 22672, 314, 13865 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 6849, 1068, 19337, 14914, 199, 1280, 18673, 199, 199, 15310, 2556, 3595, 5791, 20601, 687, 282, 373, 13551, 1654, 503, 199, 20323, 10427, 56, 1591, 14, 221, 3979, 658, 923, 63, 991, 29, 3910, 64, 334, 262, 314, 1621, 41, 570, 395, 1591, 10460, 199, 1530, 2597, 2138, 315, 10234, 370, 30641, 14, 199, 199, 2765, 2884, 911, 7427, 370, 1586, 2897, 687, 376, 1621, 41, 570, 543, 314, 2011, 199, 1095, 1788, 340, 3451, 12, 503, 658, 18970, 14, 2730, 64, 340, 440, 14, 221, 2779, 365, 3962, 370, 1218, 199, 19522, 370, 314, 8200, 2884, 370, 2291, 3663, 13422, 12, 325, 14, 71, 16781, 199, 199, 10, 658, 18970, 14, 647, 64, 334, 3749, 2884, 9, 199, 10, 658, 18970, 14, 2730, 64, 334, 885, 2897, 12, 911, 506, 1586, 701, 658, 18970, 14, 647, 10522, 199, 10, 658, 18970, 63, 396, 14, 647, 64, 334, 13380, 370, 658, 18970, 14, 647, 10522, 199, 10, 658, 18970, 63, 396, 14, 2730, 64, 334, 396, 2897, 12, 911, 506, 1586, 701, 658, 18970, 63, 396, 14, 647, 10522, 199, 10, 658, 18970, 63, 1848, 14, 647, 64, 334, 13380, 370, 658, 18970, 14, 647, 3559, 911, 1586, 658, 18970, 14, 2730, 64, 3967, 949, 523, 658, 18970, 63, 1848, 14, 2730, 64, 3495, 9, 199, 199, 1918, 931, 370, 376, 1621, 41, 570, 1443, 2597, 506, 2013, 4799, 314, 658, 6849, 3695, 63, 568, 41, 64, 3734, 199, 1975, 12, 315, 1314, 1930, 314, 1788, 4877, 4713, 3432, 911, 440, 4838, 14, 199, 199, 4965, 436, 6299, 2633, 1443, 506, 2013, 4799, 314, 658, 6849, 3695, 63, 5449, 3559, 199, 64, 6849, 3695, 63, 3791, 64, 436, 658, 6849, 3695, 63, 9032, 64, 3734, 2860, 27, 3520, 1511, 911, 199, 11066, 13823, 1806, 1511, 3451, 315, 314, 1621, 41, 570, 14, 221, 1626, 1621, 41, 570, 365, 440, 199, 2427, 340, 3520, 1511, 787, 2013, 1808, 3734, 2860, 14, 199, 2344, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 5055, 199, 646, 2022, 199, 646, 2050, 199, 646, 8691, 199, 646, 747, 199, 646, 6149, 199, 646, 984, 199, 646, 900, 199, 199, 504, 3816, 492, 3000, 63, 1313, 12, 1318, 63, 466, 12, 1059, 63, 1313, 199, 504, 3816, 14, 4912, 492, 21230, 199, 199, 3, 17534, 2050, 1245, 3229, 71, 3046, 701, 299, 22385, 15, 9648, 795, 14, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 687, 2050, 492, 18599, 339, 1021, 12119, 2461, 8, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 199, 199, 4806, 14, 5572, 360, 80, 14980, 1959, 18826, 8, 8849, 2461, 1012, 199, 4806, 14, 5572, 360, 9648, 795, 1959, 18826, 8, 8849, 2461, 1012, 199, 199, 504, 299, 14980, 14, 1258, 492, 6810, 199, 504, 299, 14980, 14, 2550, 492, 6935, 10870, 199, 504, 299, 14980, 14, 11122, 1462, 492, 10891, 3989, 12, 13311, 8412, 12, 4688, 6028, 1692, 12, 7220, 12, 16454, 8564, 4031, 199, 504, 30713, 14, 9648, 795, 785, 492, 6935, 465, 428, 14577, 1692, 421, 199, 533, 27391, 19304, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 13980, 83, 63, 2118, 29, 403, 304, 267, 291, 14, 888, 275, 21230, 14, 11090, 15218, 342, 267, 340, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 568, 41, 297, 21019, 288, 1101, 63, 1725, 275, 359, 736, 14, 2314, 459, 6849, 3695, 63, 568, 41, 6538, 267, 587, 26, 288, 1101, 63, 1725, 275, 359, 736, 14, 515, 14, 4832, 8, 1274, 14, 3020, 59, 16, 6575, 6735, 5175, 647, 358, 435, 1987, 2730, 297, 283, 18970, 14, 2730, 418, 267, 367, 1101, 63, 493, 315, 1101, 63, 1725, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 888, 63, 493, 304, 355, 291, 14, 888, 14, 739, 8, 888, 63, 493, 9, 355, 2059, 398, 327, 13939, 1454, 13980, 30641, 12, 503, 2387, 1591, 10460, 31, 267, 340, 13980, 83, 63, 2118, 365, 440, 488, 26, 288, 291, 14, 10409, 83, 63, 2118, 275, 13980, 83, 63, 2118, 267, 916, 291, 14, 888, 14, 1989, 63, 1422, 360, 4322, 297, 283, 10409, 83, 63, 2118, 735, 288, 291, 14, 10409, 83, 63, 2118, 275, 291, 14, 888, 14, 30356, 360, 4322, 297, 283, 10409, 83, 63, 2118, 358, 267, 587, 26, 288, 291, 14, 10409, 83, 63, 2118, 275, 715, 398, 327, 5574, 6299, 2556, 687, 27391, 3734, 2860, 267, 327, 334, 692, 663, 395, 4257, 687, 1621, 41, 570, 14, 267, 1790, 63, 1102, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 5449, 358, 267, 340, 440, 1790, 63, 1102, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 1102, 735, 288, 1790, 63, 1102, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 1102, 358, 267, 1790, 63, 751, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 3791, 358, 267, 340, 440, 1790, 63, 751, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 751, 735, 288, 1790, 63, 751, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 751, 358, 267, 1790, 63, 2060, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 9032, 358, 267, 340, 440, 1790, 63, 2060, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 2060, 735, 288, 1790, 63, 2060, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 2060, 358, 267, 6149, 1074, 275, 747, 14, 2314, 14, 362, 360, 6849, 3695, 63, 5413, 8936, 358, 267, 340, 440, 6149, 1074, 436, 291, 14, 888, 14, 1989, 63, 1422, 360, 1178, 297, 283, 4266, 1074, 735, 288, 6149, 1074, 275, 291, 14, 888, 14, 362, 360, 1178, 297, 283, 4266, 1074, 358, 267, 340, 440, 6149, 1074, 26, 288, 6149, 1074, 275, 715, 267, 587, 26, 288, 340, 6149, 1074, 14, 2325, 342, 315, 788, 889, 297, 283, 3910, 2565, 355, 6149, 1074, 275, 756, 288, 587, 26, 355, 6149, 1074, 275, 715, 398, 327, 22672, 314, 13865, 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,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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 ]
Weil0ng/gem5
ext/ply/test/testyacc.py
93
14230
# testyacc.py import unittest try: import StringIO except ImportError: import io as StringIO import sys import os sys.path.insert(0,"..") sys.tracebacklimit = 0 import ply.yacc def check_expected(result,expected): resultlines = [] for line in result.splitlines(): if line.startswith("WARNING: "): line = line[9:] elif line.startswith("ERROR: "): line = line[7:] resultlines.append(line) expectedlines = expected.splitlines() if len(resultlines) != len(expectedlines): return False for rline,eline in zip(resultlines,expectedlines): if not rline.endswith(eline): return False return True def run_import(module): code = "import "+module exec(code) del sys.modules[module] # Tests related to errors and warnings when building parsers class YaccErrorWarningTests(unittest.TestCase): def setUp(self): sys.stderr = StringIO.StringIO() sys.stdout = StringIO.StringIO() try: os.remove("parsetab.py") os.remove("parsetab.pyc") except OSError: pass def tearDown(self): sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ def test_yacc_badargs(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badargs") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_badargs.py:23: Rule 'p_statement_assign' has too many arguments\n" "yacc_badargs.py:27: Rule 'p_statement_expr' requires an argument\n" )) def test_yacc_badid(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badid") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_badid.py:32: Illegal name 'bad&rule' in rule 'statement'\n" "yacc_badid.py:36: Illegal rule name 'bad&rule'\n" )) def test_yacc_badprec(self): try: run_import("yacc_badprec") except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assert_(check_expected(result, "precedence must be a list or tuple\n" )) def test_yacc_badprec2(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badprec2") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Bad precedence table\n" )) def test_yacc_badprec3(self): run_import("yacc_badprec3") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Precedence already specified for terminal 'MINUS'\n" "Generating LALR tables\n" )) def test_yacc_badrule(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badrule") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_badrule.py:24: Syntax error. Expected ':'\n" "yacc_badrule.py:28: Syntax error in rule 'statement'\n" "yacc_badrule.py:33: Syntax error. Expected ':'\n" "yacc_badrule.py:42: Syntax error. Expected ':'\n" )) def test_yacc_badtok(self): try: run_import("yacc_badtok") except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assert_(check_expected(result, "tokens must be a list or tuple\n")) def test_yacc_dup(self): run_import("yacc_dup") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_dup.py:27: Function p_statement redefined. Previously defined on line 23\n" "Token 'EQUALS' defined, but not used\n" "There is 1 unused token\n" "Generating LALR tables\n" )) def test_yacc_error1(self): try: run_import("yacc_error1") except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_error1.py:61: p_error() requires 1 argument\n")) def test_yacc_error2(self): try: run_import("yacc_error2") except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_error2.py:61: p_error() requires 1 argument\n")) def test_yacc_error3(self): try: run_import("yacc_error3") except ply.yacc.YaccError: e = sys.exc_info()[1] result = sys.stderr.getvalue() self.assert_(check_expected(result, "'p_error' defined, but is not a function or method\n")) def test_yacc_error4(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_error4") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_error4.py:62: Illegal rule name 'error'. Already defined as a token\n" )) def test_yacc_inf(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_inf") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Token 'NUMBER' defined, but not used\n" "There is 1 unused token\n" "Infinite recursion detected for symbol 'statement'\n" "Infinite recursion detected for symbol 'expression'\n" )) def test_yacc_literal(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_literal") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_literal.py:36: Literal token '**' in rule 'expression' may only be a single character\n" )) def test_yacc_misplaced(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_misplaced") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_misplaced.py:32: Misplaced '|'\n" )) def test_yacc_missing1(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_missing1") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_missing1.py:24: Symbol 'location' used, but not defined as a token or a rule\n" )) def test_yacc_nested(self): run_import("yacc_nested") result = sys.stdout.getvalue() self.assert_(check_expected(result, "A\n" "A\n" "A\n", )) def test_yacc_nodoc(self): run_import("yacc_nodoc") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_nodoc.py:27: No documentation string specified in function 'p_statement_expr' (ignored)\n" "Generating LALR tables\n" )) def test_yacc_noerror(self): run_import("yacc_noerror") result = sys.stderr.getvalue() self.assert_(check_expected(result, "no p_error() function is defined\n" "Generating LALR tables\n" )) def test_yacc_nop(self): run_import("yacc_nop") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_nop.py:27: Possible grammar rule 'statement_expr' defined without p_ prefix\n" "Generating LALR tables\n" )) def test_yacc_notfunc(self): run_import("yacc_notfunc") result = sys.stderr.getvalue() self.assert_(check_expected(result, "'p_statement_assign' not defined as a function\n" "Token 'EQUALS' defined, but not used\n" "There is 1 unused token\n" "Generating LALR tables\n" )) def test_yacc_notok(self): try: run_import("yacc_notok") except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assert_(check_expected(result, "No token list is defined\n")) def test_yacc_rr(self): run_import("yacc_rr") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Generating LALR tables\n" "1 reduce/reduce conflict\n" "reduce/reduce conflict in state 15 resolved using rule (statement -> NAME EQUALS NUMBER)\n" "rejected rule (expression -> NUMBER) in state 15\n" )) def test_yacc_rr_unused(self): run_import("yacc_rr_unused") result = sys.stderr.getvalue() self.assert_(check_expected(result, "no p_error() function is defined\n" "Generating LALR tables\n" "3 reduce/reduce conflicts\n" "reduce/reduce conflict in state 1 resolved using rule (rule3 -> A)\n" "rejected rule (rule4 -> A) in state 1\n" "reduce/reduce conflict in state 1 resolved using rule (rule3 -> A)\n" "rejected rule (rule5 -> A) in state 1\n" "reduce/reduce conflict in state 1 resolved using rule (rule4 -> A)\n" "rejected rule (rule5 -> A) in state 1\n" "Rule (rule5 -> A) is never reduced\n" )) def test_yacc_simple(self): run_import("yacc_simple") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Generating LALR tables\n" )) def test_yacc_sr(self): run_import("yacc_sr") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Generating LALR tables\n" "20 shift/reduce conflicts\n" )) def test_yacc_term1(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_term1") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_term1.py:24: Illegal rule name 'NUMBER'. Already defined as a token\n" )) def test_yacc_unused(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_unused") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_unused.py:62: Symbol 'COMMA' used, but not defined as a token or a rule\n" "Symbol 'COMMA' is unreachable\n" "Symbol 'exprlist' is unreachable\n" )) def test_yacc_unused_rule(self): run_import("yacc_unused_rule") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_unused_rule.py:62: Rule 'integer' defined, but not used\n" "There is 1 unused rule\n" "Symbol 'integer' is unreachable\n" "Generating LALR tables\n" )) def test_yacc_uprec(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_uprec") result = sys.stderr.getvalue() print repr(result) self.assert_(check_expected(result, "yacc_uprec.py:37: Nothing known about the precedence of 'UMINUS'\n" )) def test_yacc_uprec2(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_uprec2") result = sys.stderr.getvalue() self.assert_(check_expected(result, "yacc_uprec2.py:37: Syntax error. Nothing follows %prec\n" )) def test_yacc_prec1(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_prec1") result = sys.stderr.getvalue() self.assert_(check_expected(result, "Precedence rule 'left' defined for unknown symbol '+'\n" "Precedence rule 'left' defined for unknown symbol '*'\n" "Precedence rule 'left' defined for unknown symbol '-'\n" "Precedence rule 'left' defined for unknown symbol '/'\n" )) unittest.main()
bsd-3-clause
[ 3, 511, 27319, 14, 647, 199, 199, 646, 2882, 199, 893, 26, 272, 492, 5228, 199, 2590, 3545, 26, 272, 492, 5890, 465, 5228, 199, 199, 646, 984, 199, 646, 747, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 4589, 703, 531, 199, 1274, 14, 6894, 3097, 275, 378, 199, 199, 646, 299, 590, 14, 27319, 199, 199, 318, 1104, 63, 2062, 8, 1099, 12, 2062, 304, 272, 754, 1278, 275, 942, 272, 367, 1004, 315, 754, 14, 7644, 837, 267, 340, 1004, 14, 2460, 480, 9171, 26, 26699, 288, 1004, 275, 1004, 59, 25, 2938, 267, 916, 1004, 14, 2460, 480, 3170, 26, 26699, 288, 1004, 275, 1004, 59, 23, 2938, 267, 754, 1278, 14, 740, 8, 604, 9, 339, 1420, 1278, 275, 1420, 14, 7644, 342, 272, 340, 822, 8, 1099, 1278, 9, 1137, 822, 8, 2062, 1278, 304, 267, 372, 756, 272, 367, 519, 604, 12, 32347, 315, 3482, 8, 1099, 1278, 12, 2062, 1278, 304, 267, 340, 440, 519, 604, 14, 4130, 8, 32347, 304, 288, 372, 756, 272, 372, 715, 199, 199, 318, 1255, 63, 646, 8, 578, 304, 272, 1233, 275, 298, 646, 7210, 578, 272, 2146, 8, 600, 9, 272, 2150, 984, 14, 3112, 59, 578, 61, 1362, 199, 3, 6496, 4048, 370, 2552, 436, 3598, 1380, 10015, 21295, 199, 533, 1488, 5470, 547, 3849, 2925, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 984, 14, 3083, 275, 5228, 14, 6424, 342, 267, 984, 14, 2703, 275, 5228, 14, 6424, 342, 267, 862, 26, 288, 747, 14, 2168, 480, 462, 409, 371, 14, 647, 531, 288, 747, 14, 2168, 480, 462, 409, 371, 14, 11357, 531, 267, 871, 6440, 26, 288, 986, 5493, 347, 6766, 8, 277, 304, 267, 984, 14, 3083, 275, 984, 855, 3083, 363, 267, 984, 14, 2703, 275, 984, 855, 2703, 363, 272, 347, 511, 63, 27319, 63, 4087, 589, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 589, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 4087, 589, 14, 647, 26, 1789, 26, 11949, 283, 80, 63, 6242, 63, 5038, 7, 965, 4634, 5002, 2368, 60, 78, 2, 2511, 298, 27319, 63, 4087, 589, 14, 647, 26, 1465, 26, 11949, 283, 80, 63, 6242, 63, 3684, 7, 5074, 376, 1423, 60, 78, 2, 2511, 5082, 260, 272, 347, 511, 63, 27319, 63, 2470, 14887, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 2470, 14887, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 2470, 14887, 14, 647, 26, 708, 26, 473, 13486, 536, 283, 4087, 6, 2200, 7, 315, 2332, 283, 6242, 1154, 78, 2, 2511, 298, 27319, 63, 2470, 14887, 14, 647, 26, 1344, 26, 473, 13486, 2332, 536, 283, 4087, 6, 2200, 1154, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9218, 8, 277, 304, 267, 862, 26, 288, 1255, 63, 646, 480, 27319, 63, 4087, 9218, 531, 267, 871, 299, 590, 14, 27319, 14, 57, 5470, 547, 26, 288, 754, 275, 984, 14, 3083, 14, 7150, 342, 288, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 3147, 298, 19571, 1471, 506, 282, 769, 503, 2008, 60, 78, 2, 3147, 5082, 272, 347, 511, 63, 27319, 63, 4087, 9218, 18, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 9218, 18, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 5725, 13823, 1817, 60, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9218, 19, 8, 277, 304, 267, 1255, 63, 646, 480, 27319, 63, 4087, 9218, 19, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 2398, 16641, 2575, 2013, 367, 11167, 283, 18004, 1154, 78, 2, 2511, 298, 29244, 491, 748, 50, 6716, 60, 78, 2, 199, 2511, 5082, 5493, 347, 511, 63, 27319, 63, 4087, 2200, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 2200, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1194, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1651, 26, 18377, 1125, 315, 2332, 283, 6242, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1153, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 2260, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9305, 8, 277, 304, 267, 862, 26, 288, 1255, 63, 646, 480, 27319, 63, 4087, 9305, 531, 267, 871, 299, 590, 14, 27319, 14, 57, 5470, 547, 26, 288, 754, 275, 984, 14, 3083, 14, 7150, 342, 288, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 3147, 298, 4504, 1471, 506, 282, 769, 503, 2008, 60, 78, 2237, 339, 347, 511, 63, 27319, 63, 11048, 8, 277, 304, 267, 1255, 63, 646, 480, 27319, 63, 11048, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 11048, 14, 647, 26, 1465, 26, 6801, 299, 63, 6242, 295, 4037, 14, 26902, 590, 3247, 641, 1004, 6546, 60, 78, 2, 2511, 298, 3264, 283, 16352, 51, 7, 3247, 12, 1325, 440, 1202, 60, 78, 2, 2511, 298, 10924, 365, 413, 9563, 1526, 60, 78, 2, 2511, 298, 29244, 491, 748, 50, 6716, 60, 78, 2, 199, 2511, 5082, 272 ]
[ 511, 27319, 14, 647, 199, 199, 646, 2882, 199, 893, 26, 272, 492, 5228, 199, 2590, 3545, 26, 272, 492, 5890, 465, 5228, 199, 199, 646, 984, 199, 646, 747, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 4589, 703, 531, 199, 1274, 14, 6894, 3097, 275, 378, 199, 199, 646, 299, 590, 14, 27319, 199, 199, 318, 1104, 63, 2062, 8, 1099, 12, 2062, 304, 272, 754, 1278, 275, 942, 272, 367, 1004, 315, 754, 14, 7644, 837, 267, 340, 1004, 14, 2460, 480, 9171, 26, 26699, 288, 1004, 275, 1004, 59, 25, 2938, 267, 916, 1004, 14, 2460, 480, 3170, 26, 26699, 288, 1004, 275, 1004, 59, 23, 2938, 267, 754, 1278, 14, 740, 8, 604, 9, 339, 1420, 1278, 275, 1420, 14, 7644, 342, 272, 340, 822, 8, 1099, 1278, 9, 1137, 822, 8, 2062, 1278, 304, 267, 372, 756, 272, 367, 519, 604, 12, 32347, 315, 3482, 8, 1099, 1278, 12, 2062, 1278, 304, 267, 340, 440, 519, 604, 14, 4130, 8, 32347, 304, 288, 372, 756, 272, 372, 715, 199, 199, 318, 1255, 63, 646, 8, 578, 304, 272, 1233, 275, 298, 646, 7210, 578, 272, 2146, 8, 600, 9, 272, 2150, 984, 14, 3112, 59, 578, 61, 1362, 199, 3, 6496, 4048, 370, 2552, 436, 3598, 1380, 10015, 21295, 199, 533, 1488, 5470, 547, 3849, 2925, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 984, 14, 3083, 275, 5228, 14, 6424, 342, 267, 984, 14, 2703, 275, 5228, 14, 6424, 342, 267, 862, 26, 288, 747, 14, 2168, 480, 462, 409, 371, 14, 647, 531, 288, 747, 14, 2168, 480, 462, 409, 371, 14, 11357, 531, 267, 871, 6440, 26, 288, 986, 5493, 347, 6766, 8, 277, 304, 267, 984, 14, 3083, 275, 984, 855, 3083, 363, 267, 984, 14, 2703, 275, 984, 855, 2703, 363, 272, 347, 511, 63, 27319, 63, 4087, 589, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 589, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 4087, 589, 14, 647, 26, 1789, 26, 11949, 283, 80, 63, 6242, 63, 5038, 7, 965, 4634, 5002, 2368, 60, 78, 2, 2511, 298, 27319, 63, 4087, 589, 14, 647, 26, 1465, 26, 11949, 283, 80, 63, 6242, 63, 3684, 7, 5074, 376, 1423, 60, 78, 2, 2511, 5082, 260, 272, 347, 511, 63, 27319, 63, 2470, 14887, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 2470, 14887, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 2470, 14887, 14, 647, 26, 708, 26, 473, 13486, 536, 283, 4087, 6, 2200, 7, 315, 2332, 283, 6242, 1154, 78, 2, 2511, 298, 27319, 63, 2470, 14887, 14, 647, 26, 1344, 26, 473, 13486, 2332, 536, 283, 4087, 6, 2200, 1154, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9218, 8, 277, 304, 267, 862, 26, 288, 1255, 63, 646, 480, 27319, 63, 4087, 9218, 531, 267, 871, 299, 590, 14, 27319, 14, 57, 5470, 547, 26, 288, 754, 275, 984, 14, 3083, 14, 7150, 342, 288, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 3147, 298, 19571, 1471, 506, 282, 769, 503, 2008, 60, 78, 2, 3147, 5082, 272, 347, 511, 63, 27319, 63, 4087, 9218, 18, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 9218, 18, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 5725, 13823, 1817, 60, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9218, 19, 8, 277, 304, 267, 1255, 63, 646, 480, 27319, 63, 4087, 9218, 19, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 2398, 16641, 2575, 2013, 367, 11167, 283, 18004, 1154, 78, 2, 2511, 298, 29244, 491, 748, 50, 6716, 60, 78, 2, 199, 2511, 5082, 5493, 347, 511, 63, 27319, 63, 4087, 2200, 8, 277, 304, 267, 291, 14, 1855, 8, 19786, 14, 27319, 14, 57, 5470, 547, 12, 1065, 63, 646, 4589, 27319, 63, 4087, 2200, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1194, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1651, 26, 18377, 1125, 315, 2332, 283, 6242, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 1153, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 298, 27319, 63, 4087, 2200, 14, 647, 26, 2260, 26, 18377, 1125, 14, 13796, 7596, 1154, 78, 2, 2511, 5082, 339, 347, 511, 63, 27319, 63, 4087, 9305, 8, 277, 304, 267, 862, 26, 288, 1255, 63, 646, 480, 27319, 63, 4087, 9305, 531, 267, 871, 299, 590, 14, 27319, 14, 57, 5470, 547, 26, 288, 754, 275, 984, 14, 3083, 14, 7150, 342, 288, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 3147, 298, 4504, 1471, 506, 282, 769, 503, 2008, 60, 78, 2237, 339, 347, 511, 63, 27319, 63, 11048, 8, 277, 304, 267, 1255, 63, 646, 480, 27319, 63, 11048, 531, 267, 754, 275, 984, 14, 3083, 14, 7150, 342, 267, 291, 14, 479, 2531, 1074, 63, 2062, 8, 1099, 12, 2511, 298, 27319, 63, 11048, 14, 647, 26, 1465, 26, 6801, 299, 63, 6242, 295, 4037, 14, 26902, 590, 3247, 641, 1004, 6546, 60, 78, 2, 2511, 298, 3264, 283, 16352, 51, 7, 3247, 12, 1325, 440, 1202, 60, 78, 2, 2511, 298, 10924, 365, 413, 9563, 1526, 60, 78, 2, 2511, 298, 29244, 491, 748, 50, 6716, 60, 78, 2, 199, 2511, 5082, 272, 0 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1, 1 ]
chris-statzer/knuckle-python
tests/test_gamepad.py
1
1522
import logging import knuckle import ui logging.basicConfig(level=logging.INFO) UP = 24 DOWN = 25 LEFT = 27 RIGHT = 26 A = ord('A') B = ord('B') class GamepadWindow(ui.Widget): def __init__(self, ui): super(GamepadWindow, self).__init__(ui, 10, 10, 40, 20) self.dirty = True self.buttons = { 'ui_up': [False, UP], 'ui_down': [False, DOWN], 'ui_left': [False, LEFT], 'ui_right': [False, RIGHT], 'ui_confirm': [False, A], 'ui_back': [False, B], 'ui_unknown': [False, 19], } def render(self): self.surface.clear() knuckle.ascii.draw_window(self.surface, 'menu', 40, 20) n = 0 x, y = 3, 3 for k, v in self.buttons.items(): color = 'default' if v[0] is True: color = 'overcast_sky' knuckle.ascii.draw_tile(self.surface, color, x+n, y, v[1]) n += 2 def handle_input_press(self, e): self.buttons[e][0] = True self.dirty = True def handle_input_release(self, e): self.buttons[e][0] = False self.dirty = True class GamepadTest(knuckle.State): name = 'GamepadTest' def on_post_init(self): self.ui.add_widget_with_focus(GamepadWindow) def quit(self): self.window.quit() window = knuckle.Window(1280, 720, "Knuckledragger Games") knuckle.ascii.load_colors('../assets/12v2.png') window.push_state(GamepadTest) window.run()
mit
[ 646, 2050, 199, 199, 646, 1022, 4850, 346, 274, 199, 646, 8574, 421, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 421, 199, 2160, 275, 5504, 199, 8819, 275, 5661, 199, 9894, 275, 8087, 199, 12811, 275, 7875, 199, 33, 275, 6206, 360, 33, 358, 199, 34, 275, 6206, 360, 34, 358, 421, 199, 533, 25132, 6226, 4301, 8, 1907, 14, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 8574, 304, 267, 1613, 8, 11454, 6226, 4301, 12, 291, 2843, 826, 721, 1907, 12, 1616, 12, 1616, 12, 6335, 12, 3388, 9, 267, 291, 14, 8799, 275, 715, 267, 291, 14, 15687, 275, 469, 288, 283, 1907, 63, 384, 356, 359, 797, 12, 7215, 467, 288, 283, 1907, 63, 2110, 356, 359, 797, 12, 10163, 467, 288, 283, 1907, 63, 3039, 356, 359, 797, 12, 6578, 467, 288, 283, 1907, 63, 1019, 356, 359, 797, 12, 7052, 467, 288, 283, 1907, 63, 9548, 356, 359, 797, 12, 437, 467, 288, 283, 1907, 63, 894, 356, 359, 797, 12, 699, 467, 288, 283, 1907, 63, 5187, 356, 359, 797, 12, 5851, 467, 267, 789, 339, 347, 3795, 8, 277, 304, 267, 291, 14, 10992, 14, 3584, 342, 267, 1022, 4850, 346, 274, 14, 4371, 14, 5485, 63, 3806, 8, 277, 14, 10992, 12, 283, 4470, 297, 6335, 12, 3388, 9, 267, 302, 275, 378, 267, 671, 12, 612, 275, 650, 12, 650, 267, 367, 1022, 12, 373, 315, 291, 14, 15687, 14, 1744, 837, 288, 3164, 275, 283, 885, 7, 288, 340, 373, 59, 16, 61, 365, 715, 26, 355, 3164, 275, 283, 1883, 2931, 63, 12267, 7, 288, 1022, 4850, 346, 274, 14, 4371, 14, 5485, 63, 7172, 8, 277, 14, 10992, 12, 3164, 12, 671, 11, 78, 12, 612, 12, 373, 59, 17, 566, 288, 302, 847, 499, 339, 347, 2429, 63, 1210, 63, 2915, 8, 277, 12, 325, 304, 267, 291, 14, 15687, 59, 69, 1527, 16, 61, 275, 715, 267, 291, 14, 8799, 275, 715, 339, 347, 2429, 63, 1210, 63, 3221, 8, 277, 12, 325, 304, 267, 291, 14, 15687, 59, 69, 1527, 16, 61, 275, 756, 267, 291, 14, 8799, 275, 715, 421, 199, 533, 25132, 6226, 774, 8, 75, 4850, 346, 274, 14, 2223, 304, 272, 536, 275, 283, 11454, 6226, 774, 7, 339, 347, 641, 63, 1932, 63, 826, 8, 277, 304, 267, 291, 14, 1907, 14, 525, 63, 3440, 63, 1045, 63, 12283, 8, 11454, 6226, 4301, 9, 339, 347, 17242, 8, 277, 304, 267, 291, 14, 3806, 14, 10589, 342, 421, 199, 3806, 275, 1022, 4850, 346, 274, 14, 4301, 8, 713, 1257, 12, 29692, 12, 298, 43, 4850, 346, 1146, 2527, 836, 598, 14015, 531, 199, 75, 4850, 346, 274, 14, 4371, 14, 912, 63, 7120, 24592, 12186, 15, 713, 86, 18, 14, 4524, 358, 199, 3806, 14, 5335, 63, 929, 8, 11454, 6226, 774, 9, 199, 3806, 14, 1065, 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 ]
[ 2050, 199, 199, 646, 1022, 4850, 346, 274, 199, 646, 8574, 421, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 421, 199, 2160, 275, 5504, 199, 8819, 275, 5661, 199, 9894, 275, 8087, 199, 12811, 275, 7875, 199, 33, 275, 6206, 360, 33, 358, 199, 34, 275, 6206, 360, 34, 358, 421, 199, 533, 25132, 6226, 4301, 8, 1907, 14, 3339, 304, 272, 347, 636, 826, 721, 277, 12, 8574, 304, 267, 1613, 8, 11454, 6226, 4301, 12, 291, 2843, 826, 721, 1907, 12, 1616, 12, 1616, 12, 6335, 12, 3388, 9, 267, 291, 14, 8799, 275, 715, 267, 291, 14, 15687, 275, 469, 288, 283, 1907, 63, 384, 356, 359, 797, 12, 7215, 467, 288, 283, 1907, 63, 2110, 356, 359, 797, 12, 10163, 467, 288, 283, 1907, 63, 3039, 356, 359, 797, 12, 6578, 467, 288, 283, 1907, 63, 1019, 356, 359, 797, 12, 7052, 467, 288, 283, 1907, 63, 9548, 356, 359, 797, 12, 437, 467, 288, 283, 1907, 63, 894, 356, 359, 797, 12, 699, 467, 288, 283, 1907, 63, 5187, 356, 359, 797, 12, 5851, 467, 267, 789, 339, 347, 3795, 8, 277, 304, 267, 291, 14, 10992, 14, 3584, 342, 267, 1022, 4850, 346, 274, 14, 4371, 14, 5485, 63, 3806, 8, 277, 14, 10992, 12, 283, 4470, 297, 6335, 12, 3388, 9, 267, 302, 275, 378, 267, 671, 12, 612, 275, 650, 12, 650, 267, 367, 1022, 12, 373, 315, 291, 14, 15687, 14, 1744, 837, 288, 3164, 275, 283, 885, 7, 288, 340, 373, 59, 16, 61, 365, 715, 26, 355, 3164, 275, 283, 1883, 2931, 63, 12267, 7, 288, 1022, 4850, 346, 274, 14, 4371, 14, 5485, 63, 7172, 8, 277, 14, 10992, 12, 3164, 12, 671, 11, 78, 12, 612, 12, 373, 59, 17, 566, 288, 302, 847, 499, 339, 347, 2429, 63, 1210, 63, 2915, 8, 277, 12, 325, 304, 267, 291, 14, 15687, 59, 69, 1527, 16, 61, 275, 715, 267, 291, 14, 8799, 275, 715, 339, 347, 2429, 63, 1210, 63, 3221, 8, 277, 12, 325, 304, 267, 291, 14, 15687, 59, 69, 1527, 16, 61, 275, 756, 267, 291, 14, 8799, 275, 715, 421, 199, 533, 25132, 6226, 774, 8, 75, 4850, 346, 274, 14, 2223, 304, 272, 536, 275, 283, 11454, 6226, 774, 7, 339, 347, 641, 63, 1932, 63, 826, 8, 277, 304, 267, 291, 14, 1907, 14, 525, 63, 3440, 63, 1045, 63, 12283, 8, 11454, 6226, 4301, 9, 339, 347, 17242, 8, 277, 304, 267, 291, 14, 3806, 14, 10589, 342, 421, 199, 3806, 275, 1022, 4850, 346, 274, 14, 4301, 8, 713, 1257, 12, 29692, 12, 298, 43, 4850, 346, 1146, 2527, 836, 598, 14015, 531, 199, 75, 4850, 346, 274, 14, 4371, 14, 912, 63, 7120, 24592, 12186, 15, 713, 86, 18, 14, 4524, 358, 199, 3806, 14, 5335, 63, 929, 8, 11454, 6226, 774, 9, 199, 3806, 14, 1065, 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, 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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, function name must start with uppercase): # $ cppcheck --dump path-to-src/ # $ python addons/naming.py --var='[a-z].*' --function='[A-Z].*' path-to-src/*.dump # import cppcheckdata import sys import re def validate_regex(expr): try: re.compile(expr) except re.error: print('Error: "{}" is not a valid regular expression.'.format(expr)) exit(1) RE_VARNAME = None RE_CONSTNAME = None RE_PRIVATE_MEMBER_VARIABLE = None RE_FUNCTIONNAME = None for arg in sys.argv[1:]: if arg[:6] == '--var=': RE_VARNAME = arg[6:] validate_regex(RE_VARNAME) elif arg.startswith('--const='): RE_CONSTNAME = arg[arg.find('=')+1:] validate_regex(RE_CONSTNAME) elif arg.startswith('--private-member-variable='): RE_PRIVATE_MEMBER_VARIABLE = arg[arg.find('=')+1:] validate_regex(RE_PRIVATE_MEMBER_VARIABLE) elif arg[:11] == '--function=': RE_FUNCTIONNAME = arg[11:] validate_regex(RE_FUNCTIONNAME) def reportError(token, severity, msg, errorId): cppcheckdata.reportError(token, severity, msg, 'naming', errorId) for arg in sys.argv[1:]: if not arg.endswith('.dump'): continue print('Checking ' + arg + '...') data = cppcheckdata.CppcheckData(arg) for cfg in data.iterconfigurations(): print('Checking %s, config %s...' % (arg, cfg.name)) if RE_VARNAME: for var in cfg.variables: if var.access == 'Private': continue if var.nameToken and not var.isConst: res = re.match(RE_VARNAME, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Variable ' + var.nameToken.str + ' violates naming convention', 'varname') if RE_CONSTNAME: for var in cfg.variables: if var.access == 'Private': continue if var.nameToken and var.isConst: res = re.match(RE_CONSTNAME, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Constant ' + var.nameToken.str + ' violates naming convention', 'constname') if RE_PRIVATE_MEMBER_VARIABLE: for var in cfg.variables: if (var.access is None) or var.access != 'Private': continue res = re.match(RE_PRIVATE_MEMBER_VARIABLE, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Private member variable ' + var.nameToken.str + ' violates naming convention', 'privateMemberVariable') if RE_FUNCTIONNAME: for scope in cfg.scopes: if scope.type == 'Function': function = scope.function if function is not None and function.type in ('Constructor', 'Destructor'): continue res = re.match(RE_FUNCTIONNAME, scope.className) if not res: reportError( scope.bodyStart, 'style', 'Function ' + scope.className + ' violates naming convention', 'functionName') sys.exit(cppcheckdata.EXIT_CODE)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 7246, 1074, 13553, 367, 19720, 8758, 852, 199, 3, 199, 3, 5679, 4503, 334, 1975, 536, 1471, 1343, 543, 12141, 12, 805, 536, 1471, 1343, 543, 22681, 304, 199, 3, 2672, 7246, 1074, 1553, 2724, 931, 13, 475, 13, 2164, 15, 199, 3, 2672, 2366, 21293, 15, 26919, 14, 647, 1553, 1391, 30845, 65, 13, 90, 1055, 10223, 1553, 1593, 30845, 33, 13, 58, 1055, 10223, 931, 13, 475, 13, 2164, 20362, 2724, 199, 3, 199, 199, 646, 7246, 1074, 576, 199, 646, 984, 199, 646, 295, 421, 199, 318, 4107, 63, 3821, 8, 3684, 304, 272, 862, 26, 267, 295, 14, 2014, 8, 3684, 9, 272, 871, 295, 14, 705, 26, 267, 870, 360, 547, 26, 28168, 365, 440, 282, 1686, 5578, 3965, 17374, 908, 8, 3684, 430, 267, 4458, 8, 17, 9, 421, 199, 907, 63, 5568, 2339, 275, 488, 199, 907, 63, 13310, 2339, 275, 488, 199, 907, 63, 18748, 63, 26682, 63, 23129, 275, 488, 199, 907, 63, 15476, 2339, 275, 488, 199, 509, 1680, 315, 984, 14, 3020, 59, 17, 10688, 272, 340, 1680, 1491, 22, 61, 508, 2850, 1391, 18749, 267, 5363, 63, 5568, 2339, 275, 1680, 59, 22, 2938, 267, 4107, 63, 3821, 8, 907, 63, 5568, 2339, 9, 272, 916, 1680, 14, 2460, 4517, 1297, 534, 304, 267, 5363, 63, 13310, 2339, 275, 1680, 59, 1273, 14, 1623, 23917, 11, 17, 2938, 267, 4107, 63, 3821, 8, 907, 63, 13310, 2339, 9, 272, 916, 1680, 14, 2460, 4517, 4239, 13, 1114, 13, 1975, 534, 304, 267, 5363, 63, 18748, 63, 26682, 63, 23129, 275, 1680, 59, 1273, 14, 1623, 23917, 11, 17, 2938, 267, 4107, 63, 3821, 8, 907, 63, 18748, 63, 26682, 63, 23129, 9, 272, 916, 1680, 1491, 845, 61, 508, 2850, 1593, 18749, 267, 5363, 63, 15476, 2339, 275, 1680, 59, 845, 2938, 267, 4107, 63, 3821, 8, 907, 63, 15476, 2339, 9, 421, 199, 318, 3622, 547, 8, 1418, 12, 25574, 12, 1499, 12, 1125, 1304, 304, 272, 7246, 1074, 576, 14, 3070, 547, 8, 1418, 12, 25574, 12, 1499, 12, 283, 26919, 297, 1125, 1304, 9, 421, 199, 509, 1680, 315, 984, 14, 3020, 59, 17, 10688, 272, 340, 440, 1680, 14, 4130, 5175, 2724, 735, 267, 1980, 272, 870, 360, 14740, 283, 435, 1680, 435, 283, 15103, 272, 666, 275, 7246, 1074, 576, 14, 19705, 1074, 1451, 8, 1273, 9, 339, 367, 4810, 315, 666, 14, 1661, 10057, 837, 267, 870, 360, 14740, 450, 83, 12, 1101, 450, 83, 13698, 450, 334, 1273, 12, 4810, 14, 354, 430, 267, 340, 5363, 63, 5568, 2339, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 2729, 14, 2732, 508, 283, 12185, 356, 490, 1980, 355, 340, 2729, 14, 354, 3264, 436, 440, 2729, 14, 374, 6361, 26, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 5568, 2339, 12, 2729, 14, 354, 3264, 14, 495, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 2773, 283, 435, 2511, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 16043, 358, 267, 340, 5363, 63, 13310, 2339, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 2729, 14, 2732, 508, 283, 12185, 356, 490, 1980, 355, 340, 2729, 14, 354, 3264, 436, 2729, 14, 374, 6361, 26, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 13310, 2339, 12, 2729, 14, 354, 3264, 14, 495, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 9737, 283, 435, 2511, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 1297, 354, 358, 267, 340, 5363, 63, 18748, 63, 26682, 63, 23129, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 334, 1391, 14, 2732, 365, 488, 9, 503, 2729, 14, 2732, 1137, 283, 12185, 356, 490, 1980, 355, 522, 275, 295, 14, 1431, 8, 907, 63, 18748, 63, 26682, 63, 23129, 12, 2729, 14, 354, 3264, 14, 495, 9, 355, 340, 440, 522, 26, 490, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 12185, 3653, 1750, 283, 435, 1816, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 4239, 7021, 2773, 358, 267, 340, 5363, 63, 15476, 2339, 26, 288, 367, 4194, 315, 4810, 14, 14129, 26, 355, 340, 4194, 14, 466, 508, 283, 3481, 356, 490, 805, 275, 4194, 14, 1593, 490, 340, 805, 365, 440, 488, 436, 805, 14, 466, 315, 661, 11447, 297, 283, 872, 1426, 735, 717, 1980, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 15476, 2339, 12, 4194, 14, 533, 985, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1169, 4194, 14, 2030, 3162, 12, 283, 2487, 297, 283, 3481, 283, 435, 4194, 14, 533, 985, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 1593, 985, 358, 199, 199, 1274, 14, 2224, 8, 5910, 1074, 576, 14, 17219, 63, 6012, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 199, 3, 7246, 1074, 13553, 367, 19720, 8758, 852, 199, 3, 199, 3, 5679, 4503, 334, 1975, 536, 1471, 1343, 543, 12141, 12, 805, 536, 1471, 1343, 543, 22681, 304, 199, 3, 2672, 7246, 1074, 1553, 2724, 931, 13, 475, 13, 2164, 15, 199, 3, 2672, 2366, 21293, 15, 26919, 14, 647, 1553, 1391, 30845, 65, 13, 90, 1055, 10223, 1553, 1593, 30845, 33, 13, 58, 1055, 10223, 931, 13, 475, 13, 2164, 20362, 2724, 199, 3, 199, 199, 646, 7246, 1074, 576, 199, 646, 984, 199, 646, 295, 421, 199, 318, 4107, 63, 3821, 8, 3684, 304, 272, 862, 26, 267, 295, 14, 2014, 8, 3684, 9, 272, 871, 295, 14, 705, 26, 267, 870, 360, 547, 26, 28168, 365, 440, 282, 1686, 5578, 3965, 17374, 908, 8, 3684, 430, 267, 4458, 8, 17, 9, 421, 199, 907, 63, 5568, 2339, 275, 488, 199, 907, 63, 13310, 2339, 275, 488, 199, 907, 63, 18748, 63, 26682, 63, 23129, 275, 488, 199, 907, 63, 15476, 2339, 275, 488, 199, 509, 1680, 315, 984, 14, 3020, 59, 17, 10688, 272, 340, 1680, 1491, 22, 61, 508, 2850, 1391, 18749, 267, 5363, 63, 5568, 2339, 275, 1680, 59, 22, 2938, 267, 4107, 63, 3821, 8, 907, 63, 5568, 2339, 9, 272, 916, 1680, 14, 2460, 4517, 1297, 534, 304, 267, 5363, 63, 13310, 2339, 275, 1680, 59, 1273, 14, 1623, 23917, 11, 17, 2938, 267, 4107, 63, 3821, 8, 907, 63, 13310, 2339, 9, 272, 916, 1680, 14, 2460, 4517, 4239, 13, 1114, 13, 1975, 534, 304, 267, 5363, 63, 18748, 63, 26682, 63, 23129, 275, 1680, 59, 1273, 14, 1623, 23917, 11, 17, 2938, 267, 4107, 63, 3821, 8, 907, 63, 18748, 63, 26682, 63, 23129, 9, 272, 916, 1680, 1491, 845, 61, 508, 2850, 1593, 18749, 267, 5363, 63, 15476, 2339, 275, 1680, 59, 845, 2938, 267, 4107, 63, 3821, 8, 907, 63, 15476, 2339, 9, 421, 199, 318, 3622, 547, 8, 1418, 12, 25574, 12, 1499, 12, 1125, 1304, 304, 272, 7246, 1074, 576, 14, 3070, 547, 8, 1418, 12, 25574, 12, 1499, 12, 283, 26919, 297, 1125, 1304, 9, 421, 199, 509, 1680, 315, 984, 14, 3020, 59, 17, 10688, 272, 340, 440, 1680, 14, 4130, 5175, 2724, 735, 267, 1980, 272, 870, 360, 14740, 283, 435, 1680, 435, 283, 15103, 272, 666, 275, 7246, 1074, 576, 14, 19705, 1074, 1451, 8, 1273, 9, 339, 367, 4810, 315, 666, 14, 1661, 10057, 837, 267, 870, 360, 14740, 450, 83, 12, 1101, 450, 83, 13698, 450, 334, 1273, 12, 4810, 14, 354, 430, 267, 340, 5363, 63, 5568, 2339, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 2729, 14, 2732, 508, 283, 12185, 356, 490, 1980, 355, 340, 2729, 14, 354, 3264, 436, 440, 2729, 14, 374, 6361, 26, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 5568, 2339, 12, 2729, 14, 354, 3264, 14, 495, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 2773, 283, 435, 2511, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 16043, 358, 267, 340, 5363, 63, 13310, 2339, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 2729, 14, 2732, 508, 283, 12185, 356, 490, 1980, 355, 340, 2729, 14, 354, 3264, 436, 2729, 14, 374, 6361, 26, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 13310, 2339, 12, 2729, 14, 354, 3264, 14, 495, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 9737, 283, 435, 2511, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 1297, 354, 358, 267, 340, 5363, 63, 18748, 63, 26682, 63, 23129, 26, 288, 367, 2729, 315, 4810, 14, 3669, 26, 355, 340, 334, 1391, 14, 2732, 365, 488, 9, 503, 2729, 14, 2732, 1137, 283, 12185, 356, 490, 1980, 355, 522, 275, 295, 14, 1431, 8, 907, 63, 18748, 63, 26682, 63, 23129, 12, 2729, 14, 354, 3264, 14, 495, 9, 355, 340, 440, 522, 26, 490, 3622, 547, 8, 1391, 14, 466, 3162, 3264, 12, 283, 2487, 297, 283, 12185, 3653, 1750, 283, 435, 1816, 2729, 14, 354, 3264, 14, 495, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 4239, 7021, 2773, 358, 267, 340, 5363, 63, 15476, 2339, 26, 288, 367, 4194, 315, 4810, 14, 14129, 26, 355, 340, 4194, 14, 466, 508, 283, 3481, 356, 490, 805, 275, 4194, 14, 1593, 490, 340, 805, 365, 440, 488, 436, 805, 14, 466, 315, 661, 11447, 297, 283, 872, 1426, 735, 717, 1980, 490, 522, 275, 295, 14, 1431, 8, 907, 63, 15476, 2339, 12, 4194, 14, 533, 985, 9, 490, 340, 440, 522, 26, 717, 3622, 547, 8, 1169, 4194, 14, 2030, 3162, 12, 283, 2487, 297, 283, 3481, 283, 435, 4194, 14, 533, 985, 435, 283, 1321, 393, 2335, 19720, 16129, 297, 283, 1593, 985, 358, 199, 199, 1274, 14, 2224, 8, 5910, 1074, 576, 14, 17219, 63, 6012, 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, 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 ]
chromium/chromium
third_party/wpt_tools/wpt/tools/wptrunner/wptrunner/update/update.py
17
6446
import os import sys from .metadata import MetadataUpdateRunner from .sync import SyncFromUpstreamRunner from .tree import GitTree, HgTree, NoVCSTree from .base import Step, StepRunner, exit_clean, exit_unclean from .state import SavedState, UnsavedState def setup_paths(sync_path): sys.path.insert(0, os.path.abspath(sync_path)) from tools import localpaths # noqa: F401 class LoadConfig(Step): """Step for loading configuration from the ini file and kwargs.""" provides = ["sync", "paths", "metadata_path", "tests_path"] def create(self, state): state.sync = {"remote_url": state.kwargs["remote_url"], "branch": state.kwargs["branch"], "path": state.kwargs["sync_path"]} state.paths = state.kwargs["test_paths"] state.tests_path = state.paths["/"]["tests_path"] state.metadata_path = state.paths["/"]["metadata_path"] assert os.path.isabs(state.tests_path) class LoadTrees(Step): """Step for creating a Tree for the local copy and a GitTree for the upstream sync.""" provides = ["local_tree", "sync_tree"] def create(self, state): if os.path.exists(state.sync["path"]): sync_tree = GitTree(root=state.sync["path"]) else: sync_tree = None if GitTree.is_type(): local_tree = GitTree() elif HgTree.is_type(): local_tree = HgTree() else: local_tree = NoVCSTree() state.update({"local_tree": local_tree, "sync_tree": sync_tree}) class SyncFromUpstream(Step): """Step that synchronises a local copy of the code with upstream.""" def create(self, state): if not state.kwargs["sync"]: return if not state.sync_tree: os.mkdir(state.sync["path"]) state.sync_tree = GitTree(root=state.sync["path"]) kwargs = state.kwargs with state.push(["sync", "paths", "metadata_path", "tests_path", "local_tree", "sync_tree"]): state.target_rev = kwargs["rev"] state.patch = kwargs["patch"] state.suite_name = kwargs["suite_name"] state.path_excludes = kwargs["exclude"] state.path_includes = kwargs["include"] runner = SyncFromUpstreamRunner(self.logger, state) runner.run() class UpdateMetadata(Step): """Update the expectation metadata from a set of run logs""" def create(self, state): if not state.kwargs["run_log"]: return kwargs = state.kwargs with state.push(["local_tree", "sync_tree", "paths", "serve_root"]): state.run_log = kwargs["run_log"] state.disable_intermittent = kwargs["disable_intermittent"] state.update_intermittent = kwargs["update_intermittent"] state.remove_intermittent = kwargs["remove_intermittent"] state.patch = kwargs["patch"] state.suite_name = kwargs["suite_name"] state.product = kwargs["product"] state.config = kwargs["config"] state.full_update = kwargs["full"] state.extra_properties = kwargs["extra_property"] runner = MetadataUpdateRunner(self.logger, state) runner.run() class RemoveObsolete(Step): """Remove metadata files that don't corespond to an existing test file""" def create(self, state): if not state.kwargs["remove_obsolete"]: return paths = state.kwargs["test_paths"] state.tests_path = state.paths["/"]["tests_path"] state.metadata_path = state.paths["/"]["metadata_path"] for url_paths in paths.values(): tests_path = url_paths["tests_path"] metadata_path = url_paths["metadata_path"] for dirpath, dirnames, filenames in os.walk(metadata_path): for filename in filenames: if filename == "__dir__.ini": continue if filename.endswith(".ini"): full_path = os.path.join(dirpath, filename) rel_path = os.path.relpath(full_path, metadata_path) test_path = os.path.join(tests_path, rel_path[:-4]) if not os.path.exists(test_path): os.unlink(full_path) class UpdateRunner(StepRunner): """Runner for doing an overall update.""" steps = [LoadConfig, LoadTrees, SyncFromUpstream, RemoveObsolete, UpdateMetadata] class WPTUpdate(object): def __init__(self, logger, runner_cls=UpdateRunner, **kwargs): """Object that controls the running of a whole wptupdate. :param runner_cls: Runner subclass holding the overall list of steps to run. :param kwargs: Command line arguments """ self.runner_cls = runner_cls self.serve_root = kwargs["test_paths"]["/"]["tests_path"] if not kwargs["sync"]: setup_paths(self.serve_root) else: if os.path.exists(kwargs["sync_path"]): # If the sync path doesn't exist we defer this until it does setup_paths(kwargs["sync_path"]) if kwargs.get("store_state", False): self.state = SavedState(logger) else: self.state = UnsavedState(logger) self.kwargs = kwargs self.logger = logger def run(self, **kwargs): if self.kwargs["abort"]: self.abort() return exit_clean if not self.kwargs["continue"] and not self.state.is_empty(): self.logger.critical("Found existing state. Run with --continue to resume or --abort to clear state") return exit_unclean if self.kwargs["continue"]: if self.state.is_empty(): self.logger.error("No sync in progress?") return exit_clean self.kwargs = self.state.kwargs else: self.state.kwargs = self.kwargs self.state.serve_root = self.serve_root update_runner = self.runner_cls(self.logger, self.state) rv = update_runner.run() if rv in (exit_clean, None): self.state.clear() return rv def abort(self): self.state.clear()
bsd-3-clause
[ 646, 747, 199, 646, 984, 199, 199, 504, 1275, 2343, 492, 16160, 4152, 7446, 199, 504, 1275, 5186, 492, 22407, 2532, 1721, 1745, 7446, 199, 504, 1275, 2350, 492, 12579, 3987, 12, 869, 71, 3987, 12, 3091, 9454, 840, 850, 199, 199, 504, 1275, 1095, 492, 13382, 12, 13382, 7446, 12, 4458, 63, 3118, 12, 4458, 63, 1097, 1270, 199, 504, 1275, 929, 492, 29026, 2223, 12, 15254, 4292, 2223, 199, 199, 318, 3272, 63, 3771, 8, 5186, 63, 515, 304, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 8, 5186, 63, 515, 430, 272, 687, 7249, 492, 2257, 3771, 221, 327, 8151, 26, 481, 8854, 199, 199, 533, 7190, 2028, 8, 7801, 304, 272, 408, 7801, 367, 8697, 2897, 687, 314, 20364, 570, 436, 2074, 1041, 339, 6571, 275, 2097, 5186, 401, 298, 3771, 401, 298, 2343, 63, 515, 401, 298, 2219, 63, 515, 937, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 1174, 14, 5186, 275, 2420, 3846, 63, 633, 582, 1174, 14, 958, 905, 3846, 63, 633, 2255, 1993, 298, 4694, 582, 1174, 14, 958, 905, 4694, 2255, 1993, 298, 515, 582, 1174, 14, 958, 905, 5186, 63, 515, 27635, 398, 1174, 14, 3771, 275, 1174, 14, 958, 905, 396, 63, 3771, 937, 267, 1174, 14, 2219, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2219, 63, 515, 937, 267, 1174, 14, 2343, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2343, 63, 515, 937, 398, 702, 747, 14, 515, 14, 17896, 8, 929, 14, 2219, 63, 515, 9, 421, 199, 533, 7190, 28785, 8, 7801, 304, 272, 408, 7801, 367, 6425, 282, 12178, 367, 314, 2257, 1331, 436, 282, 12579, 3987, 367, 314, 272, 18932, 7604, 1041, 339, 6571, 275, 2097, 1832, 63, 2350, 401, 298, 5186, 63, 2350, 937, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 929, 14, 5186, 905, 515, 21473, 288, 7604, 63, 2350, 275, 12579, 3987, 8, 1231, 29, 929, 14, 5186, 905, 515, 3135, 267, 587, 26, 288, 7604, 63, 2350, 275, 488, 398, 340, 12579, 3987, 14, 374, 63, 466, 837, 288, 2257, 63, 2350, 275, 12579, 3987, 342, 267, 916, 869, 71, 3987, 14, 374, 63, 466, 837, 288, 2257, 63, 2350, 275, 869, 71, 3987, 342, 267, 587, 26, 288, 2257, 63, 2350, 275, 3091, 9454, 840, 850, 342, 398, 1174, 14, 873, 6333, 1832, 63, 2350, 582, 2257, 63, 2350, 12, 1993, 298, 5186, 63, 2350, 582, 7604, 63, 2350, 1552, 421, 199, 533, 22407, 2532, 1721, 1745, 8, 7801, 304, 272, 408, 7801, 626, 15354, 1388, 282, 2257, 1331, 402, 314, 1233, 543, 18932, 1041, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 5186, 6229, 288, 372, 398, 340, 440, 1174, 14, 5186, 63, 2350, 26, 288, 747, 14, 8215, 8, 929, 14, 5186, 905, 515, 3135, 288, 1174, 14, 5186, 63, 2350, 275, 12579, 3987, 8, 1231, 29, 929, 14, 5186, 905, 515, 3135, 398, 2074, 275, 1174, 14, 958, 267, 543, 1174, 14, 5335, 5234, 5186, 401, 298, 3771, 401, 298, 2343, 63, 515, 401, 298, 2219, 63, 515, 401, 298, 1832, 63, 2350, 401, 586, 298, 5186, 63, 2350, 21473, 288, 1174, 14, 1375, 63, 4964, 275, 2074, 905, 4964, 937, 288, 1174, 14, 2068, 275, 2074, 905, 2068, 937, 288, 1174, 14, 5768, 63, 354, 275, 2074, 905, 5768, 63, 354, 937, 288, 1174, 14, 515, 63, 26984, 275, 2074, 905, 5473, 937, 288, 1174, 14, 515, 63, 9441, 275, 2074, 905, 2613, 937, 288, 7876, 275, 22407, 2532, 1721, 1745, 7446, 8, 277, 14, 2921, 12, 1174, 9, 288, 7876, 14, 1065, 342, 421, 199, 533, 6162, 5142, 8, 7801, 304, 272, 408, 4152, 314, 17513, 3341, 687, 282, 663, 402, 1255, 9610, 624, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 1065, 63, 793, 6229, 288, 372, 398, 2074, 275, 1174, 14, 958, 267, 543, 1174, 14, 5335, 5234, 1832, 63, 2350, 401, 298, 5186, 63, 2350, 401, 298, 3771, 401, 298, 4909, 63, 1231, 21473, 288, 1174, 14, 1065, 63, 793, 275, 2074, 905, 1065, 63, 793, 937, 288, 1174, 14, 5993, 63, 1058, 1147, 767, 275, 2074, 905, 5993, 63, 1058, 1147, 767, 937, 288, 1174, 14, 873, 63, 1058, 1147, 767, 275, 2074, 905, 873, 63, 1058, 1147, 767, 937, 288, 1174, 14, 2168, 63, 1058, 1147, 767, 275, 2074, 905, 2168, 63, 1058, 1147, 767, 937, 288, 1174, 14, 2068, 275, 2074, 905, 2068, 937, 288, 1174, 14, 5768, 63, 354, 275, 2074, 905, 5768, 63, 354, 937, 288, 1174, 14, 2558, 275, 2074, 905, 2558, 937, 288, 1174, 14, 888, 275, 2074, 905, 888, 937, 288, 1174, 14, 2861, 63, 873, 275, 2074, 905, 2861, 937, 288, 1174, 14, 2911, 63, 3282, 275, 2074, 905, 2911, 63, 1829, 937, 288, 7876, 275, 16160, 4152, 7446, 8, 277, 14, 2921, 12, 1174, 9, 288, 7876, 14, 1065, 342, 421, 199, 533, 5852, 11394, 15445, 8, 7801, 304, 272, 408, 5587, 3341, 1584, 626, 2793, 1133, 512, 22720, 370, 376, 3411, 511, 570, 624, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 2168, 63, 25385, 6229, 288, 372, 398, 3792, 275, 1174, 14, 958, 905, 396, 63, 3771, 937, 267, 1174, 14, 2219, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2219, 63, 515, 937, 267, 1174, 14, 2343, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2343, 63, 515, 937, 398, 367, 1166, 63, 3771, 315, 3792, 14, 1459, 837, 288, 2295, 63, 515, 275, 1166, 63, 3771, 905, 2219, 63, 515, 937, 288, 3341, 63, 515, 275, 1166, 63, 3771, 905, 2343, 63, 515, 937, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2343, 63, 515, 304, 355, 367, 1788, 315, 6203, 26, 490, 340, 1788, 508, 4396, 694, 4343, 2730, 582, 717, 1980, 490, 340, 1788, 14, 4130, 9520, 2730, 2349, 717, 2615, 63, 515, 275, 747, 14, 515, 14, 904, 8, 17254, 12, 1788, 9, 717, 4668, 63, 515, 275, 747, 14 ]
[ 747, 199, 646, 984, 199, 199, 504, 1275, 2343, 492, 16160, 4152, 7446, 199, 504, 1275, 5186, 492, 22407, 2532, 1721, 1745, 7446, 199, 504, 1275, 2350, 492, 12579, 3987, 12, 869, 71, 3987, 12, 3091, 9454, 840, 850, 199, 199, 504, 1275, 1095, 492, 13382, 12, 13382, 7446, 12, 4458, 63, 3118, 12, 4458, 63, 1097, 1270, 199, 504, 1275, 929, 492, 29026, 2223, 12, 15254, 4292, 2223, 199, 199, 318, 3272, 63, 3771, 8, 5186, 63, 515, 304, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 8, 5186, 63, 515, 430, 272, 687, 7249, 492, 2257, 3771, 221, 327, 8151, 26, 481, 8854, 199, 199, 533, 7190, 2028, 8, 7801, 304, 272, 408, 7801, 367, 8697, 2897, 687, 314, 20364, 570, 436, 2074, 1041, 339, 6571, 275, 2097, 5186, 401, 298, 3771, 401, 298, 2343, 63, 515, 401, 298, 2219, 63, 515, 937, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 1174, 14, 5186, 275, 2420, 3846, 63, 633, 582, 1174, 14, 958, 905, 3846, 63, 633, 2255, 1993, 298, 4694, 582, 1174, 14, 958, 905, 4694, 2255, 1993, 298, 515, 582, 1174, 14, 958, 905, 5186, 63, 515, 27635, 398, 1174, 14, 3771, 275, 1174, 14, 958, 905, 396, 63, 3771, 937, 267, 1174, 14, 2219, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2219, 63, 515, 937, 267, 1174, 14, 2343, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2343, 63, 515, 937, 398, 702, 747, 14, 515, 14, 17896, 8, 929, 14, 2219, 63, 515, 9, 421, 199, 533, 7190, 28785, 8, 7801, 304, 272, 408, 7801, 367, 6425, 282, 12178, 367, 314, 2257, 1331, 436, 282, 12579, 3987, 367, 314, 272, 18932, 7604, 1041, 339, 6571, 275, 2097, 1832, 63, 2350, 401, 298, 5186, 63, 2350, 937, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 929, 14, 5186, 905, 515, 21473, 288, 7604, 63, 2350, 275, 12579, 3987, 8, 1231, 29, 929, 14, 5186, 905, 515, 3135, 267, 587, 26, 288, 7604, 63, 2350, 275, 488, 398, 340, 12579, 3987, 14, 374, 63, 466, 837, 288, 2257, 63, 2350, 275, 12579, 3987, 342, 267, 916, 869, 71, 3987, 14, 374, 63, 466, 837, 288, 2257, 63, 2350, 275, 869, 71, 3987, 342, 267, 587, 26, 288, 2257, 63, 2350, 275, 3091, 9454, 840, 850, 342, 398, 1174, 14, 873, 6333, 1832, 63, 2350, 582, 2257, 63, 2350, 12, 1993, 298, 5186, 63, 2350, 582, 7604, 63, 2350, 1552, 421, 199, 533, 22407, 2532, 1721, 1745, 8, 7801, 304, 272, 408, 7801, 626, 15354, 1388, 282, 2257, 1331, 402, 314, 1233, 543, 18932, 1041, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 5186, 6229, 288, 372, 398, 340, 440, 1174, 14, 5186, 63, 2350, 26, 288, 747, 14, 8215, 8, 929, 14, 5186, 905, 515, 3135, 288, 1174, 14, 5186, 63, 2350, 275, 12579, 3987, 8, 1231, 29, 929, 14, 5186, 905, 515, 3135, 398, 2074, 275, 1174, 14, 958, 267, 543, 1174, 14, 5335, 5234, 5186, 401, 298, 3771, 401, 298, 2343, 63, 515, 401, 298, 2219, 63, 515, 401, 298, 1832, 63, 2350, 401, 586, 298, 5186, 63, 2350, 21473, 288, 1174, 14, 1375, 63, 4964, 275, 2074, 905, 4964, 937, 288, 1174, 14, 2068, 275, 2074, 905, 2068, 937, 288, 1174, 14, 5768, 63, 354, 275, 2074, 905, 5768, 63, 354, 937, 288, 1174, 14, 515, 63, 26984, 275, 2074, 905, 5473, 937, 288, 1174, 14, 515, 63, 9441, 275, 2074, 905, 2613, 937, 288, 7876, 275, 22407, 2532, 1721, 1745, 7446, 8, 277, 14, 2921, 12, 1174, 9, 288, 7876, 14, 1065, 342, 421, 199, 533, 6162, 5142, 8, 7801, 304, 272, 408, 4152, 314, 17513, 3341, 687, 282, 663, 402, 1255, 9610, 624, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 1065, 63, 793, 6229, 288, 372, 398, 2074, 275, 1174, 14, 958, 267, 543, 1174, 14, 5335, 5234, 1832, 63, 2350, 401, 298, 5186, 63, 2350, 401, 298, 3771, 401, 298, 4909, 63, 1231, 21473, 288, 1174, 14, 1065, 63, 793, 275, 2074, 905, 1065, 63, 793, 937, 288, 1174, 14, 5993, 63, 1058, 1147, 767, 275, 2074, 905, 5993, 63, 1058, 1147, 767, 937, 288, 1174, 14, 873, 63, 1058, 1147, 767, 275, 2074, 905, 873, 63, 1058, 1147, 767, 937, 288, 1174, 14, 2168, 63, 1058, 1147, 767, 275, 2074, 905, 2168, 63, 1058, 1147, 767, 937, 288, 1174, 14, 2068, 275, 2074, 905, 2068, 937, 288, 1174, 14, 5768, 63, 354, 275, 2074, 905, 5768, 63, 354, 937, 288, 1174, 14, 2558, 275, 2074, 905, 2558, 937, 288, 1174, 14, 888, 275, 2074, 905, 888, 937, 288, 1174, 14, 2861, 63, 873, 275, 2074, 905, 2861, 937, 288, 1174, 14, 2911, 63, 3282, 275, 2074, 905, 2911, 63, 1829, 937, 288, 7876, 275, 16160, 4152, 7446, 8, 277, 14, 2921, 12, 1174, 9, 288, 7876, 14, 1065, 342, 421, 199, 533, 5852, 11394, 15445, 8, 7801, 304, 272, 408, 5587, 3341, 1584, 626, 2793, 1133, 512, 22720, 370, 376, 3411, 511, 570, 624, 339, 347, 1218, 8, 277, 12, 1174, 304, 267, 340, 440, 1174, 14, 958, 905, 2168, 63, 25385, 6229, 288, 372, 398, 3792, 275, 1174, 14, 958, 905, 396, 63, 3771, 937, 267, 1174, 14, 2219, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2219, 63, 515, 937, 267, 1174, 14, 2343, 63, 515, 275, 1174, 14, 3771, 905, 15, 6611, 2343, 63, 515, 937, 398, 367, 1166, 63, 3771, 315, 3792, 14, 1459, 837, 288, 2295, 63, 515, 275, 1166, 63, 3771, 905, 2219, 63, 515, 937, 288, 3341, 63, 515, 275, 1166, 63, 3771, 905, 2343, 63, 515, 937, 288, 367, 20648, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2343, 63, 515, 304, 355, 367, 1788, 315, 6203, 26, 490, 340, 1788, 508, 4396, 694, 4343, 2730, 582, 717, 1980, 490, 340, 1788, 14, 4130, 9520, 2730, 2349, 717, 2615, 63, 515, 275, 747, 14, 515, 14, 904, 8, 17254, 12, 1788, 9, 717, 4668, 63, 515, 275, 747, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 import with_statement from __future__ import print_function import execnet if __name__=='__channelexec__': import os.path import subprocess if not os.path.exists('models/facemodel/model.t7'): url='https://www.dropbox.com/s/18s63zomyfacjfs/facemodel.t7?dl=1' subprocess.check_call(['wget',url,'-O','models/facemodel/model.t7']) import os os.chdir('models/facemodel') import numpy import sys import StringIO import traceback import alignface import facemodel import cPickle as pickle fm=facemodel.FaceModel() face_d,face_p=alignface.load_face_detector(predictor_path='shape_predictor_68_face_landmarks.dat') while True: args,kwargs=channel.receive() try: if len(args)<2: raise RuntimeError('invalid command') command=args[0] responseid=args[1] args=args[2:] if command=='ping': channel.send((('okay',responseid),{})) elif command=='forward_landmarks': # X is pickled N x H x W x 3 images # Xlm is pickled N x 68 x 2 landmarks # scores is pickled N x K attribute scores X=pickle.loads(kwargs['X']) Xlm=pickle.loads(kwargs['Xlm']) result=[] for x,lm in zip(X,Xlm): # lm,x=alignface.detect_landmarks('../../results/008994small.png',face_d,face_p) M,loss=alignface.fit_face_landmarks(lm,fm.celeba_template,image_dims=[160,160],twoscale=False) Y=alignface.warp_to_template(x,M,image_dims=[160,160]) Y=numpy.expand_dims(Y,0) Y=fm.preprocess(Y) Y=fm.forward(Y) scores=fm.predict_attributes(Y) result.append(scores[0]) result=numpy.asarray(result) channel.send((('okay',responseid),{'scores':pickle.dumps(result)})) elif command=='forward_images': # X is pickled list of N strings # scores is pickled N x K attributes scores X=pickle.loads(kwargs['X']) X=[(x if os.path.isabs(x) else os.path.join('../..',x)) for x in X] result=[] for ipath in X: lm,x=alignface.detect_landmarks(ipath,face_d,face_p) M,loss=alignface.fit_face_landmarks(lm,fm.celeba_template,image_dims=[160,160],twoscale=False) Y=alignface.warp_to_template(x,M,image_dims=[160,160]) Y=numpy.expand_dims(Y,0) Y=fm.preprocess(Y) Y=fm.forward(Y) scores=fm.predict_attributes(Y) result.append(scores[0]) result=numpy.asarray(result) channel.send((('okay',responseid),{'scores':pickle.dumps(result)})) elif command=='fail': raise RuntimeError('simulated failure') else: raise RuntimeError('unknown command') except: s=StringIO.StringIO() traceback.print_exc(file=s) channel.send((('fail',responseid),{'traceback':s.getvalue()})) if __name__=='__main__': import numpy import facemodel_worker import cPickle as pickle import execnet import alignface face_d,face_p=alignface.load_face_detector(predictor_path='models/shape_predictor_68_face_landmarks.dat') gw=execnet.makegateway() channel=gw.remote_exec(facemodel_worker) channel.send((('ping',0),{})) print('gw',gw.remote_status()) print('recv',channel.receive()) Xlm,X=alignface.detect_landmarks('results/008994small.png',face_d,face_p) X=numpy.expand_dims(X,0) Xlm=numpy.expand_dims(Xlm,0) channel.send((('forward_landmarks',1),{'X':pickle.dumps(X),'Xlm':pickle.dumps(Xlm)})) print('gw',gw.remote_status()) args,kwargs=channel.receive() print('recv',args[0],args[1],[pickle.loads(x) for x in args[2:]],['{} = {}'.format(k,pickle.loads(v)) for (k,v) in kwargs.iteritems()]) channel.send((('forward_images',2),{'X':pickle.dumps(['results/008994small.png'])})) print('gw',gw.remote_status()) args,kwargs=channel.receive() print('recv',args[0],args[1],[pickle.loads(x) for x in args[2:]],['{} = {}'.format(k,pickle.loads(v)) for (k,v) in kwargs.iteritems()]) def error_handler(args,kwargs): if len(args)>=1 and args[0]=='fail': if 'traceback' in kwargs: raise RuntimeError('remote command failed\n\n'+kwargs['traceback'][:-1]) else: raise RuntimeError('remote command failed (no traceback available)') channel.send((('fail',3),{})) print('gw',gw.remote_status()) args,kwargs=channel.receive() error_handler(args,kwargs) print(args,kwargs)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2146, 846, 199, 199, 692, 636, 354, 363, 6803, 363, 11984, 685, 3113, 825, 3706, 523, 492, 747, 14, 515, 523, 492, 3873, 523, 340, 440, 747, 14, 515, 14, 2444, 360, 992, 15, 1409, 1238, 15, 1238, 14, 84, 23, 735, 272, 1166, 534, 2859, 921, 1544, 14, 32118, 14, 957, 15, 83, 15, 1085, 83, 2766, 90, 676, 89, 12668, 74, 2319, 15, 1409, 1238, 14, 84, 23, 31, 5030, 29, 17, 7, 272, 3873, 14, 1074, 63, 1250, 2941, 87, 362, 297, 633, 2584, 13, 47, 1673, 992, 15, 1409, 1238, 15, 1238, 14, 84, 23, 1105, 819, 492, 747, 523, 747, 14, 8563, 360, 992, 15, 1409, 1238, 358, 523, 492, 2680, 523, 492, 984, 523, 492, 5228, 523, 492, 5190, 523, 492, 6998, 1409, 523, 492, 8870, 1238, 523, 492, 17572, 465, 5927, 819, 20831, 29, 1409, 1238, 14, 13414, 1685, 342, 523, 8870, 63, 68, 12, 1409, 63, 80, 29, 5743, 1409, 14, 912, 63, 1409, 63, 19401, 8, 5790, 630, 63, 515, 534, 1392, 63, 5790, 630, 63, 2333, 63, 1409, 63, 9688, 10375, 14, 4616, 358, 819, 1830, 715, 26, 272, 1249, 12, 958, 29, 2775, 14, 9391, 342, 272, 862, 26, 489, 340, 822, 8, 589, 21528, 18, 26, 267, 746, 6064, 360, 3197, 1414, 358, 489, 1414, 29, 589, 59, 16, 61, 489, 1177, 344, 29, 589, 59, 17, 61, 489, 1249, 29, 589, 59, 18, 2938, 489, 340, 1414, 6803, 4073, 356, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 2440, 430, 489, 916, 1414, 6803, 6688, 63, 9688, 10375, 356, 267, 327, 1323, 365, 18731, 653, 671, 869, 671, 644, 671, 650, 5935, 267, 327, 1323, 14344, 365, 18731, 653, 671, 10851, 671, 499, 20078, 10375, 267, 327, 9342, 365, 18731, 653, 671, 1804, 2225, 9342, 267, 1323, 29, 8092, 14, 3640, 8, 958, 459, 56, 1105, 267, 1323, 14344, 29, 8092, 14, 3640, 8, 958, 459, 56, 14344, 1105, 267, 754, 9811, 267, 367, 671, 12, 14344, 315, 3482, 8, 56, 12, 56, 14344, 304, 881, 327, 24546, 12, 88, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 360, 9707, 2604, 15, 8662, 14966, 7241, 14, 4524, 297, 1409, 63, 68, 12, 1409, 63, 80, 9, 881, 603, 12, 4358, 29, 5743, 1409, 14, 3269, 63, 1409, 63, 9688, 10375, 8, 14344, 12, 10886, 14, 15421, 2470, 63, 1160, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 467, 5601, 3467, 29, 797, 9, 881, 1488, 29, 5743, 1409, 14, 26692, 63, 475, 63, 1160, 8, 88, 12, 45, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 566, 881, 1488, 29, 4714, 14, 4441, 63, 5380, 8, 57, 12, 16, 9, 881, 1488, 29, 10886, 14, 17677, 8, 57, 9, 881, 1488, 29, 10886, 14, 6688, 8, 57, 9, 881, 9342, 29, 10886, 14, 6892, 63, 2987, 8, 57, 9, 881, 754, 14, 740, 8, 7107, 59, 16, 566, 267, 754, 29, 4714, 14, 8748, 8, 1099, 9, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 1445, 7107, 356, 8092, 14, 4180, 8, 1099, 6769, 430, 489, 916, 1414, 6803, 6688, 63, 4782, 356, 267, 327, 1323, 365, 18731, 769, 402, 653, 3326, 267, 327, 9342, 365, 18731, 653, 671, 1804, 3004, 9342, 267, 1323, 29, 8092, 14, 3640, 8, 958, 459, 56, 1105, 267, 1323, 17497, 88, 340, 747, 14, 515, 14, 17896, 8, 88, 9, 587, 747, 14, 515, 14, 904, 24592, 703, 297, 88, 430, 367, 671, 315, 1323, 61, 267, 754, 9811, 267, 367, 284, 515, 315, 1323, 26, 881, 24546, 12, 88, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 8, 73, 515, 12, 1409, 63, 68, 12, 1409, 63, 80, 9, 881, 603, 12, 4358, 29, 5743, 1409, 14, 3269, 63, 1409, 63, 9688, 10375, 8, 14344, 12, 10886, 14, 15421, 2470, 63, 1160, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 467, 5601, 3467, 29, 797, 9, 881, 1488, 29, 5743, 1409, 14, 26692, 63, 475, 63, 1160, 8, 88, 12, 45, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 566, 881, 1488, 29, 4714, 14, 4441, 63, 5380, 8, 57, 12, 16, 9, 881, 1488, 29, 10886, 14, 17677, 8, 57, 9, 881, 1488, 29, 10886, 14, 6688, 8, 57, 9, 881, 9342, 29, 10886, 14, 6892, 63, 2987, 8, 57, 9, 881, 754, 14, 740, 8, 7107, 59, 16, 566, 267, 754, 29, 4714, 14, 8748, 8, 1099, 9, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 1445, 7107, 356, 8092, 14, 4180, 8, 1099, 6769, 430, 489, 916, 1414, 6803, 1633, 356, 267, 746, 6064, 360, 13819, 972, 5988, 358, 489, 587, 26, 267, 746, 6064, 360, 5187, 1414, 358, 272, 871, 26, 489, 308, 29, 6424, 14, 6424, 342, 489, 5190, 14, 1361, 63, 2804, 8, 493, 29, 83, 9, 489, 3623, 14, 2254, 17861, 1633, 297, 1310, 344, 395, 1445, 6894, 356, 83, 14, 7150, 342, 12466, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 523, 492, 2680, 523, 492, 8870, 1238, 63, 6599, 523, 492, 17572, 465, 5927, 523, 492, 2146, 846, 523, 492, 6998, 1409, 819, 8870, 63, 68, 12, 1409, 63, 80, 29, 5743, 1409, 14, 912, 63, 1409, 63, 19401, 8, 5790, 630, 63, 515, 534, 992, 15, 1392, 63, 5790, 630, 63, 2333, 63, 1409, 63, 9688, 10375, 14, 4616, 358, 523, 22192, 29, 1628, 846, 14, 1875, 7019, 342, 523, 3623, 29, 8392, 14, 3846, 63, 1628, 8, 1409, 1238, 63, 6599, 9, 523, 3623, 14, 2254, 17861, 4073, 297, 16, 395, 2440, 430, 523, 870, 360, 8392, 297, 8392, 14, 3846, 63, 1205, 1012, 523, 870, 360, 7637, 297, 2775, 14, 9391, 1012, 523, 1323, 14344, 12, 56, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 360, 2604, 15, 8662, 14966, 7241, 14, 4524, 297, 1409, 63, 68, 12, 1409, 63, 80, 9, 523, 1323, 29, 4714, 14, 4441, 63, 5380, 8, 56, 12, 16 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2146, 846, 199, 199, 692, 636, 354, 363, 6803, 363, 11984, 685, 3113, 825, 3706, 523, 492, 747, 14, 515, 523, 492, 3873, 523, 340, 440, 747, 14, 515, 14, 2444, 360, 992, 15, 1409, 1238, 15, 1238, 14, 84, 23, 735, 272, 1166, 534, 2859, 921, 1544, 14, 32118, 14, 957, 15, 83, 15, 1085, 83, 2766, 90, 676, 89, 12668, 74, 2319, 15, 1409, 1238, 14, 84, 23, 31, 5030, 29, 17, 7, 272, 3873, 14, 1074, 63, 1250, 2941, 87, 362, 297, 633, 2584, 13, 47, 1673, 992, 15, 1409, 1238, 15, 1238, 14, 84, 23, 1105, 819, 492, 747, 523, 747, 14, 8563, 360, 992, 15, 1409, 1238, 358, 523, 492, 2680, 523, 492, 984, 523, 492, 5228, 523, 492, 5190, 523, 492, 6998, 1409, 523, 492, 8870, 1238, 523, 492, 17572, 465, 5927, 819, 20831, 29, 1409, 1238, 14, 13414, 1685, 342, 523, 8870, 63, 68, 12, 1409, 63, 80, 29, 5743, 1409, 14, 912, 63, 1409, 63, 19401, 8, 5790, 630, 63, 515, 534, 1392, 63, 5790, 630, 63, 2333, 63, 1409, 63, 9688, 10375, 14, 4616, 358, 819, 1830, 715, 26, 272, 1249, 12, 958, 29, 2775, 14, 9391, 342, 272, 862, 26, 489, 340, 822, 8, 589, 21528, 18, 26, 267, 746, 6064, 360, 3197, 1414, 358, 489, 1414, 29, 589, 59, 16, 61, 489, 1177, 344, 29, 589, 59, 17, 61, 489, 1249, 29, 589, 59, 18, 2938, 489, 340, 1414, 6803, 4073, 356, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 2440, 430, 489, 916, 1414, 6803, 6688, 63, 9688, 10375, 356, 267, 327, 1323, 365, 18731, 653, 671, 869, 671, 644, 671, 650, 5935, 267, 327, 1323, 14344, 365, 18731, 653, 671, 10851, 671, 499, 20078, 10375, 267, 327, 9342, 365, 18731, 653, 671, 1804, 2225, 9342, 267, 1323, 29, 8092, 14, 3640, 8, 958, 459, 56, 1105, 267, 1323, 14344, 29, 8092, 14, 3640, 8, 958, 459, 56, 14344, 1105, 267, 754, 9811, 267, 367, 671, 12, 14344, 315, 3482, 8, 56, 12, 56, 14344, 304, 881, 327, 24546, 12, 88, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 360, 9707, 2604, 15, 8662, 14966, 7241, 14, 4524, 297, 1409, 63, 68, 12, 1409, 63, 80, 9, 881, 603, 12, 4358, 29, 5743, 1409, 14, 3269, 63, 1409, 63, 9688, 10375, 8, 14344, 12, 10886, 14, 15421, 2470, 63, 1160, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 467, 5601, 3467, 29, 797, 9, 881, 1488, 29, 5743, 1409, 14, 26692, 63, 475, 63, 1160, 8, 88, 12, 45, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 566, 881, 1488, 29, 4714, 14, 4441, 63, 5380, 8, 57, 12, 16, 9, 881, 1488, 29, 10886, 14, 17677, 8, 57, 9, 881, 1488, 29, 10886, 14, 6688, 8, 57, 9, 881, 9342, 29, 10886, 14, 6892, 63, 2987, 8, 57, 9, 881, 754, 14, 740, 8, 7107, 59, 16, 566, 267, 754, 29, 4714, 14, 8748, 8, 1099, 9, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 1445, 7107, 356, 8092, 14, 4180, 8, 1099, 6769, 430, 489, 916, 1414, 6803, 6688, 63, 4782, 356, 267, 327, 1323, 365, 18731, 769, 402, 653, 3326, 267, 327, 9342, 365, 18731, 653, 671, 1804, 3004, 9342, 267, 1323, 29, 8092, 14, 3640, 8, 958, 459, 56, 1105, 267, 1323, 17497, 88, 340, 747, 14, 515, 14, 17896, 8, 88, 9, 587, 747, 14, 515, 14, 904, 24592, 703, 297, 88, 430, 367, 671, 315, 1323, 61, 267, 754, 9811, 267, 367, 284, 515, 315, 1323, 26, 881, 24546, 12, 88, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 8, 73, 515, 12, 1409, 63, 68, 12, 1409, 63, 80, 9, 881, 603, 12, 4358, 29, 5743, 1409, 14, 3269, 63, 1409, 63, 9688, 10375, 8, 14344, 12, 10886, 14, 15421, 2470, 63, 1160, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 467, 5601, 3467, 29, 797, 9, 881, 1488, 29, 5743, 1409, 14, 26692, 63, 475, 63, 1160, 8, 88, 12, 45, 12, 1569, 63, 5380, 1524, 8488, 12, 8488, 566, 881, 1488, 29, 4714, 14, 4441, 63, 5380, 8, 57, 12, 16, 9, 881, 1488, 29, 10886, 14, 17677, 8, 57, 9, 881, 1488, 29, 10886, 14, 6688, 8, 57, 9, 881, 9342, 29, 10886, 14, 6892, 63, 2987, 8, 57, 9, 881, 754, 14, 740, 8, 7107, 59, 16, 566, 267, 754, 29, 4714, 14, 8748, 8, 1099, 9, 267, 3623, 14, 2254, 17861, 745, 1187, 297, 1310, 344, 395, 1445, 7107, 356, 8092, 14, 4180, 8, 1099, 6769, 430, 489, 916, 1414, 6803, 1633, 356, 267, 746, 6064, 360, 13819, 972, 5988, 358, 489, 587, 26, 267, 746, 6064, 360, 5187, 1414, 358, 272, 871, 26, 489, 308, 29, 6424, 14, 6424, 342, 489, 5190, 14, 1361, 63, 2804, 8, 493, 29, 83, 9, 489, 3623, 14, 2254, 17861, 1633, 297, 1310, 344, 395, 1445, 6894, 356, 83, 14, 7150, 342, 12466, 199, 199, 692, 636, 354, 363, 6803, 363, 973, 3706, 523, 492, 2680, 523, 492, 8870, 1238, 63, 6599, 523, 492, 17572, 465, 5927, 523, 492, 2146, 846, 523, 492, 6998, 1409, 819, 8870, 63, 68, 12, 1409, 63, 80, 29, 5743, 1409, 14, 912, 63, 1409, 63, 19401, 8, 5790, 630, 63, 515, 534, 992, 15, 1392, 63, 5790, 630, 63, 2333, 63, 1409, 63, 9688, 10375, 14, 4616, 358, 523, 22192, 29, 1628, 846, 14, 1875, 7019, 342, 523, 3623, 29, 8392, 14, 3846, 63, 1628, 8, 1409, 1238, 63, 6599, 9, 523, 3623, 14, 2254, 17861, 4073, 297, 16, 395, 2440, 430, 523, 870, 360, 8392, 297, 8392, 14, 3846, 63, 1205, 1012, 523, 870, 360, 7637, 297, 2775, 14, 9391, 1012, 523, 1323, 14344, 12, 56, 29, 5743, 1409, 14, 13552, 63, 9688, 10375, 360, 2604, 15, 8662, 14966, 7241, 14, 4524, 297, 1409, 63, 68, 12, 1409, 63, 80, 9, 523, 1323, 29, 4714, 14, 4441, 63, 5380, 8, 56, 12, 16, 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, 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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 ]
capriele/crazyflie-clients-python-move
build/lib.linux-i686-2.7/cfclient/ui/tab.py
22
3193
#!/usr/bin/env python # -*- coding: utf-8 -*- # # || ____ _ __ # +------+ / __ )(_) /_______________ _____ ___ # | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \ # +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ # || || /_____/_/\__/\___/_/ \__,_/ /___/\___/ # # Copyright (C) 2011-2013 Bitcraze AB # # Crazyflie Nano Quadcopter Client # # 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. # # 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. """ Superclass for all tabs that implements common functions. """ __author__ = 'Bitcraze AB' __all__ = ['Tab'] import logging logger = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui, uic from PyQt4.QtCore import Qt, pyqtSlot, pyqtSignal, QThread, SIGNAL from cfclient.utils.guiconfig import GuiConfig class Tab(QtGui.QWidget): """Superclass for all tabs that implements common functions.""" def __init__(self): super(Tab, self).__init__() self.tabName = "N/A" self.menuName = "N/A" self.enabled = True @pyqtSlot(bool) def toggleVisibility(self, checked): """Show or hide the tab.""" if checked: self.tabWidget.addTab(self, self.getTabName()) s = "" try: s = GuiConfig().get("open_tabs") if (len(s) > 0): s += "," except Exception as e: logger.warning("Exception while adding tab to config and " "reading tab config") # Check this since tabs in config are opened when app is started if (self.tabName not in s): s += "%s" % self.tabName GuiConfig().set("open_tabs", s) if not checked: self.tabWidget.removeTab(self.tabWidget.indexOf(self)) try: parts = GuiConfig().get("open_tabs").split(",") except Exception as e: logger.warning("Exception while removing tab from config and " "reading tab config") parts = [] s = "" for p in parts: if (self.tabName != p): s += "%s," % p s = s[0:len(s) - 1] # Remove last comma GuiConfig().set("open_tabs", s) def getMenuName(self): """Return the name of the tab that will be shown in the menu""" return self.menuName def getTabName(self): """Return the name of the tab that will be shown in the tab""" return self.tabName
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 12208, 3515, 636, 363, 221, 485, 636, 199, 3, 221, 435, 28712, 420, 1182, 636, 776, 1547, 9, 1182, 7785, 4741, 8989, 636, 8989, 221, 31111, 199, 3, 221, 1204, 378, 88, 6265, 1204, 258, 1182, 636, 221, 1182, 1182, 636, 15, 31111, 15, 31111, 15, 636, 658, 15607, 221, 1182, 1182, 485, 971, 199, 3, 221, 435, 28712, 259, 1182, 1182, 63, 15, 1182, 1182, 1182, 63, 15, 1182, 363, 15, 1182, 221, 1182, 1182, 63, 15, 1182, 1182, 1182, 63, 15, 221, 636, 15, 199, 3, 257, 12208, 221, 12208, 259, 1182, 4741, 63, 15607, 6307, 363, 6307, 8989, 15607, 15, 257, 971, 3108, 63, 15, 1182, 8989, 6307, 8989, 15, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 7760, 13, 6965, 10199, 67, 345, 806, 14840, 199, 3, 199, 3, 221, 445, 30566, 70, 21530, 653, 8143, 5843, 350, 26950, 351, 6810, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 199, 11823, 533, 367, 1006, 12187, 626, 9031, 2863, 3423, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 4734, 67, 345, 806, 14840, 7, 199, 363, 452, 363, 275, 788, 7690, 418, 199, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 504, 14084, 20, 492, 10565, 12, 5928, 12, 399, 530, 199, 504, 14084, 20, 14, 10901, 492, 3959, 12, 27149, 15183, 12, 27149, 11274, 12, 1413, 4436, 12, 24360, 199, 199, 504, 3980, 1258, 14, 1208, 14, 5885, 888, 492, 14425, 2028, 421, 199, 533, 23159, 8, 10604, 14, 23894, 304, 272, 408, 11823, 533, 367, 1006, 12187, 626, 9031, 2863, 3423, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 7690, 12, 291, 2843, 826, 4533, 267, 291, 14, 2902, 985, 275, 298, 46, 15, 33, 2, 267, 291, 14, 4470, 985, 275, 298, 46, 15, 33, 2, 267, 291, 14, 3827, 275, 715, 339, 768, 24835, 15183, 8, 2245, 9, 272, 347, 19420, 24735, 8, 277, 12, 7923, 304, 267, 408, 6824, 503, 13714, 314, 5174, 1041, 267, 340, 7923, 26, 288, 291, 14, 2902, 3339, 14, 525, 7690, 8, 277, 12, 291, 14, 362, 7690, 985, 1012, 288, 308, 275, 3087, 288, 862, 26, 355, 308, 275, 14425, 2028, 1252, 362, 480, 1490, 63, 8741, 531, 355, 340, 334, 552, 8, 83, 9, 690, 378, 304, 490, 308, 847, 21147, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 3764, 480, 1726, 1830, 7791, 5174, 370, 1101, 436, 298, 3044, 298, 19332, 5174, 1101, 531, 288, 327, 2670, 642, 3967, 12187, 315, 1101, 787, 12123, 1380, 1145, 365, 8239, 288, 340, 334, 277, 14, 2902, 985, 440, 315, 308, 304, 355, 308, 847, 2071, 83, 2, 450, 291, 14, 2902, 985, 355, 14425, 2028, 1252, 409, 480, 1490, 63, 8741, 401, 308, 9, 398, 340, 440, 7923, 26, 288, 291, 14, 2902, 3339, 14, 2168, 7690, 8, 277, 14, 2902, 3339, 14, 31397, 8, 277, 430, 288, 862, 26, 355, 4184, 275, 14425, 2028, 1252, 362, 480, 1490, 63, 8741, 3471, 1294, 20324, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 3764, 480, 1726, 1830, 12881, 5174, 687, 1101, 436, 298, 3044, 298, 19332, 5174, 1101, 531, 355, 4184, 275, 942, 288, 308, 275, 3087, 288, 367, 299, 315, 4184, 26, 355, 340, 334, 277, 14, 2902, 985, 1137, 299, 304, 490, 308, 847, 2071, 83, 4589, 450, 299, 288, 308, 275, 308, 59, 16, 26, 552, 8, 83, 9, 446, 413, 61, 221, 327, 5852, 2061, 10029, 288, 14425, 2028, 1252, 409, 480, 1490, 63, 8741, 401, 308, 9, 339, 347, 664, 5977, 985, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 5174, 626, 911, 506, 9164, 315, 314, 6269, 624, 267, 372, 291, 14, 4470, 985, 339, 347, 664, 7690, 985, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 5174, 626, 911, 506, 9164, 315, 314, 5174, 624, 267, 372, 291, 14, 2902, 985, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 258, 12208, 3515, 636, 363, 221, 485, 636, 199, 3, 221, 435, 28712, 420, 1182, 636, 776, 1547, 9, 1182, 7785, 4741, 8989, 636, 8989, 221, 31111, 199, 3, 221, 1204, 378, 88, 6265, 1204, 258, 1182, 636, 221, 1182, 1182, 636, 15, 31111, 15, 31111, 15, 636, 658, 15607, 221, 1182, 1182, 485, 971, 199, 3, 221, 435, 28712, 259, 1182, 1182, 63, 15, 1182, 1182, 1182, 63, 15, 1182, 363, 15, 1182, 221, 1182, 1182, 63, 15, 1182, 1182, 1182, 63, 15, 221, 636, 15, 199, 3, 257, 12208, 221, 12208, 259, 1182, 4741, 63, 15607, 6307, 363, 6307, 8989, 15607, 15, 257, 971, 3108, 63, 15, 1182, 8989, 6307, 8989, 15, 199, 3, 199, 3, 221, 1898, 334, 35, 9, 7760, 13, 6965, 10199, 67, 345, 806, 14840, 199, 3, 199, 3, 221, 445, 30566, 70, 21530, 653, 8143, 5843, 350, 26950, 351, 6810, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 199, 11823, 533, 367, 1006, 12187, 626, 9031, 2863, 3423, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 4734, 67, 345, 806, 14840, 7, 199, 363, 452, 363, 275, 788, 7690, 418, 199, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 504, 14084, 20, 492, 10565, 12, 5928, 12, 399, 530, 199, 504, 14084, 20, 14, 10901, 492, 3959, 12, 27149, 15183, 12, 27149, 11274, 12, 1413, 4436, 12, 24360, 199, 199, 504, 3980, 1258, 14, 1208, 14, 5885, 888, 492, 14425, 2028, 421, 199, 533, 23159, 8, 10604, 14, 23894, 304, 272, 408, 11823, 533, 367, 1006, 12187, 626, 9031, 2863, 3423, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 7690, 12, 291, 2843, 826, 4533, 267, 291, 14, 2902, 985, 275, 298, 46, 15, 33, 2, 267, 291, 14, 4470, 985, 275, 298, 46, 15, 33, 2, 267, 291, 14, 3827, 275, 715, 339, 768, 24835, 15183, 8, 2245, 9, 272, 347, 19420, 24735, 8, 277, 12, 7923, 304, 267, 408, 6824, 503, 13714, 314, 5174, 1041, 267, 340, 7923, 26, 288, 291, 14, 2902, 3339, 14, 525, 7690, 8, 277, 12, 291, 14, 362, 7690, 985, 1012, 288, 308, 275, 3087, 288, 862, 26, 355, 308, 275, 14425, 2028, 1252, 362, 480, 1490, 63, 8741, 531, 355, 340, 334, 552, 8, 83, 9, 690, 378, 304, 490, 308, 847, 21147, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 3764, 480, 1726, 1830, 7791, 5174, 370, 1101, 436, 298, 3044, 298, 19332, 5174, 1101, 531, 288, 327, 2670, 642, 3967, 12187, 315, 1101, 787, 12123, 1380, 1145, 365, 8239, 288, 340, 334, 277, 14, 2902, 985, 440, 315, 308, 304, 355, 308, 847, 2071, 83, 2, 450, 291, 14, 2902, 985, 355, 14425, 2028, 1252, 409, 480, 1490, 63, 8741, 401, 308, 9, 398, 340, 440, 7923, 26, 288, 291, 14, 2902, 3339, 14, 2168, 7690, 8, 277, 14, 2902, 3339, 14, 31397, 8, 277, 430, 288, 862, 26, 355, 4184, 275, 14425, 2028, 1252, 362, 480, 1490, 63, 8741, 3471, 1294, 20324, 288, 871, 2186, 465, 325, 26, 355, 2512, 14, 3764, 480, 1726, 1830, 12881, 5174, 687, 1101, 436, 298, 3044, 298, 19332, 5174, 1101, 531, 355, 4184, 275, 942, 288, 308, 275, 3087, 288, 367, 299, 315, 4184, 26, 355, 340, 334, 277, 14, 2902, 985, 1137, 299, 304, 490, 308, 847, 2071, 83, 4589, 450, 299, 288, 308, 275, 308, 59, 16, 26, 552, 8, 83, 9, 446, 413, 61, 221, 327, 5852, 2061, 10029, 288, 14425, 2028, 1252, 409, 480, 1490, 63, 8741, 401, 308, 9, 339, 347, 664, 5977, 985, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 5174, 626, 911, 506, 9164, 315, 314, 6269, 624, 267, 372, 291, 14, 4470, 985, 339, 347, 664, 7690, 985, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 5174, 626, 911, 506, 9164, 315, 314, 5174, 624, 267, 372, 291, 14, 2902, 985, 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, 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, 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 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
noba3/KoTos
addons/plugin.video.iptvxtra-de-more/resources/lib/requests/packages/urllib3/response.py
328
10347
# urllib3/response.py # Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt) # # This module is part of urllib3 and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php import logging import zlib import io from ._collections import HTTPHeaderDict from .exceptions import DecodeError from .packages.six import string_types as basestring, binary_type from .util import is_fp_closed log = logging.getLogger(__name__) class DeflateDecoder(object): def __init__(self): self._first_try = True self._data = binary_type() self._obj = zlib.decompressobj() def __getattr__(self, name): return getattr(self._obj, name) def decompress(self, data): if not self._first_try: return self._obj.decompress(data) self._data += data try: return self._obj.decompress(data) except zlib.error: self._first_try = False self._obj = zlib.decompressobj(-zlib.MAX_WBITS) try: return self.decompress(self._data) finally: self._data = None def _get_decoder(mode): if mode == 'gzip': return zlib.decompressobj(16 + zlib.MAX_WBITS) return DeflateDecoder() class HTTPResponse(io.IOBase): """ HTTP Response container. Backwards-compatible to httplib's HTTPResponse but the response ``body`` is loaded and decoded on-demand when the ``data`` property is accessed. Extra parameters for behaviour not present in httplib.HTTPResponse: :param preload_content: If True, the response's body will be preloaded during construction. :param decode_content: If True, attempts to decode specific content-encoding's based on headers (like 'gzip' and 'deflate') will be skipped and raw data will be used instead. :param original_response: When this HTTPResponse wrapper is generated from an httplib.HTTPResponse object, it's convenient to include the original for debug purposes. It's otherwise unused. """ CONTENT_DECODERS = ['gzip', 'deflate'] REDIRECT_STATUSES = [301, 302, 303, 307, 308] def __init__(self, body='', headers=None, status=0, version=0, reason=None, strict=0, preload_content=True, decode_content=True, original_response=None, pool=None, connection=None): self.headers = HTTPHeaderDict() if headers: self.headers.update(headers) self.status = status self.version = version self.reason = reason self.strict = strict self.decode_content = decode_content self._decoder = None self._body = body if body and isinstance(body, basestring) else None self._fp = None self._original_response = original_response self._fp_bytes_read = 0 self._pool = pool self._connection = connection if hasattr(body, 'read'): self._fp = body if preload_content and not self._body: self._body = self.read(decode_content=decode_content) def get_redirect_location(self): """ Should we redirect and where to? :returns: Truthy redirect location string if we got a redirect status code and valid location. ``None`` if redirect status and no location. ``False`` if not a redirect status code. """ if self.status in self.REDIRECT_STATUSES: return self.headers.get('location') return False def release_conn(self): if not self._pool or not self._connection: return self._pool._put_conn(self._connection) self._connection = None @property def data(self): # For backwords-compat with earlier urllib3 0.4 and earlier. if self._body: return self._body if self._fp: return self.read(cache_content=True) def tell(self): """ Obtain the number of bytes pulled over the wire so far. May differ from the amount of content returned by :meth:``HTTPResponse.read`` if bytes are encoded on the wire (e.g, compressed). """ return self._fp_bytes_read def read(self, amt=None, decode_content=None, cache_content=False): """ Similar to :meth:`httplib.HTTPResponse.read`, but with two additional parameters: ``decode_content`` and ``cache_content``. :param amt: How much of the content to read. If specified, caching is skipped because it doesn't make sense to cache partial content as the full response. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. :param cache_content: If True, will save the returned data such that the same result is returned despite of the state of the underlying file object. This is useful if you want the ``.data`` property to continue working after having ``.read()`` the file object. (Overridden if ``amt`` is set.) """ # Note: content-encoding value should be case-insensitive, per RFC 2616 # Section 3.5 content_encoding = self.headers.get('content-encoding', '').lower() if self._decoder is None: if content_encoding in self.CONTENT_DECODERS: self._decoder = _get_decoder(content_encoding) if decode_content is None: decode_content = self.decode_content if self._fp is None: return flush_decoder = False try: if amt is None: # cStringIO doesn't like amt=None data = self._fp.read() flush_decoder = True else: cache_content = False data = self._fp.read(amt) if amt != 0 and not data: # Platform-specific: Buggy versions of Python. # Close the connection when no data is returned # # This is redundant to what httplib/http.client _should_ # already do. However, versions of python released before # December 15, 2012 (http://bugs.python.org/issue16298) do not # properly close the connection in all cases. There is no harm # in redundantly calling close. self._fp.close() flush_decoder = True self._fp_bytes_read += len(data) try: if decode_content and self._decoder: data = self._decoder.decompress(data) except (IOError, zlib.error) as e: raise DecodeError( "Received response with content-encoding: %s, but " "failed to decode it." % content_encoding, e) if flush_decoder and decode_content and self._decoder: buf = self._decoder.decompress(binary_type()) data += buf + self._decoder.flush() if cache_content: self._body = data return data finally: if self._original_response and self._original_response.isclosed(): self.release_conn() def stream(self, amt=2**16, decode_content=None): """ A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator will return up to much data per iteration, but may return less. This is particularly likely when using compressed data. However, the empty string will never be returned. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. """ while not is_fp_closed(self._fp): data = self.read(amt=amt, decode_content=decode_content) if data: yield data @classmethod def from_httplib(ResponseCls, r, **response_kw): """ Given an :class:`httplib.HTTPResponse` instance ``r``, return a corresponding :class:`urllib3.response.HTTPResponse` object. Remaining parameters are passed to the HTTPResponse constructor, along with ``original_response=r``. """ headers = HTTPHeaderDict() for k, v in r.getheaders(): headers.add(k, v) # HTTPResponse objects in Python 3 don't have a .strict attribute strict = getattr(r, 'strict', 0) return ResponseCls(body=r, headers=headers, status=r.status, version=r.version, reason=r.reason, strict=strict, original_response=r, **response_kw) # Backwards-compatibility methods for httplib.HTTPResponse def getheaders(self): return self.headers def getheader(self, name, default=None): return self.headers.get(name, default) # Overrides from io.IOBase def close(self): if not self.closed: self._fp.close() @property def closed(self): if self._fp is None: return True elif hasattr(self._fp, 'closed'): return self._fp.closed elif hasattr(self._fp, 'isclosed'): # Python 2 return self._fp.isclosed() else: return True def fileno(self): if self._fp is None: raise IOError("HTTPResponse has no file to get a fileno from") elif hasattr(self._fp, "fileno"): return self._fp.fileno() else: raise IOError("The file-like object this HTTPResponse is wrapped " "around has no file descriptor") def flush(self): if self._fp is not None and hasattr(self._fp, 'flush'): return self._fp.flush() def readable(self): return True
gpl-2.0
[ 3, 4011, 19, 15, 1310, 14, 647, 199, 3, 1898, 9079, 13, 6965, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 421, 199, 646, 2050, 199, 646, 12472, 199, 646, 5890, 199, 199, 504, 13653, 7882, 492, 3101, 2567, 2141, 199, 504, 1275, 3924, 492, 22462, 547, 199, 504, 1275, 5154, 14, 4174, 492, 1059, 63, 1313, 465, 7116, 12, 3366, 63, 466, 199, 504, 1275, 1974, 492, 365, 63, 3997, 63, 5938, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11391, 750, 8326, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 2246, 63, 893, 275, 715, 267, 291, 423, 576, 275, 3366, 63, 466, 342, 267, 291, 423, 1113, 275, 12472, 14, 14954, 1113, 342, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 423, 1113, 12, 536, 9, 339, 347, 24733, 8, 277, 12, 666, 304, 267, 340, 440, 291, 423, 2246, 63, 893, 26, 288, 372, 291, 423, 1113, 14, 14954, 8, 576, 9, 398, 291, 423, 576, 847, 666, 267, 862, 26, 288, 372, 291, 423, 1113, 14, 14954, 8, 576, 9, 267, 871, 12472, 14, 705, 26, 288, 291, 423, 2246, 63, 893, 275, 756, 288, 291, 423, 1113, 275, 12472, 14, 14954, 1113, 2801, 15371, 14, 4283, 63, 55, 14662, 9, 288, 862, 26, 355, 372, 291, 14, 14954, 8, 277, 423, 576, 9, 288, 3753, 26, 355, 291, 423, 576, 275, 488, 421, 199, 318, 485, 362, 63, 8813, 8, 632, 304, 272, 340, 818, 508, 283, 12256, 356, 267, 372, 12472, 14, 14954, 1113, 8, 975, 435, 12472, 14, 4283, 63, 55, 14662, 9, 339, 372, 11391, 750, 8326, 342, 421, 199, 533, 29034, 8, 2308, 14, 23413, 304, 272, 408, 272, 3101, 7232, 3970, 14, 339, 10257, 4751, 13, 6490, 370, 8809, 1159, 29034, 1325, 314, 1177, 1124, 2030, 1040, 365, 272, 6511, 436, 11203, 641, 13, 24152, 1380, 314, 1124, 576, 1040, 3324, 365, 13810, 14, 339, 11177, 2633, 367, 13942, 440, 3451, 315, 8809, 14, 27068, 26, 339, 520, 635, 32511, 63, 1317, 26, 267, 982, 715, 12, 314, 1177, 1159, 2396, 911, 506, 876, 4591, 5309, 14538, 14, 339, 520, 635, 4849, 63, 1317, 26, 267, 982, 715, 12, 12454, 370, 4849, 2488, 1564, 13, 2991, 1159, 4079, 641, 2323, 267, 334, 2930, 283, 12256, 7, 436, 283, 20902, 358, 911, 506, 9645, 436, 3066, 666, 911, 506, 1202, 267, 3140, 14, 339, 520, 635, 3379, 63, 1310, 26, 267, 3979, 642, 29034, 4975, 365, 4046, 687, 376, 8809, 14, 27068, 267, 909, 12, 652, 1159, 22700, 370, 2387, 314, 3379, 367, 3105, 12901, 14, 2779, 1159, 267, 4257, 9563, 14, 272, 408, 339, 29417, 63, 1093, 12592, 3960, 275, 788, 12256, 297, 283, 20902, 418, 272, 820, 7458, 4168, 63, 6305, 654, 275, 359, 8507, 12, 11485, 12, 25989, 12, 26959, 12, 650, 2036, 61, 339, 347, 636, 826, 721, 277, 12, 2396, 4581, 2323, 29, 403, 12, 2004, 29, 16, 12, 1015, 29, 16, 12, 4499, 29, 403, 12, 326, 7478, 29, 16, 12, 32511, 63, 1317, 29, 549, 12, 4849, 63, 1317, 29, 549, 12, 326, 3379, 63, 1310, 29, 403, 12, 4203, 29, 403, 12, 1950, 29, 403, 304, 398, 291, 14, 2139, 275, 3101, 2567, 2141, 342, 267, 340, 2323, 26, 288, 291, 14, 2139, 14, 873, 8, 2139, 9, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 5764, 275, 4499, 267, 291, 14, 4768, 275, 7478, 267, 291, 14, 2708, 63, 1317, 275, 4849, 63, 1317, 398, 291, 423, 8813, 275, 488, 267, 291, 423, 2030, 275, 2396, 340, 2396, 436, 1228, 8, 2030, 12, 7116, 9, 587, 488, 267, 291, 423, 3997, 275, 488, 267, 291, 423, 5043, 63, 1310, 275, 3379, 63, 1310, 267, 291, 423, 3997, 63, 2394, 63, 739, 275, 378, 398, 291, 423, 2293, 275, 4203, 267, 291, 423, 2105, 275, 1950, 398, 340, 2688, 8, 2030, 12, 283, 739, 735, 288, 291, 423, 3997, 275, 2396, 398, 340, 32511, 63, 1317, 436, 440, 291, 423, 2030, 26, 288, 291, 423, 2030, 275, 291, 14, 739, 8, 2708, 63, 1317, 29, 2708, 63, 1317, 9, 339, 347, 664, 63, 4876, 63, 1985, 8, 277, 304, 267, 408, 267, 7719, 781, 4660, 436, 2382, 370, 31, 398, 520, 5808, 26, 28814, 762, 89, 4660, 2909, 1059, 340, 781, 4788, 282, 4660, 2004, 288, 1233, 436, 1686, 2909, 14, 1124, 403, 1040, 340, 4660, 2004, 436, 949, 288, 2909, 14, 1124, 797, 1040, 340, 440, 282, 4660, 2004, 1233, 14, 267, 408, 267, 340, 291, 14, 1205, 315, 291, 14, 19747, 63, 6305, 654, 26, 288, 372, 291, 14, 2139, 14, 362, 360, 1985, 358, 398, 372, 756, 339, 347, 4683, 63, 1631, 8, 277, 304, 267, 340, 440, 291, 423, 2293, 503, 440, 291, 423, 2105, 26, 288, 372, 398, 291, 423, 2293, 423, 524, 63, 1631, 8, 277, 423, 2105, 9, 267, 291, 423, 2105, 275, 488, 339, 768, 1829, 272, 347, 666, 8, 277, 304, 267, 327, 2104, 1771, 3148, 13, 5819, 543, 14119, 4011, 19, 378, 14, 20, 436, 14119, 14, 267, 340, 291, 423, 2030, 26, 288, 372, 291, 423, 2030, 398, 340, 291, 423, 3997, 26, 288, 372, 291, 14, 739, 8, 1637, 63, 1317, 29, 549, 9, 339, 347, 11480, 8, 277, 304, 267, 408, 267, 17985, 877, 314, 1329, 402, 2783, 25239, 1146, 1806, 314, 11799, 880, 12474, 14, 10162, 14460, 687, 267, 314, 5982, 402, 1564, 2138, 701, 520, 5247, 5409, 27068, 14, 739, 1040, 340, 2783, 267, 787, 5737, 641, 314, 11799, 334, 69, 14, 71, 12, 12335, 680, 267, 408, 267, 372, 291, 423, 3997, 63, 2394, 63, 739, 339, 347, 1586, 8, 277, 12, 23486, 29, 403, 12, 4849, 63, 1317, 29, 403, 12, 2581, 63, 1317, 29, 797, 304, 267, 408, 267, 20046, 370, 520, 5247, 1705 ]
[ 4011, 19, 15, 1310, 14, 647, 199, 3, 1898, 9079, 13, 6965, 6061, 17885, 31449, 293, 86, 436, 8417, 334, 3239, 6483, 14, 2424, 9, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 4011, 19, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 421, 199, 646, 2050, 199, 646, 12472, 199, 646, 5890, 199, 199, 504, 13653, 7882, 492, 3101, 2567, 2141, 199, 504, 1275, 3924, 492, 22462, 547, 199, 504, 1275, 5154, 14, 4174, 492, 1059, 63, 1313, 465, 7116, 12, 3366, 63, 466, 199, 504, 1275, 1974, 492, 365, 63, 3997, 63, 5938, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11391, 750, 8326, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 2246, 63, 893, 275, 715, 267, 291, 423, 576, 275, 3366, 63, 466, 342, 267, 291, 423, 1113, 275, 12472, 14, 14954, 1113, 342, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 423, 1113, 12, 536, 9, 339, 347, 24733, 8, 277, 12, 666, 304, 267, 340, 440, 291, 423, 2246, 63, 893, 26, 288, 372, 291, 423, 1113, 14, 14954, 8, 576, 9, 398, 291, 423, 576, 847, 666, 267, 862, 26, 288, 372, 291, 423, 1113, 14, 14954, 8, 576, 9, 267, 871, 12472, 14, 705, 26, 288, 291, 423, 2246, 63, 893, 275, 756, 288, 291, 423, 1113, 275, 12472, 14, 14954, 1113, 2801, 15371, 14, 4283, 63, 55, 14662, 9, 288, 862, 26, 355, 372, 291, 14, 14954, 8, 277, 423, 576, 9, 288, 3753, 26, 355, 291, 423, 576, 275, 488, 421, 199, 318, 485, 362, 63, 8813, 8, 632, 304, 272, 340, 818, 508, 283, 12256, 356, 267, 372, 12472, 14, 14954, 1113, 8, 975, 435, 12472, 14, 4283, 63, 55, 14662, 9, 339, 372, 11391, 750, 8326, 342, 421, 199, 533, 29034, 8, 2308, 14, 23413, 304, 272, 408, 272, 3101, 7232, 3970, 14, 339, 10257, 4751, 13, 6490, 370, 8809, 1159, 29034, 1325, 314, 1177, 1124, 2030, 1040, 365, 272, 6511, 436, 11203, 641, 13, 24152, 1380, 314, 1124, 576, 1040, 3324, 365, 13810, 14, 339, 11177, 2633, 367, 13942, 440, 3451, 315, 8809, 14, 27068, 26, 339, 520, 635, 32511, 63, 1317, 26, 267, 982, 715, 12, 314, 1177, 1159, 2396, 911, 506, 876, 4591, 5309, 14538, 14, 339, 520, 635, 4849, 63, 1317, 26, 267, 982, 715, 12, 12454, 370, 4849, 2488, 1564, 13, 2991, 1159, 4079, 641, 2323, 267, 334, 2930, 283, 12256, 7, 436, 283, 20902, 358, 911, 506, 9645, 436, 3066, 666, 911, 506, 1202, 267, 3140, 14, 339, 520, 635, 3379, 63, 1310, 26, 267, 3979, 642, 29034, 4975, 365, 4046, 687, 376, 8809, 14, 27068, 267, 909, 12, 652, 1159, 22700, 370, 2387, 314, 3379, 367, 3105, 12901, 14, 2779, 1159, 267, 4257, 9563, 14, 272, 408, 339, 29417, 63, 1093, 12592, 3960, 275, 788, 12256, 297, 283, 20902, 418, 272, 820, 7458, 4168, 63, 6305, 654, 275, 359, 8507, 12, 11485, 12, 25989, 12, 26959, 12, 650, 2036, 61, 339, 347, 636, 826, 721, 277, 12, 2396, 4581, 2323, 29, 403, 12, 2004, 29, 16, 12, 1015, 29, 16, 12, 4499, 29, 403, 12, 326, 7478, 29, 16, 12, 32511, 63, 1317, 29, 549, 12, 4849, 63, 1317, 29, 549, 12, 326, 3379, 63, 1310, 29, 403, 12, 4203, 29, 403, 12, 1950, 29, 403, 304, 398, 291, 14, 2139, 275, 3101, 2567, 2141, 342, 267, 340, 2323, 26, 288, 291, 14, 2139, 14, 873, 8, 2139, 9, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1023, 275, 1015, 267, 291, 14, 5764, 275, 4499, 267, 291, 14, 4768, 275, 7478, 267, 291, 14, 2708, 63, 1317, 275, 4849, 63, 1317, 398, 291, 423, 8813, 275, 488, 267, 291, 423, 2030, 275, 2396, 340, 2396, 436, 1228, 8, 2030, 12, 7116, 9, 587, 488, 267, 291, 423, 3997, 275, 488, 267, 291, 423, 5043, 63, 1310, 275, 3379, 63, 1310, 267, 291, 423, 3997, 63, 2394, 63, 739, 275, 378, 398, 291, 423, 2293, 275, 4203, 267, 291, 423, 2105, 275, 1950, 398, 340, 2688, 8, 2030, 12, 283, 739, 735, 288, 291, 423, 3997, 275, 2396, 398, 340, 32511, 63, 1317, 436, 440, 291, 423, 2030, 26, 288, 291, 423, 2030, 275, 291, 14, 739, 8, 2708, 63, 1317, 29, 2708, 63, 1317, 9, 339, 347, 664, 63, 4876, 63, 1985, 8, 277, 304, 267, 408, 267, 7719, 781, 4660, 436, 2382, 370, 31, 398, 520, 5808, 26, 28814, 762, 89, 4660, 2909, 1059, 340, 781, 4788, 282, 4660, 2004, 288, 1233, 436, 1686, 2909, 14, 1124, 403, 1040, 340, 4660, 2004, 436, 949, 288, 2909, 14, 1124, 797, 1040, 340, 440, 282, 4660, 2004, 1233, 14, 267, 408, 267, 340, 291, 14, 1205, 315, 291, 14, 19747, 63, 6305, 654, 26, 288, 372, 291, 14, 2139, 14, 362, 360, 1985, 358, 398, 372, 756, 339, 347, 4683, 63, 1631, 8, 277, 304, 267, 340, 440, 291, 423, 2293, 503, 440, 291, 423, 2105, 26, 288, 372, 398, 291, 423, 2293, 423, 524, 63, 1631, 8, 277, 423, 2105, 9, 267, 291, 423, 2105, 275, 488, 339, 768, 1829, 272, 347, 666, 8, 277, 304, 267, 327, 2104, 1771, 3148, 13, 5819, 543, 14119, 4011, 19, 378, 14, 20, 436, 14119, 14, 267, 340, 291, 423, 2030, 26, 288, 372, 291, 423, 2030, 398, 340, 291, 423, 3997, 26, 288, 372, 291, 14, 739, 8, 1637, 63, 1317, 29, 549, 9, 339, 347, 11480, 8, 277, 304, 267, 408, 267, 17985, 877, 314, 1329, 402, 2783, 25239, 1146, 1806, 314, 11799, 880, 12474, 14, 10162, 14460, 687, 267, 314, 5982, 402, 1564, 2138, 701, 520, 5247, 5409, 27068, 14, 739, 1040, 340, 2783, 267, 787, 5737, 641, 314, 11799, 334, 69, 14, 71, 12, 12335, 680, 267, 408, 267, 372, 291, 423, 3997, 63, 2394, 63, 739, 339, 347, 1586, 8, 277, 12, 23486, 29, 403, 12, 4849, 63, 1317, 29, 403, 12, 2581,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ksrajkumar/openerp-6.1
openerp/addons/crm/wizard/mail_compose_message.py
7
2961
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>) # # 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 osv import osv from osv import fields import tools SUPPORTED_MODELS = ['crm.lead',] class mail_compose_message(osv.osv_memory): _inherit = 'mail.compose.message' def get_value(self, cr, uid, model, res_id, context=None): """Returns a defaults-like dict with initial values for the composition wizard when sending an email related to the document record identified by ``model`` and ``res_id``. Overrides the default implementation to provide more default field values related to the corresponding CRM case. :param str model: model name of the document record this mail is related to. :param int res_id: id of the document record this mail is related to. :param dict context: several context values will modify the behavior of the wizard, cfr. the class description. """ result = super(mail_compose_message, self).get_value(cr, uid, model, res_id, context=context) if model in SUPPORTED_MODELS and res_id: model_obj = self.pool.get(model) data = model_obj.browse(cr, uid , res_id, context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context) result.update({ 'subject' : data.name or False, 'email_to' : data.email_from or False, 'email_from' : user.user_email or tools.config.get('email_from', False), 'body_text' : '\n' + tools.ustr(user.signature or ''), 'email_cc' : tools.ustr(data.email_cc or ''), 'model': model, 'res_id': res_id, 'subtype': 'plain', }) if hasattr(data, 'section_id'): result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) return result # 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, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 9506, 492, 9506, 199, 504, 9506, 492, 1504, 199, 646, 7249, 199, 199, 15925, 63, 11429, 51, 275, 788, 15213, 14, 13799, 297, 61, 199, 199, 533, 6016, 63, 12607, 63, 1188, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 339, 347, 664, 63, 585, 8, 277, 12, 2467, 12, 1747, 12, 1402, 12, 522, 63, 344, 12, 1067, 29, 403, 304, 267, 408, 3407, 282, 4243, 13, 2930, 1211, 543, 2536, 1338, 367, 314, 31586, 1779, 12262, 1380, 10209, 376, 3031, 4048, 370, 314, 2213, 2777, 15836, 1779, 701, 1124, 1238, 1040, 436, 1124, 470, 63, 344, 4345, 13596, 31144, 314, 849, 4514, 370, 5647, 1655, 849, 901, 1338, 1779, 4048, 370, 314, 5226, 445, 11026, 1930, 14, 13596, 520, 635, 620, 1402, 26, 1402, 536, 402, 314, 2213, 2777, 642, 6016, 365, 4048, 370, 14, 1779, 520, 635, 1109, 522, 63, 344, 26, 1305, 402, 314, 2213, 2777, 642, 6016, 365, 4048, 370, 14, 1779, 520, 635, 1211, 1067, 26, 9978, 1067, 1338, 911, 2811, 314, 5953, 1816, 402, 314, 12262, 12, 3980, 82, 14, 314, 1021, 1369, 14, 267, 408, 267, 754, 275, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 362, 63, 585, 8, 1556, 12, 1747, 12, 221, 1402, 12, 522, 63, 344, 12, 1067, 29, 1100, 9, 267, 340, 1402, 315, 32501, 63, 11429, 51, 436, 522, 63, 344, 26, 288, 1402, 63, 1113, 275, 291, 14, 2293, 14, 362, 8, 1238, 9, 288, 666, 275, 1402, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 2360, 522, 63, 344, 12, 1067, 9, 288, 922, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 9, 288, 754, 14, 873, 2561, 490, 283, 5875, 7, 520, 666, 14, 354, 503, 756, 12, 490, 283, 2123, 63, 475, 7, 520, 666, 14, 2123, 63, 504, 503, 756, 12, 490, 283, 2123, 63, 504, 7, 520, 922, 14, 751, 63, 2123, 503, 7249, 14, 888, 14, 362, 360, 2123, 63, 504, 297, 756, 395, 490, 283, 2030, 63, 505, 7, 520, 1557, 78, 7, 435, 7249, 14, 11409, 8, 751, 14, 5233, 503, 9929, 490, 283, 2123, 63, 2055, 7, 520, 7249, 14, 11409, 8, 576, 14, 2123, 63, 2055, 503, 9929, 490, 283, 1238, 356, 1402, 12, 490, 283, 470, 63, 344, 356, 522, 63, 344, 12, 490, 283, 10512, 356, 283, 6104, 297, 355, 3828, 288, 340, 2688, 8, 576, 12, 283, 2792, 63, 344, 735, 355, 754, 14, 873, 3252, 8102, 63, 475, 7, 520, 666, 14, 2792, 63, 344, 436, 666, 14, 2792, 63, 344, 14, 8102, 63, 475, 503, 756, 1552, 267, 372, 754, 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 ]
[ 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, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 9506, 492, 9506, 199, 504, 9506, 492, 1504, 199, 646, 7249, 199, 199, 15925, 63, 11429, 51, 275, 788, 15213, 14, 13799, 297, 61, 199, 199, 533, 6016, 63, 12607, 63, 1188, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 339, 347, 664, 63, 585, 8, 277, 12, 2467, 12, 1747, 12, 1402, 12, 522, 63, 344, 12, 1067, 29, 403, 304, 267, 408, 3407, 282, 4243, 13, 2930, 1211, 543, 2536, 1338, 367, 314, 31586, 1779, 12262, 1380, 10209, 376, 3031, 4048, 370, 314, 2213, 2777, 15836, 1779, 701, 1124, 1238, 1040, 436, 1124, 470, 63, 344, 4345, 13596, 31144, 314, 849, 4514, 370, 5647, 1655, 849, 901, 1338, 1779, 4048, 370, 314, 5226, 445, 11026, 1930, 14, 13596, 520, 635, 620, 1402, 26, 1402, 536, 402, 314, 2213, 2777, 642, 6016, 365, 4048, 370, 14, 1779, 520, 635, 1109, 522, 63, 344, 26, 1305, 402, 314, 2213, 2777, 642, 6016, 365, 4048, 370, 14, 1779, 520, 635, 1211, 1067, 26, 9978, 1067, 1338, 911, 2811, 314, 5953, 1816, 402, 314, 12262, 12, 3980, 82, 14, 314, 1021, 1369, 14, 267, 408, 267, 754, 275, 1613, 8, 1198, 63, 12607, 63, 1188, 12, 291, 680, 362, 63, 585, 8, 1556, 12, 1747, 12, 221, 1402, 12, 522, 63, 344, 12, 1067, 29, 1100, 9, 267, 340, 1402, 315, 32501, 63, 11429, 51, 436, 522, 63, 344, 26, 288, 1402, 63, 1113, 275, 291, 14, 2293, 14, 362, 8, 1238, 9, 288, 666, 275, 1402, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 2360, 522, 63, 344, 12, 1067, 9, 288, 922, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 9, 288, 754, 14, 873, 2561, 490, 283, 5875, 7, 520, 666, 14, 354, 503, 756, 12, 490, 283, 2123, 63, 475, 7, 520, 666, 14, 2123, 63, 504, 503, 756, 12, 490, 283, 2123, 63, 504, 7, 520, 922, 14, 751, 63, 2123, 503, 7249, 14, 888, 14, 362, 360, 2123, 63, 504, 297, 756, 395, 490, 283, 2030, 63, 505, 7, 520, 1557, 78, 7, 435, 7249, 14, 11409, 8, 751, 14, 5233, 503, 9929, 490, 283, 2123, 63, 2055, 7, 520, 7249, 14, 11409, 8, 576, 14, 2123, 63, 2055, 503, 9929, 490, 283, 1238, 356, 1402, 12, 490, 283, 470, 63, 344, 356, 522, 63, 344, 12, 490, 283, 10512, 356, 283, 6104, 297, 355, 3828, 288, 340, 2688, 8, 576, 12, 283, 2792, 63, 344, 735, 355, 754, 14, 873, 3252, 8102, 63, 475, 7, 520, 666, 14, 2792, 63, 344, 436, 666, 14, 2792, 63, 344, 14, 8102, 63, 475, 503, 756, 1552, 267, 372, 754, 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, 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 ]
EvanK/ansible
lib/ansible/modules/cloud/openstack/os_quota.py
23
15745
#!/usr/bin/python # Copyright (c) 2016 Pason System Corporation # 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_quota short_description: Manage OpenStack Quotas extends_documentation_fragment: openstack version_added: "2.3" author: "Michael Gale (@mgale) <gale.michael@gmail.com>" description: - Manage OpenStack Quotas. Quotas can be created, updated or deleted using this module. A quota will be updated if matches an existing project and is present. options: name: description: - Name of the OpenStack Project to manage. required: true state: description: - A value of present sets the quota and a value of absent resets the quota to system defaults. default: present backup_gigabytes: description: Maximum size of backups in GB's. backups: description: Maximum number of backups allowed. cores: description: Maximum number of CPU's per project. fixed_ips: description: Number of fixed IP's to allow. floating_ips: description: Number of floating IP's to allow in Compute. aliases: ['compute_floating_ips'] floatingip: description: Number of floating IP's to allow in Network. aliases: ['network_floating_ips'] gigabytes: description: Maximum volume storage allowed for project. gigabytes_lvm: description: Maximum size in GB's of individual lvm volumes. injected_file_size: description: Maximum file size in bytes. injected_files: description: Number of injected files to allow. injected_path_size: description: Maximum path size. instances: description: Maximum number of instances allowed. key_pairs: description: Number of key pairs to allow. loadbalancer: description: Number of load balancers to allow. version_added: "2.4" network: description: Number of networks to allow. per_volume_gigabytes: description: Maximum size in GB's of individual volumes. pool: description: Number of load balancer pools to allow. version_added: "2.4" port: description: Number of Network ports to allow, this needs to be greater than the instances limit. properties: description: Number of properties to allow. ram: description: Maximum amount of ram in MB to allow. rbac_policy: description: Number of policies to allow. router: description: Number of routers to allow. security_group_rule: description: Number of rules per security group to allow. security_group: description: Number of security groups to allow. server_group_members: description: Number of server group members to allow. server_groups: description: Number of server groups to allow. snapshots: description: Number of snapshots to allow. snapshots_lvm: description: Number of LVM snapshots to allow. subnet: description: Number of subnets to allow. subnetpool: description: Number of subnet pools to allow. volumes: description: Number of volumes to allow. volumes_lvm: description: Number of LVM volumes to allow. availability_zone: description: - Ignored. Present for backwards compatibility requirements: - "python >= 2.7" - "openstacksdk >= 0.13.0" ''' EXAMPLES = ''' # List a Project Quota - os_quota: cloud: mycloud name: demoproject # Set a Project back to the defaults - os_quota: cloud: mycloud name: demoproject state: absent # Update a Project Quota for cores - os_quota: cloud: mycloud name: demoproject cores: 100 # Update a Project Quota - os_quota: name: demoproject cores: 1000 volumes: 20 volumes_type: - volume_lvm: 10 # Complete example based on list of projects - name: Update quotas os_quota: name: "{{ item.name }}" backup_gigabytes: "{{ item.backup_gigabytes }}" backups: "{{ item.backups }}" cores: "{{ item.cores }}" fixed_ips: "{{ item.fixed_ips }}" floating_ips: "{{ item.floating_ips }}" floatingip: "{{ item.floatingip }}" gigabytes: "{{ item.gigabytes }}" injected_file_size: "{{ item.injected_file_size }}" injected_files: "{{ item.injected_files }}" injected_path_size: "{{ item.injected_path_size }}" instances: "{{ item.instances }}" key_pairs: "{{ item.key_pairs }}" loadbalancer: "{{ item.loadbalancer }}" per_volume_gigabytes: "{{ item.per_volume_gigabytes }}" pool: "{{ item.pool }}" port: "{{ item.port }}" properties: "{{ item.properties }}" ram: "{{ item.ram }}" security_group_rule: "{{ item.security_group_rule }}" security_group: "{{ item.security_group }}" server_group_members: "{{ item.server_group_members }}" server_groups: "{{ item.server_groups }}" snapshots: "{{ item.snapshots }}" volumes: "{{ item.volumes }}" volumes_types: volumes_lvm: "{{ item.volumes_lvm }}" snapshots_types: snapshots_lvm: "{{ item.snapshots_lvm }}" gigabytes_types: gigabytes_lvm: "{{ item.gigabytes_lvm }}" with_items: - "{{ projects }}" when: item.state == "present" ''' RETURN = ''' openstack_quotas: description: Dictionary describing the project quota. returned: Regardless if changes where made or not type: complex contains: openstack_quotas: { compute: { cores: 150, fixed_ips: -1, floating_ips: 10, injected_file_content_bytes: 10240, injected_file_path_bytes: 255, injected_files: 5, instances: 100, key_pairs: 100, metadata_items: 128, ram: 153600, security_group_rules: 20, security_groups: 10, server_group_members: 10, server_groups: 10 }, network: { floatingip: 50, loadbalancer: 10, network: 10, pool: 10, port: 160, rbac_policy: 10, router: 10, security_group: 10, security_group_rule: 100, subnet: 10, subnetpool: -1 }, volume: { backup_gigabytes: 1000, backups: 10, gigabytes: 1000, gigabytes_lvm: -1, per_volume_gigabytes: -1, snapshots: 10, snapshots_lvm: -1, volumes: 10, volumes_lvm: -1 } } ''' 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 _get_volume_quotas(cloud, project): return cloud.get_volume_quotas(project) def _get_network_quotas(cloud, project): return cloud.get_network_quotas(project) def _get_compute_quotas(cloud, project): return cloud.get_compute_quotas(project) def _get_quotas(sdk, module, cloud, project): quota = {} try: quota['volume'] = _get_volume_quotas(cloud, project) except sdk.exceptions.NotFoundException: module.warn("No public endpoint for volumev2 service was found. Ignoring volume quotas.") try: quota['network'] = _get_network_quotas(cloud, project) except sdk.exceptions.NotFoundException: module.warn("No public endpoint for network service was found. Ignoring network quotas.") quota['compute'] = _get_compute_quotas(cloud, project) for quota_type in quota.keys(): quota[quota_type] = _scrub_results(quota[quota_type]) return quota def _scrub_results(quota): filter_attr = [ 'HUMAN_ID', 'NAME_ATTR', 'human_id', 'request_ids', 'x_openstack_request_ids', ] for attr in filter_attr: if attr in quota: del quota[attr] return quota def _system_state_change_details(module, project_quota_output): quota_change_request = {} changes_required = False for quota_type in project_quota_output.keys(): for quota_option in project_quota_output[quota_type].keys(): if quota_option in module.params and module.params[quota_option] is not None: if project_quota_output[quota_type][quota_option] != module.params[quota_option]: changes_required = True if quota_type not in quota_change_request: quota_change_request[quota_type] = {} quota_change_request[quota_type][quota_option] = module.params[quota_option] return (changes_required, quota_change_request) def _system_state_change(module, project_quota_output): """ Determine if changes are required to the current project quota. This is done by comparing the current project_quota_output against the desired quota settings set on the module params. """ changes_required, quota_change_request = _system_state_change_details( module, project_quota_output ) if changes_required: return True else: return False def main(): argument_spec = openstack_full_argument_spec( name=dict(required=True), state=dict(default='present', choices=['absent', 'present']), backup_gigabytes=dict(required=False, type='int', default=None), backups=dict(required=False, type='int', default=None), cores=dict(required=False, type='int', default=None), fixed_ips=dict(required=False, type='int', default=None), floating_ips=dict(required=False, type='int', default=None, aliases=['compute_floating_ips']), floatingip=dict(required=False, type='int', default=None, aliases=['network_floating_ips']), gigabytes=dict(required=False, type='int', default=None), gigabytes_types=dict(required=False, type='dict', default={}), injected_file_size=dict(required=False, type='int', default=None), injected_files=dict(required=False, type='int', default=None), injected_path_size=dict(required=False, type='int', default=None), instances=dict(required=False, type='int', default=None), key_pairs=dict(required=False, type='int', default=None), loadbalancer=dict(required=False, type='int', default=None), network=dict(required=False, type='int', default=None), per_volume_gigabytes=dict(required=False, type='int', default=None), pool=dict(required=False, type='int', default=None), port=dict(required=False, type='int', default=None), project=dict(required=False, type='int', default=None), properties=dict(required=False, type='int', default=None), ram=dict(required=False, type='int', default=None), rbac_policy=dict(required=False, type='int', default=None), router=dict(required=False, type='int', default=None), security_group_rule=dict(required=False, type='int', default=None), security_group=dict(required=False, type='int', default=None), server_group_members=dict(required=False, type='int', default=None), server_groups=dict(required=False, type='int', default=None), snapshots=dict(required=False, type='int', default=None), snapshots_types=dict(required=False, type='dict', default={}), subnet=dict(required=False, type='int', default=None), subnetpool=dict(required=False, type='int', default=None), volumes=dict(required=False, type='int', default=None), volumes_types=dict(required=False, type='dict', default={}) ) module = AnsibleModule(argument_spec, supports_check_mode=True ) sdk, cloud = openstack_cloud_from_module(module) try: cloud_params = dict(module.params) # In order to handle the different volume types we update module params after. dynamic_types = [ 'gigabytes_types', 'snapshots_types', 'volumes_types', ] for dynamic_type in dynamic_types: for k, v in module.params[dynamic_type].items(): module.params[k] = int(v) # Get current quota values project_quota_output = _get_quotas( sdk, module, cloud, cloud_params['name']) changes_required = False if module.params['state'] == "absent": # If a quota state is set to absent we should assume there will be changes. # The default quota values are not accessible so we can not determine if # no changes will occur or not. if module.check_mode: module.exit_json(changed=True) # Calling delete_network_quotas when a quota has not been set results # in an error, according to the sdk docs it should return the # current quota. # The following error string is returned: # network client call failed: Quota for tenant 69dd91d217e949f1a0b35a4b901741dc could not be found. neutron_msg1 = "network client call failed: Quota for tenant" neutron_msg2 = "could not be found" for quota_type in project_quota_output.keys(): quota_call = getattr(cloud, 'delete_%s_quotas' % (quota_type)) try: quota_call(cloud_params['name']) except sdk.exceptions.OpenStackCloudException as e: error_msg = str(e) if error_msg.find(neutron_msg1) > -1 and error_msg.find(neutron_msg2) > -1: pass else: module.fail_json(msg=str(e), extra_data=e.extra_data) project_quota_output = _get_quotas( sdk, module, cloud, cloud_params['name']) changes_required = True elif module.params['state'] == "present": if module.check_mode: module.exit_json(changed=_system_state_change(module, project_quota_output)) changes_required, quota_change_request = _system_state_change_details( module, project_quota_output ) if changes_required: for quota_type in quota_change_request.keys(): quota_call = getattr(cloud, 'set_%s_quotas' % (quota_type)) quota_call(cloud_params['name'], **quota_change_request[quota_type]) # Get quota state post changes for validation project_quota_update = _get_quotas( sdk, module, cloud, cloud_params['name']) if project_quota_output == project_quota_update: module.fail_json(msg='Could not apply quota update') project_quota_output = project_quota_update module.exit_json(changed=changes_required, openstack_quotas=project_quota_output ) except sdk.exceptions.OpenStackCloudException as e: module.fail_json(msg=str(e), extra_data=e.extra_data) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 7800, 510, 2660, 6187, 11098, 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, 8848, 199, 3612, 63, 1802, 26, 14944, 14260, 5843, 357, 305, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 45, 11781, 598, 1895, 8593, 6649, 1895, 9, 665, 71, 1895, 14, 22333, 32, 6799, 14, 957, 4335, 199, 1802, 26, 272, 446, 14944, 14260, 5843, 357, 305, 14, 5843, 357, 305, 883, 506, 2737, 12, 489, 4588, 503, 5463, 1808, 642, 859, 14, 437, 12132, 911, 506, 4588, 489, 340, 4450, 376, 3411, 2199, 436, 365, 3451, 14, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 14260, 7290, 370, 9635, 14, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 437, 574, 402, 3451, 5951, 314, 12132, 436, 282, 574, 402, 9552, 295, 2193, 314, 12132, 370, 2656, 4243, 14, 267, 849, 26, 3451, 272, 6902, 63, 71, 528, 27601, 26, 267, 1369, 26, 14212, 1568, 402, 6902, 83, 315, 18553, 1159, 14, 272, 6902, 83, 26, 267, 1369, 26, 14212, 1329, 402, 6902, 83, 4370, 14, 272, 23857, 26, 267, 1369, 26, 14212, 1329, 402, 11952, 1159, 1126, 2199, 14, 272, 6317, 63, 6142, 26, 267, 1369, 26, 4860, 402, 6317, 3531, 1159, 370, 2040, 14, 272, 8402, 63, 6142, 26, 267, 1369, 26, 4860, 402, 8402, 3531, 1159, 370, 2040, 315, 8354, 14, 267, 5481, 26, 788, 3357, 63, 7774, 63, 6142, 418, 272, 8402, 711, 26, 267, 1369, 26, 4860, 402, 8402, 3531, 1159, 370, 2040, 315, 7220, 14, 267, 5481, 26, 788, 1200, 63, 7774, 63, 6142, 418, 272, 486, 528, 27601, 26, 267, 1369, 26, 14212, 3301, 4887, 4370, 367, 2199, 14, 272, 486, 528, 27601, 63, 31283, 26, 267, 1369, 26, 14212, 1568, 315, 18553, 1159, 402, 8212, 634, 2611, 12158, 14, 272, 26121, 63, 493, 63, 890, 26, 267, 1369, 26, 14212, 570, 1568, 315, 2783, 14, 272, 26121, 63, 1725, 26, 267, 1369, 26, 4860, 402, 26121, 1584, 370, 2040, 14, 272, 26121, 63, 515, 63, 890, 26, 267, 1369, 26, 14212, 931, 1568, 14, 272, 4454, 26, 267, 1369, 26, 14212, 1329, 402, 4454, 4370, 14, 272, 790, 63, 7322, 26, 267, 1369, 26, 4860, 402, 790, 6342, 370, 2040, 14, 272, 2248, 11841, 26, 267, 1369, 26, 4860, 402, 2248, 8091, 23102, 370, 2040, 14, 267, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 2784, 26, 267, 1369, 26, 4860, 402, 11759, 370, 2040, 14, 272, 1126, 63, 2405, 63, 71, 528, 27601, 26, 267, 1369, 26, 14212, 1568, 315, 18553, 1159, 402, 8212, 12158, 14, 272, 4203, 26, 267, 1369, 26, 4860, 402, 2248, 17005, 20092, 370, 2040, 14, 267, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 1844, 26, 267, 1369, 26, 4860, 402, 7220, 8873, 370, 2040, 12, 642, 4839, 370, 506, 8932, 2419, 314, 4454, 2304, 14, 272, 4382, 26, 267, 1369, 26, 4860, 402, 4382, 370, 2040, 14, 272, 21394, 26, 267, 1369, 26, 14212, 5982, 402, 21394, 315, 19487, 370, 2040, 14, 272, 11587, 645, 63, 3185, 26, 267, 1369, 26, 4860, 402, 14118, 370, 2040, 14, 272, 6197, 26, 267, 1369, 26, 4860, 402, 24464, 370, 2040, 14, 272, 6391, 63, 923, 63, 2200, 26, 267, 1369, 26, 4860, 402, 4713, 1126, 6391, 1572, 370, 2040, 14, 272, 6391, 63, 923, 26, 267, 1369, 26, 4860, 402, 6391, 4652, 370, 2040, 14, 272, 1654, 63, 923, 63, 6334, 26, 267, 1369, 26, 4860, 402, 1654, 1572, 7556, 370, 2040, 14, 272, 1654, 63, 2634, 26, 267, 1369, 26, 4860, 402, 1654, 4652, 370, 2040, 14, 272, 19076, 26, 267, 1369, 26, 4860, 402, 19076, 370, 2040, 14, 272, 19076, 63, 31283, 26, 267, 1369, 26, 4860, 402, 491, 6849, 19076, 370, 2040, 14, 272, 6303, 26, 267, 1369, 26, 4860, 402, 18709, 370, 2040, 14, 272, 6303, 2293, 26, 267, 1369, 26, 4860, 402, 6303, 20092, 370, 2040, 14, 272, 12158, 26, 267, 1369, 26, 4860, 402, 12158, 370, 2040, 14, 272, 12158, 63, 31283, 26, 267, 1369, 26, 4860, 402, 491, 6849, 12158, 370, 2040, 14, 272, 14962, 63, 2619, 26, 489, 1369, 26, 267, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 421, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 23, 2, 272, 446, 298, 8512, 9277, 2356, 378, 14, 969, 14, 16, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3820, 282, 7290, 5843, 12041, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 199, 199, 3, 2494, 282, 7290, 1771, 370, 314, 4243, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 272, 1174, 26, 9552, 199, 199, 3, 6162, 282, 7290, 5843, 12041, 367, 23857, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 272, 23857, 26, 2948, 199, 199, 3, 6162, 282, 7290, 5843, 12041, 199, 13, 747, 63, 8848, 26, 272, 536, 26, 28548, 13798, 272, 23857, 26, 5198, 272, 12158, 26, 3388, 272, 12158, 63, 466, 26, 489, 446, 3301, 63, 31283, 26, 1616, 199, 199, 3, 28393, 2893, 4079, 641, 769, 402, 11336, 199, 13, 536, 26, 6162, 22874, 523, 747, 63, 8848, 26, 272, 536, 26, 7370, 1242, 14, 354, 7820, 272, 6902, 63, 71, 528, 27601, 26, 7370, 1242, 14, 5751, 63, 71, 528, 27601, 7820, 272, 6902, 83, 26, 7370, 1242, 14, 27376, 7820, 272, 23857 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 7800, 510, 2660, 6187, 11098, 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, 8848, 199, 3612, 63, 1802, 26, 14944, 14260, 5843, 357, 305, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 45, 11781, 598, 1895, 8593, 6649, 1895, 9, 665, 71, 1895, 14, 22333, 32, 6799, 14, 957, 4335, 199, 1802, 26, 272, 446, 14944, 14260, 5843, 357, 305, 14, 5843, 357, 305, 883, 506, 2737, 12, 489, 4588, 503, 5463, 1808, 642, 859, 14, 437, 12132, 911, 506, 4588, 489, 340, 4450, 376, 3411, 2199, 436, 365, 3451, 14, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 14260, 7290, 370, 9635, 14, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 437, 574, 402, 3451, 5951, 314, 12132, 436, 282, 574, 402, 9552, 295, 2193, 314, 12132, 370, 2656, 4243, 14, 267, 849, 26, 3451, 272, 6902, 63, 71, 528, 27601, 26, 267, 1369, 26, 14212, 1568, 402, 6902, 83, 315, 18553, 1159, 14, 272, 6902, 83, 26, 267, 1369, 26, 14212, 1329, 402, 6902, 83, 4370, 14, 272, 23857, 26, 267, 1369, 26, 14212, 1329, 402, 11952, 1159, 1126, 2199, 14, 272, 6317, 63, 6142, 26, 267, 1369, 26, 4860, 402, 6317, 3531, 1159, 370, 2040, 14, 272, 8402, 63, 6142, 26, 267, 1369, 26, 4860, 402, 8402, 3531, 1159, 370, 2040, 315, 8354, 14, 267, 5481, 26, 788, 3357, 63, 7774, 63, 6142, 418, 272, 8402, 711, 26, 267, 1369, 26, 4860, 402, 8402, 3531, 1159, 370, 2040, 315, 7220, 14, 267, 5481, 26, 788, 1200, 63, 7774, 63, 6142, 418, 272, 486, 528, 27601, 26, 267, 1369, 26, 14212, 3301, 4887, 4370, 367, 2199, 14, 272, 486, 528, 27601, 63, 31283, 26, 267, 1369, 26, 14212, 1568, 315, 18553, 1159, 402, 8212, 634, 2611, 12158, 14, 272, 26121, 63, 493, 63, 890, 26, 267, 1369, 26, 14212, 570, 1568, 315, 2783, 14, 272, 26121, 63, 1725, 26, 267, 1369, 26, 4860, 402, 26121, 1584, 370, 2040, 14, 272, 26121, 63, 515, 63, 890, 26, 267, 1369, 26, 14212, 931, 1568, 14, 272, 4454, 26, 267, 1369, 26, 14212, 1329, 402, 4454, 4370, 14, 272, 790, 63, 7322, 26, 267, 1369, 26, 4860, 402, 790, 6342, 370, 2040, 14, 272, 2248, 11841, 26, 267, 1369, 26, 4860, 402, 2248, 8091, 23102, 370, 2040, 14, 267, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 2784, 26, 267, 1369, 26, 4860, 402, 11759, 370, 2040, 14, 272, 1126, 63, 2405, 63, 71, 528, 27601, 26, 267, 1369, 26, 14212, 1568, 315, 18553, 1159, 402, 8212, 12158, 14, 272, 4203, 26, 267, 1369, 26, 4860, 402, 2248, 17005, 20092, 370, 2040, 14, 267, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 1844, 26, 267, 1369, 26, 4860, 402, 7220, 8873, 370, 2040, 12, 642, 4839, 370, 506, 8932, 2419, 314, 4454, 2304, 14, 272, 4382, 26, 267, 1369, 26, 4860, 402, 4382, 370, 2040, 14, 272, 21394, 26, 267, 1369, 26, 14212, 5982, 402, 21394, 315, 19487, 370, 2040, 14, 272, 11587, 645, 63, 3185, 26, 267, 1369, 26, 4860, 402, 14118, 370, 2040, 14, 272, 6197, 26, 267, 1369, 26, 4860, 402, 24464, 370, 2040, 14, 272, 6391, 63, 923, 63, 2200, 26, 267, 1369, 26, 4860, 402, 4713, 1126, 6391, 1572, 370, 2040, 14, 272, 6391, 63, 923, 26, 267, 1369, 26, 4860, 402, 6391, 4652, 370, 2040, 14, 272, 1654, 63, 923, 63, 6334, 26, 267, 1369, 26, 4860, 402, 1654, 1572, 7556, 370, 2040, 14, 272, 1654, 63, 2634, 26, 267, 1369, 26, 4860, 402, 1654, 4652, 370, 2040, 14, 272, 19076, 26, 267, 1369, 26, 4860, 402, 19076, 370, 2040, 14, 272, 19076, 63, 31283, 26, 267, 1369, 26, 4860, 402, 491, 6849, 19076, 370, 2040, 14, 272, 6303, 26, 267, 1369, 26, 4860, 402, 18709, 370, 2040, 14, 272, 6303, 2293, 26, 267, 1369, 26, 4860, 402, 6303, 20092, 370, 2040, 14, 272, 12158, 26, 267, 1369, 26, 4860, 402, 12158, 370, 2040, 14, 272, 12158, 63, 31283, 26, 267, 1369, 26, 4860, 402, 491, 6849, 12158, 370, 2040, 14, 272, 14962, 63, 2619, 26, 489, 1369, 26, 267, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 421, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 23, 2, 272, 446, 298, 8512, 9277, 2356, 378, 14, 969, 14, 16, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 3820, 282, 7290, 5843, 12041, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 199, 199, 3, 2494, 282, 7290, 1771, 370, 314, 4243, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 272, 1174, 26, 9552, 199, 199, 3, 6162, 282, 7290, 5843, 12041, 367, 23857, 199, 13, 747, 63, 8848, 26, 272, 8002, 26, 3002, 4091, 272, 536, 26, 28548, 13798, 272, 23857, 26, 2948, 199, 199, 3, 6162, 282, 7290, 5843, 12041, 199, 13, 747, 63, 8848, 26, 272, 536, 26, 28548, 13798, 272, 23857, 26, 5198, 272, 12158, 26, 3388, 272, 12158, 63, 466, 26, 489, 446, 3301, 63, 31283, 26, 1616, 199, 199, 3, 28393, 2893, 4079, 641, 769, 402, 11336, 199, 13, 536, 26, 6162, 22874, 523, 747, 63, 8848, 26, 272, 536, 26, 7370, 1242, 14, 354, 7820, 272, 6902, 63, 71, 528, 27601, 26, 7370, 1242, 14, 5751, 63, 71, 528, 27601, 7820, 272, 6902, 83, 26, 7370, 1242, 14, 27376, 7820, 272, 23857, 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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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 ]
yiducn/airvis
src/main/webapp/js/OpenLayers-2.13.1/tests/selenium/remotecontrol/test_ol.py
254
2873
from selenium import selenium import time import sys from ConfigParser import ConfigParser MAX_TEST_LENGTH = 300 if len(sys.argv) > 2: filename = sys.argv[2] else: filename = "config.cfg" c = ConfigParser() c.read(filename) targets = {} server = c.get('config', 'server') url= c.get('config', 'url') if c.has_option('config', 'timeout'): MAX_TEST_LENGTH = int(c.get('config', 'timeout')) sections = c.sections() for s in sections: if s == 'config': continue targets[s] = dict(c.items(s)) targets[s]['name'] = s if sys.argv[1] == "all": browsers = list(targets.values()) elif sys.argv[1] not in targets: print "Invalid target" sys.exit() else: browsers = [targets[sys.argv[1]]] keep_going = True if 1: for b in browsers: if not keep_going: continue print "Running %s on %s" % (b['name'], b['host']) s = selenium(b['host'], 4444, "*%s" % b['browsercmd'], server) s.start() try: s.open_window(url, "test_running") time.sleep(2) s.select_window("test_running") time.sleep(2) s.refresh() count = 0 while count == 0: count = int(s.get_eval("window.document.getElementById('testtable').getElementsByTagName('tr').length")) time.sleep(5) ok = 0 fail = 0 last_change = time.time() while True: new_ok = int(s.get_eval('window.Test.AnotherWay._g_ok_pages')) new_fail = int(s.get_eval('window.Test.AnotherWay._g_fail_pages')) if new_ok != ok or new_fail != fail: ok = new_ok fail = new_fail last_change = time.time() if (ok + fail) >= count: break if time.time() - last_change > MAX_TEST_LENGTH: raise Exception("Failed: with %s okay and %s failed, ran out of time: %s is more than %s" % (ok, fail, (time.time() - last_change), MAX_TEST_LENGTH)) time.sleep(10) if fail: print "Failed: %s" % fail html = s.get_eval("window.document.getElementById('results').innerHTML").encode("utf-8") all_html = """<html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> </head> <body>%s</body></html>""" % html f = open("fail.%s.%s.html" % (time.time(), b['name']), "w") f.write(all_html) f.close() except KeyboardInterrupt, E: keep_going = False print "Stopped by keyboard interrupt" except Exception, E: print "Error: ", E s.stop()
agpl-3.0
[ 504, 19481, 492, 19481, 199, 646, 900, 199, 646, 984, 199, 504, 14196, 492, 14196, 199, 199, 4283, 63, 2864, 63, 9127, 275, 9601, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 5591, 1788, 275, 984, 14, 3020, 59, 18, 61, 199, 2836, 26, 272, 1788, 275, 298, 888, 14, 4128, 2, 199, 199, 67, 275, 14196, 342, 199, 67, 14, 739, 8, 1501, 9, 199, 199, 4684, 275, 1052, 199, 199, 1000, 275, 286, 14, 362, 360, 888, 297, 283, 1000, 358, 221, 199, 633, 29, 286, 14, 362, 360, 888, 297, 283, 633, 358, 199, 692, 286, 14, 1989, 63, 1422, 360, 888, 297, 283, 2593, 735, 272, 9141, 63, 2864, 63, 9127, 275, 1109, 8, 67, 14, 362, 360, 888, 297, 283, 2593, 1333, 421, 199, 7786, 275, 286, 14, 7786, 342, 199, 509, 308, 315, 10189, 26, 272, 340, 308, 508, 283, 888, 356, 2126, 1980, 272, 4545, 59, 83, 61, 275, 1211, 8, 67, 14, 1744, 8, 83, 430, 272, 4545, 59, 83, 2733, 354, 418, 275, 308, 199, 199, 692, 984, 14, 3020, 59, 17, 61, 508, 298, 452, 582, 272, 23776, 275, 769, 8, 4684, 14, 1459, 1012, 199, 4164, 984, 14, 3020, 59, 17, 61, 440, 315, 4545, 26, 272, 870, 298, 3364, 1347, 2, 272, 984, 14, 2224, 342, 199, 2836, 26, 14821, 23776, 275, 359, 4684, 59, 1274, 14, 3020, 59, 17, 20737, 199, 199, 3250, 63, 10947, 275, 715, 199, 199, 692, 413, 26, 272, 367, 330, 315, 23776, 26, 267, 340, 440, 4215, 63, 10947, 26, 7205, 1980, 398, 870, 298, 9602, 450, 83, 641, 450, 83, 2, 450, 334, 66, 459, 354, 995, 330, 459, 1102, 1105, 4960, 308, 275, 19481, 8, 66, 459, 1102, 995, 841, 18078, 12, 8969, 5, 83, 2, 450, 330, 459, 5750, 1760, 995, 1654, 9, 267, 308, 14, 928, 342, 267, 862, 26, 288, 308, 14, 1490, 63, 3806, 8, 633, 12, 298, 396, 63, 5720, 531, 288, 900, 14, 4532, 8, 18, 9, 288, 308, 14, 2416, 63, 3806, 480, 396, 63, 5720, 531, 288, 900, 14, 4532, 8, 18, 9, 288, 308, 14, 6635, 342, 7846, 2338, 275, 378, 288, 1830, 2338, 508, 378, 26, 8892, 2338, 275, 1109, 8, 83, 14, 362, 63, 2579, 480, 3806, 14, 3554, 14, 26215, 360, 396, 1224, 1959, 15045, 360, 454, 1959, 1267, 2237, 355, 900, 14, 4532, 8, 21, 9, 24850, 4112, 275, 378, 7205, 2449, 275, 378, 288, 2061, 63, 1461, 275, 900, 14, 521, 342, 288, 1830, 715, 26, 355, 892, 63, 745, 275, 1109, 8, 83, 14, 362, 63, 2579, 360, 3806, 14, 774, 14, 23296, 25544, 423, 71, 63, 745, 63, 5856, 1333, 355, 892, 63, 1633, 275, 1109, 8, 83, 14, 362, 63, 2579, 360, 3806, 14, 774, 14, 23296, 25544, 423, 71, 63, 1633, 63, 5856, 1333, 355, 340, 892, 63, 745, 1137, 4112, 503, 892, 63, 1633, 1137, 2449, 26, 490, 4112, 275, 892, 63, 745, 490, 2449, 275, 892, 63, 1633, 490, 2061, 63, 1461, 275, 900, 14, 521, 342, 2151, 355, 340, 334, 745, 435, 2449, 9, 2356, 2338, 26, 490, 2059, 8892, 340, 900, 14, 521, 342, 446, 2061, 63, 1461, 690, 9141, 63, 2864, 63, 9127, 26, 490, 746, 2186, 480, 4276, 26, 543, 450, 83, 5849, 436, 450, 83, 3405, 12, 21471, 734, 402, 900, 26, 450, 83, 365, 1655, 2419, 450, 83, 2, 450, 334, 745, 12, 2449, 12, 334, 521, 14, 521, 342, 446, 2061, 63, 1461, 395, 9141, 63, 2864, 63, 9127, 430, 755, 355, 900, 14, 4532, 8, 709, 9, 7846, 340, 2449, 26, 355, 870, 298, 4276, 26, 450, 83, 2, 450, 2449, 355, 3517, 275, 308, 14, 362, 63, 2579, 480, 3806, 14, 3554, 14, 26215, 360, 2604, 1959, 26502, 3471, 2143, 480, 1624, 13, 24, 531, 355, 1006, 63, 1360, 275, 8894, 1360, 30, 523, 665, 2993, 30, 14821, 665, 2024, 1564, 628, 505, 15, 1360, 27, 5960, 29, 1624, 13, 24, 2, 1455, 13, 20146, 628, 1317, 13, 466, 2, 7082, 523, 3068, 2993, 30, 523, 665, 2030, 6598, 83, 1108, 2030, 2957, 1360, 11193, 450, 3517, 2234, 289, 275, 1551, 480, 1633, 4111, 83, 4111, 83, 14, 1360, 2, 450, 334, 521, 14, 521, 1062, 330, 459, 354, 3815, 298, 87, 531, 355, 289, 14, 952, 8, 452, 63, 1360, 9, 355, 289, 14, 1600, 342, 267, 871, 13483, 12, 662, 26, 288, 4215, 63, 10947, 275, 756, 288, 870, 298, 28500, 701, 18716, 26791, 2, 267, 871, 2186, 12, 662, 26, 288, 870, 298, 547, 26, 3872, 662, 267, 308, 14, 2379, 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 ]
[ 19481, 492, 19481, 199, 646, 900, 199, 646, 984, 199, 504, 14196, 492, 14196, 199, 199, 4283, 63, 2864, 63, 9127, 275, 9601, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 5591, 1788, 275, 984, 14, 3020, 59, 18, 61, 199, 2836, 26, 272, 1788, 275, 298, 888, 14, 4128, 2, 199, 199, 67, 275, 14196, 342, 199, 67, 14, 739, 8, 1501, 9, 199, 199, 4684, 275, 1052, 199, 199, 1000, 275, 286, 14, 362, 360, 888, 297, 283, 1000, 358, 221, 199, 633, 29, 286, 14, 362, 360, 888, 297, 283, 633, 358, 199, 692, 286, 14, 1989, 63, 1422, 360, 888, 297, 283, 2593, 735, 272, 9141, 63, 2864, 63, 9127, 275, 1109, 8, 67, 14, 362, 360, 888, 297, 283, 2593, 1333, 421, 199, 7786, 275, 286, 14, 7786, 342, 199, 509, 308, 315, 10189, 26, 272, 340, 308, 508, 283, 888, 356, 2126, 1980, 272, 4545, 59, 83, 61, 275, 1211, 8, 67, 14, 1744, 8, 83, 430, 272, 4545, 59, 83, 2733, 354, 418, 275, 308, 199, 199, 692, 984, 14, 3020, 59, 17, 61, 508, 298, 452, 582, 272, 23776, 275, 769, 8, 4684, 14, 1459, 1012, 199, 4164, 984, 14, 3020, 59, 17, 61, 440, 315, 4545, 26, 272, 870, 298, 3364, 1347, 2, 272, 984, 14, 2224, 342, 199, 2836, 26, 14821, 23776, 275, 359, 4684, 59, 1274, 14, 3020, 59, 17, 20737, 199, 199, 3250, 63, 10947, 275, 715, 199, 199, 692, 413, 26, 272, 367, 330, 315, 23776, 26, 267, 340, 440, 4215, 63, 10947, 26, 7205, 1980, 398, 870, 298, 9602, 450, 83, 641, 450, 83, 2, 450, 334, 66, 459, 354, 995, 330, 459, 1102, 1105, 4960, 308, 275, 19481, 8, 66, 459, 1102, 995, 841, 18078, 12, 8969, 5, 83, 2, 450, 330, 459, 5750, 1760, 995, 1654, 9, 267, 308, 14, 928, 342, 267, 862, 26, 288, 308, 14, 1490, 63, 3806, 8, 633, 12, 298, 396, 63, 5720, 531, 288, 900, 14, 4532, 8, 18, 9, 288, 308, 14, 2416, 63, 3806, 480, 396, 63, 5720, 531, 288, 900, 14, 4532, 8, 18, 9, 288, 308, 14, 6635, 342, 7846, 2338, 275, 378, 288, 1830, 2338, 508, 378, 26, 8892, 2338, 275, 1109, 8, 83, 14, 362, 63, 2579, 480, 3806, 14, 3554, 14, 26215, 360, 396, 1224, 1959, 15045, 360, 454, 1959, 1267, 2237, 355, 900, 14, 4532, 8, 21, 9, 24850, 4112, 275, 378, 7205, 2449, 275, 378, 288, 2061, 63, 1461, 275, 900, 14, 521, 342, 288, 1830, 715, 26, 355, 892, 63, 745, 275, 1109, 8, 83, 14, 362, 63, 2579, 360, 3806, 14, 774, 14, 23296, 25544, 423, 71, 63, 745, 63, 5856, 1333, 355, 892, 63, 1633, 275, 1109, 8, 83, 14, 362, 63, 2579, 360, 3806, 14, 774, 14, 23296, 25544, 423, 71, 63, 1633, 63, 5856, 1333, 355, 340, 892, 63, 745, 1137, 4112, 503, 892, 63, 1633, 1137, 2449, 26, 490, 4112, 275, 892, 63, 745, 490, 2449, 275, 892, 63, 1633, 490, 2061, 63, 1461, 275, 900, 14, 521, 342, 2151, 355, 340, 334, 745, 435, 2449, 9, 2356, 2338, 26, 490, 2059, 8892, 340, 900, 14, 521, 342, 446, 2061, 63, 1461, 690, 9141, 63, 2864, 63, 9127, 26, 490, 746, 2186, 480, 4276, 26, 543, 450, 83, 5849, 436, 450, 83, 3405, 12, 21471, 734, 402, 900, 26, 450, 83, 365, 1655, 2419, 450, 83, 2, 450, 334, 745, 12, 2449, 12, 334, 521, 14, 521, 342, 446, 2061, 63, 1461, 395, 9141, 63, 2864, 63, 9127, 430, 755, 355, 900, 14, 4532, 8, 709, 9, 7846, 340, 2449, 26, 355, 870, 298, 4276, 26, 450, 83, 2, 450, 2449, 355, 3517, 275, 308, 14, 362, 63, 2579, 480, 3806, 14, 3554, 14, 26215, 360, 2604, 1959, 26502, 3471, 2143, 480, 1624, 13, 24, 531, 355, 1006, 63, 1360, 275, 8894, 1360, 30, 523, 665, 2993, 30, 14821, 665, 2024, 1564, 628, 505, 15, 1360, 27, 5960, 29, 1624, 13, 24, 2, 1455, 13, 20146, 628, 1317, 13, 466, 2, 7082, 523, 3068, 2993, 30, 523, 665, 2030, 6598, 83, 1108, 2030, 2957, 1360, 11193, 450, 3517, 2234, 289, 275, 1551, 480, 1633, 4111, 83, 4111, 83, 14, 1360, 2, 450, 334, 521, 14, 521, 1062, 330, 459, 354, 3815, 298, 87, 531, 355, 289, 14, 952, 8, 452, 63, 1360, 9, 355, 289, 14, 1600, 342, 267, 871, 13483, 12, 662, 26, 288, 4215, 63, 10947, 275, 756, 288, 870, 298, 28500, 701, 18716, 26791, 2, 267, 871, 2186, 12, 662, 26, 288, 870, 298, 547, 26, 3872, 662, 267, 308, 14, 2379, 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, 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,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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 ]
mlperf/training_results_v0.6
Fujitsu/benchmarks/resnet/implementations/mxnet/example/image-classification/train_imagenet_dali.py
1
2782
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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 os import argparse import logging logging.basicConfig(level=logging.DEBUG) from common import find_mxnet, data, dali, fit from common.util import download_file import mxnet as mx import numpy as np from gluoncv.model_zoo import get_model if __name__ == '__main__': # parse args parser = argparse.ArgumentParser(description="train imagenet-1k", formatter_class=argparse.ArgumentDefaultsHelpFormatter) fit.add_fit_args(parser) data.add_data_args(parser) dali.add_dali_args(parser) data.add_data_aug_args(parser) # set to 0 for standard resnet augmentation data.set_data_aug_level(parser, 0) parser.set_defaults( # network network = 'resnet', num_layers = 50, # data num_classes = 1000, num_examples = 1281167, image_shape = '4,224,224', min_random_scale = 1, # if input image has min size k, suggest to use # 256.0/x, e.g. 0.533 for 480 # train num_epochs = 90, lr_step_epochs = '30,60,80', dtype = 'float32' ) args = parser.parse_args() # load network from importlib import import_module if args.network == "resnet-v1b" and args.num_layers == 50: net = get_model('resnet50_v1b', ctx=[mx.gpu(int(i)) for i in args.gpus.split(',')], pretrained=False, classes=args.num_classes, last_gamma=args.bn_gamma_init0) d = mx.sym.var('data') if args.dtype == 'float16': d = mx.sym.Cast(data=d, dtype=np.float16) net.cast(args.dtype) out = net(d) if args.dtype == 'float16': out = mx.sym.Cast(data=out, dtype=np.float32) sym = mx.sym.SoftmaxOutput(out, name='softmax') else: net = import_module('symbols.'+args.network) sym = net.get_symbol(**vars(args)) # train fit.fit(args, sym, dali.get_rec_iter)
apache-2.0
[ 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 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, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 7534, 199, 646, 2050, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 199, 504, 2863, 492, 2342, 63, 9457, 846, 12, 666, 12, 366, 10874, 12, 5542, 199, 504, 2863, 14, 1974, 492, 5235, 63, 493, 199, 646, 8728, 846, 465, 8728, 199, 646, 2680, 465, 980, 199, 504, 26752, 5107, 14, 1238, 63, 90, 1534, 492, 664, 63, 1238, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 2198, 1249, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 2834, 18884, 2268, 386, 13, 17, 75, 401, 3660, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 272, 5542, 14, 525, 63, 3269, 63, 589, 8, 2087, 9, 272, 666, 14, 525, 63, 576, 63, 589, 8, 2087, 9, 272, 366, 10874, 14, 525, 63, 68, 10874, 63, 589, 8, 2087, 9, 272, 666, 14, 525, 63, 576, 63, 20669, 63, 589, 8, 2087, 9, 272, 327, 663, 370, 378, 367, 4465, 522, 846, 18336, 3117, 272, 666, 14, 409, 63, 576, 63, 20669, 63, 1896, 8, 2087, 12, 378, 9, 272, 1798, 14, 409, 63, 4322, 8, 267, 327, 2784, 267, 2784, 3515, 275, 283, 28998, 297, 267, 1967, 63, 4359, 755, 275, 5238, 12, 267, 327, 666, 267, 1967, 63, 2888, 420, 275, 5198, 12, 267, 1967, 63, 8589, 258, 275, 7960, 845, 1822, 12, 267, 1834, 63, 1392, 420, 275, 283, 20, 12, 8731, 12, 8731, 297, 267, 1748, 63, 2355, 63, 3467, 275, 413, 12, 327, 340, 1324, 1834, 965, 1748, 1568, 1022, 12, 18453, 370, 675, 2892, 327, 7633, 14, 16, 15, 88, 12, 325, 14, 71, 14, 378, 14, 25293, 367, 29504, 267, 327, 3560, 267, 1967, 63, 13161, 755, 275, 9137, 12, 267, 13645, 63, 2926, 63, 13161, 257, 275, 283, 1216, 12, 2259, 12, 1257, 297, 267, 2152, 3322, 275, 283, 1609, 708, 7, 272, 776, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 327, 2248, 2784, 272, 687, 14802, 492, 492, 63, 578, 272, 340, 1249, 14, 1200, 508, 298, 28998, 13, 86, 17, 66, 2, 436, 1249, 14, 1507, 63, 4359, 508, 5238, 26, 267, 1851, 275, 664, 63, 1238, 360, 28998, 1400, 63, 86, 17, 66, 297, 4027, 1524, 9457, 14, 6477, 8, 442, 8, 73, 430, 367, 284, 315, 1249, 14, 23652, 14, 1294, 5102, 2665, 717, 876, 23782, 29, 797, 12, 3992, 29, 589, 14, 1507, 63, 2888, 12, 2061, 63, 7325, 29, 589, 14, 10472, 63, 7325, 63, 826, 16, 9, 267, 366, 275, 8728, 14, 3840, 14, 1391, 360, 576, 358, 267, 340, 1249, 14, 2271, 508, 283, 1609, 975, 356, 288, 366, 275, 8728, 14, 3840, 14, 24654, 8, 576, 29, 68, 12, 2152, 29, 1590, 14, 1609, 975, 9, 267, 1851, 14, 2931, 8, 589, 14, 2271, 9, 267, 734, 275, 1851, 8, 68, 9, 267, 340, 1249, 14, 2271, 508, 283, 1609, 975, 356, 288, 734, 275, 8728, 14, 3840, 14, 24654, 8, 576, 29, 548, 12, 2152, 29, 1590, 14, 1609, 708, 9, 267, 4678, 275, 8728, 14, 3840, 14, 19302, 988, 2959, 8, 548, 12, 536, 534, 16395, 358, 272, 587, 26, 267, 1851, 275, 492, 63, 578, 360, 7450, 3530, 11, 589, 14, 1200, 9, 267, 4678, 275, 1851, 14, 362, 63, 5155, 3682, 2936, 8, 589, 430, 339, 327, 3560, 272, 5542, 14, 3269, 8, 589, 12, 4678, 12, 366, 10874, 14, 362, 63, 2761, 63, 1661, 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 ]
[ 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 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, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 646, 7534, 199, 646, 2050, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 199, 504, 2863, 492, 2342, 63, 9457, 846, 12, 666, 12, 366, 10874, 12, 5542, 199, 504, 2863, 14, 1974, 492, 5235, 63, 493, 199, 646, 8728, 846, 465, 8728, 199, 646, 2680, 465, 980, 199, 504, 26752, 5107, 14, 1238, 63, 90, 1534, 492, 664, 63, 1238, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 2198, 1249, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 2834, 18884, 2268, 386, 13, 17, 75, 401, 3660, 9698, 63, 533, 29, 18978, 14, 5201, 16986, 22779, 9, 272, 5542, 14, 525, 63, 3269, 63, 589, 8, 2087, 9, 272, 666, 14, 525, 63, 576, 63, 589, 8, 2087, 9, 272, 366, 10874, 14, 525, 63, 68, 10874, 63, 589, 8, 2087, 9, 272, 666, 14, 525, 63, 576, 63, 20669, 63, 589, 8, 2087, 9, 272, 327, 663, 370, 378, 367, 4465, 522, 846, 18336, 3117, 272, 666, 14, 409, 63, 576, 63, 20669, 63, 1896, 8, 2087, 12, 378, 9, 272, 1798, 14, 409, 63, 4322, 8, 267, 327, 2784, 267, 2784, 3515, 275, 283, 28998, 297, 267, 1967, 63, 4359, 755, 275, 5238, 12, 267, 327, 666, 267, 1967, 63, 2888, 420, 275, 5198, 12, 267, 1967, 63, 8589, 258, 275, 7960, 845, 1822, 12, 267, 1834, 63, 1392, 420, 275, 283, 20, 12, 8731, 12, 8731, 297, 267, 1748, 63, 2355, 63, 3467, 275, 413, 12, 327, 340, 1324, 1834, 965, 1748, 1568, 1022, 12, 18453, 370, 675, 2892, 327, 7633, 14, 16, 15, 88, 12, 325, 14, 71, 14, 378, 14, 25293, 367, 29504, 267, 327, 3560, 267, 1967, 63, 13161, 755, 275, 9137, 12, 267, 13645, 63, 2926, 63, 13161, 257, 275, 283, 1216, 12, 2259, 12, 1257, 297, 267, 2152, 3322, 275, 283, 1609, 708, 7, 272, 776, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 327, 2248, 2784, 272, 687, 14802, 492, 492, 63, 578, 272, 340, 1249, 14, 1200, 508, 298, 28998, 13, 86, 17, 66, 2, 436, 1249, 14, 1507, 63, 4359, 508, 5238, 26, 267, 1851, 275, 664, 63, 1238, 360, 28998, 1400, 63, 86, 17, 66, 297, 4027, 1524, 9457, 14, 6477, 8, 442, 8, 73, 430, 367, 284, 315, 1249, 14, 23652, 14, 1294, 5102, 2665, 717, 876, 23782, 29, 797, 12, 3992, 29, 589, 14, 1507, 63, 2888, 12, 2061, 63, 7325, 29, 589, 14, 10472, 63, 7325, 63, 826, 16, 9, 267, 366, 275, 8728, 14, 3840, 14, 1391, 360, 576, 358, 267, 340, 1249, 14, 2271, 508, 283, 1609, 975, 356, 288, 366, 275, 8728, 14, 3840, 14, 24654, 8, 576, 29, 68, 12, 2152, 29, 1590, 14, 1609, 975, 9, 267, 1851, 14, 2931, 8, 589, 14, 2271, 9, 267, 734, 275, 1851, 8, 68, 9, 267, 340, 1249, 14, 2271, 508, 283, 1609, 975, 356, 288, 734, 275, 8728, 14, 3840, 14, 24654, 8, 576, 29, 548, 12, 2152, 29, 1590, 14, 1609, 708, 9, 267, 4678, 275, 8728, 14, 3840, 14, 19302, 988, 2959, 8, 548, 12, 536, 534, 16395, 358, 272, 587, 26, 267, 1851, 275, 492, 63, 578, 360, 7450, 3530, 11, 589, 14, 1200, 9, 267, 4678, 275, 1851, 14, 362, 63, 5155, 3682, 2936, 8, 589, 430, 339, 327, 3560, 272, 5542, 14, 3269, 8, 589, 12, 4678, 12, 366, 10874, 14, 362, 63, 2761, 63, 1661, 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, 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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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 ]
leeseuljeong/leeseulstack_neutron
neutron/tests/unit/nec/test_portbindings.py
12
15823
# Copyright 2013 NEC Corporation # 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. from oslo.config import cfg from testtools import matchers from webob import exc from neutron.common import exceptions as n_exc from neutron import context from neutron.extensions import portbindings from neutron.tests.unit import _test_extension_portbindings as test_bindings from neutron.tests.unit.nec import test_nec_plugin from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc class TestNecPortBinding(test_bindings.PortBindingsTestCase, test_nec_plugin.NecPluginV2TestCase): VIF_TYPE = portbindings.VIF_TYPE_OVS VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True, portbindings.OVS_HYBRID_PLUG: True} ENABLE_SG = True FIREWALL_DRIVER = test_sg_rpc.FIREWALL_HYBRID_DRIVER def setUp(self): test_sg_rpc.set_firewall_driver(self.FIREWALL_DRIVER) cfg.CONF.set_override( 'enable_security_group', self.ENABLE_SG, group='SECURITYGROUP') super(TestNecPortBinding, self).setUp() class TestNecPortBindingNoSG(TestNecPortBinding): VIF_DETAILS = {portbindings.CAP_PORT_FILTER: False, portbindings.OVS_HYBRID_PLUG: False} ENABLE_SG = False FIREWALL_DRIVER = test_sg_rpc.FIREWALL_NOOP_DRIVER class TestNecPortBindingHost( test_bindings.PortBindingsHostTestCaseMixin, test_nec_plugin.NecPluginV2TestCase): pass class TestNecPortBindingPortInfo(test_nec_plugin.NecPluginV2TestCase): def _get_portinfo(self, datapath_id=None, port_no=None): if datapath_id is None: datapath_id = '0xabc' if port_no is None: port_no = 1 return {'datapath_id': datapath_id, 'port_no': port_no} def _check_response_portbinding_profile(self, port, datapath_id=None, port_no=None): expected = self._get_portinfo(datapath_id, port_no) profile = port[portbindings.PROFILE] self.assertEqual(len(profile), 2) self.assertEqual(profile['datapath_id'], expected['datapath_id']) self.assertEqual(profile['port_no'], expected['port_no']) def _check_response_portbinding_no_profile(self, port): self.assertIn('status', port) self.assertNotIn(portbindings.PROFILE, port) def _get_non_admin_context(self): return context.Context(user_id=None, tenant_id=self._tenant_id, is_admin=False, read_deleted="no") def test_port_create_portinfo(self): profile_arg = {portbindings.PROFILE: self._get_portinfo()} with self.port(arg_list=(portbindings.PROFILE,), **profile_arg) as port: port_id = port['port']['id'] # Check a response of create_port self._check_response_portbinding_profile(port['port']) self.assertEqual(self.ofc.create_ofc_port.call_count, 1) # Check a response of get_port ctx = context.get_admin_context() port = self._show('ports', port_id, neutron_context=ctx)['port'] self._check_response_portbinding_profile(port) # By default user is admin - now test non admin user ctx = self._get_non_admin_context() non_admin_port = self._show( 'ports', port_id, neutron_context=ctx)['port'] self._check_response_portbinding_no_profile(non_admin_port) # port-update with non admin user should fail self._update('ports', port_id, {'port': profile_arg}, expected_code=exc.HTTPForbidden.code, neutron_context=ctx) def test_port_update_portinfo(self): profile_arg = {portbindings.PROFILE: self._get_portinfo()} with self.port() as port: self.assertEqual(self.ofc.create_ofc_port.call_count, 0) port_id = port['port']['id'] # Check a response of create_port self._check_response_portbinding_no_profile(port['port']) # Check a response of update_port ctx = context.get_admin_context() port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self._check_response_portbinding_profile(port) port = self._show('ports', port_id, neutron_context=ctx)['port'] self._check_response_portbinding_profile(port) def test_port_update_portinfo_detail(self): with self.port() as port: self.assertEqual(self.ofc.create_ofc_port.call_count, 0) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) port_id = port['port']['id'] ctx = context.get_admin_context() # add portinfo profile_arg = {portbindings.PROFILE: self._get_portinfo()} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) # portinfo unchanged port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) # modify portinfo profile_arg = {portbindings.PROFILE: self._get_portinfo(datapath_id='0x1234567890', port_no=99)} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 2) self.assertEqual(self.ofc.delete_ofc_port.call_count, 1) # delete portinfo with an empty dict profile_arg = {portbindings.PROFILE: {}} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 2) self.assertEqual(self.ofc.delete_ofc_port.call_count, 2) def test_port_update_portinfo_detail_clear_with_none(self): with self.port() as port: self.assertEqual(self.ofc.create_ofc_port.call_count, 0) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) port_id = port['port']['id'] ctx = context.get_admin_context() # add portinfo profile_arg = {portbindings.PROFILE: self._get_portinfo()} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) # delete portinfo with None profile_arg = {portbindings.PROFILE: None} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 1) def test_port_create_portinfo_with_empty_dict(self): profile_arg = {portbindings.PROFILE: {}} with self.port(arg_list=(portbindings.PROFILE,), **profile_arg) as port: port_id = port['port']['id'] # Check a response of create_port self._check_response_portbinding_no_profile(port['port']) self.assertEqual(self.ofc.create_ofc_port.call_count, 0) # add portinfo ctx = context.get_admin_context() profile_arg = {portbindings.PROFILE: self._get_portinfo()} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self._check_response_portbinding_profile(port) self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) def test_port_create_portinfo_with_none(self): profile_arg = {portbindings.PROFILE: None} with self.port(arg_list=(portbindings.PROFILE,), **profile_arg) as port: port_id = port['port']['id'] # Check a response of create_port self._check_response_portbinding_no_profile(port['port']) self.assertEqual(self.ofc.create_ofc_port.call_count, 0) # add portinfo ctx = context.get_admin_context() profile_arg = {portbindings.PROFILE: self._get_portinfo()} port = self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx)['port'] self._check_response_portbinding_profile(port) self.assertEqual(self.ofc.create_ofc_port.call_count, 1) self.assertEqual(self.ofc.delete_ofc_port.call_count, 0) def test_port_update_for_existing_port_with_different_padding_dpid(self): ctx = context.get_admin_context() with self.port() as port: port_id = port['port']['id'] portinfo = {'id': port_id, 'port_no': 123} self.rpcapi_update_ports(datapath_id='0x000000000000abcd', added=[portinfo]) self.assertEqual(1, self.ofc.create_ofc_port.call_count) self.assertEqual(0, self.ofc.delete_ofc_port.call_count) profile_arg = {portbindings.PROFILE: self._get_portinfo(datapath_id='0xabcd', port_no=123)} self._update('ports', port_id, {'port': profile_arg}, neutron_context=ctx) # Check create_ofc_port/delete_ofc_port are not called. self.assertEqual(1, self.ofc.create_ofc_port.call_count) self.assertEqual(0, self.ofc.delete_ofc_port.call_count) def test_port_create_portinfo_non_admin(self): with self.network(set_context=True, tenant_id='test') as net1: with self.subnet(network=net1) as subnet1: profile_arg = {portbindings.PROFILE: self._get_portinfo()} try: with self.port(subnet=subnet1, expected_res_status=403, arg_list=(portbindings.PROFILE,), set_context=True, tenant_id='test', **profile_arg): pass except exc.HTTPClientError: pass self.assertEqual(self.ofc.create_ofc_port.call_count, 0) def test_port_update_portinfo_non_admin(self): profile_arg = {portbindings.PROFILE: self._get_portinfo()} with self.network() as net1: with self.subnet(network=net1) as subnet1: with self.port(subnet=subnet1) as port: # By default user is admin - now test non admin user port_id = port['port']['id'] ctx = self._get_non_admin_context() port = self._update('ports', port_id, {'port': profile_arg}, expected_code=exc.HTTPForbidden.code, neutron_context=ctx) self.assertEqual(self.ofc.create_ofc_port.call_count, 0) def test_port_create_portinfo_validation_called(self): # Check validate_portinfo is called. profile_arg = {portbindings.PROFILE: {'datapath_id': '0xabc', 'port_no': 0xffff + 1}} try: with self.port(arg_list=(portbindings.PROFILE,), expected_res_status=400, **profile_arg): pass except exc.HTTPClientError: pass class TestNecPortBindingValidatePortInfo(test_nec_plugin.NecPluginV2TestCase): def test_validate_portinfo_ok(self): profile = {'datapath_id': '0x1234567890abcdef', 'port_no': 123} portinfo = self.plugin._validate_portinfo(profile) # NOTE(mriedem): Handle long integer conversion universally. self.assertEqual( 0x1234567890abcdef, int(portinfo['datapath_id'].replace('L', ''), 16) ) self.assertEqual(portinfo['port_no'], 123) def test_validate_portinfo_ok_without_0x(self): profile = {'datapath_id': '1234567890abcdef', 'port_no': 123} portinfo = self.plugin._validate_portinfo(profile) # NOTE(mriedem): Handle long integer conversion universally. self.assertEqual( 0x1234567890abcdef, int(portinfo['datapath_id'].replace('L', ''), 16) ) self.assertEqual(portinfo['port_no'], 123) def _test_validate_exception(self, profile, expected_msg): e = self.assertRaises(n_exc.InvalidInput, self.plugin._validate_portinfo, profile) self.assertThat(str(e), matchers.StartsWith(expected_msg)) def test_validate_portinfo_dict_validation(self): expected_msg = ("Invalid input for operation: " "Validation of dictionary's keys failed.") profile = {'port_no': 123} self._test_validate_exception(profile, expected_msg) profile = {'datapath_id': '0xabcdef'} self._test_validate_exception(profile, expected_msg) def test_validate_portinfo_negative_port_number(self): profile = {'datapath_id': '0x1234567890abcdef', 'port_no': -1} expected_msg = ("Invalid input for operation: " "'-1' should be non-negative.") self._test_validate_exception(profile, expected_msg) def test_validate_portinfo_invalid_datapath_id(self): expected_msg = ("Invalid input for operation: " "datapath_id should be a hex string") # non hexidecimal datapath_id profile = {'datapath_id': 'INVALID', 'port_no': 123} self._test_validate_exception(profile, expected_msg) # Too big datapath_id profile = {'datapath_id': '0x10000000000000000', 'port_no': 123} self._test_validate_exception(profile, expected_msg) def test_validate_portinfo_too_big_port_number(self): profile = {'datapath_id': '0x1234567890abcdef', 'port_no': 65536} expected_msg = ("Invalid input for operation: " "port_no should be [0:65535]") self._test_validate_exception(profile, expected_msg)
apache-2.0
[ 3, 1898, 6171, 653, 4220, 11098, 199, 3, 2900, 4481, 4644, 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, 504, 11258, 14, 888, 492, 4810, 199, 504, 30741, 492, 31679, 199, 504, 14568, 492, 3178, 199, 199, 504, 8224, 14, 2330, 492, 4967, 465, 302, 63, 2804, 199, 504, 8224, 492, 1067, 199, 504, 8224, 14, 5359, 492, 1844, 10880, 199, 504, 8224, 14, 2219, 14, 3248, 492, 485, 396, 63, 3435, 63, 719, 10880, 465, 511, 63, 10880, 199, 504, 8224, 14, 2219, 14, 3248, 14, 12453, 492, 511, 63, 12453, 63, 2718, 199, 504, 8224, 14, 2219, 14, 3248, 492, 511, 63, 4416, 63, 2634, 63, 4354, 465, 511, 63, 1226, 63, 4354, 421, 199, 533, 1379, 46, 825, 4313, 17490, 8, 396, 63, 10880, 14, 4313, 8198, 780, 1746, 12, 586, 511, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 812, 4656, 63, 2711, 275, 1844, 10880, 14, 27890, 63, 2711, 63, 47, 7428, 272, 812, 4656, 63, 25081, 51, 275, 469, 719, 10880, 14, 8549, 63, 3657, 63, 9905, 26, 715, 12, 673, 1844, 10880, 14, 47, 7428, 63, 16255, 7184, 998, 63, 16483, 26, 715, 93, 272, 27926, 63, 4254, 275, 715, 272, 15435, 907, 55, 1761, 63, 23401, 275, 511, 63, 1226, 63, 4354, 14, 1976, 907, 55, 1761, 63, 16255, 7184, 998, 63, 23401, 339, 347, 3613, 8, 277, 304, 267, 511, 63, 1226, 63, 4354, 14, 409, 63, 10794, 63, 3090, 8, 277, 14, 1976, 907, 55, 1761, 63, 23401, 9, 267, 4810, 14, 3103, 14, 409, 63, 4415, 8, 288, 283, 4296, 63, 4416, 63, 923, 297, 291, 14, 8898, 63, 4254, 12, 288, 1572, 534, 13554, 7823, 358, 267, 1613, 8, 774, 46, 825, 4313, 17490, 12, 291, 680, 5996, 342, 421, 199, 533, 1379, 46, 825, 4313, 17490, 1944, 4254, 8, 774, 46, 825, 4313, 17490, 304, 272, 812, 4656, 63, 25081, 51, 275, 469, 719, 10880, 14, 8549, 63, 3657, 63, 9905, 26, 756, 12, 673, 1844, 10880, 14, 47, 7428, 63, 16255, 7184, 998, 63, 16483, 26, 756, 93, 272, 27926, 63, 4254, 275, 756, 272, 15435, 907, 55, 1761, 63, 23401, 275, 511, 63, 1226, 63, 4354, 14, 1976, 907, 55, 1761, 63, 2826, 1938, 63, 23401, 421, 199, 533, 1379, 46, 825, 4313, 17490, 4965, 8, 272, 511, 63, 10880, 14, 4313, 8198, 780, 4965, 1746, 4256, 12, 272, 511, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 986, 421, 199, 533, 1379, 46, 825, 4313, 17490, 4313, 2354, 8, 396, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 347, 485, 362, 63, 719, 815, 8, 277, 12, 24991, 63, 344, 29, 403, 12, 1844, 63, 889, 29, 403, 304, 267, 340, 24991, 63, 344, 365, 488, 26, 288, 24991, 63, 344, 275, 283, 16, 88, 3175, 7, 267, 340, 1844, 63, 889, 365, 488, 26, 288, 1844, 63, 889, 275, 413, 267, 372, 791, 25019, 63, 344, 356, 24991, 63, 344, 12, 355, 283, 719, 63, 889, 356, 1844, 63, 889, 93, 339, 347, 485, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 277, 12, 1844, 12, 24991, 63, 344, 29, 403, 12, 4490, 1844, 63, 889, 29, 403, 304, 267, 1420, 275, 291, 423, 362, 63, 719, 815, 8, 25019, 63, 344, 12, 1844, 63, 889, 9, 267, 4690, 275, 1844, 59, 719, 10880, 14, 16632, 61, 267, 291, 14, 629, 8, 552, 8, 2913, 395, 499, 9, 267, 291, 14, 629, 8, 2913, 459, 25019, 63, 344, 995, 586, 1420, 459, 25019, 63, 344, 1105, 267, 291, 14, 629, 8, 2913, 459, 719, 63, 889, 995, 586, 1420, 459, 719, 63, 889, 1105, 339, 347, 485, 1074, 63, 1310, 63, 719, 9140, 63, 889, 63, 2913, 8, 277, 12, 1844, 304, 267, 291, 14, 4080, 360, 1205, 297, 1844, 9, 267, 291, 14, 8795, 8, 719, 10880, 14, 16632, 12, 1844, 9, 339, 347, 485, 362, 63, 2865, 63, 2113, 63, 1100, 8, 277, 304, 267, 372, 1067, 14, 2998, 8, 751, 63, 344, 29, 403, 12, 3044, 8261, 63, 344, 29, 277, 423, 4647, 63, 344, 12, 3044, 365, 63, 2113, 29, 797, 12, 3044, 1586, 63, 6062, 628, 889, 531, 339, 347, 511, 63, 719, 63, 981, 63, 719, 815, 8, 277, 304, 267, 4690, 63, 1273, 275, 469, 719, 10880, 14, 16632, 26, 291, 423, 362, 63, 719, 815, 12737, 267, 543, 291, 14, 719, 8, 1273, 63, 513, 2687, 719, 10880, 14, 16632, 4706, 2432, 1011, 2913, 63, 1273, 9, 465, 1844, 26, 288, 1844, 63, 344, 275, 1844, 459, 719, 2545, 344, 418, 288, 327, 2670, 282, 1177, 402, 1218, 63, 719, 288, 291, 423, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 719, 459, 719, 1105, 288, 291, 14, 629, 8, 277, 14, 24357, 14, 981, 63, 24357, 63, 719, 14, 1250, 63, 835, 12, 413, 9, 288, 327, 2670, 282, 1177, 402, 664, 63, 719, 288, 4027, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 288, 1844, 275, 291, 423, 2384, 360, 5203, 297, 1844, 63, 344, 12, 8224, 63, 1100, 29, 3799, 11820, 719, 418, 288, 291, 423, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 719, 9, 288, 327, 4885, 849, 922, 365, 4628, 446, 3063, 511, 2222, 4628, 922, 288, 4027, 275, 291 ]
[ 1898, 6171, 653, 4220, 11098, 199, 3, 2900, 4481, 4644, 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, 504, 11258, 14, 888, 492, 4810, 199, 504, 30741, 492, 31679, 199, 504, 14568, 492, 3178, 199, 199, 504, 8224, 14, 2330, 492, 4967, 465, 302, 63, 2804, 199, 504, 8224, 492, 1067, 199, 504, 8224, 14, 5359, 492, 1844, 10880, 199, 504, 8224, 14, 2219, 14, 3248, 492, 485, 396, 63, 3435, 63, 719, 10880, 465, 511, 63, 10880, 199, 504, 8224, 14, 2219, 14, 3248, 14, 12453, 492, 511, 63, 12453, 63, 2718, 199, 504, 8224, 14, 2219, 14, 3248, 492, 511, 63, 4416, 63, 2634, 63, 4354, 465, 511, 63, 1226, 63, 4354, 421, 199, 533, 1379, 46, 825, 4313, 17490, 8, 396, 63, 10880, 14, 4313, 8198, 780, 1746, 12, 586, 511, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 812, 4656, 63, 2711, 275, 1844, 10880, 14, 27890, 63, 2711, 63, 47, 7428, 272, 812, 4656, 63, 25081, 51, 275, 469, 719, 10880, 14, 8549, 63, 3657, 63, 9905, 26, 715, 12, 673, 1844, 10880, 14, 47, 7428, 63, 16255, 7184, 998, 63, 16483, 26, 715, 93, 272, 27926, 63, 4254, 275, 715, 272, 15435, 907, 55, 1761, 63, 23401, 275, 511, 63, 1226, 63, 4354, 14, 1976, 907, 55, 1761, 63, 16255, 7184, 998, 63, 23401, 339, 347, 3613, 8, 277, 304, 267, 511, 63, 1226, 63, 4354, 14, 409, 63, 10794, 63, 3090, 8, 277, 14, 1976, 907, 55, 1761, 63, 23401, 9, 267, 4810, 14, 3103, 14, 409, 63, 4415, 8, 288, 283, 4296, 63, 4416, 63, 923, 297, 291, 14, 8898, 63, 4254, 12, 288, 1572, 534, 13554, 7823, 358, 267, 1613, 8, 774, 46, 825, 4313, 17490, 12, 291, 680, 5996, 342, 421, 199, 533, 1379, 46, 825, 4313, 17490, 1944, 4254, 8, 774, 46, 825, 4313, 17490, 304, 272, 812, 4656, 63, 25081, 51, 275, 469, 719, 10880, 14, 8549, 63, 3657, 63, 9905, 26, 756, 12, 673, 1844, 10880, 14, 47, 7428, 63, 16255, 7184, 998, 63, 16483, 26, 756, 93, 272, 27926, 63, 4254, 275, 756, 272, 15435, 907, 55, 1761, 63, 23401, 275, 511, 63, 1226, 63, 4354, 14, 1976, 907, 55, 1761, 63, 2826, 1938, 63, 23401, 421, 199, 533, 1379, 46, 825, 4313, 17490, 4965, 8, 272, 511, 63, 10880, 14, 4313, 8198, 780, 4965, 1746, 4256, 12, 272, 511, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 986, 421, 199, 533, 1379, 46, 825, 4313, 17490, 4313, 2354, 8, 396, 63, 12453, 63, 2718, 14, 46, 825, 5061, 54, 18, 1746, 304, 272, 347, 485, 362, 63, 719, 815, 8, 277, 12, 24991, 63, 344, 29, 403, 12, 1844, 63, 889, 29, 403, 304, 267, 340, 24991, 63, 344, 365, 488, 26, 288, 24991, 63, 344, 275, 283, 16, 88, 3175, 7, 267, 340, 1844, 63, 889, 365, 488, 26, 288, 1844, 63, 889, 275, 413, 267, 372, 791, 25019, 63, 344, 356, 24991, 63, 344, 12, 355, 283, 719, 63, 889, 356, 1844, 63, 889, 93, 339, 347, 485, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 277, 12, 1844, 12, 24991, 63, 344, 29, 403, 12, 4490, 1844, 63, 889, 29, 403, 304, 267, 1420, 275, 291, 423, 362, 63, 719, 815, 8, 25019, 63, 344, 12, 1844, 63, 889, 9, 267, 4690, 275, 1844, 59, 719, 10880, 14, 16632, 61, 267, 291, 14, 629, 8, 552, 8, 2913, 395, 499, 9, 267, 291, 14, 629, 8, 2913, 459, 25019, 63, 344, 995, 586, 1420, 459, 25019, 63, 344, 1105, 267, 291, 14, 629, 8, 2913, 459, 719, 63, 889, 995, 586, 1420, 459, 719, 63, 889, 1105, 339, 347, 485, 1074, 63, 1310, 63, 719, 9140, 63, 889, 63, 2913, 8, 277, 12, 1844, 304, 267, 291, 14, 4080, 360, 1205, 297, 1844, 9, 267, 291, 14, 8795, 8, 719, 10880, 14, 16632, 12, 1844, 9, 339, 347, 485, 362, 63, 2865, 63, 2113, 63, 1100, 8, 277, 304, 267, 372, 1067, 14, 2998, 8, 751, 63, 344, 29, 403, 12, 3044, 8261, 63, 344, 29, 277, 423, 4647, 63, 344, 12, 3044, 365, 63, 2113, 29, 797, 12, 3044, 1586, 63, 6062, 628, 889, 531, 339, 347, 511, 63, 719, 63, 981, 63, 719, 815, 8, 277, 304, 267, 4690, 63, 1273, 275, 469, 719, 10880, 14, 16632, 26, 291, 423, 362, 63, 719, 815, 12737, 267, 543, 291, 14, 719, 8, 1273, 63, 513, 2687, 719, 10880, 14, 16632, 4706, 2432, 1011, 2913, 63, 1273, 9, 465, 1844, 26, 288, 1844, 63, 344, 275, 1844, 459, 719, 2545, 344, 418, 288, 327, 2670, 282, 1177, 402, 1218, 63, 719, 288, 291, 423, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 719, 459, 719, 1105, 288, 291, 14, 629, 8, 277, 14, 24357, 14, 981, 63, 24357, 63, 719, 14, 1250, 63, 835, 12, 413, 9, 288, 327, 2670, 282, 1177, 402, 664, 63, 719, 288, 4027, 275, 1067, 14, 362, 63, 2113, 63, 1100, 342, 288, 1844, 275, 291, 423, 2384, 360, 5203, 297, 1844, 63, 344, 12, 8224, 63, 1100, 29, 3799, 11820, 719, 418, 288, 291, 423, 1074, 63, 1310, 63, 719, 9140, 63, 2913, 8, 719, 9, 288, 327, 4885, 849, 922, 365, 4628, 446, 3063, 511, 2222, 4628, 922, 288, 4027, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
BackupGGCode/python-for-android
python-build/python-libs/xmpppy/doc/examples/xsend.py
87
1497
#!/usr/bin/python # $Id: xsend.py,v 1.8 2006/10/06 12:30:42 normanr Exp $ import sys,os,xmpp,time if len(sys.argv) < 2: print "Syntax: xsend JID text" sys.exit(0) tojid=sys.argv[1] text=' '.join(sys.argv[2:]) jidparams={} if os.access(os.environ['HOME']+'/.xsend',os.R_OK): for ln in open(os.environ['HOME']+'/.xsend').readlines(): if not ln[0] in ('#',';'): key,val=ln.strip().split('=',1) jidparams[key.lower()]=val for mandatory in ['jid','password']: if mandatory not in jidparams.keys(): open(os.environ['HOME']+'/.xsend','w').write('#Uncomment fields before use and type in correct credentials.\n#JID=romeo@montague.net/resource (/resource is optional)\n#PASSWORD=juliet\n') print 'Please point ~/.xsend config file to valid JID for sending messages.' sys.exit(0) jid=xmpp.protocol.JID(jidparams['jid']) cl=xmpp.Client(jid.getDomain(),debug=[]) con=cl.connect() if not con: print 'could not connect!' sys.exit() print 'connected with',con auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource()) if not auth: print 'could not authenticate!' sys.exit() print 'authenticated using',auth #cl.SendInitPresence(requestRoster=0) # you may need to uncomment this for old server id=cl.send(xmpp.protocol.Message(tojid,text)) print 'sent message with id',id time.sleep(1) # some older servers will not send the message if you disconnect immediately after sending #cl.disconnect()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2672, 1304, 26, 671, 2254, 14, 647, 12, 86, 413, 14, 24, 8315, 15, 709, 15, 1690, 3144, 26, 1216, 26, 2260, 6316, 290, 82, 7910, 2672, 199, 646, 984, 12, 736, 12, 26608, 12, 521, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 272, 870, 298, 16626, 26, 671, 2254, 1603, 998, 1318, 2, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 475, 14203, 29, 1274, 14, 3020, 59, 17, 61, 199, 505, 534, 1987, 904, 8, 1274, 14, 3020, 59, 18, 5728, 199, 199, 14203, 1162, 7622, 199, 692, 747, 14, 2732, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 297, 736, 14, 50, 63, 3593, 304, 272, 367, 10359, 315, 1551, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 1959, 9684, 837, 267, 340, 440, 10359, 59, 16, 61, 315, 22870, 1673, 27, 735, 288, 790, 12, 637, 29, 6066, 14, 1913, 1252, 1294, 25283, 17, 9, 288, 21752, 1162, 59, 498, 14, 2325, 5106, 29, 637, 199, 509, 15230, 315, 788, 14203, 1673, 2060, 2565, 272, 340, 15230, 440, 315, 21752, 1162, 14, 1612, 837, 267, 1551, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 1673, 87, 1959, 952, 7863, 1358, 3349, 1504, 2544, 675, 436, 730, 315, 3211, 6235, 3134, 78, 3, 42, 998, 29, 5864, 79, 32, 2106, 1450, 310, 14, 846, 15, 1927, 334, 15, 1927, 365, 2716, 2862, 78, 3, 9032, 29, 74, 13987, 386, 60, 78, 358, 267, 870, 283, 8254, 2376, 25975, 88, 2254, 1101, 570, 370, 1686, 1603, 998, 367, 10209, 3788, 3530, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 14203, 29, 26608, 14, 3922, 14, 42, 998, 8, 14203, 1162, 459, 14203, 1105, 199, 429, 29, 26608, 14, 3041, 8, 14203, 14, 362, 7705, 1062, 1757, 14285, 199, 199, 388, 29, 429, 14, 2242, 342, 199, 692, 440, 406, 26, 272, 870, 283, 15153, 440, 4907, 11213, 272, 984, 14, 2224, 342, 199, 1361, 283, 7113, 543, 297, 388, 199, 1178, 29, 429, 14, 1178, 8, 14203, 14, 362, 1716, 1062, 14203, 1162, 459, 2060, 995, 1927, 29, 14203, 14, 362, 4031, 1012, 199, 692, 440, 1790, 26, 272, 870, 283, 15153, 440, 12895, 11213, 272, 984, 14, 2224, 342, 199, 1361, 283, 12177, 1808, 297, 1178, 199, 199, 3, 429, 14, 6795, 9346, 2398, 14073, 8, 1069, 50, 29895, 29, 16, 9, 257, 327, 1265, 1443, 1929, 370, 625, 3349, 642, 367, 2269, 1654, 199, 344, 29, 429, 14, 2254, 8, 26608, 14, 3922, 14, 2209, 8, 475, 14203, 12, 505, 430, 199, 1361, 283, 1150, 1245, 543, 1305, 297, 344, 199, 199, 521, 14, 4532, 8, 17, 9, 257, 327, 2005, 12731, 8037, 911, 440, 3222, 314, 1245, 340, 1265, 17639, 9939, 2410, 10209, 199, 199, 3, 429, 14, 10673, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2672, 1304, 26, 671, 2254, 14, 647, 12, 86, 413, 14, 24, 8315, 15, 709, 15, 1690, 3144, 26, 1216, 26, 2260, 6316, 290, 82, 7910, 2672, 199, 646, 984, 12, 736, 12, 26608, 12, 521, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 272, 870, 298, 16626, 26, 671, 2254, 1603, 998, 1318, 2, 272, 984, 14, 2224, 8, 16, 9, 199, 199, 475, 14203, 29, 1274, 14, 3020, 59, 17, 61, 199, 505, 534, 1987, 904, 8, 1274, 14, 3020, 59, 18, 5728, 199, 199, 14203, 1162, 7622, 199, 692, 747, 14, 2732, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 297, 736, 14, 50, 63, 3593, 304, 272, 367, 10359, 315, 1551, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 1959, 9684, 837, 267, 340, 440, 10359, 59, 16, 61, 315, 22870, 1673, 27, 735, 288, 790, 12, 637, 29, 6066, 14, 1913, 1252, 1294, 25283, 17, 9, 288, 21752, 1162, 59, 498, 14, 2325, 5106, 29, 637, 199, 509, 15230, 315, 788, 14203, 1673, 2060, 2565, 272, 340, 15230, 440, 315, 21752, 1162, 14, 1612, 837, 267, 1551, 8, 736, 14, 2314, 459, 9524, 418, 4786, 8083, 88, 2254, 1673, 87, 1959, 952, 7863, 1358, 3349, 1504, 2544, 675, 436, 730, 315, 3211, 6235, 3134, 78, 3, 42, 998, 29, 5864, 79, 32, 2106, 1450, 310, 14, 846, 15, 1927, 334, 15, 1927, 365, 2716, 2862, 78, 3, 9032, 29, 74, 13987, 386, 60, 78, 358, 267, 870, 283, 8254, 2376, 25975, 88, 2254, 1101, 570, 370, 1686, 1603, 998, 367, 10209, 3788, 3530, 267, 984, 14, 2224, 8, 16, 9, 199, 199, 14203, 29, 26608, 14, 3922, 14, 42, 998, 8, 14203, 1162, 459, 14203, 1105, 199, 429, 29, 26608, 14, 3041, 8, 14203, 14, 362, 7705, 1062, 1757, 14285, 199, 199, 388, 29, 429, 14, 2242, 342, 199, 692, 440, 406, 26, 272, 870, 283, 15153, 440, 4907, 11213, 272, 984, 14, 2224, 342, 199, 1361, 283, 7113, 543, 297, 388, 199, 1178, 29, 429, 14, 1178, 8, 14203, 14, 362, 1716, 1062, 14203, 1162, 459, 2060, 995, 1927, 29, 14203, 14, 362, 4031, 1012, 199, 692, 440, 1790, 26, 272, 870, 283, 15153, 440, 12895, 11213, 272, 984, 14, 2224, 342, 199, 1361, 283, 12177, 1808, 297, 1178, 199, 199, 3, 429, 14, 6795, 9346, 2398, 14073, 8, 1069, 50, 29895, 29, 16, 9, 257, 327, 1265, 1443, 1929, 370, 625, 3349, 642, 367, 2269, 1654, 199, 344, 29, 429, 14, 2254, 8, 26608, 14, 3922, 14, 2209, 8, 475, 14203, 12, 505, 430, 199, 1361, 283, 1150, 1245, 543, 1305, 297, 344, 199, 199, 521, 14, 4532, 8, 17, 9, 257, 327, 2005, 12731, 8037, 911, 440, 3222, 314, 1245, 340, 1265, 17639, 9939, 2410, 10209, 199, 199, 3, 429, 14, 10673, 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, 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,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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 ]
tingcar/PSEP
src/internalmail/models.py
1
1878
from django.db import models from django.contrib.auth.models import User # Create your models here. class InternalMail(models.Model): user = models.ForeignKey(User) Ticketid = models.CharField(max_length=50, null=True, blank=True) From = models.CharField(max_length=50, null=True, blank=True) FromEmail = models.CharField(max_length=50, null=True, blank=True) is_read = models.BooleanField(default=False) Content = models.CharField(max_length=200, null=True, blank=True) Address = models.CharField(max_length=200, null=True, blank=True) Title = models.CharField(max_length=50, null=True, blank=True) slug = models.SlugField() timestamp = models.DateTimeField(auto_now_add=True, auto_now=False) updated = models.DateTimeField(auto_now=True, auto_now_add=False) def __unicode__(self,): return "From: "+str(self.From)+" To: "+str(self.user)+" Title: "+str(self.Title) class Meta: ordering = ['timestamp',] class OutMail(models.Model): user = models.ForeignKey(User) Ticketid = models.CharField(max_length=50, null=True, blank=True) From = models.CharField(max_length=50, null=True, blank=True) FromEmail = models.CharField(max_length=50, null=True, blank=True) is_read = models.BooleanField(default=False) Content = models.CharField(max_length=200, null=True, blank=True) Address = models.CharField(max_length=200, null=True, blank=True) Title = models.CharField(max_length=50, null=True, blank=True) slug = models.SlugField() timestamp = models.DateTimeField(auto_now_add=True, auto_now=False) updated = models.DateTimeField(auto_now=True, auto_now_add=False) def __unicode__(self,): return "From: "+str(self.From)+" To: "+str(self.user)+" Title: "+str(self.Title) class Meta: ordering = ['timestamp',]
apache-2.0
[ 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 3, 2790, 2195, 1709, 2348, 14, 421, 199, 533, 12624, 13681, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 3190, 8, 1899, 9, 272, 18742, 69, 5700, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 11606, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 11606, 7035, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 365, 63, 739, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 6646, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 9906, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16881, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 8889, 275, 1709, 14, 17315, 342, 272, 4913, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 2599, 63, 2131, 29, 797, 9, 272, 4588, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 797, 9, 1362, 17635, 347, 636, 2975, 721, 277, 16095, 267, 372, 298, 2532, 26, 7210, 495, 8, 277, 14, 2532, 18663, 4005, 26, 7210, 495, 8, 277, 14, 751, 18663, 16881, 26, 7210, 495, 8, 277, 14, 6888, 9, 272, 1021, 6288, 26, 267, 7794, 275, 788, 3954, 297, 61, 421, 199, 533, 6219, 13681, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 3190, 8, 1899, 9, 272, 18742, 69, 5700, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 11606, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 11606, 7035, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 365, 63, 739, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 6646, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 9906, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16881, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 8889, 275, 1709, 14, 17315, 342, 272, 4913, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 2599, 63, 2131, 29, 797, 9, 272, 4588, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 797, 9, 1362, 17635, 347, 636, 2975, 721, 277, 16095, 267, 372, 298, 2532, 26, 7210, 495, 8, 277, 14, 2532, 18663, 4005, 26, 7210, 495, 8, 277, 14, 751, 18663, 16881, 26, 7210, 495, 8, 277, 14, 6888, 9, 272, 1021, 6288, 26, 267, 7794, 275, 788, 3954, 297, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 3, 2790, 2195, 1709, 2348, 14, 421, 199, 533, 12624, 13681, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 3190, 8, 1899, 9, 272, 18742, 69, 5700, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 11606, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 11606, 7035, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 365, 63, 739, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 6646, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 9906, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16881, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 8889, 275, 1709, 14, 17315, 342, 272, 4913, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 2599, 63, 2131, 29, 797, 9, 272, 4588, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 797, 9, 1362, 17635, 347, 636, 2975, 721, 277, 16095, 267, 372, 298, 2532, 26, 7210, 495, 8, 277, 14, 2532, 18663, 4005, 26, 7210, 495, 8, 277, 14, 751, 18663, 16881, 26, 7210, 495, 8, 277, 14, 6888, 9, 272, 1021, 6288, 26, 267, 7794, 275, 788, 3954, 297, 61, 421, 199, 533, 6219, 13681, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 3190, 8, 1899, 9, 272, 18742, 69, 5700, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 11606, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 11606, 7035, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 365, 63, 739, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 6646, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 9906, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 16881, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 2378, 8889, 275, 1709, 14, 17315, 342, 272, 4913, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 2599, 63, 2131, 29, 797, 9, 272, 4588, 275, 1709, 14, 4626, 8, 2495, 63, 2131, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 797, 9, 1362, 17635, 347, 636, 2975, 721, 277, 16095, 267, 372, 298, 2532, 26, 7210, 495, 8, 277, 14, 2532, 18663, 4005, 26, 7210, 495, 8, 277, 14, 751, 18663, 16881, 26, 7210, 495, 8, 277, 14, 6888, 9, 272, 1021, 6288, 26, 267, 7794, 275, 788, 3954, 297, 61, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
coberger/DIRAC
Core/Utilities/Subprocess.py
5
20847
# $HeadURL$ """ DIRAC Wrapper to execute python and system commands with a wrapper, that might set a timeout. 3 FUNCTIONS are provided: - shellCall( iTimeOut, cmdSeq, callbackFunction = None, env = None ): it uses subprocess.Popen class with "shell = True". If cmdSeq is a string, it specifies the command string to execute through the shell. If cmdSeq is a sequence, the first item specifies the command string, and any additional items will be treated as additional shell arguments. - systemCall( iTimeOut, cmdSeq, callbackFunction = None, env = None ): it uses subprocess.Popen class with "shell = False". cmdSeq should be a string, or a sequence of program arguments. stderr and stdout are piped. callbackFunction( pipeId, line ) can be defined to process the stdout (pipeId = 0) and stderr (pipeId = 1) as they are produced They return a DIRAC.ReturnValue dictionary with a tuple in Value ( returncode, stdout, stderr ) the tuple will also be available upon timeout error or buffer overflow error. - pythonCall( iTimeOut, function, \*stArgs, \*\*stKeyArgs ) calls function with given arguments within a timeout Wrapper should be used to wrap third party python functions """ __RCSID__ = "$Id$" from multiprocessing import Process, Manager import threading import time import select import os import sys import types import subprocess import signal # Very Important: # Here we can not import directly from DIRAC, since this file it is imported # at initialization time therefore the full path is necessary # from DIRAC import S_OK, S_ERROR from DIRAC.Core.Utilities.ReturnValues import S_OK, S_ERROR # from DIRAC import gLogger from DIRAC.FrameworkSystem.Client.Logger import gLogger from DIRAC.Core.Utilities import DEncode USE_WATCHDOG = False class Watchdog( object ): """ .. class Watchdog timeout watchdog decorator """ def __init__( self, func, args=None, kwargs=None ): """ c'tor """ self.func = func if callable(func) else None self.args = args if args else tuple() self.kwargs = kwargs if kwargs else {} self.start = self.end = self.pid = None self.rwEvent = threading.Event() self.rwEvent.clear() self.__watchdogThread = None self.manager = Manager() self.s_ok_error = self.manager.dict() self.__executor = Process( target = self.run_func, args = (self.s_ok_error, ) ) def run_func( self, s_ok_error ): """ subprocess target :param Pipe pipe: pipe used for communication """ try: ret = self.func( *self.args, **self.kwargs ) ## set rw event self.rwEvent.set() for k in ret: s_ok_error[k] = ret[k] except Exception, error: s_ok_error["OK"] = False s_ok_error["Message"] = str(error) finally: ## clear rw event self.rwEvent.clear() def watchdog( self ): """ watchdog thread target """ while True: if self.rwEvent.is_set() or time.time() < self.end: time.sleep(5) else: break if not self.__executor.is_alive(): return else: ## wait until r/w operation finishes while self.rwEvent.is_set(): time.sleep(5) continue ## SIGTERM os.kill( self.pid, signal.SIGTERM ) time.sleep(5) ## SIGKILL if self.__executor.is_alive(): os.kill( self.pid, signal.SIGKILL ) def __call__( self, timeout = 0 ): """ decorator execution """ timeout = int(timeout) ret = { "OK" : True, "Value" : "" } if timeout: self.start = int( time.time() ) self.end = self.start + timeout + 2 self.__watchdogThread = threading.Thread( target = self.watchdog ) self.__watchdogThread.daemon = True self.__watchdogThread.start() ret = { "OK" : False, "Message" : "Timeout after %s seconds" % timeout, "Value": ( 1, '', '' ) } try: self.__executor.start() time.sleep(0.5) self.pid = self.__executor.pid if timeout: self.__executor.join( timeout ) else: self.__executor.join() ## get results if any, block watchdog by setting rwEvent if not self.__executor.is_alive(): self.rwEvent.set() for k in self.s_ok_error.keys(): ret[k] = self.s_ok_error[k] self.rwEvent.clear() except Exception, error: return { "OK" : False, "Message" : str(error), "Value": ( 2, '', '' ) } return ret class Subprocess: """ .. class:: Subprocess """ def __init__( self, timeout = False, bufferLimit = 52428800 ): """ c'tor :param int timeout: timeout in seconds :param int bufferLimit: buffer size, default 5MB """ self.log = gLogger.getSubLogger( 'Subprocess' ) self.timeout = False try: self.changeTimeout( timeout ) self.bufferLimit = int( bufferLimit ) # 5MB limit for data except Exception, x: self.log.exception( 'Failed initialisation of Subprocess object' ) raise x self.child = None self.childPID = 0 self.childKilled = False self.callback = None self.bufferList = [] self.cmdSeq = [] def changeTimeout( self, timeout ): """ set the time out limit to :timeout: seconds :param int timeout: time out in seconds """ self.timeout = int( timeout ) if self.timeout == 0: self.timeout = False #self.log.debug( 'Timeout set to', timeout ) def __readFromFD( self, fd, baseLength = 0 ): """ read from file descriptior :fd: :param fd: file descriptior :param int baseLength: ??? """ dataString = '' redBuf = " " while len( redBuf ) > 0: redBuf = os.read( fd, 8192 ) dataString += redBuf if len( dataString ) + baseLength > self.bufferLimit: self.log.error( 'Maximum output buffer length reached' ) retDict = S_ERROR( 'Reached maximum allowed length (%d bytes) ' 'for called function return value' % self.bufferLimit ) retDict[ 'Value' ] = dataString return retDict return S_OK( dataString ) def __executePythonFunction( self, function, writePipe, *stArgs, **stKeyArgs ): """ execute function :funtion: using :stArgs: and :stKeyArgs: """ try: os.write( writePipe, DEncode.encode( S_OK( function( *stArgs, **stKeyArgs ) ) ) ) except OSError, x: if str( x ) == '[Errno 32] Broken pipe': # the parent has died pass except Exception, x: self.log.exception( 'Exception while executing', function.__name__ ) os.write( writePipe, DEncode.encode( S_ERROR( str( x ) ) ) ) #HACK: Allow some time to flush logs time.sleep( 1 ) try: os.close( writePipe ) finally: os._exit( 0 ) def __selectFD( self, readSeq, timeout = False ): """ select file descriptor from :readSeq: list """ validList = [] for fd in readSeq: try: os.fstat( fd ) validList.append( fd ) except OSError: pass if not validList: return False if self.timeout and not timeout: timeout = self.timeout if not timeout: return select.select( validList , [], [] )[0] else: return select.select( validList , [], [], timeout )[0] def __killPid( self, pid, sig = 9 ): """ send signal :sig: to process :pid: :param int pid: process id :param int sig: signal to send, default 9 (SIGKILL) """ try: os.kill( pid, sig ) except Exception, x: if not str( x ) == '[Errno 3] No such process': self.log.exception( 'Exception while killing timed out process' ) raise x def __poll( self, pid ): """ wait for :pid: """ try: return os.waitpid( pid, os.WNOHANG ) except os.error: if self.childKilled: return False return None def killChild( self, recursive = True ): """ kill child process :param boolean recursive: flag to kill all descendants """ if self.childPID < 1: self.log.error( "Could not kill child", "Child PID is %s" % self.childPID ) return - 1 os.kill( self.childPID, signal.SIGSTOP ) if recursive: for gcpid in getChildrenPIDs( self.childPID, lambda cpid: os.kill( cpid, signal.SIGSTOP ) ): try: os.kill( gcpid, signal.SIGKILL ) self.__poll( gcpid ) except Exception: pass self.__killPid( self.childPID ) #HACK to avoid python bug # self.child.wait() exitStatus = self.__poll( self.childPID ) i = 0 while exitStatus == None and i < 1000: i += 1 time.sleep( 0.000001 ) exitStatus = self.__poll( self.childPID ) try: exitStatus = os.waitpid( self.childPID, 0 ) except os.error: pass self.childKilled = True if exitStatus == None: return exitStatus return exitStatus[1] def pythonCall( self, function, *stArgs, **stKeyArgs ): """ call python function :function: with :stArgs: and :stKeyArgs: """ self.log.verbose( 'pythonCall:', function.__name__ ) readFD, writeFD = os.pipe() pid = os.fork() self.childPID = pid if pid == 0: os.close( readFD ) self.__executePythonFunction( function, writeFD, *stArgs, **stKeyArgs ) # FIXME: the close it is done at __executePythonFunction, do we need it here? os.close( writeFD ) else: os.close( writeFD ) readSeq = self.__selectFD( [ readFD ] ) if readSeq == False: return S_ERROR( "Can't read from call %s" % ( function.__name__ ) ) try: if len( readSeq ) == 0: self.log.debug( 'Timeout limit reached for pythonCall', function.__name__ ) self.__killPid( pid ) #HACK to avoid python bug # self.wait() retries = 10000 while os.waitpid( pid, 0 ) == -1 and retries > 0: time.sleep( 0.001 ) retries -= 1 return S_ERROR( '%d seconds timeout for "%s" call' % ( self.timeout, function.__name__ ) ) elif readSeq[0] == readFD: retDict = self.__readFromFD( readFD ) os.waitpid( pid, 0 ) if retDict[ 'OK' ]: dataStub = retDict[ 'Value' ] if not dataStub: return S_ERROR( "Error decoding data coming from call" ) retObj, stubLen = DEncode.decode( dataStub ) if stubLen == len( dataStub ): return retObj else: return S_ERROR( "Error decoding data coming from call" ) return retDict finally: os.close( readFD ) def __generateSystemCommandError( self, exitStatus, message ): """ create system command error :param int exitStatus: exist status :param str message: error message :return: S_ERROR with additional 'Value' tuple ( existStatus, stdoutBuf, stderrBuf ) """ retDict = S_ERROR( message ) retDict[ 'Value' ] = ( exitStatus, self.bufferList[0][0], self.bufferList[1][0] ) return retDict def __readFromFile( self, fd, baseLength, doAll = True ): """ read from file descriptor :fd: and save it to the dedicated buffer """ try: dataString = "" fn = fd.fileno() rawRead = type( fn ) == types.IntType while fd in select.select( [ fd ], [], [], 1 )[0]: if rawRead: nB = os.read( fn, self.bufferLimit ) else: nB = fd.read( 1 ) if nB == "": break dataString += nB except Exception, x: self.log.exception( "SUBPROCESS: readFromFile exception" ) try: self.log.error( 'Error reading', 'type(nB) =%s' % type( nB ) ) self.log.error( 'Error reading', 'nB =%s' % str( nB ) ) except Exception: pass return S_ERROR( 'Can not read from output: %s' % str( x ) ) if len( dataString ) + baseLength > self.bufferLimit: self.log.error( 'Maximum output buffer length reached' ) retDict = S_ERROR( 'Reached maximum allowed length (%d bytes) for called ' 'function return value' % self.bufferLimit ) retDict[ 'Value' ] = dataString return retDict return S_OK( dataString ) def __readFromSystemCommandOutput( self, fd, bufferIndex ): """ read stdout from file descriptor :fd: """ retDict = self.__readFromFile( fd, len( self.bufferList[ bufferIndex ][0] ) ) if retDict[ 'OK' ]: self.bufferList[ bufferIndex ][0] += retDict[ 'Value' ] if not self.callback == None: while self.__callLineCallback( bufferIndex ): pass return S_OK() else: # buffer size limit reached killing process (see comment on __readFromFile) exitStatus = self.killChild() return self.__generateSystemCommandError( exitStatus, "%s for '%s' call" % ( retDict['Message'], self.cmdSeq ) ) def systemCall( self, cmdSeq, callbackFunction = None, shell = False, env = None ): """ system call (no shell) - execute :cmdSeq: """ if shell: self.log.verbose( 'shellCall:', cmdSeq ) else: self.log.verbose( 'systemCall:', cmdSeq ) self.cmdSeq = cmdSeq self.callback = callbackFunction if sys.platform.find( "win" ) == 0: closefd = False else: closefd = True try: self.child = subprocess.Popen( self.cmdSeq, shell = shell, stdout = subprocess.PIPE, stderr = subprocess.PIPE, close_fds = closefd, env = env ) self.childPID = self.child.pid except OSError, v: retDict = S_ERROR( v ) retDict['Value'] = ( -1, '' , str( v ) ) return retDict except Exception, x: try: self.child.stdout.close() self.child.stderr.close() except Exception: pass retDict = S_ERROR( x ) retDict['Value'] = ( -1, '' , str( x ) ) return retDict try: self.bufferList = [ [ "", 0 ], [ "", 0 ] ] initialTime = time.time() exitStatus = self.__poll( self.child.pid ) while ( 0, 0 ) == exitStatus or None == exitStatus: retDict = self.__readFromCommand() if not retDict[ 'OK' ]: return retDict if self.timeout and time.time() - initialTime > self.timeout: exitStatus = self.killChild() self.__readFromCommand() return self.__generateSystemCommandError( exitStatus, "Timeout (%d seconds) for '%s' call" % ( self.timeout, cmdSeq ) ) time.sleep( 0.01 ) exitStatus = self.__poll( self.child.pid ) self.__readFromCommand() if exitStatus: exitStatus = exitStatus[1] if exitStatus >= 256: exitStatus /= 256 return S_OK( ( exitStatus, self.bufferList[0][0], self.bufferList[1][0] ) ) finally: try: self.child.stdout.close() self.child.stderr.close() except Exception: pass def getChildPID( self ): """ child pid getter """ return self.childPID def __readFromCommand( self, isLast = False ): """ read child stdout and stderr """ fdList = [] for i in ( self.child.stdout, self.child.stderr ): try: if not i.closed: fdList.append( i.fileno() ) except Exception: self.log.exception( "SUBPROCESS: readFromCommand exception" ) readSeq = self.__selectFD( fdList, True ) if readSeq == False: return S_OK() if self.child.stdout.fileno() in readSeq: retDict = self.__readFromSystemCommandOutput( self.child.stdout, 0 ) if not retDict[ 'OK' ]: return retDict if self.child.stderr.fileno() in readSeq: retDict = self.__readFromSystemCommandOutput( self.child.stderr, 1 ) if not retDict[ 'OK' ]: return retDict return S_OK() def __callLineCallback( self, bufferIndex ): """ line callback execution """ nextLineIndex = self.bufferList[ bufferIndex ][0][ self.bufferList[ bufferIndex ][1]: ].find( "\n" ) if nextLineIndex > -1: try: self.callback( bufferIndex, self.bufferList[ bufferIndex ][0][ self.bufferList[ bufferIndex ][1]: self.bufferList[ bufferIndex ][1] + nextLineIndex ] ) #Each line processed is taken out of the buffer to prevent the limit from killing us nL = self.bufferList[ bufferIndex ][1] + nextLineIndex + 1 self.bufferList[ bufferIndex ][0] = self.bufferList[ bufferIndex ][0][ nL: ] self.bufferList[ bufferIndex ][1] = 0 except Exception: self.log.exception( 'Exception while calling callback function', '%s' % self.callback.__name__ ) self.log.showStack() return True return False def systemCall( timeout, cmdSeq, callbackFunction = None, env = None, bufferLimit = 52428800 ): """ Use SubprocessExecutor class to execute cmdSeq (it can be a string or a sequence) with a timeout wrapper, it is executed directly without calling a shell """ if timeout > 0 and USE_WATCHDOG: spObject = Subprocess( timeout=timeout, bufferLimit = bufferLimit ) sysCall = Watchdog( spObject.systemCall, args=( cmdSeq, ), kwargs = { "callbackFunction" : callbackFunction, "env" : env, "shell" : False } ) spObject.log.verbose( 'Subprocess Watchdog timeout set to %d' % timeout ) result = sysCall(timeout+1) else: spObject = Subprocess( timeout, bufferLimit = bufferLimit ) result = spObject.systemCall( cmdSeq, callbackFunction = callbackFunction, env = env, shell = False ) return result def shellCall( timeout, cmdSeq, callbackFunction = None, env = None, bufferLimit = 52428800 ): """ Use SubprocessExecutor class to execute cmdSeq (it can be a string or a sequence) with a timeout wrapper, cmdSeq it is invoque by /bin/sh """ if timeout > 0 and USE_WATCHDOG: spObject = Subprocess( timeout=timeout, bufferLimit = bufferLimit ) shCall = Watchdog( spObject.systemCall, args=( cmdSeq, ), kwargs = { "callbackFunction" : callbackFunction, "env" : env, "shell" : True } ) spObject.log.verbose( 'Subprocess Watchdog timeout set to %d' % timeout ) result = shCall(timeout+1) else: spObject = Subprocess( timeout, bufferLimit = bufferLimit ) result = spObject.systemCall( cmdSeq, callbackFunction = callbackFunction, env = env, shell = True ) return result def pythonCall( timeout, function, *stArgs, **stKeyArgs ): """ Use SubprocessExecutor class to execute function with provided arguments, with a timeout wrapper. """ if timeout > 0 and USE_WATCHDOG: spObject = Subprocess( timeout=timeout ) pyCall = Watchdog( spObject.pythonCall, args=( function, ) + stArgs, kwargs=stKeyArgs ) spObject.log.verbose( 'Subprocess Watchdog timeout set to %d' % timeout ) result = pyCall(timeout+1) else: spObject = Subprocess( timeout ) result = spObject.pythonCall( function, *stArgs, **stKeyArgs ) return result def __getChildrenForPID( ppid ): """ Get a list of children pids for ppid """ magicCmd = "ps --no-headers --ppid %d -o pid" % ppid try: import psutil childrenList = [] for proc in psutil.process_iter(): if proc.ppid == ppid: childrenList.append( proc.pid ) return childrenList except Exception: exc = subprocess.Popen( magicCmd, stdout = subprocess.PIPE, shell = True, close_fds = True ) exc.wait() return [ int( pid.strip() ) for pid in exc.stdout.readlines() if pid.strip() ] def getChildrenPIDs( ppid, foreachFunc = None ): """ Get all children recursively for a given ppid. Optional foreachFunc will be executed for each children pid """ cpids = __getChildrenForPID( ppid ) pids = [] for pid in cpids: pids.append( pid ) if foreachFunc: foreachFunc( pid ) pids.extend( getChildrenPIDs( pid, foreachFunc ) ) return pids
gpl-3.0
[ 3, 2672, 11664, 2632, 4, 199, 624, 199, 3022, 1348, 21947, 370, 5341, 2366, 436, 2656, 3718, 543, 282, 4975, 12, 626, 5594, 199, 409, 282, 2653, 14, 199, 19, 21498, 19560, 787, 2741, 26, 272, 1362, 446, 5218, 2176, 8, 284, 1366, 2204, 12, 2088, 11205, 12, 3233, 3481, 275, 488, 12, 2589, 275, 488, 3461, 2126, 652, 4440, 3873, 14, 7942, 1021, 543, 298, 5641, 275, 715, 1674, 2126, 982, 2088, 11205, 365, 282, 1059, 12, 652, 9314, 314, 1414, 1059, 370, 5341, 4012, 2126, 314, 5218, 14, 221, 982, 2088, 11205, 365, 282, 3414, 12, 314, 1642, 1242, 9314, 314, 1414, 2126, 1059, 12, 436, 1263, 4722, 2974, 911, 506, 10184, 465, 4722, 5218, 2368, 14, 10813, 446, 2656, 2176, 8, 284, 1366, 2204, 12, 2088, 11205, 12, 3233, 3481, 275, 488, 12, 2589, 275, 488, 3461, 2126, 652, 4440, 3873, 14, 7942, 1021, 543, 298, 5641, 275, 756, 1674, 2126, 2088, 11205, 1077, 506, 282, 1059, 12, 503, 282, 3414, 402, 2240, 2368, 14, 10817, 4635, 436, 3839, 787, 6682, 1915, 14, 3233, 3481, 8, 5200, 1304, 12, 1004, 776, 883, 506, 2126, 3247, 370, 2112, 314, 3839, 334, 4990, 1304, 275, 378, 9, 436, 4635, 334, 4990, 1304, 275, 413, 9, 465, 2126, 2985, 787, 13584, 267, 2126, 9322, 372, 282, 26565, 14, 1767, 1110, 2600, 543, 282, 2008, 315, 1594, 2126, 334, 17630, 12, 3839, 12, 4635, 776, 314, 2008, 911, 2597, 506, 2808, 12188, 2126, 2653, 1125, 503, 3335, 15784, 1125, 14, 10813, 446, 2366, 2176, 8, 284, 1366, 2204, 12, 805, 12, 971, 10, 270, 6213, 12, 971, 27804, 270, 1197, 6213, 776, 2126, 4882, 805, 543, 1627, 2368, 4453, 282, 2653, 21947, 2126, 1077, 506, 1202, 370, 4816, 10919, 17135, 2366, 3423, 199, 199, 624, 199, 363, 50, 3298, 998, 363, 275, 7880, 1304, 17351, 199, 199, 504, 12866, 492, 7132, 12, 13537, 199, 646, 5796, 199, 646, 900, 199, 646, 3504, 199, 646, 747, 199, 646, 984, 199, 646, 2943, 199, 646, 3873, 199, 646, 4673, 199, 3, 812, 994, 3161, 867, 26, 199, 3, 221, 11842, 781, 883, 440, 492, 5370, 687, 26565, 12, 3967, 642, 570, 652, 365, 8439, 199, 3, 221, 737, 11097, 900, 16119, 314, 2615, 931, 365, 5784, 199, 3, 687, 26565, 492, 428, 63, 3593, 12, 428, 63, 3170, 199, 504, 26565, 14, 5402, 14, 22905, 14, 1767, 6550, 492, 428, 63, 3593, 12, 428, 63, 3170, 199, 3, 687, 26565, 492, 30068, 199, 504, 26565, 14, 16442, 3989, 14, 3041, 14, 4455, 492, 30068, 199, 504, 26565, 14, 5402, 14, 22905, 492, 577, 9686, 199, 199, 4701, 63, 55, 8078, 1649, 39, 275, 756, 199, 199, 533, 29075, 13889, 8, 909, 3461, 523, 408, 523, 2508, 1021, 29075, 13889, 819, 2653, 9626, 13889, 7531, 523, 408, 523, 347, 636, 826, 721, 291, 12, 2562, 12, 1249, 29, 403, 12, 2074, 29, 403, 3461, 272, 408, 286, 1133, 269, 408, 272, 291, 14, 1532, 275, 2562, 340, 4550, 8, 1532, 9, 587, 488, 272, 291, 14, 589, 275, 1249, 340, 1249, 587, 2008, 342, 272, 291, 14, 958, 275, 2074, 340, 2074, 587, 1052, 272, 291, 14, 928, 275, 291, 14, 500, 275, 291, 14, 3150, 275, 488, 272, 291, 14, 13057, 2390, 275, 5796, 14, 2390, 342, 272, 291, 14, 13057, 2390, 14, 3584, 342, 272, 291, 855, 6821, 13889, 4436, 275, 488, 272, 291, 14, 2609, 275, 13537, 342, 272, 291, 14, 83, 63, 745, 63, 705, 275, 291, 14, 2609, 14, 807, 342, 272, 291, 855, 13471, 275, 7132, 8, 1347, 275, 291, 14, 1065, 63, 1532, 12, 1249, 275, 334, 277, 14, 83, 63, 745, 63, 705, 12, 776, 776, 819, 347, 1255, 63, 1532, 8, 291, 12, 308, 63, 745, 63, 705, 3461, 272, 408, 3873, 1347, 18407, 520, 635, 16850, 5200, 26, 5200, 1202, 367, 23506, 272, 408, 272, 862, 26, 489, 2203, 275, 291, 14, 1532, 8, 627, 277, 14, 589, 12, 1011, 277, 14, 958, 776, 489, 925, 663, 29329, 1566, 489, 291, 14, 13057, 2390, 14, 409, 342, 489, 367, 1022, 315, 2203, 26, 267, 308, 63, 745, 63, 705, 59, 75, 61, 275, 2203, 59, 75, 61, 272, 871, 2186, 12, 1125, 26, 489, 308, 63, 745, 63, 705, 905, 3593, 937, 275, 221, 756, 489, 308, 63, 745, 63, 705, 905, 2209, 937, 275, 620, 8, 705, 9, 272, 3753, 26, 489, 925, 5436, 29329, 1566, 489, 291, 14, 13057, 2390, 14, 3584, 342, 819, 347, 9626, 13889, 8, 291, 3461, 272, 408, 9626, 13889, 2462, 1347, 408, 272, 1830, 715, 26, 489, 340, 291, 14, 13057, 2390, 14, 374, 63, 409, 342, 503, 900, 14, 521, 342, 665, 291, 14, 500, 26, 267, 900, 14, 4532, 8, 21, 9, 489, 587, 26, 267, 2059, 272, 340, 440, 291, 855, 13471, 14, 374, 63, 9631, 837, 489, 372, 272, 587, 26, 489, 925, 3618, 5133, 519, 15, 87, 3439, 9578, 397, 489, 1830, 291, 14, 13057, 2390, 14, 374, 63, 409, 837, 267, 900, 14, 4532, 8, 21, 9, 267, 1980, 489, 925, 15522, 16718, 489, 747, 14, 8997, 8, 291, 14, 3150, 12, 4673, 14, 29190, 776, 489, 900, 14, 4532, 8, 21, 9, 489, 925, 15522, 30691, 489, 340, 291, 855, 13471, 14, 374, 63, 9631, 837, 267, 747, 14, 8997, 8, 291, 14, 3150, 12, 4673, 14, 7864, 30691, 776, 2126, 523, 347, 636, 1250, 721, 291, 12, 2653, 275, 378, 3461, 272, 408, 7531, 6451, 408, 272, 2653, 275, 1109, 8, 2593, 9, 272, 2203, 275, 469, 298, 3593, 2, 520, 715, 12, 298, 1110, 2, 520, 3087, 789, 272, 340, 2653, 26, 489, 291, 14, 928, 275, 1109, 8, 900, 14, 521, 342, 776, 489, 291, 14, 500, 275, 291, 14, 928, 435, 2653, 435, 499, 489, 291, 855, 6821, 13889, 4436, 275, 5796, 14, 4436, 8, 1347, 275, 291, 14, 6821, 13889, 776, 489, 291, 855, 6821, 13889, 4436, 14, 10824, 275, 715, 489, 291, 855, 6821, 13889, 4436, 14, 928, 342, 489, 2203, 275, 469, 298, 3593, 2, 520, 756, 12, 298, 2209, 2, 520, 298, 6372, 2410, 450, 83, 4696, 2, 450, 2653, 12, 1598, 298, 1110, 582, 334 ]
[ 2672, 11664, 2632, 4, 199, 624, 199, 3022, 1348, 21947, 370, 5341, 2366, 436, 2656, 3718, 543, 282, 4975, 12, 626, 5594, 199, 409, 282, 2653, 14, 199, 19, 21498, 19560, 787, 2741, 26, 272, 1362, 446, 5218, 2176, 8, 284, 1366, 2204, 12, 2088, 11205, 12, 3233, 3481, 275, 488, 12, 2589, 275, 488, 3461, 2126, 652, 4440, 3873, 14, 7942, 1021, 543, 298, 5641, 275, 715, 1674, 2126, 982, 2088, 11205, 365, 282, 1059, 12, 652, 9314, 314, 1414, 1059, 370, 5341, 4012, 2126, 314, 5218, 14, 221, 982, 2088, 11205, 365, 282, 3414, 12, 314, 1642, 1242, 9314, 314, 1414, 2126, 1059, 12, 436, 1263, 4722, 2974, 911, 506, 10184, 465, 4722, 5218, 2368, 14, 10813, 446, 2656, 2176, 8, 284, 1366, 2204, 12, 2088, 11205, 12, 3233, 3481, 275, 488, 12, 2589, 275, 488, 3461, 2126, 652, 4440, 3873, 14, 7942, 1021, 543, 298, 5641, 275, 756, 1674, 2126, 2088, 11205, 1077, 506, 282, 1059, 12, 503, 282, 3414, 402, 2240, 2368, 14, 10817, 4635, 436, 3839, 787, 6682, 1915, 14, 3233, 3481, 8, 5200, 1304, 12, 1004, 776, 883, 506, 2126, 3247, 370, 2112, 314, 3839, 334, 4990, 1304, 275, 378, 9, 436, 4635, 334, 4990, 1304, 275, 413, 9, 465, 2126, 2985, 787, 13584, 267, 2126, 9322, 372, 282, 26565, 14, 1767, 1110, 2600, 543, 282, 2008, 315, 1594, 2126, 334, 17630, 12, 3839, 12, 4635, 776, 314, 2008, 911, 2597, 506, 2808, 12188, 2126, 2653, 1125, 503, 3335, 15784, 1125, 14, 10813, 446, 2366, 2176, 8, 284, 1366, 2204, 12, 805, 12, 971, 10, 270, 6213, 12, 971, 27804, 270, 1197, 6213, 776, 2126, 4882, 805, 543, 1627, 2368, 4453, 282, 2653, 21947, 2126, 1077, 506, 1202, 370, 4816, 10919, 17135, 2366, 3423, 199, 199, 624, 199, 363, 50, 3298, 998, 363, 275, 7880, 1304, 17351, 199, 199, 504, 12866, 492, 7132, 12, 13537, 199, 646, 5796, 199, 646, 900, 199, 646, 3504, 199, 646, 747, 199, 646, 984, 199, 646, 2943, 199, 646, 3873, 199, 646, 4673, 199, 3, 812, 994, 3161, 867, 26, 199, 3, 221, 11842, 781, 883, 440, 492, 5370, 687, 26565, 12, 3967, 642, 570, 652, 365, 8439, 199, 3, 221, 737, 11097, 900, 16119, 314, 2615, 931, 365, 5784, 199, 3, 687, 26565, 492, 428, 63, 3593, 12, 428, 63, 3170, 199, 504, 26565, 14, 5402, 14, 22905, 14, 1767, 6550, 492, 428, 63, 3593, 12, 428, 63, 3170, 199, 3, 687, 26565, 492, 30068, 199, 504, 26565, 14, 16442, 3989, 14, 3041, 14, 4455, 492, 30068, 199, 504, 26565, 14, 5402, 14, 22905, 492, 577, 9686, 199, 199, 4701, 63, 55, 8078, 1649, 39, 275, 756, 199, 199, 533, 29075, 13889, 8, 909, 3461, 523, 408, 523, 2508, 1021, 29075, 13889, 819, 2653, 9626, 13889, 7531, 523, 408, 523, 347, 636, 826, 721, 291, 12, 2562, 12, 1249, 29, 403, 12, 2074, 29, 403, 3461, 272, 408, 286, 1133, 269, 408, 272, 291, 14, 1532, 275, 2562, 340, 4550, 8, 1532, 9, 587, 488, 272, 291, 14, 589, 275, 1249, 340, 1249, 587, 2008, 342, 272, 291, 14, 958, 275, 2074, 340, 2074, 587, 1052, 272, 291, 14, 928, 275, 291, 14, 500, 275, 291, 14, 3150, 275, 488, 272, 291, 14, 13057, 2390, 275, 5796, 14, 2390, 342, 272, 291, 14, 13057, 2390, 14, 3584, 342, 272, 291, 855, 6821, 13889, 4436, 275, 488, 272, 291, 14, 2609, 275, 13537, 342, 272, 291, 14, 83, 63, 745, 63, 705, 275, 291, 14, 2609, 14, 807, 342, 272, 291, 855, 13471, 275, 7132, 8, 1347, 275, 291, 14, 1065, 63, 1532, 12, 1249, 275, 334, 277, 14, 83, 63, 745, 63, 705, 12, 776, 776, 819, 347, 1255, 63, 1532, 8, 291, 12, 308, 63, 745, 63, 705, 3461, 272, 408, 3873, 1347, 18407, 520, 635, 16850, 5200, 26, 5200, 1202, 367, 23506, 272, 408, 272, 862, 26, 489, 2203, 275, 291, 14, 1532, 8, 627, 277, 14, 589, 12, 1011, 277, 14, 958, 776, 489, 925, 663, 29329, 1566, 489, 291, 14, 13057, 2390, 14, 409, 342, 489, 367, 1022, 315, 2203, 26, 267, 308, 63, 745, 63, 705, 59, 75, 61, 275, 2203, 59, 75, 61, 272, 871, 2186, 12, 1125, 26, 489, 308, 63, 745, 63, 705, 905, 3593, 937, 275, 221, 756, 489, 308, 63, 745, 63, 705, 905, 2209, 937, 275, 620, 8, 705, 9, 272, 3753, 26, 489, 925, 5436, 29329, 1566, 489, 291, 14, 13057, 2390, 14, 3584, 342, 819, 347, 9626, 13889, 8, 291, 3461, 272, 408, 9626, 13889, 2462, 1347, 408, 272, 1830, 715, 26, 489, 340, 291, 14, 13057, 2390, 14, 374, 63, 409, 342, 503, 900, 14, 521, 342, 665, 291, 14, 500, 26, 267, 900, 14, 4532, 8, 21, 9, 489, 587, 26, 267, 2059, 272, 340, 440, 291, 855, 13471, 14, 374, 63, 9631, 837, 489, 372, 272, 587, 26, 489, 925, 3618, 5133, 519, 15, 87, 3439, 9578, 397, 489, 1830, 291, 14, 13057, 2390, 14, 374, 63, 409, 837, 267, 900, 14, 4532, 8, 21, 9, 267, 1980, 489, 925, 15522, 16718, 489, 747, 14, 8997, 8, 291, 14, 3150, 12, 4673, 14, 29190, 776, 489, 900, 14, 4532, 8, 21, 9, 489, 925, 15522, 30691, 489, 340, 291, 855, 13471, 14, 374, 63, 9631, 837, 267, 747, 14, 8997, 8, 291, 14, 3150, 12, 4673, 14, 7864, 30691, 776, 2126, 523, 347, 636, 1250, 721, 291, 12, 2653, 275, 378, 3461, 272, 408, 7531, 6451, 408, 272, 2653, 275, 1109, 8, 2593, 9, 272, 2203, 275, 469, 298, 3593, 2, 520, 715, 12, 298, 1110, 2, 520, 3087, 789, 272, 340, 2653, 26, 489, 291, 14, 928, 275, 1109, 8, 900, 14, 521, 342, 776, 489, 291, 14, 500, 275, 291, 14, 928, 435, 2653, 435, 499, 489, 291, 855, 6821, 13889, 4436, 275, 5796, 14, 4436, 8, 1347, 275, 291, 14, 6821, 13889, 776, 489, 291, 855, 6821, 13889, 4436, 14, 10824, 275, 715, 489, 291, 855, 6821, 13889, 4436, 14, 928, 342, 489, 2203, 275, 469, 298, 3593, 2, 520, 756, 12, 298, 2209, 2, 520, 298, 6372, 2410, 450, 83, 4696, 2, 450, 2653, 12, 1598, 298, 1110, 582, 334, 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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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 ]
hbrunn/OCB
addons/hr_holidays/tests/common.py
389
4347
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2013-TODAY 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/>. # ############################################################################## from openerp.tests import common class TestHrHolidaysBase(common.TransactionCase): def setUp(self): super(TestHrHolidaysBase, self).setUp() cr, uid = self.cr, self.uid # Usefull models self.hr_employee = self.registry('hr.employee') self.hr_holidays = self.registry('hr.holidays') self.hr_holidays_status = self.registry('hr.holidays.status') self.res_users = self.registry('res.users') self.res_partner = self.registry('res.partner') # Find Employee group group_employee_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user') self.group_employee_id = group_employee_ref and group_employee_ref[1] or False # Find Hr User group group_hr_user_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_hr_user') self.group_hr_user_ref_id = group_hr_user_ref and group_hr_user_ref[1] or False # Find Hr Manager group group_hr_manager_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_hr_manager') self.group_hr_manager_ref_id = group_hr_manager_ref and group_hr_manager_ref[1] or False # Test partners to use through the various tests self.hr_partner_id = self.res_partner.create(cr, uid, { 'name': 'Gertrude AgrolaitPartner', 'email': 'gertrude.partner@agrolait.com', }) self.email_partner_id = self.res_partner.create(cr, uid, { 'name': 'Patrick Ratatouille', 'email': 'patrick.ratatouille@agrolait.com', }) # Test users to use through the various tests self.user_hruser_id = self.res_users.create(cr, uid, { 'name': 'Armande HrUser', 'login': 'Armande', 'alias_name': 'armande', 'email': 'armande.hruser@example.com', 'groups_id': [(6, 0, [self.group_employee_id, self.group_hr_user_ref_id])] }, {'no_reset_password': True}) self.user_hrmanager_id = self.res_users.create(cr, uid, { 'name': 'Bastien HrManager', 'login': 'bastien', 'alias_name': 'bastien', 'email': 'bastien.hrmanager@example.com', 'groups_id': [(6, 0, [self.group_employee_id, self.group_hr_manager_ref_id])] }, {'no_reset_password': True}) self.user_none_id = self.res_users.create(cr, uid, { 'name': 'Charlie Avotbonkeur', 'login': 'charlie', 'alias_name': 'charlie', 'email': 'charlie.noone@example.com', 'groups_id': [(6, 0, [])] }, {'no_reset_password': True}) self.user_employee_id = self.res_users.create(cr, uid, { 'name': 'David Employee', 'login': 'david', 'alias_name': 'david', 'email': 'david.employee@example.com', 'groups_id': [(6, 0, [self.group_employee_id])] }, {'no_reset_password': True}) # Hr Data self.employee_emp_id = self.hr_employee.create(cr, uid, { 'name': 'David Employee', 'user_id': self.user_employee_id, }) self.employee_hruser_id = self.hr_employee.create(cr, uid, { 'name': 'Armande HrUser', 'user_id': self.user_hruser_id, })
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 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, 504, 5166, 14, 2219, 492, 2863, 421, 199, 533, 1379, 40, 82, 17810, 317, 4899, 1563, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 40, 82, 17810, 317, 4899, 1563, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 3645, 2861, 1709, 267, 291, 14, 6271, 63, 10103, 275, 291, 14, 5189, 360, 6271, 14, 10103, 358, 267, 291, 14, 6271, 63, 26131, 275, 291, 14, 5189, 360, 6271, 14, 26131, 358, 267, 291, 14, 6271, 63, 26131, 63, 1205, 275, 291, 14, 5189, 360, 6271, 14, 26131, 14, 1205, 358, 267, 291, 14, 470, 63, 3707, 275, 291, 14, 5189, 360, 470, 14, 3707, 358, 267, 291, 14, 470, 63, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 398, 327, 6668, 24089, 1572, 267, 1572, 63, 10103, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 751, 358, 267, 291, 14, 923, 63, 10103, 63, 344, 275, 1572, 63, 10103, 63, 1121, 436, 1572, 63, 10103, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 6668, 869, 82, 2876, 1572, 267, 1572, 63, 6271, 63, 751, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 6271, 63, 751, 358, 267, 291, 14, 923, 63, 6271, 63, 751, 63, 1121, 63, 344, 275, 1572, 63, 6271, 63, 751, 63, 1121, 436, 1572, 63, 6271, 63, 751, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 6668, 869, 82, 13537, 1572, 267, 1572, 63, 6271, 63, 2609, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 6271, 63, 2609, 358, 267, 291, 14, 923, 63, 6271, 63, 2609, 63, 1121, 63, 344, 275, 1572, 63, 6271, 63, 2609, 63, 1121, 436, 1572, 63, 6271, 63, 2609, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 1379, 18943, 370, 675, 4012, 314, 7750, 2295, 267, 291, 14, 6271, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 27866, 454, 3786, 21582, 293, 416, 390, 24120, 297, 288, 283, 2123, 356, 283, 836, 454, 3786, 14, 3899, 32, 643, 293, 416, 390, 14, 957, 297, 267, 3828, 267, 291, 14, 2123, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 48, 292, 27091, 820, 292, 292, 810, 17142, 297, 288, 283, 2123, 356, 283, 10853, 27091, 14, 17565, 292, 810, 17142, 32, 643, 293, 416, 390, 14, 957, 297, 267, 3828, 398, 327, 1379, 4390, 370, 675, 4012, 314, 7750, 2295, 267, 291, 14, 751, 63, 6271, 751, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 1596, 1237, 271, 869, 82, 1899, 297, 288, 283, 2886, 356, 283, 1596, 1237, 271, 297, 288, 283, 3620, 63, 354, 356, 283, 285, 1237, 271, 297, 288, 283, 2123, 356, 283, 285, 1237, 271, 14, 6271, 751, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 10103, 63, 344, 12, 291, 14, 923, 63, 6271, 63, 751, 63, 1121, 63, 344, 12457, 267, 1660, 791, 889, 63, 3958, 63, 2060, 356, 715, 1552, 267, 291, 14, 751, 63, 6271, 2609, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 34, 1810, 24555, 869, 82, 2988, 297, 288, 283, 2886, 356, 283, 66, 1810, 24555, 297, 288, 283, 3620, 63, 354, 356, 283, 66, 1810, 24555, 297, 288, 283, 2123, 356, 283, 66, 1810, 24555, 14, 6271, 2609, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 10103, 63, 344, 12, 291, 14, 923, 63, 6271, 63, 2609, 63, 1121, 63, 344, 12457, 267, 1660, 791, 889, 63, 3958, 63, 2060, 356, 715, 1552, 267, 291, 14, 751, 63, 3592, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 1610, 21530, 16599, 357, 13520, 415, 300, 297, 288, 283, 2886, 356, 283, 1560, 21530, 297, 288, 283, 3620, 63, 354, 356, 283, 1560, 21530, 297, 288, 283, 2123, 356, 283, 1560, 21530, 14, 889, 368, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 3073, 61, 267, 1660, 791 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 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, 504, 5166, 14, 2219, 492, 2863, 421, 199, 533, 1379, 40, 82, 17810, 317, 4899, 1563, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 40, 82, 17810, 317, 4899, 1563, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 3645, 2861, 1709, 267, 291, 14, 6271, 63, 10103, 275, 291, 14, 5189, 360, 6271, 14, 10103, 358, 267, 291, 14, 6271, 63, 26131, 275, 291, 14, 5189, 360, 6271, 14, 26131, 358, 267, 291, 14, 6271, 63, 26131, 63, 1205, 275, 291, 14, 5189, 360, 6271, 14, 26131, 14, 1205, 358, 267, 291, 14, 470, 63, 3707, 275, 291, 14, 5189, 360, 470, 14, 3707, 358, 267, 291, 14, 470, 63, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 398, 327, 6668, 24089, 1572, 267, 1572, 63, 10103, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 751, 358, 267, 291, 14, 923, 63, 10103, 63, 344, 275, 1572, 63, 10103, 63, 1121, 436, 1572, 63, 10103, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 6668, 869, 82, 2876, 1572, 267, 1572, 63, 6271, 63, 751, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 6271, 63, 751, 358, 267, 291, 14, 923, 63, 6271, 63, 751, 63, 1121, 63, 344, 275, 1572, 63, 6271, 63, 751, 63, 1121, 436, 1572, 63, 6271, 63, 751, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 6668, 869, 82, 13537, 1572, 267, 1572, 63, 6271, 63, 2609, 63, 1121, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 6271, 63, 2609, 358, 267, 291, 14, 923, 63, 6271, 63, 2609, 63, 1121, 63, 344, 275, 1572, 63, 6271, 63, 2609, 63, 1121, 436, 1572, 63, 6271, 63, 2609, 63, 1121, 59, 17, 61, 503, 756, 398, 327, 1379, 18943, 370, 675, 4012, 314, 7750, 2295, 267, 291, 14, 6271, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 27866, 454, 3786, 21582, 293, 416, 390, 24120, 297, 288, 283, 2123, 356, 283, 836, 454, 3786, 14, 3899, 32, 643, 293, 416, 390, 14, 957, 297, 267, 3828, 267, 291, 14, 2123, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 48, 292, 27091, 820, 292, 292, 810, 17142, 297, 288, 283, 2123, 356, 283, 10853, 27091, 14, 17565, 292, 810, 17142, 32, 643, 293, 416, 390, 14, 957, 297, 267, 3828, 398, 327, 1379, 4390, 370, 675, 4012, 314, 7750, 2295, 267, 291, 14, 751, 63, 6271, 751, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 1596, 1237, 271, 869, 82, 1899, 297, 288, 283, 2886, 356, 283, 1596, 1237, 271, 297, 288, 283, 3620, 63, 354, 356, 283, 285, 1237, 271, 297, 288, 283, 2123, 356, 283, 285, 1237, 271, 14, 6271, 751, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 10103, 63, 344, 12, 291, 14, 923, 63, 6271, 63, 751, 63, 1121, 63, 344, 12457, 267, 1660, 791, 889, 63, 3958, 63, 2060, 356, 715, 1552, 267, 291, 14, 751, 63, 6271, 2609, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 34, 1810, 24555, 869, 82, 2988, 297, 288, 283, 2886, 356, 283, 66, 1810, 24555, 297, 288, 283, 3620, 63, 354, 356, 283, 66, 1810, 24555, 297, 288, 283, 2123, 356, 283, 66, 1810, 24555, 14, 6271, 2609, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 10103, 63, 344, 12, 291, 14, 923, 63, 6271, 63, 2609, 63, 1121, 63, 344, 12457, 267, 1660, 791, 889, 63, 3958, 63, 2060, 356, 715, 1552, 267, 291, 14, 751, 63, 3592, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 1610, 21530, 16599, 357, 13520, 415, 300, 297, 288, 283, 2886, 356, 283, 1560, 21530, 297, 288, 283, 3620, 63, 354, 356, 283, 1560, 21530, 297, 288, 283, 2123, 356, 283, 1560, 21530, 14, 889, 368, 32, 2694, 14, 957, 297, 288, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 3073, 61, 267, 1660, 791, 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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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 ]
brittanystoroz/kitsune
kitsune/wiki/events.py
3
13229
import difflib import logging from django.conf import settings from django.contrib.sites.models import Site from django.core.urlresolvers import reverse as django_reverse from django.utils.translation import ugettext as _, ugettext_lazy as _lazy from bleach import clean from tidings.events import InstanceEvent, Event, EventUnion from tidings.utils import hash_to_unsigned from wikimarkup.parser import ALLOWED_TAGS, ALLOWED_ATTRIBUTES from kitsune.sumo import email_utils from kitsune.sumo.templatetags.jinja_helpers import add_utm from kitsune.sumo.urlresolvers import reverse from kitsune.wiki.models import Document log = logging.getLogger('k.wiki.events') def get_diff_for(doc, old_rev, new_rev): fromfile = u'[%s] %s #%s' % (doc.locale, doc.title, old_rev.id) tofile = u'[%s] %s #%s' % (doc.locale, doc.title, new_rev.id) # difflib expects these to be bytes, not unicode fromfile = fromfile.encode('utf8') tofile = tofile.encode('utf8') # Get diff diff_parts = difflib.unified_diff( old_rev.content.splitlines(1), new_rev.content.splitlines(1), fromfile=fromfile, tofile=tofile) # Join diff parts # XXX this is super goofy acc = u'' for d in diff_parts: if isinstance(d, unicode): acc = acc + d else: acc = acc + d.decode('utf8') # Clean output return clean(acc, ALLOWED_TAGS, ALLOWED_ATTRIBUTES) def context_dict(revision, ready_for_l10n=False, revision_approved=False): """Return a dict that fills in the blanks in KB notification templates.""" diff = '' l10n = revision.document.revisions.filter(is_ready_for_localization=True) approved = revision.document.revisions.filter(is_approved=True) if ready_for_l10n and l10n.count() > 1: old_rev = l10n.order_by('-created')[1] diff = get_diff_for(revision.document, old_rev, revision) elif revision_approved and approved.count() > 1: old_rev = approved.order_by('-created')[1] diff = get_diff_for(revision.document, old_rev, revision) elif revision.document.current_revision is not None: old_rev = revision.document.current_revision diff = get_diff_for(revision.document, old_rev, revision) return { 'document_title': revision.document.title, 'creator': revision.creator, 'host': Site.objects.get_current().domain, 'diff': diff, 'summary': clean(revision.summary, ALLOWED_TAGS, ALLOWED_ATTRIBUTES), 'fulltext': clean(revision.content, ALLOWED_TAGS, ALLOWED_ATTRIBUTES), } class EditDocumentEvent(InstanceEvent): """Event fired when a certain document is edited""" event_type = 'wiki edit document' content_type = Document def __init__(self, revision): super(EditDocumentEvent, self).__init__(revision.document) self.revision = revision def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug('Sending edited notification email for document (id=%s)' % document.id) subject = _lazy(u'{title} was edited by {creator}') url = reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]) context = context_dict(revision) context['revisions_url'] = add_utm(url, 'wiki-edit') context['locale'] = document.locale context['title'] = document.title context['creator'] = revision.creator context['comment'] = revision.comment return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/edited.ltxt', html_template='wiki/email/edited.html', context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale) class _RevisionConstructor(object): """An event that receives a revision when constructed""" def __init__(self, revision): super(_RevisionConstructor, self).__init__() self.revision = revision class _BaseProductFilter(object): """A base class for product filters. It adds a _filter_by_product method that filters down a list of (user, watches) to only the users watching the products for the revision. """ def _filter_by_product(self, all_watchers): products = self.revision.document.get_products() product_hashes = [hash_to_unsigned(s.slug) for s in products] watchers_and_watches = [] # Weed out the users that have a product filter that isn't one of the # document's products. for user, watches in all_watchers: for watch in watches: # Get the product filters for the watch, if any. prods = watch.filters.filter( name='product').values_list('value', flat=True) # If there are no product filters, they are watching them all. if len(prods) == 0: watchers_and_watches.append((user, watches)) break # Otherwise, check if they are watching any of the document's # products. for prod in prods: if prod in product_hashes: watchers_and_watches.append((user, watches)) break return watchers_and_watches class _ProductFilter(_BaseProductFilter): """An event that receives a revision when constructed and filters according to that revision's document's products""" filters = set(['product']) # notify(), stop_notifying(), and is_notifying() take... # (user_or_email, product=optional_product) def _users_watching(self, **kwargs): # Get the users watching any or all products. users = list(self._users_watching_by_filter(**kwargs)) # Weed out the users that have a product filter that isn't one of the # document's products. return self._filter_by_product(users) class _LocaleAndProductFilter(_BaseProductFilter): """An event that receives a revision when constructed and filters according to that revision's document's locale and products.""" filters = set(['locale', 'product']) # notify(), stop_notifying(), and is_notifying() take... # (user_or_email, locale=some_locale, product=optional_product) def _users_watching(self, **kwargs): locale = self.revision.document.locale # Get the users just subscribed to the locale (any and all products). users = list(self._users_watching_by_filter(locale=locale, **kwargs)) # Weed out the users that have a product filter that isn't one of the # document's products. return self._filter_by_product(users) class ReviewableRevisionInLocaleEvent(_RevisionConstructor, _LocaleAndProductFilter, Event): """Event fired when any revision in a certain locale is ready for review""" # Our event_type suffices to limit our scope, so we don't bother # setting content_type. event_type = 'reviewable wiki in locale' def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug('Sending ready for review email for revision (id=%s)' % revision.id) subject = _lazy(u'{title} is ready for review ({creator})') url = reverse('wiki.review_revision', locale=document.locale, args=[document.slug, revision.id]) context = context_dict(revision) context['revision_url'] = add_utm(url, 'wiki-ready-review') context['locale'] = document.locale context['title'] = document.title context['creator'] = revision.creator context['comment'] = revision.comment users = [] for u, w in users_and_watches: if document.allows(u, 'review_revision'): users.append((u, w)) return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/ready_for_review.ltxt', html_template='wiki/email/ready_for_review.html', context_vars=context, users_and_watches=users, default_locale=document.locale) class ReadyRevisionEvent(_RevisionConstructor, _ProductFilter, Event): """Event fired when a revision becomes ready for l10n.""" event_type = 'ready wiki' def _mails(self, users_and_watches): """Send readiness mails.""" revision = self.revision document = revision.document log.debug('Sending ready notifications for revision (id=%s)' % revision.id) subject = _lazy(u'{title} has a revision ready for localization') url = django_reverse('wiki.select_locale', args=[document.slug]) context = context_dict(revision, ready_for_l10n=True) context['l10n_url'] = add_utm(url, 'wiki-ready-l10n') context['title'] = document.title return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/ready_for_l10n.ltxt', html_template='wiki/email/ready_for_l10n.html', context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale) class ApproveRevisionInLocaleEvent(_RevisionConstructor, _LocaleAndProductFilter, Event): """Event fed to a union when any revision in a certain locale is approved Not intended to be fired individually """ # No other content types have a concept of approval, so we don't bother # setting content_type. event_type = 'approved wiki in locale' class ApprovedOrReadyUnion(EventUnion): """Event union fired when a revision is approved and also possibly ready Unioned events must have a `revision` attr. """ def __init__(self, *args, **kwargs): super(ApprovedOrReadyUnion, self).__init__(*args, **kwargs) self._revision = self.events[0].revision def _mails(self, users_and_watches): """Send approval or readiness mails, as appropriate. If a given user is watching the Ready event and the revision is in fact ready, say so. Otherwise, just send the Approval email. """ revision = self._revision document = revision.document is_ready = revision.is_ready_for_localization log.debug('Sending approved/ready notifications for revision (id=%s)' % revision.id) # Localize the subject and message with the appropriate # context. If there is an error, fall back to English. @email_utils.safe_translation def _make_mail(locale, user, watches): if (is_ready and ReadyRevisionEvent.event_type in (w.event_type for w in watches)): c = context_dict(revision, ready_for_l10n=True) # TODO: Expose all watches c['watch'] = watches[0] url = django_reverse( 'wiki.select_locale', args=[document.slug]) c['l10n_url'] = add_utm(url, 'wiki-ready-l10n') subject = _(u'{title} has a revision ready for ' 'localization') text_template = 'wiki/email/ready_for_l10n.ltxt' html_template = 'wiki/email/ready_for_l10n.html' else: c = context_dict(revision, revision_approved=True) approved_url = reverse('wiki.document', locale=document.locale, args=[document.slug]) c['document_url'] = add_utm(approved_url, 'wiki-approved') # TODO: Expose all watches. c['watch'] = watches[0] c['reviewer'] = revision.reviewer subject = _(u'{title} ({locale}) has a new approved ' 'revision ({reviewer})') text_template = 'wiki/email/approved.ltxt' html_template = 'wiki/email/approved.html' subject = subject.format( title=document.title, reviewer=revision.reviewer.username, locale=document.locale) mail = email_utils.make_mail( subject=subject, text_template=text_template, html_template=html_template, context_vars=c, from_email=settings.TIDINGS_FROM_ADDRESS, to_email=user.email) return mail for user, watches in users_and_watches: # Figure out the locale to use for l10n. if hasattr(user, 'profile'): locale = user.profile.locale else: locale = document.locale yield _make_mail(locale, user, watches)
bsd-3-clause
[ 646, 27070, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 465, 1639, 63, 4471, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 465, 485, 6395, 199, 199, 504, 29603, 1225, 492, 3633, 199, 504, 11559, 780, 14, 4368, 492, 10066, 2390, 12, 6763, 12, 6763, 15540, 199, 504, 11559, 780, 14, 1208, 492, 2631, 63, 475, 63, 2244, 199, 504, 336, 3258, 1017, 1096, 384, 14, 2087, 492, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 199, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 492, 3031, 63, 1208, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 1050, 63, 337, 77, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 16522, 492, 3837, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 992, 492, 7543, 421, 199, 793, 275, 2050, 14, 5572, 360, 75, 14, 6797, 14, 4368, 358, 421, 199, 318, 664, 63, 3028, 63, 509, 8, 1301, 12, 2269, 63, 4964, 12, 892, 63, 4964, 304, 267, 687, 493, 275, 399, 3894, 5, 83, 61, 450, 83, 24307, 83, 7, 450, 334, 1301, 14, 5508, 12, 1382, 14, 1213, 12, 2269, 63, 4964, 14, 344, 9, 267, 370, 493, 275, 399, 3894, 5, 83, 61, 450, 83, 24307, 83, 7, 450, 334, 1301, 14, 5508, 12, 1382, 14, 1213, 12, 892, 63, 4964, 14, 344, 9, 267, 327, 27070, 14292, 3520, 370, 506, 2783, 12, 440, 2649, 267, 687, 493, 275, 687, 493, 14, 2143, 360, 1624, 24, 358, 267, 370, 493, 275, 370, 493, 14, 2143, 360, 1624, 24, 358, 398, 327, 2372, 3915, 267, 3915, 63, 4181, 275, 27070, 14, 32180, 63, 3028, 8, 288, 2269, 63, 4964, 14, 1317, 14, 7644, 8, 17, 395, 288, 892, 63, 4964, 14, 1317, 14, 7644, 8, 17, 395, 288, 687, 493, 29, 30717, 12, 370, 493, 29, 475, 493, 9, 398, 327, 25733, 3915, 4184, 267, 327, 5787, 642, 365, 1613, 486, 1534, 1399, 267, 6907, 275, 399, 891, 267, 367, 366, 315, 3915, 63, 4181, 26, 288, 340, 1228, 8, 68, 12, 2649, 304, 355, 6907, 275, 6907, 435, 366, 288, 587, 26, 355, 6907, 275, 6907, 435, 366, 14, 2708, 360, 1624, 24, 358, 398, 327, 12762, 1072, 267, 372, 3633, 8, 5470, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 9, 421, 199, 318, 1067, 63, 807, 8, 5792, 12, 10144, 63, 509, 63, 76, 709, 78, 29, 797, 12, 6974, 63, 21556, 29, 797, 304, 272, 408, 1767, 282, 1211, 626, 1794, 478, 315, 314, 4596, 83, 315, 27638, 6955, 7009, 1041, 272, 3915, 275, 2125, 272, 634, 709, 78, 275, 6974, 14, 3554, 14, 23449, 14, 1541, 8, 374, 63, 2179, 63, 509, 63, 1832, 2072, 29, 549, 9, 272, 30055, 275, 6974, 14, 3554, 14, 23449, 14, 1541, 8, 374, 63, 21556, 29, 549, 9, 339, 340, 10144, 63, 509, 63, 76, 709, 78, 436, 634, 709, 78, 14, 835, 342, 690, 413, 26, 267, 2269, 63, 4964, 275, 634, 709, 78, 14, 1648, 63, 991, 3654, 3966, 5832, 17, 61, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 272, 916, 6974, 63, 21556, 436, 30055, 14, 835, 342, 690, 413, 26, 267, 2269, 63, 4964, 275, 30055, 14, 1648, 63, 991, 3654, 3966, 5832, 17, 61, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 272, 916, 6974, 14, 3554, 14, 1818, 63, 5792, 365, 440, 488, 26, 267, 2269, 63, 4964, 275, 6974, 14, 3554, 14, 1818, 63, 5792, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 339, 372, 469, 267, 283, 3554, 63, 1213, 356, 6974, 14, 3554, 14, 1213, 12, 267, 283, 9986, 356, 6974, 14, 9986, 12, 267, 283, 1102, 356, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 12, 267, 283, 3028, 356, 3915, 12, 267, 283, 4705, 356, 3633, 8, 5792, 14, 4705, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 395, 267, 283, 2861, 505, 356, 3633, 8, 5792, 14, 1317, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 395, 272, 789, 421, 199, 533, 16407, 5564, 2390, 8, 3244, 2390, 304, 272, 408, 2390, 31974, 1380, 282, 9842, 2213, 365, 21062, 624, 272, 1566, 63, 466, 275, 283, 6797, 5283, 2213, 7, 272, 1564, 63, 466, 275, 7543, 339, 347, 636, 826, 721, 277, 12, 6974, 304, 267, 1613, 8, 4685, 5564, 2390, 12, 291, 2843, 826, 721, 5792, 14, 3554, 9, 267, 291, 14, 5792, 275, 6974, 339, 347, 485, 1198, 83, 8, 277, 12, 4390, 63, 460, 63, 6821, 397, 304, 267, 6974, 275, 291, 14, 5792, 267, 2213, 275, 6974, 14, 3554, 267, 943, 14, 1757, 360, 27219, 21062, 6955, 3031, 367, 2213, 334, 344, 2458, 83, 3171, 450, 2116, 2213, 14, 344, 9, 398, 5420, 275, 485, 6395, 8, 85, 16019, 1213, 93, 1990, 21062, 701, 469, 9986, 12216, 267, 1166, 275, 3837, 360, 6797, 14, 3554, 63, 23449, 297, 5867, 29, 3554, 14, 5508, 12, 1993, 1249, 1524, 3554, 14, 5464, 566, 398, 1067, 275, 1067, 63, 807, 8, 5792, 9, 267, 1067, 459, 23449, 63, 633, 418, 275, 1050, 63, 337, 77, 8, 633, 12, 283, 6797, 13, 3773, 358, 267, 1067, 459, 5508, 418, 275, 2213, 14, 5508, 267, 1067, 459, 1213, 418, 275, 2213, 14, 1213, 267, 1067, 459, 9986, 418, 275, 6974, 14, 9986, 267, 1067, 459, 3349, 418, 275, 6974, 14, 3349, 398, 372, 3031, 63, 1208, 14, 14170, 63, 1045, 63, 3707, 63, 460, 63, 6821, 397, 8, 288, 5420, 29, 5875, 12, 288, 1318, 63, 1160, 534, 6797, 15, 2123, 15, 17642, 14, 76, 2424, 297, 288, 3517, 63, 1160, 534, 6797, 15, 2123, 15, 17642, 14, 1360, 297, 288, 1067, 63, 2936, 29, 1100, 12, 288, 4390, 63, 460, 63, 6821, 397, 29, 3707, 63, 460, 63, 6821 ]
[ 27070, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 465, 1639, 63, 4471, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 5501, 10366, 63, 6395, 465, 485, 6395, 199, 199, 504, 29603, 1225, 492, 3633, 199, 504, 11559, 780, 14, 4368, 492, 10066, 2390, 12, 6763, 12, 6763, 15540, 199, 504, 11559, 780, 14, 1208, 492, 2631, 63, 475, 63, 2244, 199, 504, 336, 3258, 1017, 1096, 384, 14, 2087, 492, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 199, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 492, 3031, 63, 1208, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 1160, 2969, 14, 12264, 63, 7546, 492, 1050, 63, 337, 77, 199, 504, 1022, 1405, 11474, 14, 1838, 79, 14, 16522, 492, 3837, 199, 504, 1022, 1405, 11474, 14, 6797, 14, 992, 492, 7543, 421, 199, 793, 275, 2050, 14, 5572, 360, 75, 14, 6797, 14, 4368, 358, 421, 199, 318, 664, 63, 3028, 63, 509, 8, 1301, 12, 2269, 63, 4964, 12, 892, 63, 4964, 304, 267, 687, 493, 275, 399, 3894, 5, 83, 61, 450, 83, 24307, 83, 7, 450, 334, 1301, 14, 5508, 12, 1382, 14, 1213, 12, 2269, 63, 4964, 14, 344, 9, 267, 370, 493, 275, 399, 3894, 5, 83, 61, 450, 83, 24307, 83, 7, 450, 334, 1301, 14, 5508, 12, 1382, 14, 1213, 12, 892, 63, 4964, 14, 344, 9, 267, 327, 27070, 14292, 3520, 370, 506, 2783, 12, 440, 2649, 267, 687, 493, 275, 687, 493, 14, 2143, 360, 1624, 24, 358, 267, 370, 493, 275, 370, 493, 14, 2143, 360, 1624, 24, 358, 398, 327, 2372, 3915, 267, 3915, 63, 4181, 275, 27070, 14, 32180, 63, 3028, 8, 288, 2269, 63, 4964, 14, 1317, 14, 7644, 8, 17, 395, 288, 892, 63, 4964, 14, 1317, 14, 7644, 8, 17, 395, 288, 687, 493, 29, 30717, 12, 370, 493, 29, 475, 493, 9, 398, 327, 25733, 3915, 4184, 267, 327, 5787, 642, 365, 1613, 486, 1534, 1399, 267, 6907, 275, 399, 891, 267, 367, 366, 315, 3915, 63, 4181, 26, 288, 340, 1228, 8, 68, 12, 2649, 304, 355, 6907, 275, 6907, 435, 366, 288, 587, 26, 355, 6907, 275, 6907, 435, 366, 14, 2708, 360, 1624, 24, 358, 398, 327, 12762, 1072, 267, 372, 3633, 8, 5470, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 9, 421, 199, 318, 1067, 63, 807, 8, 5792, 12, 10144, 63, 509, 63, 76, 709, 78, 29, 797, 12, 6974, 63, 21556, 29, 797, 304, 272, 408, 1767, 282, 1211, 626, 1794, 478, 315, 314, 4596, 83, 315, 27638, 6955, 7009, 1041, 272, 3915, 275, 2125, 272, 634, 709, 78, 275, 6974, 14, 3554, 14, 23449, 14, 1541, 8, 374, 63, 2179, 63, 509, 63, 1832, 2072, 29, 549, 9, 272, 30055, 275, 6974, 14, 3554, 14, 23449, 14, 1541, 8, 374, 63, 21556, 29, 549, 9, 339, 340, 10144, 63, 509, 63, 76, 709, 78, 436, 634, 709, 78, 14, 835, 342, 690, 413, 26, 267, 2269, 63, 4964, 275, 634, 709, 78, 14, 1648, 63, 991, 3654, 3966, 5832, 17, 61, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 272, 916, 6974, 63, 21556, 436, 30055, 14, 835, 342, 690, 413, 26, 267, 2269, 63, 4964, 275, 30055, 14, 1648, 63, 991, 3654, 3966, 5832, 17, 61, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 272, 916, 6974, 14, 3554, 14, 1818, 63, 5792, 365, 440, 488, 26, 267, 2269, 63, 4964, 275, 6974, 14, 3554, 14, 1818, 63, 5792, 267, 3915, 275, 664, 63, 3028, 63, 509, 8, 5792, 14, 3554, 12, 2269, 63, 4964, 12, 6974, 9, 339, 372, 469, 267, 283, 3554, 63, 1213, 356, 6974, 14, 3554, 14, 1213, 12, 267, 283, 9986, 356, 6974, 14, 9986, 12, 267, 283, 1102, 356, 11666, 14, 1462, 14, 362, 63, 1818, 1252, 2261, 12, 267, 283, 3028, 356, 3915, 12, 267, 283, 4705, 356, 3633, 8, 5792, 14, 4705, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 395, 267, 283, 2861, 505, 356, 3633, 8, 5792, 14, 1317, 12, 27805, 1149, 63, 17626, 12, 27805, 1149, 63, 18166, 395, 272, 789, 421, 199, 533, 16407, 5564, 2390, 8, 3244, 2390, 304, 272, 408, 2390, 31974, 1380, 282, 9842, 2213, 365, 21062, 624, 272, 1566, 63, 466, 275, 283, 6797, 5283, 2213, 7, 272, 1564, 63, 466, 275, 7543, 339, 347, 636, 826, 721, 277, 12, 6974, 304, 267, 1613, 8, 4685, 5564, 2390, 12, 291, 2843, 826, 721, 5792, 14, 3554, 9, 267, 291, 14, 5792, 275, 6974, 339, 347, 485, 1198, 83, 8, 277, 12, 4390, 63, 460, 63, 6821, 397, 304, 267, 6974, 275, 291, 14, 5792, 267, 2213, 275, 6974, 14, 3554, 267, 943, 14, 1757, 360, 27219, 21062, 6955, 3031, 367, 2213, 334, 344, 2458, 83, 3171, 450, 2116, 2213, 14, 344, 9, 398, 5420, 275, 485, 6395, 8, 85, 16019, 1213, 93, 1990, 21062, 701, 469, 9986, 12216, 267, 1166, 275, 3837, 360, 6797, 14, 3554, 63, 23449, 297, 5867, 29, 3554, 14, 5508, 12, 1993, 1249, 1524, 3554, 14, 5464, 566, 398, 1067, 275, 1067, 63, 807, 8, 5792, 9, 267, 1067, 459, 23449, 63, 633, 418, 275, 1050, 63, 337, 77, 8, 633, 12, 283, 6797, 13, 3773, 358, 267, 1067, 459, 5508, 418, 275, 2213, 14, 5508, 267, 1067, 459, 1213, 418, 275, 2213, 14, 1213, 267, 1067, 459, 9986, 418, 275, 6974, 14, 9986, 267, 1067, 459, 3349, 418, 275, 6974, 14, 3349, 398, 372, 3031, 63, 1208, 14, 14170, 63, 1045, 63, 3707, 63, 460, 63, 6821, 397, 8, 288, 5420, 29, 5875, 12, 288, 1318, 63, 1160, 534, 6797, 15, 2123, 15, 17642, 14, 76, 2424, 297, 288, 3517, 63, 1160, 534, 6797, 15, 2123, 15, 17642, 14, 1360, 297, 288, 1067, 63, 2936, 29, 1100, 12, 288, 4390, 63, 460, 63, 6821, 397, 29, 3707, 63, 460, 63, 6821, 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, 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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 ]
luxick/mtg-collector
mtg-collector/mtgsdk/querybuilder.py
1
2831
#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of mtgsdk. # https://github.com/MagicTheGathering/mtg-sdk-python # Licensed under the MIT license: # http://www.opensource.org/licenses/MIT-license # Copyright (c) 2016, Andrew Backes <backes.andrew@gmail.com> from mtgsdk.restclient import RestClient from mtgsdk.config import __endpoint__ class QueryBuilder(object): def __init__(self, type): self.params = {} self.type = type def find(self, id): """Get a resource by its id Args: id (string): Resource id Returns: object: Instance of the resource type """ url = "{}/{}/{}".format(__endpoint__, self.type.RESOURCE, id) response = RestClient.get(url)[self.type.RESOURCE[:-1]] return self.type(response) def find_many(self, url, type, resource): """Get a list of resources Args: url (string): URL to invoke type (class): Class type resource (string): The REST Resource Returns: list of object: List of resource instances """ list = [] response = RestClient.get(url)[resource] if len(response) > 0: for item in response: list.append(type(item)) return list def where(self, **kwargs): """Adds a parameter to the dictionary of query parameters Args: **kwargs: Arbitrary keyword arguments. Returns: QueryBuilder: Instance of the QueryBuilder """ for key, value in kwargs.items(): self.params[key] = value return self def all(self): """Get all resources, automatically paging through data Returns: list of object: List of resource objects """ list = [] page = 1 fetch_all = True url = "{}/{}".format(__endpoint__, self.type.RESOURCE) if 'page' in self.params: page = self.params['page'] fetch_all = False while True: response = RestClient.get(url, self.params)[self.type.RESOURCE] if len(response) > 0: for item in response: list.append(self.type(item)) if not fetch_all: break else: page += 1 self.where(page=page) else: break return list def array(self): """Get all resources and return the result as an array Returns: array of str: Array of resources """ url = "{}/{}".format(__endpoint__, self.type.RESOURCE) return RestClient.get(url, self.params)[self.type.RESOURCE]
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 19592, 458, 6341, 14, 199, 3, 4178, 921, 5031, 14, 957, 15, 45, 6573, 1918, 39, 7404, 316, 15, 2037, 71, 13, 9277, 13, 1548, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 199, 3, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 13965, 13, 1682, 199, 3, 1898, 334, 67, 9, 7800, 12, 6061, 5257, 10257, 397, 665, 894, 397, 14, 460, 5257, 32, 6799, 14, 957, 30, 199, 504, 19592, 458, 6341, 14, 3911, 1258, 492, 30417, 3041, 199, 504, 19592, 458, 6341, 14, 888, 492, 636, 6520, 363, 421, 199, 533, 8133, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 730, 304, 267, 291, 14, 1162, 275, 1052, 267, 291, 14, 466, 275, 730, 339, 347, 2342, 8, 277, 12, 1305, 304, 267, 408, 1002, 282, 2073, 701, 2399, 1305, 2728, 3033, 26, 288, 1305, 334, 875, 304, 7337, 1305, 27144, 1803, 26, 288, 909, 26, 10066, 402, 314, 2073, 730, 267, 408, 267, 1166, 275, 11491, 19655, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 12, 1305, 9, 267, 1177, 275, 30417, 3041, 14, 362, 8, 633, 2788, 277, 14, 466, 14, 14110, 4439, 17, 2677, 267, 372, 291, 14, 466, 8, 1310, 9, 339, 347, 2342, 63, 3479, 8, 277, 12, 1166, 12, 730, 12, 2073, 304, 267, 408, 1002, 282, 769, 402, 5944, 2728, 3033, 26, 288, 1166, 334, 875, 304, 2851, 370, 12677, 288, 730, 334, 533, 304, 8089, 730, 288, 2073, 334, 875, 304, 710, 14880, 7337, 267, 1803, 26, 288, 769, 402, 909, 26, 3820, 402, 2073, 4454, 267, 408, 267, 769, 275, 942, 267, 1177, 275, 30417, 3041, 14, 362, 8, 633, 2788, 1927, 61, 267, 340, 822, 8, 1310, 9, 690, 378, 26, 288, 367, 1242, 315, 1177, 26, 355, 769, 14, 740, 8, 466, 8, 1053, 430, 398, 372, 769, 339, 347, 2382, 8, 277, 12, 1011, 958, 304, 267, 408, 14995, 282, 2725, 370, 314, 2600, 402, 1827, 2633, 2728, 3033, 26, 288, 1011, 958, 26, 1952, 8734, 4252, 2368, 14, 267, 1803, 26, 288, 8133, 6437, 26, 10066, 402, 314, 8133, 6437, 267, 408, 267, 367, 790, 12, 574, 315, 2074, 14, 1744, 837, 288, 291, 14, 1162, 59, 498, 61, 275, 574, 398, 372, 291, 339, 347, 1006, 8, 277, 304, 267, 408, 1002, 1006, 5944, 12, 5847, 299, 7407, 4012, 666, 398, 1803, 26, 288, 769, 402, 909, 26, 3820, 402, 2073, 2251, 267, 408, 267, 769, 275, 942, 267, 2034, 275, 413, 267, 5267, 63, 452, 275, 715, 267, 1166, 275, 11491, 15, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 9, 398, 340, 283, 1606, 7, 315, 291, 14, 1162, 26, 288, 2034, 275, 291, 14, 1162, 459, 1606, 418, 288, 5267, 63, 452, 275, 756, 398, 1830, 715, 26, 288, 1177, 275, 30417, 3041, 14, 362, 8, 633, 12, 291, 14, 1162, 2788, 277, 14, 466, 14, 14110, 61, 288, 340, 822, 8, 1310, 9, 690, 378, 26, 355, 367, 1242, 315, 1177, 26, 490, 769, 14, 740, 8, 277, 14, 466, 8, 1053, 430, 2234, 340, 440, 5267, 63, 452, 26, 490, 2059, 355, 587, 26, 490, 2034, 847, 413, 490, 291, 14, 4509, 8, 1606, 29, 1606, 9, 288, 587, 26, 355, 2059, 398, 372, 769, 5493, 347, 1625, 8, 277, 304, 267, 408, 1002, 1006, 5944, 436, 372, 314, 754, 465, 376, 1625, 398, 1803, 26, 288, 1625, 402, 620, 26, 8725, 402, 5944, 267, 408, 267, 1166, 275, 11491, 15, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 9, 267, 372, 30417, 3041, 14, 362, 8, 633, 12, 291, 14, 1162, 2788, 277, 14, 466, 14, 14110, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 961, 570, 365, 1777, 402, 19592, 458, 6341, 14, 199, 3, 4178, 921, 5031, 14, 957, 15, 45, 6573, 1918, 39, 7404, 316, 15, 2037, 71, 13, 9277, 13, 1548, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 199, 3, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 13965, 13, 1682, 199, 3, 1898, 334, 67, 9, 7800, 12, 6061, 5257, 10257, 397, 665, 894, 397, 14, 460, 5257, 32, 6799, 14, 957, 30, 199, 504, 19592, 458, 6341, 14, 3911, 1258, 492, 30417, 3041, 199, 504, 19592, 458, 6341, 14, 888, 492, 636, 6520, 363, 421, 199, 533, 8133, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 730, 304, 267, 291, 14, 1162, 275, 1052, 267, 291, 14, 466, 275, 730, 339, 347, 2342, 8, 277, 12, 1305, 304, 267, 408, 1002, 282, 2073, 701, 2399, 1305, 2728, 3033, 26, 288, 1305, 334, 875, 304, 7337, 1305, 27144, 1803, 26, 288, 909, 26, 10066, 402, 314, 2073, 730, 267, 408, 267, 1166, 275, 11491, 19655, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 12, 1305, 9, 267, 1177, 275, 30417, 3041, 14, 362, 8, 633, 2788, 277, 14, 466, 14, 14110, 4439, 17, 2677, 267, 372, 291, 14, 466, 8, 1310, 9, 339, 347, 2342, 63, 3479, 8, 277, 12, 1166, 12, 730, 12, 2073, 304, 267, 408, 1002, 282, 769, 402, 5944, 2728, 3033, 26, 288, 1166, 334, 875, 304, 2851, 370, 12677, 288, 730, 334, 533, 304, 8089, 730, 288, 2073, 334, 875, 304, 710, 14880, 7337, 267, 1803, 26, 288, 769, 402, 909, 26, 3820, 402, 2073, 4454, 267, 408, 267, 769, 275, 942, 267, 1177, 275, 30417, 3041, 14, 362, 8, 633, 2788, 1927, 61, 267, 340, 822, 8, 1310, 9, 690, 378, 26, 288, 367, 1242, 315, 1177, 26, 355, 769, 14, 740, 8, 466, 8, 1053, 430, 398, 372, 769, 339, 347, 2382, 8, 277, 12, 1011, 958, 304, 267, 408, 14995, 282, 2725, 370, 314, 2600, 402, 1827, 2633, 2728, 3033, 26, 288, 1011, 958, 26, 1952, 8734, 4252, 2368, 14, 267, 1803, 26, 288, 8133, 6437, 26, 10066, 402, 314, 8133, 6437, 267, 408, 267, 367, 790, 12, 574, 315, 2074, 14, 1744, 837, 288, 291, 14, 1162, 59, 498, 61, 275, 574, 398, 372, 291, 339, 347, 1006, 8, 277, 304, 267, 408, 1002, 1006, 5944, 12, 5847, 299, 7407, 4012, 666, 398, 1803, 26, 288, 769, 402, 909, 26, 3820, 402, 2073, 2251, 267, 408, 267, 769, 275, 942, 267, 2034, 275, 413, 267, 5267, 63, 452, 275, 715, 267, 1166, 275, 11491, 15, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 9, 398, 340, 283, 1606, 7, 315, 291, 14, 1162, 26, 288, 2034, 275, 291, 14, 1162, 459, 1606, 418, 288, 5267, 63, 452, 275, 756, 398, 1830, 715, 26, 288, 1177, 275, 30417, 3041, 14, 362, 8, 633, 12, 291, 14, 1162, 2788, 277, 14, 466, 14, 14110, 61, 288, 340, 822, 8, 1310, 9, 690, 378, 26, 355, 367, 1242, 315, 1177, 26, 490, 769, 14, 740, 8, 277, 14, 466, 8, 1053, 430, 2234, 340, 440, 5267, 63, 452, 26, 490, 2059, 355, 587, 26, 490, 2034, 847, 413, 490, 291, 14, 4509, 8, 1606, 29, 1606, 9, 288, 587, 26, 355, 2059, 398, 372, 769, 5493, 347, 1625, 8, 277, 304, 267, 408, 1002, 1006, 5944, 436, 372, 314, 754, 465, 376, 1625, 398, 1803, 26, 288, 1625, 402, 620, 26, 8725, 402, 5944, 267, 408, 267, 1166, 275, 11491, 15, 13536, 908, 3460, 6520, 3108, 291, 14, 466, 14, 14110, 9, 267, 372, 30417, 3041, 14, 362, 8, 633, 12, 291, 14, 1162, 2788, 277, 14, 466, 14, 14110, 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, 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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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 ]
maestro-hybrid-cloud/horizon
openstack_dashboard/test/integration_tests/regions/forms.py
10
12501
# 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 six from selenium.webdriver.common import by import selenium.webdriver.support.ui as Support from openstack_dashboard.test.integration_tests.regions import baseregion from openstack_dashboard.test.integration_tests.regions import exceptions from openstack_dashboard.test.integration_tests.regions import menus class FieldFactory(baseregion.BaseRegion): """Factory for creating form field objects.""" FORM_FIELDS_TYPES = set() def make_form_field(self): for form_type in self.FORM_FIELDS_TYPES: if self._is_element_present(*form_type._element_locator): return form_type(self.driver, self.conf, self.src_elem) raise exceptions.UnknownFormFieldTypeException() @classmethod def register_field_cls(cls, field_class, base_classes=None): """Register new field class. Add new field class and remove all base classes from the set of registered classes as they should not be in. """ cls.FORM_FIELDS_TYPES.add(field_class) cls.FORM_FIELDS_TYPES -= set(base_classes) class MetaBaseFormFieldRegion(type): """Register form field class in FieldFactory.""" def __init__(cls, name, bases, dct): FieldFactory.register_field_cls(cls, bases) super(MetaBaseFormFieldRegion, cls).__init__(name, bases, dct) @six.add_metaclass(MetaBaseFormFieldRegion) class BaseFormFieldRegion(baseregion.BaseRegion): """Base class for form fields classes.""" _label_locator = None _element_locator = None @property def label(self): return self._get_element(*self._label_locator) @property def element(self): return self._get_element(*self._element_locator) @property def name(self): return self.element.get_attribute('name') def is_required(self): classes = self.driver.get_attribute('class') return 'required' in classes def is_displayed(self): return self.element.is_displayed() class CheckBoxMixin(object): def is_marked(self): return self.element.is_selected() def mark(self): if not self.is_marked(): self.element.click() def unmark(self): if self.is_marked(): self.element.click() class CheckBoxFormFieldRegion(BaseFormFieldRegion, CheckBoxMixin): """Checkbox field.""" _element_locator = (by.By.CSS_SELECTOR, 'div > label > input[type=checkbox]') class ProjectPageCheckBoxFormFieldRegion(BaseFormFieldRegion, CheckBoxMixin): """Checkbox field for Project-page.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=checkbox]') class ChooseFileFormFieldRegion(BaseFormFieldRegion): """Choose file field.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=file]') def choose(self, path): self.element.send_keys(path) class BaseTextFormFieldRegion(BaseFormFieldRegion): _element_locator = None @property def text(self): return self.element.text @text.setter def text(self, text): self._fill_field_element(text, self.element) class TextInputFormFieldRegion(BaseTextFormFieldRegion): """Text input box.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=text],' 'div > input[type=None]') class FileInputFormFieldRegion(BaseFormFieldRegion): """Text input box.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=file]') @property def path(self): return self.element.text @path.setter def path(self, path): # clear does not work on this kind of element # because it is not user editable self.element.send_keys(path) class PasswordInputFormFieldRegion(BaseTextFormFieldRegion): """Password text input box.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=password]') class EmailInputFormFieldRegion(BaseTextFormFieldRegion): """Email text input box.""" _element_locator = (by.By.ID, 'id_email') class TextAreaFormFieldRegion(BaseTextFormFieldRegion): """Multi-line text input box.""" _element_locator = (by.By.CSS_SELECTOR, 'div > textarea') class IntegerFormFieldRegion(BaseFormFieldRegion): """Integer input box.""" _element_locator = (by.By.CSS_SELECTOR, 'div > input[type=number]') @property def value(self): return self.element.get_attribute("value") @value.setter def value(self, value): self._fill_field_element(value, self.element) class SelectFormFieldRegion(BaseFormFieldRegion): """Select box field.""" _element_locator = (by.By.CSS_SELECTOR, 'div > select') def is_displayed(self): return self.element._el.is_displayed() @property def element(self): select = self._get_element(*self._element_locator) return Support.Select(select) @property def values(self): results = [] for option in self.element.all_selected_options: results.append(option.get_attribute('value')) return results @property def name(self): return self.element._el.get_attribute('name') @property def text(self): return self.element.first_selected_option.text @text.setter def text(self, text): self.element.select_by_visible_text(text) @property def value(self): return self.element.first_selected_option.get_attribute('value') @value.setter def value(self, value): self.element.select_by_value(value) class BaseFormRegion(baseregion.BaseRegion): """Base class for forms.""" _submit_locator = (by.By.CSS_SELECTOR, '*.btn.btn-primary') _cancel_locator = (by.By.CSS_SELECTOR, '*.btn.cancel') _default_form_locator = (by.By.CSS_SELECTOR, 'div.modal-dialog') def __init__(self, driver, conf, src_elem=None): """In most cases forms can be located through _default_form_locator, so specifying source element can be skipped. """ if src_elem is None: # fake self.src_elem must be set up in order self._get_element work self.src_elem = driver src_elem = self._get_element(*self._default_form_locator) super(BaseFormRegion, self).__init__(driver, conf, src_elem) @property def submit(self): return self._get_element(*self._submit_locator) @property def cancel(self): return self._get_element(*self._cancel_locator) class FormRegion(BaseFormRegion): """Standard form.""" _header_locator = (by.By.CSS_SELECTOR, 'div.modal-header > h3') _side_info_locator = (by.By.CSS_SELECTOR, 'div.right') _fields_locator = (by.By.CSS_SELECTOR, 'fieldset > div.form-group') _input_locator = (by.By.CSS_SELECTOR, 'input,select,textarea') # private methods def __init__(self, driver, conf, src_elem, form_field_names): super(FormRegion, self).__init__(driver, conf, src_elem) self.form_field_names = form_field_names self._init_form_fields() # protected methods def _init_form_fields(self): self._init_dynamic_properties(self.form_field_names, self._get_form_fields) def _get_form_fields(self): fields_els = self._get_elements(*self._fields_locator) form_fields = {} try: self._turn_off_implicit_wait() for elem in fields_els: field_factory = FieldFactory(self.driver, self.conf, elem) field = field_factory.make_form_field() form_fields[field.name] = field finally: self._turn_on_implicit_wait() return form_fields def set_field_values(self, data): """Set fields values data - {field_name: field_value, field_name: field_value ...} """ for field_name in data: field = getattr(self, field_name, None) # Field form does not exist if field is None: raise AttributeError("Unknown form field name.") value = data[field_name] # if None - default value is left in field if value is not None: # all text fields if hasattr(field, "text"): field.text = value # file upload field elif hasattr(field, "path"): field.path = value # integers fields elif hasattr(field, "value"): field.value = value # properties @property def header(self): """Form header.""" return self._get_element(*self._header_locator) @property def sideinfo(self): """Right part of form, usually contains description.""" return self._get_element(*self._side_info_locator) @property def fields(self): """List of all fields that form contains.""" return self._get_form_fields() class TabbedFormRegion(FormRegion): """Forms that are divided with tabs. As example is taken form under the the Project/Network/Networks/Create Network, on initialization form needs to have form field names divided into tuples, that represents the tabs and the fields located under them. Usage: form_field_names = (("network_name", "admin_state"), ("create_subnet", "subnet_name", "network_address", "ip_version", "gateway_ip", "disable_gateway"), ("enable_dhcp", "allocation_pools", "dns_name_servers", "host_routes")) form = TabbedFormRegion(self.conf, self.driver, None, form_field_names) form.network_name.text = "test_network_name" """ _submit_locator = (by.By.CSS_SELECTOR, '*.btn.btn-primary[type=submit]') _side_info_locator = (by.By.CSS_SELECTOR, "td.help_text") _fields_locator = (by.By.CSS_SELECTOR, "div.form-group") class GetFieldsMethod(object): def __init__(self, get_fields_method, tab_index, switch_tab_method): self.get_fields = get_fields_method self.tab_index = tab_index self.switch_to_tab = switch_tab_method def __call__(self, *args, **kwargs): self.switch_to_tab(self.tab_index) fields = self.get_fields() if isinstance(fields, dict): return dict([(key, field) for (key, field) in fields.iteritems() if field.is_displayed()]) else: return [field for field in fields if field.is_displayed()] @property def tabs(self): return menus.TabbedMenuRegion(self.driver, self.conf) def _init_form_fields(self): for index, tab_names in enumerate(self.form_field_names): get_fields = self.GetFieldsMethod(self._get_form_fields, index, self.tabs.switch_to) self._init_dynamic_properties(tab_names, get_fields) class DateFormRegion(BaseFormRegion): """Form that queries data to table that is regularly below the form, typical example is located on Project/Compute/Overview page. """ _from_field_locator = (by.By.CSS_SELECTOR, 'input#id_start') _to_field_locator = (by.By.CSS_SELECTOR, 'input#id_end') @property def from_date(self): return self._get_element(*self._from_field_locator) @property def to_date(self): return self._get_element(*self._to_field_locator) def query(self, start, end): self._set_from_field(start) self._set_to_field(end) self.submit.click() def _set_from_field(self, value): self._fill_field_element(value, self.from_date) def _set_to_field(self, value): self._fill_field_element(value, self.to_date)
apache-2.0
[ 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, 646, 3816, 199, 199, 504, 19481, 14, 17946, 14, 2330, 492, 701, 199, 646, 19481, 14, 17946, 14, 4058, 14, 1907, 465, 12502, 199, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 1300, 4551, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 4967, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 27906, 421, 199, 533, 5024, 2927, 8, 1095, 4551, 14, 1563, 10708, 304, 272, 408, 2927, 367, 6425, 1824, 901, 2251, 1041, 339, 11295, 63, 12767, 63, 7893, 275, 663, 342, 339, 347, 1852, 63, 964, 63, 698, 8, 277, 304, 267, 367, 1824, 63, 466, 315, 291, 14, 3516, 63, 12767, 63, 7893, 26, 288, 340, 291, 423, 374, 63, 2108, 63, 1881, 2031, 964, 63, 466, 423, 2108, 63, 6354, 304, 355, 372, 1824, 63, 466, 8, 277, 14, 3090, 12, 291, 14, 2190, 12, 291, 14, 2164, 63, 6086, 9, 267, 746, 4967, 14, 5912, 2821, 792, 804, 1726, 342, 339, 768, 3744, 272, 347, 2274, 63, 698, 63, 1886, 8, 1886, 12, 901, 63, 533, 12, 1300, 63, 2888, 29, 403, 304, 267, 408, 7099, 892, 901, 1021, 14, 398, 2654, 892, 901, 1021, 436, 2813, 1006, 1300, 3992, 687, 314, 663, 402, 267, 7264, 3992, 465, 2985, 1077, 440, 506, 315, 14, 267, 408, 267, 843, 14, 3516, 63, 12767, 63, 7893, 14, 525, 8, 698, 63, 533, 9, 267, 843, 14, 3516, 63, 12767, 63, 7893, 4862, 663, 8, 1095, 63, 2888, 9, 421, 199, 533, 6288, 1563, 2821, 792, 10708, 8, 466, 304, 272, 408, 7099, 1824, 901, 1021, 315, 5024, 2927, 1041, 339, 347, 636, 826, 721, 1886, 12, 536, 12, 9768, 12, 16354, 304, 267, 5024, 2927, 14, 2683, 63, 698, 63, 1886, 8, 1886, 12, 9768, 9, 267, 1613, 8, 3396, 1563, 2821, 792, 10708, 12, 843, 2843, 826, 721, 354, 12, 9768, 12, 16354, 9, 421, 199, 32, 4174, 14, 525, 63, 6577, 8, 3396, 1563, 2821, 792, 10708, 9, 199, 533, 3523, 2821, 792, 10708, 8, 1095, 4551, 14, 1563, 10708, 304, 272, 408, 1563, 1021, 367, 1824, 1504, 3992, 1041, 339, 485, 1302, 63, 6354, 275, 488, 272, 485, 2108, 63, 6354, 275, 488, 339, 768, 1829, 272, 347, 1768, 8, 277, 304, 267, 372, 291, 423, 362, 63, 2108, 2031, 277, 423, 1302, 63, 6354, 9, 339, 768, 1829, 272, 347, 1819, 8, 277, 304, 267, 372, 291, 423, 362, 63, 2108, 2031, 277, 423, 2108, 63, 6354, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 362, 63, 3215, 360, 354, 358, 339, 347, 365, 63, 2427, 8, 277, 304, 267, 3992, 275, 291, 14, 3090, 14, 362, 63, 3215, 360, 533, 358, 267, 372, 283, 2427, 7, 315, 3992, 339, 347, 365, 63, 22283, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 374, 63, 22283, 342, 421, 199, 533, 2670, 3532, 4256, 8, 785, 304, 272, 347, 365, 63, 17938, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 374, 63, 5511, 342, 339, 347, 2216, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 17938, 837, 288, 291, 14, 2108, 14, 4891, 342, 339, 347, 625, 1657, 8, 277, 304, 267, 340, 291, 14, 374, 63, 17938, 837, 288, 291, 14, 2108, 14, 4891, 342, 421, 199, 533, 2670, 3532, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 12, 2670, 3532, 4256, 304, 272, 408, 26366, 901, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 717, 283, 3015, 690, 1768, 690, 1324, 59, 466, 29, 13456, 10374, 421, 199, 533, 7290, 3276, 20530, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 12, 2670, 3532, 4256, 304, 272, 408, 26366, 901, 367, 7290, 13, 1606, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 717, 283, 3015, 690, 1324, 59, 466, 29, 13456, 10374, 421, 199, 533, 29826, 1173, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 272, 408, 23932, 570, 901, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466, 29, 493, 10374, 339, 347, 11496, 8, 277, 12, 931, 304, 267, 291, 14, 2108, 14, 2254, 63, 1612, 8, 515, 9, 421, 199, 533, 3523, 1872, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 339, 485, 2108, 63, 6354, 275, 488, 339, 768, 1829, 272, 347, 1318, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 505, 339, 768, 505, 14, 8345, 272, 347, 1318, 8, 277, 12, 1318, 304, 267, 291, 423, 4498, 63, 698, 63, 2108, 8, 505, 12, 291, 14, 2108, 9, 421, 199, 533, 4516, 3205, 2821, 792, 10708, 8, 1563, 1872, 2821, 792, 10708, 304, 272, 408, 1872, 1324, 5689, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466, 29, 505, 26801, 4490, 283, 3015, 690, 1324, 59, 466, 29, 403, 10374, 421, 199, 533, 3814, 3205, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 272, 408, 1872, 1324, 5689, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466 ]
[ 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, 646, 3816, 199, 199, 504, 19481, 14, 17946, 14, 2330, 492, 701, 199, 646, 19481, 14, 17946, 14, 4058, 14, 1907, 465, 12502, 199, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 1300, 4551, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 4967, 199, 504, 13869, 63, 9743, 14, 396, 14, 15092, 63, 2219, 14, 11963, 492, 27906, 421, 199, 533, 5024, 2927, 8, 1095, 4551, 14, 1563, 10708, 304, 272, 408, 2927, 367, 6425, 1824, 901, 2251, 1041, 339, 11295, 63, 12767, 63, 7893, 275, 663, 342, 339, 347, 1852, 63, 964, 63, 698, 8, 277, 304, 267, 367, 1824, 63, 466, 315, 291, 14, 3516, 63, 12767, 63, 7893, 26, 288, 340, 291, 423, 374, 63, 2108, 63, 1881, 2031, 964, 63, 466, 423, 2108, 63, 6354, 304, 355, 372, 1824, 63, 466, 8, 277, 14, 3090, 12, 291, 14, 2190, 12, 291, 14, 2164, 63, 6086, 9, 267, 746, 4967, 14, 5912, 2821, 792, 804, 1726, 342, 339, 768, 3744, 272, 347, 2274, 63, 698, 63, 1886, 8, 1886, 12, 901, 63, 533, 12, 1300, 63, 2888, 29, 403, 304, 267, 408, 7099, 892, 901, 1021, 14, 398, 2654, 892, 901, 1021, 436, 2813, 1006, 1300, 3992, 687, 314, 663, 402, 267, 7264, 3992, 465, 2985, 1077, 440, 506, 315, 14, 267, 408, 267, 843, 14, 3516, 63, 12767, 63, 7893, 14, 525, 8, 698, 63, 533, 9, 267, 843, 14, 3516, 63, 12767, 63, 7893, 4862, 663, 8, 1095, 63, 2888, 9, 421, 199, 533, 6288, 1563, 2821, 792, 10708, 8, 466, 304, 272, 408, 7099, 1824, 901, 1021, 315, 5024, 2927, 1041, 339, 347, 636, 826, 721, 1886, 12, 536, 12, 9768, 12, 16354, 304, 267, 5024, 2927, 14, 2683, 63, 698, 63, 1886, 8, 1886, 12, 9768, 9, 267, 1613, 8, 3396, 1563, 2821, 792, 10708, 12, 843, 2843, 826, 721, 354, 12, 9768, 12, 16354, 9, 421, 199, 32, 4174, 14, 525, 63, 6577, 8, 3396, 1563, 2821, 792, 10708, 9, 199, 533, 3523, 2821, 792, 10708, 8, 1095, 4551, 14, 1563, 10708, 304, 272, 408, 1563, 1021, 367, 1824, 1504, 3992, 1041, 339, 485, 1302, 63, 6354, 275, 488, 272, 485, 2108, 63, 6354, 275, 488, 339, 768, 1829, 272, 347, 1768, 8, 277, 304, 267, 372, 291, 423, 362, 63, 2108, 2031, 277, 423, 1302, 63, 6354, 9, 339, 768, 1829, 272, 347, 1819, 8, 277, 304, 267, 372, 291, 423, 362, 63, 2108, 2031, 277, 423, 2108, 63, 6354, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 362, 63, 3215, 360, 354, 358, 339, 347, 365, 63, 2427, 8, 277, 304, 267, 3992, 275, 291, 14, 3090, 14, 362, 63, 3215, 360, 533, 358, 267, 372, 283, 2427, 7, 315, 3992, 339, 347, 365, 63, 22283, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 374, 63, 22283, 342, 421, 199, 533, 2670, 3532, 4256, 8, 785, 304, 272, 347, 365, 63, 17938, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 374, 63, 5511, 342, 339, 347, 2216, 8, 277, 304, 267, 340, 440, 291, 14, 374, 63, 17938, 837, 288, 291, 14, 2108, 14, 4891, 342, 339, 347, 625, 1657, 8, 277, 304, 267, 340, 291, 14, 374, 63, 17938, 837, 288, 291, 14, 2108, 14, 4891, 342, 421, 199, 533, 2670, 3532, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 12, 2670, 3532, 4256, 304, 272, 408, 26366, 901, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 717, 283, 3015, 690, 1768, 690, 1324, 59, 466, 29, 13456, 10374, 421, 199, 533, 7290, 3276, 20530, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 12, 2670, 3532, 4256, 304, 272, 408, 26366, 901, 367, 7290, 13, 1606, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 717, 283, 3015, 690, 1324, 59, 466, 29, 13456, 10374, 421, 199, 533, 29826, 1173, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 272, 408, 23932, 570, 901, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466, 29, 493, 10374, 339, 347, 11496, 8, 277, 12, 931, 304, 267, 291, 14, 2108, 14, 2254, 63, 1612, 8, 515, 9, 421, 199, 533, 3523, 1872, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 339, 485, 2108, 63, 6354, 275, 488, 339, 768, 1829, 272, 347, 1318, 8, 277, 304, 267, 372, 291, 14, 2108, 14, 505, 339, 768, 505, 14, 8345, 272, 347, 1318, 8, 277, 12, 1318, 304, 267, 291, 423, 4498, 63, 698, 63, 2108, 8, 505, 12, 291, 14, 2108, 9, 421, 199, 533, 4516, 3205, 2821, 792, 10708, 8, 1563, 1872, 2821, 792, 10708, 304, 272, 408, 1872, 1324, 5689, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466, 29, 505, 26801, 4490, 283, 3015, 690, 1324, 59, 466, 29, 403, 10374, 421, 199, 533, 3814, 3205, 2821, 792, 10708, 8, 1563, 2821, 792, 10708, 304, 272, 408, 1872, 1324, 5689, 1041, 339, 485, 2108, 63, 6354, 275, 334, 991, 14, 2175, 14, 14391, 63, 25691, 12, 283, 3015, 690, 1324, 59, 466, 0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 1, 1 ]
tomscript/babbage
backend/main.py
1
3720
"""Babbage - Framework for decoding data. Copyright 2014 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. """ __author__ = 'tomfitzgerald@google.com (Tom Fitzgerald)' import base64 import logging import json import os import re import urllib import jinja2 import webapp2 import plugin_handler JINJA_ENVIRONMENT = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), extensions=['jinja2.ext.autoescape'], autoescape=True) WHITELISTED_ORIGINS = os.environ['WHITELISTED_ORIGINS'] HEADERS = [ "Access-Control-Allow-Headers", "Origin,Accept, X-Requested-With", "Content-Type", "Access-Control-Request-Method", "Access-Control-Request-Headers", ] def Process(input_text, plugins): """Runs input text through each selected plugin. Args: input_text: Text to be processed. plugins: Dict of plugins to process: {'name': 'Base 64 Encode'} Returns: Dict of decoded data containing a success or failure. """ try: response = plugin_handler.ProcessPlugins(input_text.encode('utf-8'), plugins) except plugin_handler.Error as e: return json.dumps({'failure': str(e)}) return json.dumps({'success': response}, ensure_ascii=False) class MainPoster(webapp2.RequestHandler): """Data was posted so we must be converting data. Pass to plugins.""" def options(self): self.response.headers.add_header('Access-Control-Allow-Methods', 'POST,OPTIONS') self.response.headers.add_header("Access-Control-Allow-Headers", ','.join(HEADERS)); self.response.headers.add_header('Access-Control-Allow-Origin', '*') def post(self): response = json.loads(self.request.body) if response.get('input') is None: return self.response.headers.add_header('Access-Control-Allow-Methods', 'POST,OPTIONS') self.response.headers.add_header("Access-Control-Allow-Headers", ','.join(HEADERS)); self.response.headers.add_header('Access-Control-Allow-Origin', '*') self.response.out.write(Process(response['input'], response['plugins'])) class ListPlugins(webapp2.RequestHandler): """List plugins via JSON to frontend.""" def get(self): """Responds to GET requests.""" self.response.headers.add_header('Access-Control-Allow-Origin', '*') self.response.out.write(")]}',\n"+ json.dumps(plugin_handler.ListPlugins())) class SendBlob(webapp2.RequestHandler): """External data sent via POST.""" def get(self): """Responds to GET requests.""" template = JINJA_ENVIRONMENT.get_template('index-ext.html') self.response.write(template.render()) def post(self): """Responds to POST requests.""" origin = self.request.headers.get('Origin', '') if not re.search(WHITELISTED_ORIGINS, origin): return template_values = { 'data': self.request.get('data', '') } self.response.headers.add_header('Access-Control-Allow-Origin', origin) self.response.headers.add_header('Access-Control-Allow-Credentials', 'true') template = JINJA_ENVIRONMENT.get_template('index-ext.html') self.response.write(template.render(template_values)) app = webapp2.WSGIApplication([ ('/convert', MainPoster), ('/listplugins', ListPlugins), ], debug=False)
apache-2.0
[ 624, 34, 12198, 474, 446, 22545, 367, 15952, 666, 14, 199, 199, 7384, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 3151, 3269, 90, 836, 27075, 32, 3098, 14, 957, 334, 52, 676, 481, 23751, 836, 27075, 3171, 199, 199, 646, 1300, 772, 199, 646, 2050, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 4011, 199, 199, 646, 10321, 18, 199, 646, 24812, 18, 199, 199, 646, 3589, 63, 2232, 199, 199, 42, 568, 29849, 63, 9984, 31168, 4479, 275, 10321, 18, 14, 8263, 8, 272, 5077, 29, 12264, 18, 14, 17521, 5455, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 272, 5478, 2968, 12264, 18, 14, 832, 14, 15818, 995, 272, 19102, 29, 549, 9, 199, 199, 18817, 4924, 1149, 63, 20332, 10789, 275, 747, 14, 2314, 459, 18817, 4924, 1149, 63, 20332, 10789, 418, 199, 199, 21178, 275, 359, 523, 298, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 523, 298, 12834, 12, 8422, 12, 1323, 13, 17935, 13, 3007, 401, 523, 298, 2714, 13, 804, 401, 523, 298, 3946, 13, 3717, 13, 2017, 13, 3767, 401, 523, 298, 3946, 13, 3717, 13, 2017, 13, 9883, 401, 199, 61, 421, 199, 318, 7132, 8, 1210, 63, 505, 12, 8963, 304, 523, 408, 16291, 1324, 1318, 4012, 1924, 4895, 3589, 14, 819, 3033, 26, 272, 1324, 63, 505, 26, 4516, 370, 506, 7686, 14, 272, 8963, 26, 7448, 402, 8963, 370, 2112, 26, 791, 354, 356, 283, 1563, 5049, 19244, 936, 819, 1803, 26, 272, 7448, 402, 11203, 666, 3035, 282, 3182, 503, 5988, 14, 523, 408, 523, 862, 26, 272, 1177, 275, 3589, 63, 2232, 14, 3498, 19330, 8, 1210, 63, 505, 14, 2143, 360, 1624, 13, 24, 659, 8963, 9, 523, 871, 3589, 63, 2232, 14, 547, 465, 325, 26, 272, 372, 2022, 14, 4180, 3252, 5328, 356, 620, 8, 69, 11466, 523, 372, 2022, 14, 4180, 3252, 3742, 356, 1177, 1386, 4868, 63, 4371, 29, 797, 9, 421, 199, 533, 11298, 6981, 351, 8, 22632, 18, 14, 11149, 304, 523, 408, 1451, 1990, 22752, 880, 781, 1471, 506, 13806, 666, 14, 8325, 370, 8963, 1041, 819, 347, 1511, 8, 277, 304, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 10385, 297, 283, 4030, 12, 8808, 358, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 12814, 904, 8, 21178, 16674, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 819, 347, 2963, 8, 277, 304, 272, 1177, 275, 2022, 14, 3640, 8, 277, 14, 1069, 14, 2030, 9, 272, 340, 1177, 14, 362, 360, 1210, 358, 365, 488, 26, 489, 372, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 10385, 297, 283, 4030, 12, 8808, 358, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 12814, 904, 8, 21178, 16674, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 272, 291, 14, 1310, 14, 548, 14, 952, 8, 3498, 8, 1310, 459, 1210, 995, 1177, 459, 5265, 5156, 421, 199, 533, 3820, 19330, 8, 22632, 18, 14, 11149, 304, 523, 408, 1296, 8963, 4799, 4840, 370, 22523, 1041, 819, 347, 664, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 9576, 4145, 1041, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 272, 291, 14, 1310, 14, 548, 14, 952, 480, 1874, 7293, 60, 78, 7709, 2022, 14, 4180, 8, 2718, 63, 2232, 14, 1296, 19330, 4059, 421, 199, 533, 10217, 16799, 8, 22632, 18, 14, 11149, 304, 523, 408, 11389, 666, 4847, 4799, 8761, 1041, 819, 347, 664, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 9576, 4145, 1041, 272, 1978, 275, 1603, 568, 29849, 63, 9984, 31168, 4479, 14, 362, 63, 1160, 360, 1080, 13, 832, 14, 1360, 358, 272, 291, 14, 1310, 14, 952, 8, 1160, 14, 3352, 1012, 819, 347, 2963, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 8761, 4145, 1041, 272, 6330, 275, 291, 14, 1069, 14, 2139, 14, 362, 360, 12834, 297, 4074, 272, 340, 440, 295, 14, 1733, 8, 18817, 4924, 1149, 63, 20332, 10789, 12, 6330, 304, 489, 372, 272, 1978, 63, 1459, 275, 469, 267, 283, 576, 356, 291, 14, 1069, 14, 362, 360, 576, 297, 4074, 272, 789, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6330, 9, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 13428, 297, 283, 2052, 358, 272, 1978, 275, 1603, 568, 29849, 63, 9984, 31168, 4479, 14, 362, 63, 1160, 360, 1080, 13, 832, 14, 1360, 358, 272, 291, 14, 1310, 14, 952, 8, 1160, 14, 3352, 8, 1160, 63, 1459, 430, 421, 199, 571, 275, 24812, 18, 14, 16828, 5039, 779, 272, 14606, 3916, 297, 11298, 6981, 351, 395, 272, 14606, 513, 5265, 297, 3820, 19330, 395, 272, 2156, 3105, 29, 797, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 34, 12198, 474, 446, 22545, 367, 15952, 666, 14, 199, 199, 7384, 6927, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 3151, 3269, 90, 836, 27075, 32, 3098, 14, 957, 334, 52, 676, 481, 23751, 836, 27075, 3171, 199, 199, 646, 1300, 772, 199, 646, 2050, 199, 646, 2022, 199, 646, 747, 199, 646, 295, 199, 646, 4011, 199, 199, 646, 10321, 18, 199, 646, 24812, 18, 199, 199, 646, 3589, 63, 2232, 199, 199, 42, 568, 29849, 63, 9984, 31168, 4479, 275, 10321, 18, 14, 8263, 8, 272, 5077, 29, 12264, 18, 14, 17521, 5455, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 272, 5478, 2968, 12264, 18, 14, 832, 14, 15818, 995, 272, 19102, 29, 549, 9, 199, 199, 18817, 4924, 1149, 63, 20332, 10789, 275, 747, 14, 2314, 459, 18817, 4924, 1149, 63, 20332, 10789, 418, 199, 199, 21178, 275, 359, 523, 298, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 523, 298, 12834, 12, 8422, 12, 1323, 13, 17935, 13, 3007, 401, 523, 298, 2714, 13, 804, 401, 523, 298, 3946, 13, 3717, 13, 2017, 13, 3767, 401, 523, 298, 3946, 13, 3717, 13, 2017, 13, 9883, 401, 199, 61, 421, 199, 318, 7132, 8, 1210, 63, 505, 12, 8963, 304, 523, 408, 16291, 1324, 1318, 4012, 1924, 4895, 3589, 14, 819, 3033, 26, 272, 1324, 63, 505, 26, 4516, 370, 506, 7686, 14, 272, 8963, 26, 7448, 402, 8963, 370, 2112, 26, 791, 354, 356, 283, 1563, 5049, 19244, 936, 819, 1803, 26, 272, 7448, 402, 11203, 666, 3035, 282, 3182, 503, 5988, 14, 523, 408, 523, 862, 26, 272, 1177, 275, 3589, 63, 2232, 14, 3498, 19330, 8, 1210, 63, 505, 14, 2143, 360, 1624, 13, 24, 659, 8963, 9, 523, 871, 3589, 63, 2232, 14, 547, 465, 325, 26, 272, 372, 2022, 14, 4180, 3252, 5328, 356, 620, 8, 69, 11466, 523, 372, 2022, 14, 4180, 3252, 3742, 356, 1177, 1386, 4868, 63, 4371, 29, 797, 9, 421, 199, 533, 11298, 6981, 351, 8, 22632, 18, 14, 11149, 304, 523, 408, 1451, 1990, 22752, 880, 781, 1471, 506, 13806, 666, 14, 8325, 370, 8963, 1041, 819, 347, 1511, 8, 277, 304, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 10385, 297, 283, 4030, 12, 8808, 358, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 12814, 904, 8, 21178, 16674, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 819, 347, 2963, 8, 277, 304, 272, 1177, 275, 2022, 14, 3640, 8, 277, 14, 1069, 14, 2030, 9, 272, 340, 1177, 14, 362, 360, 1210, 358, 365, 488, 26, 489, 372, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 10385, 297, 283, 4030, 12, 8808, 358, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 12814, 904, 8, 21178, 16674, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 272, 291, 14, 1310, 14, 548, 14, 952, 8, 3498, 8, 1310, 459, 1210, 995, 1177, 459, 5265, 5156, 421, 199, 533, 3820, 19330, 8, 22632, 18, 14, 11149, 304, 523, 408, 1296, 8963, 4799, 4840, 370, 22523, 1041, 819, 347, 664, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 9576, 4145, 1041, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6438, 358, 272, 291, 14, 1310, 14, 548, 14, 952, 480, 1874, 7293, 60, 78, 7709, 2022, 14, 4180, 8, 2718, 63, 2232, 14, 1296, 19330, 4059, 421, 199, 533, 10217, 16799, 8, 22632, 18, 14, 11149, 304, 523, 408, 11389, 666, 4847, 4799, 8761, 1041, 819, 347, 664, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 9576, 4145, 1041, 272, 1978, 275, 1603, 568, 29849, 63, 9984, 31168, 4479, 14, 362, 63, 1160, 360, 1080, 13, 832, 14, 1360, 358, 272, 291, 14, 1310, 14, 952, 8, 1160, 14, 3352, 1012, 819, 347, 2963, 8, 277, 304, 272, 408, 1322, 678, 795, 370, 8761, 4145, 1041, 272, 6330, 275, 291, 14, 1069, 14, 2139, 14, 362, 360, 12834, 297, 4074, 272, 340, 440, 295, 14, 1733, 8, 18817, 4924, 1149, 63, 20332, 10789, 12, 6330, 304, 489, 372, 272, 1978, 63, 1459, 275, 469, 267, 283, 576, 356, 291, 14, 1069, 14, 362, 360, 576, 297, 4074, 272, 789, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 12834, 297, 6330, 9, 272, 291, 14, 1310, 14, 2139, 14, 525, 63, 1291, 360, 3946, 13, 3717, 13, 7852, 13, 13428, 297, 283, 2052, 358, 272, 1978, 275, 1603, 568, 29849, 63, 9984, 31168, 4479, 14, 362, 63, 1160, 360, 1080, 13, 832, 14, 1360, 358, 272, 291, 14, 1310, 14, 952, 8, 1160, 14, 3352, 8, 1160, 63, 1459, 430, 421, 199, 571, 275, 24812, 18, 14, 16828, 5039, 779, 272, 14606, 3916, 297, 11298, 6981, 351, 395, 272, 14606, 513, 5265, 297, 3820, 19330, 395, 272, 2156, 3105, 29, 797, 9, 199, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
qgis/QGIS-Django
qgis-app/settings_local_vagrant.py
1
6701
import os SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) DEBUG = True THUMBNAIL_DEBUG = DEBUG # sorl.thumbnail verbose debug ALLOWED_HOSTS = ['*'] # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/Chicago' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" # Override assets for Vagrant # User uploaded files MEDIA_ROOT = "/home/dimas/Documents/Kartoza/QGIS-Django/vagrant_static/" # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '/static/' MEDIA_URL_FOLDER = '/static/' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". ADMIN_MEDIA_PREFIX = '/admin/' STATIC_URL='/static_media/' STATIC_ROOT=SITE_ROOT + '/static_media/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'y2vu=4qarl)p=g_blq_c4afk!p6u_cor1gy1k@05ro=+tf7+)g' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader', #Tim: needed on live server for CAB ) MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Needed by rpc4django 'plugins.middleware.HttpAuthMiddleware', 'django.contrib.auth.middleware.RemoteUserMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', # Added by Tim for advanced loggin options 'django.middleware.cache.FetchFromCacheMiddleware', 'middleware.XForwardedForMiddleware', ] ROOT_URLCONF = 'urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. os.path.join(SITE_ROOT, 'templates'), ) STATICFILES_DIRS = [ os.path.join(SITE_ROOT, "static"), ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors' : ( "django.contrib.auth.context_processors.auth", 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', # ABP: adds DEBUG and BASE_TEMPLATE vars "qgis_context_processor.additions", ), }, }, ] ADMINS = ( ('Admin', 'admin@email.com'), ) MANAGERS = ADMINS # Tell django which clients may receive debug messages...used by django-debug-toolbar INTERNAL_IPS = ('127.0.0.1','') # Disable for prod machine TEMPLATE_DEBUG = DEBUG LOGGING_OUTPUT_ENABLED=DEBUG LOGGING_LOG_SQL=DEBUG DATABASES = { 'default': { # Newer django versions may require you to use the postgis backed #'ENGINE': 'django.contrib.gis.db.backends.postgis', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. #'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. #'NAME': 'qgis-django-plugins.db', # Or path to database file if using sqlite3. 'NAME': 'qgis_django', # Or path to database file if using sqlite3. 'USER': 'qgis_django', # Not used with sqlite3. 'PASSWORD': 'qgis_django', # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '5432', # Set to empty string for default. Not used with sqlite3. } } #Tim for google maps in user community page #qgis-django.localhost GOOGLE_API_KEY='ABQIAAAAyZw9WlHOs4CazzwUByOgZxQok5WFiNcwymBq4ClbhSeQY6fSMhTl0KHT2Donh18dLk3P4AC4ddOarA' PAGINATION_DEFAULT_PAGINATION=5 LOGIN_REDIRECT_URL='/' SERVE_STATIC_MEDIA = DEBUG # TIM: Place where search indexes are stored for snippets - should be non web accessible HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'), }, } # Tim Email settings EMAIL_HOST = 'localhost' #EMAIL_PORT = DEFAULT_FROM_EMAIL = 'noreply@qgis.org' INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.staticfiles', 'django.contrib.flatpages', # ABP: 'plugins', 'django.contrib.humanize', 'django.contrib.syndication', 'bootstrap_pagination', 'sortable_listview', 'lib', # Container for small tags and functions 'sorl.thumbnail', 'djangoratings', 'taggit', 'taggit_autosuggest', 'taggit_templatetags', 'haystack', 'simplemenu', 'tinymce', 'rpc4django', ] PLUGIN_MAX_UPLOAD_SIZE=1024*1024*20 if DEBUG: INSTALLED_APPS.append('django_extensions')
gpl-2.0
[ 646, 747, 199, 7917, 63, 5441, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 5287, 275, 715, 199, 2080, 2639, 18273, 6593, 63, 5287, 275, 10990, 257, 327, 308, 269, 76, 14, 8311, 3376, 3105, 199, 199, 17350, 63, 23775, 275, 788, 10, 418, 199, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 199, 3, 4068, 13074, 10460, 12, 282, 574, 402, 488, 911, 7675, 5634, 370, 675, 314, 2011, 199, 3, 7137, 465, 314, 17406, 2656, 14, 199, 3, 982, 3879, 315, 282, 5417, 3734, 642, 1471, 506, 663, 370, 314, 2011, 465, 2195, 199, 3, 2656, 900, 5718, 14, 199, 4961, 63, 15353, 275, 283, 8841, 15, 28796, 7, 199, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 7917, 63, 998, 275, 413, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 3, 24964, 931, 370, 314, 2082, 626, 15164, 5898, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 6687, 199, 199, 3, 11041, 17202, 367, 812, 643, 17633, 199, 3, 2876, 14238, 1584, 199, 13669, 63, 5441, 275, 3286, 4219, 15, 3572, 305, 15, 26872, 15, 43, 285, 475, 8076, 15, 31329, 13, 9323, 15, 86, 643, 17633, 63, 1986, 6687, 199, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 340, 2337, 365, 282, 931, 3931, 334, 4144, 315, 1163, 5560, 680, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 401, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 199, 13669, 63, 2632, 275, 1994, 1986, 4805, 199, 13669, 63, 2632, 63, 19041, 275, 1994, 1986, 4805, 199, 199, 3, 2851, 2403, 367, 4628, 5898, 1553, 15750, 12, 15250, 436, 5935, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 14, 199, 3, 6058, 26, 298, 1014, 921, 1421, 14, 957, 15, 4603, 10665, 3286, 4603, 15, 1674, 199, 14288, 63, 13669, 63, 6351, 275, 1994, 2113, 4805, 199, 199, 10449, 63, 2632, 8805, 1986, 63, 4603, 4805, 199, 10449, 63, 5441, 29, 7917, 63, 5441, 435, 1994, 1986, 63, 4603, 4805, 421, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 199, 12961, 63, 3078, 275, 283, 89, 18, 86, 85, 29, 20, 81, 285, 76, 9, 80, 29, 71, 63, 3345, 81, 63, 67, 20, 2756, 75, 1, 80, 22, 85, 63, 989, 17, 4312, 17, 75, 32, 1717, 293, 29744, 3249, 23, 8771, 71, 7, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 272, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 327, 23853, 26, 4346, 641, 12166, 1654, 367, 445, 1217, 199, 9, 199, 199, 19987, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 5754, 14, 1637, 14, 4152, 4437, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 327, 28196, 701, 8985, 20, 1176, 272, 283, 5265, 14, 5754, 14, 5779, 2817, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 6713, 1899, 6608, 297, 272, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 297, 272, 327, 16230, 701, 26244, 367, 19472, 943, 903, 1511, 272, 283, 1176, 14, 5754, 14, 1637, 14, 11135, 2532, 4437, 6608, 297, 272, 283, 5754, 14, 56, 1858, 15295, 1858, 6608, 297, 199, 61, 199, 199, 5441, 63, 18125, 275, 283, 3603, 7, 199, 199, 7433, 63, 14455, 275, 334, 272, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1176, 63, 5876, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 5876, 1674, 272, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 272, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 272, 747, 14, 515, 14, 904, 8, 7917, 63, 5441, 12, 283, 5876, 659, 199, 9, 421, 199, 10449, 9472, 63, 14455, 275, 359, 272, 747, 14, 515, 14, 904, 8, 7917, 63, 5441, 12, 298, 1986, 1288, 199, 61, 199, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 788, 5876, 995, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 7, 520, 334, 355, 298, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 401, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 327, 14840, 48, 26, 9584, 10990, 436, 19721 ]
[ 747, 199, 7917, 63, 5441, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 199, 5287, 275, 715, 199, 2080, 2639, 18273, 6593, 63, 5287, 275, 10990, 257, 327, 308, 269, 76, 14, 8311, 3376, 3105, 199, 199, 17350, 63, 23775, 275, 788, 10, 418, 199, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 199, 3, 4068, 13074, 10460, 12, 282, 574, 402, 488, 911, 7675, 5634, 370, 675, 314, 2011, 199, 3, 7137, 465, 314, 17406, 2656, 14, 199, 3, 982, 3879, 315, 282, 5417, 3734, 642, 1471, 506, 663, 370, 314, 2011, 465, 2195, 199, 3, 2656, 900, 5718, 14, 199, 4961, 63, 15353, 275, 283, 8841, 15, 28796, 7, 199, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 199, 199, 7917, 63, 998, 275, 413, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 3, 24964, 931, 370, 314, 2082, 626, 15164, 5898, 14, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 6687, 199, 199, 3, 11041, 17202, 367, 812, 643, 17633, 199, 3, 2876, 14238, 1584, 199, 13669, 63, 5441, 275, 3286, 4219, 15, 3572, 305, 15, 26872, 15, 43, 285, 475, 8076, 15, 31329, 13, 9323, 15, 86, 643, 17633, 63, 1986, 6687, 199, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 340, 2337, 365, 282, 931, 3931, 334, 4144, 315, 1163, 5560, 680, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 401, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 199, 13669, 63, 2632, 275, 1994, 1986, 4805, 199, 13669, 63, 2632, 63, 19041, 275, 1994, 1986, 4805, 199, 199, 3, 2851, 2403, 367, 4628, 5898, 1553, 15750, 12, 15250, 436, 5935, 14, 4155, 3238, 370, 675, 282, 199, 3, 8520, 14457, 14, 199, 3, 6058, 26, 298, 1014, 921, 1421, 14, 957, 15, 4603, 10665, 3286, 4603, 15, 1674, 199, 14288, 63, 13669, 63, 6351, 275, 1994, 2113, 4805, 199, 199, 10449, 63, 2632, 8805, 1986, 63, 4603, 4805, 199, 10449, 63, 5441, 29, 7917, 63, 5441, 435, 1994, 1986, 63, 4603, 4805, 421, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 199, 12961, 63, 3078, 275, 283, 89, 18, 86, 85, 29, 20, 81, 285, 76, 9, 80, 29, 71, 63, 3345, 81, 63, 67, 20, 2756, 75, 1, 80, 22, 85, 63, 989, 17, 4312, 17, 75, 32, 1717, 293, 29744, 3249, 23, 8771, 71, 7, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 272, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 327, 23853, 26, 4346, 641, 12166, 1654, 367, 445, 1217, 199, 9, 199, 199, 19987, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 5754, 14, 1637, 14, 4152, 4437, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 327, 28196, 701, 8985, 20, 1176, 272, 283, 5265, 14, 5754, 14, 5779, 2817, 6608, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 6713, 1899, 6608, 297, 272, 283, 1176, 14, 2828, 14, 29974, 14, 5754, 14, 17271, 1606, 21860, 6608, 297, 272, 327, 16230, 701, 26244, 367, 19472, 943, 903, 1511, 272, 283, 1176, 14, 5754, 14, 1637, 14, 11135, 2532, 4437, 6608, 297, 272, 283, 5754, 14, 56, 1858, 15295, 1858, 6608, 297, 199, 61, 199, 199, 5441, 63, 18125, 275, 283, 3603, 7, 199, 199, 7433, 63, 14455, 275, 334, 272, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1176, 63, 5876, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 5876, 1674, 272, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 272, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 272, 747, 14, 515, 14, 904, 8, 7917, 63, 5441, 12, 283, 5876, 659, 199, 9, 421, 199, 10449, 9472, 63, 14455, 275, 359, 272, 747, 14, 515, 14, 904, 8, 7917, 63, 5441, 12, 298, 1986, 1288, 199, 61, 199, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 788, 5876, 995, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 7, 520, 334, 355, 298, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 401, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 327, 14840, 48, 26, 9584, 10990, 436, 19721, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
lonetwin/opencore
opencore/views/tests/test_login.py
4
18599
# Copyright (C) 2008-2009 Open Society Institute # Thomas Moroz: tmoroz.org # 2010-2011 Large Blue # Fergus Doyle: fergus.doyle@largeblue.com # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License Version 2 as published # by the Free Software Foundation. You may not use, modify or distribute # this program under any other version of the GNU General Public License. # # 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, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import unittest from zope.testing.cleanup import cleanUp from repoze.bfg import testing class TestLoginView(unittest.TestCase): def setUp(self): cleanUp() def tearDown(self): cleanUp() def _callFUT(self, context, request): from opencore.views.login import login_view from opencore.views.api import get_template_api request.api = get_template_api(context, request) return login_view(context, request) def test_GET_came_from_endswith_login_html_relative(self): request = testing.DummyRequest({'came_from':'/login.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_came_from_endswith_login_html_absolute(self): request = testing.DummyRequest({'came_from': 'http://example.com/login.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_came_from_endswith_logout_html_relative(self): request = testing.DummyRequest({'came_from':'/logout.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_came_from_endswith_logout_html_absolute(self): request = testing.DummyRequest({'came_from': 'http://example.com/logout.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_came_from_other_relative(self): request = testing.DummyRequest({'came_from':'/somewhere.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/somewhere.html') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_came_from_other_absolute(self): request = testing.DummyRequest({'came_from': 'http://example.com/somewhere.html'}) context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(renderer.came_from, 'http://example.com/somewhere.html') self.assertEqual(renderer.app_url, 'http://example.com') def test_GET_forget_headers_when_auth_tkt_not_None(self): request = testing.DummyRequest({'came_from':'/somewhere.html'}) plugin = DummyAuthenticationPlugin() request.environ['repoze.who.plugins'] = {'auth_tkt':plugin} context = testing.DummyModel() renderer = testing.registerDummyRenderer('templates/login.pt') response = self._callFUT(context, request) self.assertEqual(dict(response.headers), dict([('Content-Type', 'text/html; charset=UTF-8'), ('Content-Length', '0'), ('a', '1')])) self.assertEqual(plugin._forget_called, (request.environ, {})) def test_POST_no_login_in_form(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['password'] = 'password' context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com/login.html') def test_POST_no_password_in_form(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com/login.html') def test_POST_no_authentication_plugins(self): from webob.exc import HTTPFound from urlparse import urlsplit try: from urlparse import parse_qsl except ImportError: # Python < 2.6 from cgi import parse_qsl request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) (_, _, path, query, _) = urlsplit(response.location) self.assertEqual(path, '/login.html') query = dict(parse_qsl(query, 1, 1)) self.assertEqual(query['came_from'], 'http://example.com') self.assertEqual(query['reason'], 'No authenticatable users') def test_POST_w_plugins_miss(self): from webob.exc import HTTPFound from urlparse import urlsplit try: from urlparse import parse_qsl except ImportError: # Python < 2.6 from cgi import parse_qsl request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' zodb = DummyAuthenticationPlugin() #zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() #impostor._userid = 'impostor' request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, } context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) (_, _, path, query, _) = urlsplit(response.location) self.assertEqual(path, '/login.html') query = dict(parse_qsl(query, 1, 1)) self.assertEqual(query['came_from'], 'http://example.com') self.assertEqual(query['reason'], 'Bad username or password') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password'})) self.assertEqual(impostor._auth_called, (request.environ, {'login': 'login', 'password': 'password'})) def test_POST_w_plugins_zodb_hit_no_came_from_w_profile(self): from datetime import datetime from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' zodb = DummyAuthenticationPlugin() zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() #impostor._userid = 'impostor' auth_tkt = DummyAuthenticationPlugin() request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, 'auth_tkt': auth_tkt, } context = testing.DummyModel() context['profiles'] = testing.DummyModel() profile = context['profiles']['zodb'] = testing.DummyModel() before = datetime.utcnow() response = self._callFUT(context, request) after = datetime.utcnow() self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'repoze.who.userid': 'zodb'})) self.assertEqual(impostor._auth_called, None) self.assertEqual(auth_tkt._auth_called, None) self.assertEqual(auth_tkt._remember_called, (request.environ, {'login': 'login', 'password': 'password', 'repoze.who.userid': 'zodb'})) headers = dict(response.headers) self.assertEqual(headers['Faux-Header'], 'Faux-Value') self.failUnless(before <= profile.last_login_time <= after) def test_POST_w_plugins_impostor_hit_w_came_from_no_profile(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' request.POST['came_from'] = '/somewhere.html' zodb = DummyAuthenticationPlugin() #zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() impostor._userid = 'impostor' auth_tkt = DummyAuthenticationPlugin() request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, 'auth_tkt': auth_tkt, } context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com/somewhere.html') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'repoze.who.userid': 'impostor'})) self.assertEqual(impostor._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'repoze.who.userid': 'impostor'})) self.assertEqual(auth_tkt._auth_called, None) self.assertEqual(auth_tkt._remember_called, (request.environ, {'login': 'login', 'password': 'password', 'repoze.who.userid': 'impostor'})) headers = dict(response.headers) self.assertEqual(headers['Faux-Header'], 'Faux-Value') def test_POST_w_zodb_hit_w_max_age(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' request.POST['max_age'] = '100' zodb = DummyAuthenticationPlugin() zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() #impostor._userid = 'impostor' auth_tkt = DummyAuthenticationPlugin() request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, 'auth_tkt': auth_tkt, } context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'max_age': 100, 'repoze.who.userid': 'zodb'})) self.assertEqual(impostor._auth_called, None) self.assertEqual(auth_tkt._auth_called, None) self.assertEqual(auth_tkt._remember_called, (request.environ, {'login': 'login', 'password': 'password', 'max_age': 100, 'repoze.who.userid': 'zodb'})) headers = dict(response.headers) self.assertEqual(headers['Faux-Header'], 'Faux-Value') def test_POST_w_zodb_hit_w_max_age_unicode(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' request.POST['max_age'] = u'100' zodb = DummyAuthenticationPlugin() zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() #impostor._userid = 'impostor' auth_tkt = DummyAuthenticationPlugin() request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, 'auth_tkt': auth_tkt, } context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'max_age': 100, 'repoze.who.userid': 'zodb'})) self.assertEqual(impostor._auth_called, None) self.assertEqual(auth_tkt._auth_called, None) self.assertEqual(auth_tkt._remember_called, (request.environ, {'login': 'login', 'password': 'password', 'max_age': 100, 'repoze.who.userid': 'zodb'})) headers = dict(response.headers) self.assertEqual(headers['Faux-Header'], 'Faux-Value') def test_POST_w_zodb_hit_w_max_age_no_auth_tkt_plugin(self): from webob.exc import HTTPFound request = testing.DummyRequest() request.POST['form.submitted'] = 1 request.POST['login'] = 'login' request.POST['password'] = 'password' request.POST['max_age'] = '100' zodb = DummyAuthenticationPlugin() zodb._userid = 'zodb' impostor = DummyAuthenticationPlugin() #impostor._userid = 'impostor' request.environ['repoze.who.plugins'] = {'zodb': zodb, 'zodb_impersonate': impostor, } context = testing.DummyModel() response = self._callFUT(context, request) self.failUnless(isinstance(response, HTTPFound)) self.assertEqual(response.location, 'http://example.com') self.assertEqual(zodb._auth_called, (request.environ, {'login': 'login', 'password': 'password', 'max_age': 100, 'repoze.who.userid': 'zodb'})) self.assertEqual(impostor._auth_called, None) headers = dict(response.headers) self.failIf('Faux-Header' in headers) _marker = object() class TestLogoutView(unittest.TestCase): def setUp(self): cleanUp() def tearDown(self): cleanUp() def _callFUT(self, context, request, reason=_marker): from opencore.views.login import logout_view if reason is not _marker: return logout_view(context, request, reason) return logout_view(context, request) def test_w_default_reason(self): request = testing.DummyRequest() context = testing.DummyModel() response = self._callFUT(context, request) self.assertEqual(response.status, '401 Unauthorized') headers = dict(response.headers) self.assertEqual(headers['X-Authorization-Failure-Reason'], 'Logged out') def test_w_explicit_reason(self): request = testing.DummyRequest() context = testing.DummyModel() response = self._callFUT(context, request, reason='testing') self.assertEqual(response.status, '401 Unauthorized') headers = dict(response.headers) self.assertEqual(headers['X-Authorization-Failure-Reason'], 'testing') class DummyAuthenticationPlugin(object): _auth_called = _remember_called = _forget_called = _userid = None def authenticate(self, environ, credentials): self._auth_called = (environ, credentials) return self._userid def remember(self, environ, credentials): self._remember_called = (environ, credentials) return [('Faux-Header', 'Faux-Value')] def forget(self, environ, identity): self._forget_called = (environ, identity) return [('a', '1')]
gpl-2.0
[ 3, 1898, 334, 35, 9, 9079, 13, 8664, 3232, 2002, 559, 23364, 1010, 25585, 199, 3, 5185, 27864, 603, 269, 26051, 26, 7352, 269, 26051, 14, 1308, 199, 3, 5185, 7129, 13, 8128, 29095, 22447, 199, 3, 5185, 481, 281, 17360, 4226, 1775, 26, 289, 281, 17360, 14, 1117, 1775, 32, 9629, 6304, 14, 957, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 3394, 499, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 14, 221, 2047, 1443, 440, 675, 12, 2811, 503, 11207, 199, 3, 642, 2240, 1334, 1263, 1163, 1015, 402, 314, 1664, 1696, 1684, 844, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 646, 2882, 199, 504, 20110, 14, 4776, 14, 7661, 492, 3633, 1721, 199, 504, 3831, 806, 14, 4361, 71, 492, 5343, 199, 199, 533, 1379, 8880, 2768, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 3633, 1721, 342, 339, 347, 6766, 8, 277, 304, 267, 3633, 1721, 342, 339, 347, 485, 1250, 20254, 8, 277, 12, 1067, 12, 1056, 304, 267, 687, 1551, 1018, 14, 4196, 14, 2886, 492, 4676, 63, 1345, 267, 687, 1551, 1018, 14, 4196, 14, 1246, 492, 664, 63, 1160, 63, 1246, 267, 1056, 14, 1246, 275, 664, 63, 1160, 63, 1246, 8, 1100, 12, 1056, 9, 267, 372, 4676, 63, 1345, 8, 1100, 12, 1056, 9, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 2886, 63, 1360, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 2886, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 2886, 63, 1360, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 4490, 283, 1014, 921, 2694, 14, 957, 15, 2886, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 11646, 63, 1360, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 11646, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 11646, 63, 1360, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 4490, 283, 1014, 921, 2694, 14, 957, 15, 11646, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 1848, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 3972, 4509, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 586, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 358, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 1848, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 1460, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 586, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 358, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970 ]
[ 1898, 334, 35, 9, 9079, 13, 8664, 3232, 2002, 559, 23364, 1010, 25585, 199, 3, 5185, 27864, 603, 269, 26051, 26, 7352, 269, 26051, 14, 1308, 199, 3, 5185, 7129, 13, 8128, 29095, 22447, 199, 3, 5185, 481, 281, 17360, 4226, 1775, 26, 289, 281, 17360, 14, 1117, 1775, 32, 9629, 6304, 14, 957, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 3394, 499, 465, 3267, 199, 3, 701, 314, 2868, 2290, 2752, 14, 221, 2047, 1443, 440, 675, 12, 2811, 503, 11207, 199, 3, 642, 2240, 1334, 1263, 1163, 1015, 402, 314, 1664, 1696, 1684, 844, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 646, 2882, 199, 504, 20110, 14, 4776, 14, 7661, 492, 3633, 1721, 199, 504, 3831, 806, 14, 4361, 71, 492, 5343, 199, 199, 533, 1379, 8880, 2768, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 3633, 1721, 342, 339, 347, 6766, 8, 277, 304, 267, 3633, 1721, 342, 339, 347, 485, 1250, 20254, 8, 277, 12, 1067, 12, 1056, 304, 267, 687, 1551, 1018, 14, 4196, 14, 2886, 492, 4676, 63, 1345, 267, 687, 1551, 1018, 14, 4196, 14, 1246, 492, 664, 63, 1160, 63, 1246, 267, 1056, 14, 1246, 275, 664, 63, 1160, 63, 1246, 8, 1100, 12, 1056, 9, 267, 372, 4676, 63, 1345, 8, 1100, 12, 1056, 9, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 2886, 63, 1360, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 2886, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 2886, 63, 1360, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 4490, 283, 1014, 921, 2694, 14, 957, 15, 2886, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 11646, 63, 1360, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 11646, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 4130, 63, 11646, 63, 1360, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 4490, 283, 1014, 921, 2694, 14, 957, 15, 11646, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 283, 1014, 921, 2694, 14, 957, 6217, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 1848, 63, 6188, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 5242, 15, 3972, 4509, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 586, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 358, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 63, 27467, 63, 504, 63, 1848, 63, 6116, 8, 277, 304, 267, 1056, 275, 5343, 14, 11324, 2017, 3252, 27467, 63, 504, 356, 1460, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 3071, 267, 1067, 275, 5343, 14, 11324, 1685, 342, 267, 11889, 275, 5343, 14, 2683, 11324, 11355, 360, 5876, 15, 2886, 14, 541, 358, 267, 1177, 275, 291, 423, 1250, 20254, 8, 1100, 12, 1056, 9, 267, 291, 14, 629, 8, 12471, 14, 27467, 63, 504, 12, 586, 283, 1014, 921, 2694, 14, 957, 15, 3972, 4509, 14, 1360, 358, 267, 291, 14, 629, 8, 12471, 14, 571, 63, 633, 12, 283, 1014, 921, 2694, 14, 957, 358, 339, 347, 511, 63, 2970, 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, 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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 ]
techtonik/buildozer
docs/source/conf.py
9
7963
# -*- coding: utf-8 -*- # # Buildozer documentation build configuration file, created by # sphinx-quickstart on Sun Apr 20 16:56:31 2014. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Buildozer' copyright = u'2014, Kivy\'s Developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.11' # The full version, including alpha/beta/rc tags. release = '0.11' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'Buildozerdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'Buildozer.tex', u'Buildozer Documentation', u'Kivy\'s Developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'buildozer', u'Buildozer Documentation', [u'Kivy\'s Developers'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'Buildozer', u'Buildozer Documentation', u'Kivy\'s Developers', 'Buildozer', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 6516, 79, 2282, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 25625, 437, 2700, 3388, 3193, 26, 1367, 26, 2192, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 942, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3425, 79, 2282, 7, 199, 7307, 275, 399, 7, 7280, 12, 1804, 10241, 3985, 83, 23493, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 845, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 845, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 6516, 79, 2282, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 25625, 437, 2700, 3388, 3193, 26, 1367, 26, 2192, 6927, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 942, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 3425, 79, 2282, 7, 199, 7307, 275, 399, 7, 7280, 12, 1804, 10241, 3985, 83, 23493, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 16, 14, 845, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 845, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 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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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 ]
anbangleo/NlsdeWeb
Python-3.6.0/Lib/test/test_keyword.py
98
5840
import keyword import unittest from test import support import filecmp import os import sys import subprocess import shutil import textwrap KEYWORD_FILE = support.findfile('keyword.py') GRAMMAR_FILE = os.path.join(os.path.split(__file__)[0], '..', '..', 'Python', 'graminit.c') TEST_PY_FILE = 'keyword_test.py' GRAMMAR_TEST_FILE = 'graminit_test.c' PY_FILE_WITHOUT_KEYWORDS = 'minimal_keyword.py' NONEXISTENT_FILE = 'not_here.txt' class Test_iskeyword(unittest.TestCase): def test_true_is_a_keyword(self): self.assertTrue(keyword.iskeyword('True')) def test_uppercase_true_is_not_a_keyword(self): self.assertFalse(keyword.iskeyword('TRUE')) def test_none_value_is_not_a_keyword(self): self.assertFalse(keyword.iskeyword(None)) # This is probably an accident of the current implementation, but should be # preserved for backward compatibility. def test_changing_the_kwlist_does_not_affect_iskeyword(self): oldlist = keyword.kwlist self.addCleanup(setattr, keyword, 'kwlist', oldlist) keyword.kwlist = ['its', 'all', 'eggs', 'beans', 'and', 'a', 'slice'] self.assertFalse(keyword.iskeyword('eggs')) class TestKeywordGeneration(unittest.TestCase): def _copy_file_without_generated_keywords(self, source_file, dest_file): with open(source_file, 'rb') as fp: lines = fp.readlines() nl = lines[0][len(lines[0].strip()):] with open(dest_file, 'wb') as fp: fp.writelines(lines[:lines.index(b"#--start keywords--" + nl) + 1]) fp.writelines(lines[lines.index(b"#--end keywords--" + nl):]) def _generate_keywords(self, grammar_file, target_keyword_py_file): proc = subprocess.Popen([sys.executable, KEYWORD_FILE, grammar_file, target_keyword_py_file], stderr=subprocess.PIPE) stderr = proc.communicate()[1] return proc.returncode, stderr @unittest.skipIf(not os.path.exists(GRAMMAR_FILE), 'test only works from source build directory') def test_real_grammar_and_keyword_file(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) self.assertFalse(filecmp.cmp(KEYWORD_FILE, TEST_PY_FILE)) self.assertEqual((0, b''), self._generate_keywords(GRAMMAR_FILE, TEST_PY_FILE)) self.assertTrue(filecmp.cmp(KEYWORD_FILE, TEST_PY_FILE)) def test_grammar(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) with open(GRAMMAR_TEST_FILE, 'w') as fp: # Some of these are probably implementation accidents. fp.writelines(textwrap.dedent("""\ {2, 1}, {11, "encoding_decl", 0, 2, states_79, "\000\000\040\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000"}, {1, "jello"}, {326, 0}, {1, "turnip"}, \t{1, "This one is tab indented" {278, 0}, {1, "crazy but legal" "also legal" {1, " {1, "continue"}, {1, "lemon"}, {1, "tomato"}, {1, "wigii"}, {1, 'no good'} {283, 0}, {1, "too many spaces"}""")) self.addCleanup(support.unlink, GRAMMAR_TEST_FILE) self._generate_keywords(GRAMMAR_TEST_FILE, TEST_PY_FILE) expected = [ " 'This one is tab indented',", " 'also legal',", " 'continue',", " 'crazy but legal',", " 'jello',", " 'lemon',", " 'tomato',", " 'turnip',", " 'wigii',", ] with open(TEST_PY_FILE) as fp: lines = fp.read().splitlines() start = lines.index("#--start keywords--") + 1 end = lines.index("#--end keywords--") actual = lines[start:end] self.assertEqual(actual, expected) def test_empty_grammar_results_in_no_keywords(self): self._copy_file_without_generated_keywords(KEYWORD_FILE, PY_FILE_WITHOUT_KEYWORDS) self.addCleanup(support.unlink, PY_FILE_WITHOUT_KEYWORDS) shutil.copyfile(KEYWORD_FILE, TEST_PY_FILE) self.addCleanup(support.unlink, TEST_PY_FILE) self.assertEqual((0, b''), self._generate_keywords(os.devnull, TEST_PY_FILE)) self.assertTrue(filecmp.cmp(TEST_PY_FILE, PY_FILE_WITHOUT_KEYWORDS)) def test_keywords_py_without_markers_produces_error(self): rc, stderr = self._generate_keywords(os.devnull, os.devnull) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'does not contain format markers') def test_missing_grammar_file_produces_error(self): rc, stderr = self._generate_keywords(NONEXISTENT_FILE, KEYWORD_FILE) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) def test_missing_keywords_py_file_produces_error(self): rc, stderr = self._generate_keywords(os.devnull, NONEXISTENT_FILE) self.assertNotEqual(rc, 0) self.assertRegex(stderr, b'(?ms)' + NONEXISTENT_FILE.encode()) if __name__ == "__main__": unittest.main()
mit
[ 646, 4252, 199, 646, 2882, 199, 504, 511, 492, 2291, 199, 646, 570, 5730, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 646, 5145, 199, 646, 13390, 199, 199, 17714, 63, 3817, 3777, 275, 2291, 14, 1623, 493, 360, 6691, 14, 647, 358, 199, 10896, 45, 689, 63, 3817, 3777, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 467, 3147, 19155, 19155, 283, 4718, 297, 283, 1679, 826, 14, 67, 358, 199, 2864, 63, 4521, 63, 3817, 3777, 275, 283, 6691, 63, 396, 14, 647, 7, 199, 10896, 45, 689, 63, 2864, 63, 3817, 263, 275, 283, 1679, 826, 63, 396, 14, 67, 7, 199, 4521, 63, 3817, 63, 29946, 63, 32187, 275, 283, 21508, 63, 6691, 14, 647, 7, 199, 13887, 13301, 1309, 63, 3817, 260, 275, 283, 1397, 63, 1681, 14, 2424, 7, 421, 199, 533, 1379, 63, 374, 6691, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 2052, 63, 374, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 1815, 8, 6691, 14, 374, 6691, 360, 549, 1333, 339, 347, 511, 63, 26831, 63, 2052, 63, 374, 63, 1397, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 360, 15064, 1333, 339, 347, 511, 63, 3592, 63, 585, 63, 374, 63, 1397, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 8, 403, 430, 339, 327, 961, 365, 8646, 376, 24634, 402, 314, 1453, 4514, 12, 1325, 1077, 506, 272, 327, 17731, 367, 13388, 7163, 14, 272, 347, 511, 63, 29131, 63, 1589, 63, 829, 513, 63, 9105, 63, 1397, 63, 65, 5551, 63, 374, 6691, 8, 277, 304, 267, 2269, 513, 275, 4252, 14, 829, 513, 267, 291, 14, 12808, 8, 10202, 12, 4252, 12, 283, 829, 513, 297, 2269, 513, 9, 267, 4252, 14, 829, 513, 275, 788, 1405, 297, 283, 452, 297, 283, 14488, 297, 283, 1235, 796, 297, 283, 460, 297, 283, 65, 297, 283, 5224, 418, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 360, 14488, 1333, 421, 199, 533, 1379, 10650, 18514, 8, 2796, 14, 1746, 304, 339, 347, 485, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 277, 12, 1350, 63, 493, 12, 2053, 63, 493, 304, 267, 543, 1551, 8, 1365, 63, 493, 12, 283, 4848, 358, 465, 4090, 26, 288, 2385, 275, 4090, 14, 9684, 342, 267, 12992, 275, 2385, 59, 16, 1527, 552, 8, 1278, 59, 16, 1055, 1913, 5109, 61, 267, 543, 1551, 8, 2614, 63, 493, 12, 283, 6603, 358, 465, 4090, 26, 288, 4090, 14, 23277, 8, 1278, 1491, 1278, 14, 1080, 8, 66, 2, 3, 306, 928, 7681, 306, 2, 435, 12992, 9, 435, 413, 566, 288, 4090, 14, 23277, 8, 1278, 59, 1278, 14, 1080, 8, 66, 2, 3, 306, 500, 7681, 306, 2, 435, 12992, 304, 566, 339, 347, 485, 4208, 63, 7511, 8, 277, 12, 12528, 63, 493, 12, 1347, 63, 6691, 63, 647, 63, 493, 304, 267, 6499, 275, 3873, 14, 7942, 779, 1274, 14, 5904, 12, 639, 9301, 5172, 63, 3817, 12, 639, 12528, 63, 493, 12, 639, 1347, 63, 6691, 63, 647, 63, 493, 467, 4635, 29, 5781, 14, 6089, 9, 267, 4635, 275, 6499, 14, 10664, 3430, 17, 61, 267, 372, 6499, 14, 9913, 12, 4635, 339, 768, 2796, 14, 15118, 8, 1397, 747, 14, 515, 14, 2444, 8, 10896, 45, 689, 63, 3817, 395, 2151, 283, 396, 1454, 5419, 687, 1350, 1900, 2082, 358, 272, 347, 511, 63, 3093, 63, 15239, 63, 460, 63, 6691, 63, 493, 8, 277, 304, 267, 291, 423, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 3334, 8, 493, 5730, 14, 5730, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 430, 267, 291, 14, 629, 1332, 16, 12, 330, 7, 659, 291, 423, 4208, 63, 7511, 8, 10896, 45, 689, 63, 3817, 12, 15491, 7393, 63, 4521, 63, 3817, 430, 267, 291, 14, 1815, 8, 493, 5730, 14, 5730, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 430, 339, 347, 511, 63, 15239, 8, 277, 304, 267, 291, 423, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 7393, 63, 4521, 63, 3817, 9, 267, 543, 1551, 8, 10896, 45, 689, 63, 2864, 63, 3817, 12, 283, 87, 358, 465, 4090, 26, 288, 327, 6601, 402, 3520, 787, 8646, 4514, 24634, 83, 14, 288, 4090, 14, 23277, 8, 505, 3823, 14, 14674, 21723, 355, 469, 18, 12, 413, 1386, 490, 469, 845, 12, 298, 2991, 63, 9427, 401, 378, 12, 499, 12, 6363, 63, 1965, 12, 2151, 1867, 1493, 60, 1493, 60, 11189, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 2, 2151, 1867, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 6018, 490, 469, 17, 12, 298, 74, 3312, 6018, 490, 469, 8342, 12, 378, 1386, 490, 469, 17, 12, 298, 353, 711, 6018, 355, 971, 84, 91, 17, 12, 298, 2765, 1373, 365, 5174, 19197, 2, 490, 469, 13909, 12, 378, 1386, 490, 469, 17, 12, 298, 67, 30566, 1325, 18393, 2, 355, 298, 12344, 18393, 2, 469, 17, 12, 298, 490, 469, 17, 12, 298, 6958, 6018, 673, 469, 17, 12, 298, 274, 2106, 6018, 2151, 469, 17, 12, 298, 475, 569, 79, 6018, 355, 469, 17, 12, 298, 87, 528, 5908, 6018, 490, 469, 17, 12, 283, 889, 6954, 936, 490, 469, 16029, 12, 378, 1386, 490, 469, 17, 12, 221, 298, 7354, 5002, 7883, 3570, 624, 430, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 21772, 1156, 45, 689, 63, 2864, 63, 3817, 9, 267, 291, 423, 4208, 63, 7511, 8, 10896, 45, 689, 63, 2864, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9 ]
[ 4252, 199, 646, 2882, 199, 504, 511, 492, 2291, 199, 646, 570, 5730, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 646, 5145, 199, 646, 13390, 199, 199, 17714, 63, 3817, 3777, 275, 2291, 14, 1623, 493, 360, 6691, 14, 647, 358, 199, 10896, 45, 689, 63, 3817, 3777, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 467, 3147, 19155, 19155, 283, 4718, 297, 283, 1679, 826, 14, 67, 358, 199, 2864, 63, 4521, 63, 3817, 3777, 275, 283, 6691, 63, 396, 14, 647, 7, 199, 10896, 45, 689, 63, 2864, 63, 3817, 263, 275, 283, 1679, 826, 63, 396, 14, 67, 7, 199, 4521, 63, 3817, 63, 29946, 63, 32187, 275, 283, 21508, 63, 6691, 14, 647, 7, 199, 13887, 13301, 1309, 63, 3817, 260, 275, 283, 1397, 63, 1681, 14, 2424, 7, 421, 199, 533, 1379, 63, 374, 6691, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 2052, 63, 374, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 1815, 8, 6691, 14, 374, 6691, 360, 549, 1333, 339, 347, 511, 63, 26831, 63, 2052, 63, 374, 63, 1397, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 360, 15064, 1333, 339, 347, 511, 63, 3592, 63, 585, 63, 374, 63, 1397, 63, 65, 63, 6691, 8, 277, 304, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 8, 403, 430, 339, 327, 961, 365, 8646, 376, 24634, 402, 314, 1453, 4514, 12, 1325, 1077, 506, 272, 327, 17731, 367, 13388, 7163, 14, 272, 347, 511, 63, 29131, 63, 1589, 63, 829, 513, 63, 9105, 63, 1397, 63, 65, 5551, 63, 374, 6691, 8, 277, 304, 267, 2269, 513, 275, 4252, 14, 829, 513, 267, 291, 14, 12808, 8, 10202, 12, 4252, 12, 283, 829, 513, 297, 2269, 513, 9, 267, 4252, 14, 829, 513, 275, 788, 1405, 297, 283, 452, 297, 283, 14488, 297, 283, 1235, 796, 297, 283, 460, 297, 283, 65, 297, 283, 5224, 418, 267, 291, 14, 3334, 8, 6691, 14, 374, 6691, 360, 14488, 1333, 421, 199, 533, 1379, 10650, 18514, 8, 2796, 14, 1746, 304, 339, 347, 485, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 277, 12, 1350, 63, 493, 12, 2053, 63, 493, 304, 267, 543, 1551, 8, 1365, 63, 493, 12, 283, 4848, 358, 465, 4090, 26, 288, 2385, 275, 4090, 14, 9684, 342, 267, 12992, 275, 2385, 59, 16, 1527, 552, 8, 1278, 59, 16, 1055, 1913, 5109, 61, 267, 543, 1551, 8, 2614, 63, 493, 12, 283, 6603, 358, 465, 4090, 26, 288, 4090, 14, 23277, 8, 1278, 1491, 1278, 14, 1080, 8, 66, 2, 3, 306, 928, 7681, 306, 2, 435, 12992, 9, 435, 413, 566, 288, 4090, 14, 23277, 8, 1278, 59, 1278, 14, 1080, 8, 66, 2, 3, 306, 500, 7681, 306, 2, 435, 12992, 304, 566, 339, 347, 485, 4208, 63, 7511, 8, 277, 12, 12528, 63, 493, 12, 1347, 63, 6691, 63, 647, 63, 493, 304, 267, 6499, 275, 3873, 14, 7942, 779, 1274, 14, 5904, 12, 639, 9301, 5172, 63, 3817, 12, 639, 12528, 63, 493, 12, 639, 1347, 63, 6691, 63, 647, 63, 493, 467, 4635, 29, 5781, 14, 6089, 9, 267, 4635, 275, 6499, 14, 10664, 3430, 17, 61, 267, 372, 6499, 14, 9913, 12, 4635, 339, 768, 2796, 14, 15118, 8, 1397, 747, 14, 515, 14, 2444, 8, 10896, 45, 689, 63, 3817, 395, 2151, 283, 396, 1454, 5419, 687, 1350, 1900, 2082, 358, 272, 347, 511, 63, 3093, 63, 15239, 63, 460, 63, 6691, 63, 493, 8, 277, 304, 267, 291, 423, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 3334, 8, 493, 5730, 14, 5730, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 430, 267, 291, 14, 629, 1332, 16, 12, 330, 7, 659, 291, 423, 4208, 63, 7511, 8, 10896, 45, 689, 63, 3817, 12, 15491, 7393, 63, 4521, 63, 3817, 430, 267, 291, 14, 1815, 8, 493, 5730, 14, 5730, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 430, 339, 347, 511, 63, 15239, 8, 277, 304, 267, 291, 423, 1574, 63, 493, 63, 7395, 63, 10176, 63, 7511, 8, 17714, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 7393, 63, 4521, 63, 3817, 9, 267, 543, 1551, 8, 10896, 45, 689, 63, 2864, 63, 3817, 12, 283, 87, 358, 465, 4090, 26, 288, 327, 6601, 402, 3520, 787, 8646, 4514, 24634, 83, 14, 288, 4090, 14, 23277, 8, 505, 3823, 14, 14674, 21723, 355, 469, 18, 12, 413, 1386, 490, 469, 845, 12, 298, 2991, 63, 9427, 401, 378, 12, 499, 12, 6363, 63, 1965, 12, 2151, 1867, 1493, 60, 1493, 60, 11189, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 2, 2151, 1867, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 60, 1493, 6018, 490, 469, 17, 12, 298, 74, 3312, 6018, 490, 469, 8342, 12, 378, 1386, 490, 469, 17, 12, 298, 353, 711, 6018, 355, 971, 84, 91, 17, 12, 298, 2765, 1373, 365, 5174, 19197, 2, 490, 469, 13909, 12, 378, 1386, 490, 469, 17, 12, 298, 67, 30566, 1325, 18393, 2, 355, 298, 12344, 18393, 2, 469, 17, 12, 298, 490, 469, 17, 12, 298, 6958, 6018, 673, 469, 17, 12, 298, 274, 2106, 6018, 2151, 469, 17, 12, 298, 475, 569, 79, 6018, 355, 469, 17, 12, 298, 87, 528, 5908, 6018, 490, 469, 17, 12, 283, 889, 6954, 936, 490, 469, 16029, 12, 378, 1386, 490, 469, 17, 12, 221, 298, 7354, 5002, 7883, 3570, 624, 430, 267, 291, 14, 12808, 8, 4058, 14, 7162, 12, 21772, 1156, 45, 689, 63, 2864, 63, 3817, 9, 267, 291, 423, 4208, 63, 7511, 8, 10896, 45, 689, 63, 2864, 63, 3817, 12, 7393, 63, 4521, 63, 3817, 9, 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,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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 ]
VeNoMouS/Sick-Beard
lib/requests/packages/chardet/sbcsgroupprober.py
2936
3291
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # Shy Shalom - original C code # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .charsetgroupprober import CharSetGroupProber from .sbcharsetprober import SingleByteCharSetProber from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model) from .langgreekmodel import Latin7GreekModel, Win1253GreekModel from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel from .langthaimodel import TIS620ThaiModel from .langhebrewmodel import Win1255HebrewModel from .hebrewprober import HebrewProber class SBCSGroupProber(CharSetGroupProber): def __init__(self): CharSetGroupProber.__init__(self) self._mProbers = [ SingleByteCharSetProber(Win1251CyrillicModel), SingleByteCharSetProber(Koi8rModel), SingleByteCharSetProber(Latin5CyrillicModel), SingleByteCharSetProber(MacCyrillicModel), SingleByteCharSetProber(Ibm866Model), SingleByteCharSetProber(Ibm855Model), SingleByteCharSetProber(Latin7GreekModel), SingleByteCharSetProber(Win1253GreekModel), SingleByteCharSetProber(Latin5BulgarianModel), SingleByteCharSetProber(Win1251BulgarianModel), SingleByteCharSetProber(Latin2HungarianModel), SingleByteCharSetProber(Win1250HungarianModel), SingleByteCharSetProber(TIS620ThaiModel), ] hebrewProber = HebrewProber() logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, False, hebrewProber) visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, hebrewProber) hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) self._mProbers.extend([hebrewProber, logicalHebrewProber, visualHebrewProber]) self.reset()
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 29347, 5960, 17842, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 12521, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 257, 428, 3577, 5244, 279, 676, 446, 3379, 445, 1233, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 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, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 6043, 923, 19903, 492, 6659, 1084, 2448, 8029, 199, 504, 1275, 9264, 6043, 19903, 492, 13050, 21312, 199, 504, 1275, 4159, 17405, 1238, 492, 334, 8886, 21381, 9156, 11909, 1685, 12, 1804, 16142, 24, 82, 1685, 12, 1816, 23864, 21, 9156, 11909, 1685, 12, 10444, 9156, 11909, 1685, 12, 1816, 473, 12648, 13465, 1685, 12, 473, 12648, 12593, 1685, 9, 199, 504, 1275, 4159, 32007, 1238, 492, 23864, 23, 29480, 1685, 12, 13036, 28452, 29480, 1685, 199, 504, 1275, 4159, 25792, 71, 15289, 1238, 492, 23864, 21, 34, 27092, 15289, 1685, 12, 13036, 21381, 34, 27092, 15289, 1685, 199, 504, 1275, 4159, 72, 25364, 1238, 492, 23864, 18, 40, 25364, 1685, 12, 13036, 26572, 40, 25364, 1685, 199, 504, 1275, 4159, 24825, 1238, 492, 377, 1311, 22085, 52, 17945, 1685, 199, 504, 1275, 4159, 14557, 1238, 492, 13036, 20197, 1966, 15850, 1685, 199, 504, 1275, 14557, 19903, 492, 19771, 8029, 421, 199, 533, 26811, 3298, 2448, 8029, 8, 1610, 1084, 2448, 8029, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 1084, 2448, 8029, 855, 826, 721, 277, 9, 267, 291, 423, 77, 8029, 83, 275, 359, 288, 13050, 21312, 8, 8886, 21381, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 43, 16142, 24, 82, 1685, 395, 288, 13050, 21312, 8, 27317, 21, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 3399, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 41, 12648, 13465, 1685, 395, 288, 13050, 21312, 8, 41, 12648, 12593, 1685, 395, 288, 13050, 21312, 8, 27317, 23, 29480, 1685, 395, 288, 13050, 21312, 8, 8886, 28452, 29480, 1685, 395, 288, 13050, 21312, 8, 27317, 21, 34, 27092, 15289, 1685, 395, 288, 13050, 21312, 8, 8886, 21381, 34, 27092, 15289, 1685, 395, 288, 13050, 21312, 8, 27317, 18, 40, 25364, 1685, 395, 288, 13050, 21312, 8, 8886, 26572, 40, 25364, 1685, 395, 288, 13050, 21312, 8, 52, 1311, 22085, 52, 17945, 1685, 395, 267, 1622, 267, 946, 15850, 8029, 275, 19771, 8029, 342, 267, 11461, 1966, 15850, 8029, 275, 13050, 21312, 8, 8886, 20197, 1966, 15850, 1685, 12, 10028, 756, 12, 946, 15850, 8029, 9, 267, 13104, 1966, 15850, 8029, 275, 13050, 21312, 8, 8886, 20197, 1966, 15850, 1685, 12, 715, 12, 9349, 946, 15850, 8029, 9, 267, 946, 15850, 8029, 14, 409, 63, 1238, 63, 19903, 83, 8, 7954, 1966, 15850, 8029, 12, 13104, 1966, 15850, 8029, 9, 267, 291, 423, 77, 8029, 83, 14, 2880, 779, 14557, 8029, 12, 11461, 1966, 15850, 8029, 12, 3044, 13104, 1966, 15850, 8029, 566, 398, 291, 14, 3958, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 29347, 5960, 17842, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 12521, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 257, 428, 3577, 5244, 279, 676, 446, 3379, 445, 1233, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 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, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 6043, 923, 19903, 492, 6659, 1084, 2448, 8029, 199, 504, 1275, 9264, 6043, 19903, 492, 13050, 21312, 199, 504, 1275, 4159, 17405, 1238, 492, 334, 8886, 21381, 9156, 11909, 1685, 12, 1804, 16142, 24, 82, 1685, 12, 1816, 23864, 21, 9156, 11909, 1685, 12, 10444, 9156, 11909, 1685, 12, 1816, 473, 12648, 13465, 1685, 12, 473, 12648, 12593, 1685, 9, 199, 504, 1275, 4159, 32007, 1238, 492, 23864, 23, 29480, 1685, 12, 13036, 28452, 29480, 1685, 199, 504, 1275, 4159, 25792, 71, 15289, 1238, 492, 23864, 21, 34, 27092, 15289, 1685, 12, 13036, 21381, 34, 27092, 15289, 1685, 199, 504, 1275, 4159, 72, 25364, 1238, 492, 23864, 18, 40, 25364, 1685, 12, 13036, 26572, 40, 25364, 1685, 199, 504, 1275, 4159, 24825, 1238, 492, 377, 1311, 22085, 52, 17945, 1685, 199, 504, 1275, 4159, 14557, 1238, 492, 13036, 20197, 1966, 15850, 1685, 199, 504, 1275, 14557, 19903, 492, 19771, 8029, 421, 199, 533, 26811, 3298, 2448, 8029, 8, 1610, 1084, 2448, 8029, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6659, 1084, 2448, 8029, 855, 826, 721, 277, 9, 267, 291, 423, 77, 8029, 83, 275, 359, 288, 13050, 21312, 8, 8886, 21381, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 43, 16142, 24, 82, 1685, 395, 288, 13050, 21312, 8, 27317, 21, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 3399, 9156, 11909, 1685, 395, 288, 13050, 21312, 8, 41, 12648, 13465, 1685, 395, 288, 13050, 21312, 8, 41, 12648, 12593, 1685, 395, 288, 13050, 21312, 8, 27317, 23, 29480, 1685, 395, 288, 13050, 21312, 8, 8886, 28452, 29480, 1685, 395, 288, 13050, 21312, 8, 27317, 21, 34, 27092, 15289, 1685, 395, 288, 13050, 21312, 8, 8886, 21381, 34, 27092, 15289, 1685, 395, 288, 13050, 21312, 8, 27317, 18, 40, 25364, 1685, 395, 288, 13050, 21312, 8, 8886, 26572, 40, 25364, 1685, 395, 288, 13050, 21312, 8, 52, 1311, 22085, 52, 17945, 1685, 395, 267, 1622, 267, 946, 15850, 8029, 275, 19771, 8029, 342, 267, 11461, 1966, 15850, 8029, 275, 13050, 21312, 8, 8886, 20197, 1966, 15850, 1685, 12, 10028, 756, 12, 946, 15850, 8029, 9, 267, 13104, 1966, 15850, 8029, 275, 13050, 21312, 8, 8886, 20197, 1966, 15850, 1685, 12, 715, 12, 9349, 946, 15850, 8029, 9, 267, 946, 15850, 8029, 14, 409, 63, 1238, 63, 19903, 83, 8, 7954, 1966, 15850, 8029, 12, 13104, 1966, 15850, 8029, 9, 267, 291, 423, 77, 8029, 83, 14, 2880, 779, 14557, 8029, 12, 11461, 1966, 15850, 8029, 12, 3044, 13104, 1966, 15850, 8029, 566, 398, 291, 14, 3958, 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, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
OpenMOOC/moocng
moocng/courses/templatetags/usercourses.py
1
1137
# -*- coding: utf-8 -*- # Copyright 2012-2013 UNED # # 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 django import template register = template.Library() @register.inclusion_tag('courses/usercourses.html', takes_context=True) def usercourses(context): user = context['user'] courses = user.courses_as_student.all() return {'courses': courses} @register.inclusion_tag('courses/clone_activity.html', takes_context=False) def clone_activity(course, user): course_student_relation = user.coursestudent_set.get(course=course) return {'course': course, 'course_student_relation': course_student_relation}
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 6029, 13, 6965, 6778, 1149, 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, 259, 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, 199, 504, 1639, 492, 1978, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 11653, 15, 751, 11653, 14, 1360, 297, 6181, 63, 1100, 29, 549, 9, 199, 318, 922, 11653, 8, 1100, 304, 272, 922, 275, 1067, 459, 751, 418, 272, 13588, 275, 922, 14, 11653, 63, 305, 63, 5500, 14, 452, 342, 272, 372, 791, 11653, 356, 13588, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 11653, 15, 6311, 63, 8240, 14, 1360, 297, 6181, 63, 1100, 29, 797, 9, 199, 318, 7289, 63, 8240, 8, 1972, 12, 922, 304, 272, 2518, 63, 5500, 63, 5690, 275, 922, 14, 1972, 5500, 63, 409, 14, 362, 8, 1972, 29, 1972, 9, 272, 372, 791, 1972, 356, 2518, 12, 288, 283, 1972, 63, 5500, 63, 5690, 356, 2518, 63, 5500, 63, 5690, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6029, 13, 6965, 6778, 1149, 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, 259, 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, 199, 504, 1639, 492, 1978, 199, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 11653, 15, 751, 11653, 14, 1360, 297, 6181, 63, 1100, 29, 549, 9, 199, 318, 922, 11653, 8, 1100, 304, 272, 922, 275, 1067, 459, 751, 418, 272, 13588, 275, 922, 14, 11653, 63, 305, 63, 5500, 14, 452, 342, 272, 372, 791, 11653, 356, 13588, 93, 421, 199, 32, 2683, 14, 24265, 63, 1450, 360, 11653, 15, 6311, 63, 8240, 14, 1360, 297, 6181, 63, 1100, 29, 797, 9, 199, 318, 7289, 63, 8240, 8, 1972, 12, 922, 304, 272, 2518, 63, 5500, 63, 5690, 275, 922, 14, 1972, 5500, 63, 409, 14, 362, 8, 1972, 29, 1972, 9, 272, 372, 791, 1972, 356, 2518, 12, 288, 283, 1972, 63, 5500, 63, 5690, 356, 2518, 63, 5500, 63, 5690, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
chloerh/avocado-vt
virttest/step_editor.py
4
50745
#!/usr/bin/python """ Step file creator/editor. :copyright: Red Hat Inc 2009 :author: mgoldish@redhat.com (Michael Goldish) """ import os import glob import shutil import sys import logging import pygtk import gtk from virttest import ppm_utils pygtk.require('2.0') # General utilities def corner_and_size_clipped(startpoint, endpoint, limits): c0 = startpoint[:] c1 = endpoint[:] if c0[0] < 0: c0[0] = 0 if c0[1] < 0: c0[1] = 0 if c1[0] < 0: c1[0] = 0 if c1[1] < 0: c1[1] = 0 if c0[0] > limits[0] - 1: c0[0] = limits[0] - 1 if c0[1] > limits[1] - 1: c0[1] = limits[1] - 1 if c1[0] > limits[0] - 1: c1[0] = limits[0] - 1 if c1[1] > limits[1] - 1: c1[1] = limits[1] - 1 return ([min(c0[0], c1[0]), min(c0[1], c1[1])], [abs(c1[0] - c0[0]) + 1, abs(c1[1] - c0[1]) + 1]) def key_event_to_qemu_string(event): keymap = gtk.gdk.keymap_get_default() keyvals = keymap.get_entries_for_keycode(event.hardware_keycode) keyval = keyvals[0][0] keyname = gtk.gdk.keyval_name(keyval) keymap = {"Return": "ret", "Tab": "tab", "space": "spc", "Left": "left", "Right": "right", "Up": "up", "Down": "down", "F1": "f1", "F2": "f2", "F3": "f3", "F4": "f4", "F5": "f5", "F6": "f6", "F7": "f7", "F8": "f8", "F9": "f9", "F10": "f10", "F11": "f11", "F12": "f12", "Escape": "esc", "minus": "minus", "equal": "equal", "BackSpace": "backspace", "comma": "comma", "period": "dot", "slash": "slash", "Insert": "insert", "Delete": "delete", "Home": "home", "End": "end", "Page_Up": "pgup", "Page_Down": "pgdn", "Menu": "menu", "semicolon": "0x27", "backslash": "0x2b", "apostrophe": "0x28", "grave": "0x29", "less": "0x2b", "bracketleft": "0x1a", "bracketright": "0x1b", "Super_L": "0xdc", "Super_R": "0xdb", } if ord('a') <= keyval <= ord('z') or ord('0') <= keyval <= ord('9'): sr = keyname elif keyname in list(keymap.keys()): sr = keymap[keyname] else: return "" if event.state & gtk.gdk.CONTROL_MASK: sr = "ctrl-" + str if event.state & gtk.gdk.MOD1_MASK: sr = "alt-" + str if event.state & gtk.gdk.SHIFT_MASK: sr = "shift-" + str return sr class StepMakerWindow(object): def __init__(self): # Window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Step Maker Window") self.window.connect("delete-event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_default_size(600, 800) # Main box (inside a frame which is inside a VBox) self.menu_vbox = gtk.VBox() self.window.add(self.menu_vbox) self.menu_vbox.show() frame = gtk.Frame() frame.set_border_width(10) frame.set_shadow_type(gtk.SHADOW_NONE) self.menu_vbox.pack_end(frame) frame.show() self.main_vbox = gtk.VBox(spacing=10) frame.add(self.main_vbox) self.main_vbox.show() # EventBox self.scrolledwindow = gtk.ScrolledWindow() self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolledwindow.set_shadow_type(gtk.SHADOW_NONE) self.main_vbox.pack_start(self.scrolledwindow) self.scrolledwindow.show() table = gtk.Table(1, 1) self.scrolledwindow.add_with_viewport(table) table.show() table.realize() self.event_box = gtk.EventBox() table.attach(self.event_box, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND) self.event_box.show() self.event_box.realize() # Image self.image = gtk.Image() self.event_box.add(self.image) self.image.show() # Data VBox self.data_vbox = gtk.VBox(spacing=10) self.main_vbox.pack_start(self.data_vbox, expand=False) self.data_vbox.show() # User VBox self.user_vbox = gtk.VBox(spacing=10) self.main_vbox.pack_start(self.user_vbox, expand=False) self.user_vbox.show() # Screendump ID HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() label = gtk.Label("Screendump ID:") box.pack_start(label, False) label.show() self.entry_screendump = gtk.Entry() self.entry_screendump.set_editable(False) box.pack_start(self.entry_screendump) self.entry_screendump.show() label = gtk.Label("Time:") box.pack_start(label, False) label.show() self.entry_time = gtk.Entry() self.entry_time.set_editable(False) self.entry_time.set_width_chars(10) box.pack_start(self.entry_time, False) self.entry_time.show() # Comment HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() label = gtk.Label("Comment:") box.pack_start(label, False) label.show() self.entry_comment = gtk.Entry() box.pack_start(self.entry_comment) self.entry_comment.show() # Sleep HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() self.check_sleep = gtk.CheckButton("Sleep:") self.check_sleep.connect("toggled", self.event_check_sleep_toggled) box.pack_start(self.check_sleep, False) self.check_sleep.show() self.spin_sleep = gtk.SpinButton(gtk.Adjustment(0, 0, 50000, 1, 10, 0), climb_rate=0.0) box.pack_start(self.spin_sleep, False) self.spin_sleep.show() # Barrier HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() self.check_barrier = gtk.CheckButton("Barrier:") self.check_barrier.connect("toggled", self.event_check_barrier_toggled) box.pack_start(self.check_barrier, False) self.check_barrier.show() vbox = gtk.VBox() box.pack_start(vbox) vbox.show() self.label_barrier_region = gtk.Label("Region:") self.label_barrier_region.set_alignment(0, 0.5) vbox.pack_start(self.label_barrier_region) self.label_barrier_region.show() self.label_barrier_md5sum = gtk.Label("MD5:") self.label_barrier_md5sum.set_alignment(0, 0.5) vbox.pack_start(self.label_barrier_md5sum) self.label_barrier_md5sum.show() self.label_barrier_timeout = gtk.Label("Timeout:") box.pack_start(self.label_barrier_timeout, False) self.label_barrier_timeout.show() self.spin_barrier_timeout = gtk.SpinButton(gtk.Adjustment(0, 0, 50000, 1, 10, 0), climb_rate=0.0) box.pack_start(self.spin_barrier_timeout, False) self.spin_barrier_timeout.show() self.check_barrier_optional = gtk.CheckButton("Optional") box.pack_start(self.check_barrier_optional, False) self.check_barrier_optional.show() # Keystrokes HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() label = gtk.Label("Keystrokes:") box.pack_start(label, False) label.show() frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_IN) box.pack_start(frame) frame.show() self.text_buffer = gtk.TextBuffer() self.entry_keys = gtk.TextView(self.text_buffer) self.entry_keys.set_wrap_mode(gtk.WRAP_WORD) self.entry_keys.connect("key-press-event", self.event_key_press) frame.add(self.entry_keys) self.entry_keys.show() self.check_manual = gtk.CheckButton("Manual") self.check_manual.connect("toggled", self.event_manual_toggled) box.pack_start(self.check_manual, False) self.check_manual.show() button = gtk.Button("Clear") button.connect("clicked", self.event_clear_clicked) box.pack_start(button, False) button.show() # Mouse click HBox box = gtk.HBox(spacing=10) self.data_vbox.pack_start(box) box.show() label = gtk.Label("Mouse action:") box.pack_start(label, False) label.show() self.button_capture = gtk.Button("Capture") box.pack_start(self.button_capture, False) self.button_capture.show() self.check_mousemove = gtk.CheckButton("Move: ...") box.pack_start(self.check_mousemove, False) self.check_mousemove.show() self.check_mouseclick = gtk.CheckButton("Click: ...") box.pack_start(self.check_mouseclick, False) self.check_mouseclick.show() self.spin_sensitivity = gtk.SpinButton(gtk.Adjustment(1, 1, 100, 1, 10, 0), climb_rate=0.0) box.pack_end(self.spin_sensitivity, False) self.spin_sensitivity.show() label = gtk.Label("Sensitivity:") box.pack_end(label, False) label.show() self.spin_latency = gtk.SpinButton( gtk.Adjustment(10, 1, 500, 1, 10, 0), climb_rate=0.0) box.pack_end(self.spin_latency, False) self.spin_latency.show() label = gtk.Label("Latency:") box.pack_end(label, False) label.show() self.handler_event_box_press = None self.handler_event_box_release = None self.handler_event_box_scroll = None self.handler_event_box_motion = None self.handler_event_box_expose = None self.window.realize() self.window.show() self.clear_state() # Utilities def message(self, text, title): dlg = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, title) dlg.set_title(title) dlg.format_secondary_text(text) dlg.run() dlg.destroy() def question_yes_no(self, text, title): dlg = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, title) dlg.set_title(title) dlg.format_secondary_text(text) response = dlg.run() dlg.destroy() if response == gtk.RESPONSE_YES: return True return False def inputdialog(self, text, title, default_response=""): # Define a little helper function def inputdialog_entry_activated(entry): dlg.response(gtk.RESPONSE_OK) # Create the dialog dlg = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, title) dlg.set_title(title) dlg.format_secondary_text(text) # Create an entry widget entry = gtk.Entry() entry.set_text(default_response) entry.connect("activate", inputdialog_entry_activated) dlg.vbox.pack_start(entry) entry.show() # Run the dialog response = dlg.run() dlg.destroy() if response == gtk.RESPONSE_OK: return entry.get_text() return None def filedialog(self, title=None, default_filename=None): chooser = gtk.FileChooserDialog(title=title, parent=self.window, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser.resize(700, 500) if default_filename: chooser.set_filename(os.path.abspath(default_filename)) filename = None response = chooser.run() if response == gtk.RESPONSE_OK: filename = chooser.get_filename() chooser.destroy() return filename def redirect_event_box_input(self, press=None, release=None, scroll=None, motion=None, expose=None): if self.handler_event_box_press is not None: self.event_box.disconnect(self.handler_event_box_press) if self.handler_event_box_release is not None: self.event_box.disconnect(self.handler_event_box_release) if self.handler_event_box_scroll is not None: self.event_box.disconnect(self.handler_event_box_scroll) if self.handler_event_box_motion is not None: self.event_box.disconnect(self.handler_event_box_motion) if self.handler_event_box_expose is not None: self.event_box.disconnect(self.handler_event_box_expose) self.handler_event_box_press = None self.handler_event_box_release = None self.handler_event_box_scroll = None self.handler_event_box_motion = None self.handler_event_box_expose = None if press is not None: self.handler_event_box_press = ( self.event_box.connect("button-press-event", press)) if release is not None: self.handler_event_box_release = ( self.event_box.connect("button-release-event", release)) if scroll is not None: self.handler_event_box_scroll = ( self.event_box.connect("scroll-event", scroll)) if motion is not None: self.handler_event_box_motion = ( self.event_box.connect("motion-notify-event", motion)) if expose is not None: self.handler_event_box_expose = ( self.event_box.connect_after("expose-event", expose)) def get_keys(self): return self.text_buffer.get_text( self.text_buffer.get_start_iter(), self.text_buffer.get_end_iter()) def add_key(self, key): text = self.get_keys() if len(text) > 0 and text[-1] != ' ': text += " " text += key self.text_buffer.set_text(text) def clear_keys(self): self.text_buffer.set_text("") def update_barrier_info(self): if self.barrier_selected: self.label_barrier_region.set_text("Selected region: Corner: " + str(tuple(self.barrier_corner)) + " Size: " + str(tuple(self.barrier_size))) else: self.label_barrier_region.set_text("No region selected.") self.label_barrier_md5sum.set_text("MD5: " + self.barrier_md5sum) def update_mouse_click_info(self): if self.mouse_click_captured: self.check_mousemove.set_label("Move: " + str(tuple(self.mouse_click_coords))) self.check_mouseclick.set_label("Click: button %d" % self.mouse_click_button) else: self.check_mousemove.set_label("Move: ...") self.check_mouseclick.set_label("Click: ...") def clear_state(self, clear_screendump=True): # Recording time self.entry_time.set_text("unknown") if clear_screendump: # Screendump self.clear_image() # Screendump ID self.entry_screendump.set_text("") # Comment self.entry_comment.set_text("") # Sleep self.check_sleep.set_active(True) self.check_sleep.set_active(False) self.spin_sleep.set_value(10) # Barrier self.clear_barrier_state() # Keystrokes self.check_manual.set_active(False) self.clear_keys() # Mouse actions self.check_mousemove.set_sensitive(False) self.check_mouseclick.set_sensitive(False) self.check_mousemove.set_active(False) self.check_mouseclick.set_active(False) self.mouse_click_captured = False self.mouse_click_coords = [0, 0] self.mouse_click_button = 0 self.update_mouse_click_info() def clear_barrier_state(self): self.check_barrier.set_active(True) self.check_barrier.set_active(False) self.check_barrier_optional.set_active(False) self.spin_barrier_timeout.set_value(10) self.barrier_selection_started = False self.barrier_selected = False self.barrier_corner0 = [0, 0] self.barrier_corner1 = [0, 0] self.barrier_corner = [0, 0] self.barrier_size = [0, 0] self.barrier_md5sum = "" self.update_barrier_info() def set_image(self, w, h, data): (self.image_width, self.image_height, self.image_data) = (w, h, data) self.image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_data( data, gtk.gdk.COLORSPACE_RGB, False, 8, w, h, w * 3)) hscrollbar = self.scrolledwindow.get_hscrollbar() hscrollbar.set_range(0, w) vscrollbar = self.scrolledwindow.get_vscrollbar() vscrollbar.set_range(0, h) def set_image_from_file(self, filename): if not ppm_utils.image_verify_ppm_file(filename): logging.warning("set_image_from_file: Warning: received invalid" "screendump file") return self.clear_image() (w, h, data) = ppm_utils.image_read_from_ppm_file(filename) self.set_image(w, h, data) def clear_image(self): self.image.clear() self.image_width = 0 self.image_height = 0 self.image_data = b"" def update_screendump_id(self, data_dir): if not self.image_data: return # Find a proper ID for the screendump scrdump_md5sum = ppm_utils.image_md5sum(self.image_width, self.image_height, self.image_data) scrdump_id = ppm_utils.find_id_for_screendump(scrdump_md5sum, data_dir) if not scrdump_id: # Not found; generate one scrdump_id = ppm_utils.generate_id_for_screendump(scrdump_md5sum, data_dir) self.entry_screendump.set_text(scrdump_id) def get_step_lines(self, data_dir=None): if self.check_barrier.get_active() and not self.barrier_selected: self.message("No barrier region selected.", "Error") return sr = "step" # Add step recording time if self.entry_time.get_text(): sr += " " + self.entry_time.get_text() sr += "\n" # Add screendump line if self.image_data: sr += "screendump %s\n" % self.entry_screendump.get_text() # Add comment if self.entry_comment.get_text(): sr += "# %s\n" % self.entry_comment.get_text() # Add sleep line if self.check_sleep.get_active(): sr += "sleep %d\n" % self.spin_sleep.get_value() # Add barrier_2 line if self.check_barrier.get_active(): sr += "barrier_2 %d %d %d %d %s %d" % ( self.barrier_size[0], self.barrier_size[1], self.barrier_corner[0], self.barrier_corner[1], self.barrier_md5sum, self.spin_barrier_timeout.get_value()) if self.check_barrier_optional.get_active(): sr += " optional" sr += "\n" # Add "Sending keys" comment keys_to_send = self.get_keys().split() if keys_to_send: sr += "# Sending keys: %s\n" % self.get_keys() # Add key and var lines for key in keys_to_send: if key.startswith("$"): varname = key[1:] sr += "var %s\n" % varname else: sr += "key %s\n" % key # Add mousemove line if self.check_mousemove.get_active(): sr += "mousemove %d %d\n" % (self.mouse_click_coords[0], self.mouse_click_coords[1]) # Add mouseclick line if self.check_mouseclick.get_active(): mapping = {1: 1, 2: 2, 3: 4} sr += "mouseclick %d\n" % mapping[self.mouse_click_button] # Write screendump and cropped screendump image files if data_dir and self.image_data: # Create the data dir if it doesn't exist if not os.path.exists(data_dir): os.makedirs(data_dir) # Get the full screendump filename scrdump_filename = os.path.join(data_dir, self.entry_screendump.get_text()) # Write screendump file if it doesn't exist if not os.path.exists(scrdump_filename): try: ppm_utils.image_write_to_ppm_file(scrdump_filename, self.image_width, self.image_height, self.image_data) except IOError: self.message("Could not write screendump file.", "Error") return sr def set_state_from_step_lines(self, sr, data_dir, warn=True): self.clear_state() for line in sr.splitlines(): words = line.split() if not words: continue if (line.startswith("#") and not self.entry_comment.get_text() and not line.startswith("# Sending keys:") and not line.startswith("# ----")): self.entry_comment.set_text(line.strip("#").strip()) elif words[0] == "step": if len(words) >= 2: self.entry_time.set_text(words[1]) elif words[0] == "screendump": self.entry_screendump.set_text(words[1]) self.set_image_from_file(os.path.join(data_dir, words[1])) elif words[0] == "sleep": self.spin_sleep.set_value(int(words[1])) self.check_sleep.set_active(True) elif words[0] == "key": self.add_key(words[1]) elif words[0] == "var": self.add_key("$%s" % words[1]) elif words[0] == "mousemove": self.mouse_click_captured = True self.mouse_click_coords = [int(words[1]), int(words[2])] self.update_mouse_click_info() elif words[0] == "mouseclick": self.mouse_click_captured = True self.mouse_click_button = int(words[1]) self.update_mouse_click_info() elif words[0] == "barrier_2": # Get region corner and size from step lines self.barrier_corner = [int(words[3]), int(words[4])] self.barrier_size = [int(words[1]), int(words[2])] # Get corner0 and corner1 from step lines self.barrier_corner0 = self.barrier_corner self.barrier_corner1 = [self.barrier_corner[0] + self.barrier_size[0] - 1, self.barrier_corner[1] + self.barrier_size[1] - 1] # Get the md5sum self.barrier_md5sum = words[5] # Pretend the user selected the region with the mouse self.barrier_selection_started = True self.barrier_selected = True # Update label widgets according to region information self.update_barrier_info() # Check the barrier checkbutton self.check_barrier.set_active(True) # Set timeout value self.spin_barrier_timeout.set_value(int(words[6])) # Set 'optional' checkbutton state self.check_barrier_optional.set_active(words[-1] == "optional") # Update the image widget self.event_box.queue_draw() if warn: # See if the computed md5sum matches the one recorded in # the file computed_md5sum = ppm_utils.get_region_md5sum( self.image_width, self.image_height, self.image_data, self.barrier_corner[0], self.barrier_corner[1], self.barrier_size[0], self.barrier_size[1]) if computed_md5sum != self.barrier_md5sum: self.message("Computed MD5 sum (%s) differs from MD5" " sum recorded in steps file (%s)" % (computed_md5sum, self.barrier_md5sum), "Warning") # Events def delete_event(self, widget, event): pass def destroy(self, widget): gtk.main_quit() def event_check_barrier_toggled(self, widget): if self.check_barrier.get_active(): self.redirect_event_box_input( self.event_button_press, self.event_button_release, None, None, self.event_expose) self.event_box.queue_draw() self.event_box.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSSHAIR)) self.label_barrier_region.set_sensitive(True) self.label_barrier_md5sum.set_sensitive(True) self.label_barrier_timeout.set_sensitive(True) self.spin_barrier_timeout.set_sensitive(True) self.check_barrier_optional.set_sensitive(True) else: self.redirect_event_box_input() self.event_box.queue_draw() self.event_box.window.set_cursor(None) self.label_barrier_region.set_sensitive(False) self.label_barrier_md5sum.set_sensitive(False) self.label_barrier_timeout.set_sensitive(False) self.spin_barrier_timeout.set_sensitive(False) self.check_barrier_optional.set_sensitive(False) def event_check_sleep_toggled(self, widget): if self.check_sleep.get_active(): self.spin_sleep.set_sensitive(True) else: self.spin_sleep.set_sensitive(False) def event_manual_toggled(self, widget): self.entry_keys.grab_focus() def event_clear_clicked(self, widget): self.clear_keys() self.entry_keys.grab_focus() def event_expose(self, widget, event): if not self.barrier_selection_started: return (corner, size) = corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1, self.event_box.size_request()) gc = self.event_box.window.new_gc(line_style=gtk.gdk.LINE_DOUBLE_DASH, line_width=1) gc.set_foreground(gc.get_colormap().alloc_color("red")) gc.set_background(gc.get_colormap().alloc_color("dark red")) gc.set_dashes(0, (4, 4)) self.event_box.window.draw_rectangle( gc, False, corner[0], corner[1], size[0] - 1, size[1] - 1) def event_drag_motion(self, widget, event): old_corner1 = self.barrier_corner1 self.barrier_corner1 = [int(event.x), int(event.y)] (corner, size) = corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1, self.event_box.size_request()) (old_corner, old_size) = corner_and_size_clipped(self.barrier_corner0, old_corner1, self.event_box.size_request()) corner0 = [ min(corner[0], old_corner[0]), min(corner[1], old_corner[1])] corner1 = [max(corner[0] + size[0], old_corner[0] + old_size[0]), max(corner[1] + size[1], old_corner[1] + old_size[1])] size = [corner1[0] - corner0[0] + 1, corner1[1] - corner0[1] + 1] self.event_box.queue_draw_area( corner0[0], corner0[1], size[0], size[1]) def event_button_press(self, widget, event): (corner, size) = corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1, self.event_box.size_request()) self.event_box.queue_draw_area(corner[0], corner[1], size[0], size[1]) self.barrier_corner0 = [int(event.x), int(event.y)] self.barrier_corner1 = [int(event.x), int(event.y)] self.redirect_event_box_input( self.event_button_press, self.event_button_release, None, self.event_drag_motion, self.event_expose) self.barrier_selection_started = True def event_button_release(self, widget, event): self.redirect_event_box_input( self.event_button_press, self.event_button_release, None, None, self.event_expose) (self.barrier_corner, self.barrier_size) = \ corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1, self.event_box.size_request()) self.barrier_md5sum = ppm_utils.get_region_md5sum( self.image_width, self.image_height, self.image_data, self.barrier_corner[0], self.barrier_corner[1], self.barrier_size[0], self.barrier_size[1]) self.barrier_selected = True self.update_barrier_info() def event_key_press(self, widget, event): if self.check_manual.get_active(): return False sr = key_event_to_qemu_string(event) self.add_key(sr) return True class StepEditor(StepMakerWindow): ui = '''<ui> <menubar name="MenuBar"> <menu action="File"> <menuitem action="Open"/> <separator/> <menuitem action="Quit"/> </menu> <menu action="Edit"> <menuitem action="CopyStep"/> <menuitem action="DeleteStep"/> </menu> <menu action="Insert"> <menuitem action="InsertNewBefore"/> <menuitem action="InsertNewAfter"/> <separator/> <menuitem action="InsertStepsBefore"/> <menuitem action="InsertStepsAfter"/> </menu> <menu action="Tools"> <menuitem action="CleanUp"/> </menu> </menubar> </ui>''' # Constructor def __init__(self, filename=None): StepMakerWindow.__init__(self) self.steps_filename = None self.steps = [] # Create a UIManager instance uimanager = gtk.UIManager() # Add the accelerator group to the toplevel window accelgroup = uimanager.get_accel_group() self.window.add_accel_group(accelgroup) # Create an ActionGroup actiongroup = gtk.ActionGroup('StepEditor') # Create actions actiongroup.add_actions([ ('Quit', gtk.STOCK_QUIT, '_Quit', None, 'Quit the Program', self.quit), ('Open', gtk.STOCK_OPEN, '_Open', None, 'Open steps file', self.open_steps_file), ('CopyStep', gtk.STOCK_COPY, '_Copy current step...', "", 'Copy current step to user specified position', self.copy_step), ('DeleteStep', gtk.STOCK_DELETE, '_Delete current step', "", 'Delete current step', self.event_remove_clicked), ('InsertNewBefore', gtk.STOCK_ADD, '_New step before current', "", 'Insert new step before current step', self.insert_before), ('InsertNewAfter', gtk.STOCK_ADD, 'N_ew step after current', "", 'Insert new step after current step', self.insert_after), ('InsertStepsBefore', gtk.STOCK_ADD, '_Steps before current...', "", 'Insert steps (from file) before current step', self.insert_steps_before), ('InsertStepsAfter', gtk.STOCK_ADD, 'Steps _after current...', "", 'Insert steps (from file) after current step', self.insert_steps_after), ('CleanUp', gtk.STOCK_DELETE, '_Clean up data directory', "", 'Move unused PPM files to a backup directory', self.cleanup), ('File', None, '_File'), ('Edit', None, '_Edit'), ('Insert', None, '_Insert'), ('Tools', None, '_Tools') ]) def create_shortcut(name, callback, keyname): # Create an action action = gtk.Action(name, None, None, None) # Connect a callback to the action action.connect("activate", callback) actiongroup.add_action_with_accel(action, keyname) # Have the action use accelgroup action.set_accel_group(accelgroup) # Connect the accelerator to the action action.connect_accelerator() create_shortcut("Next", self.event_next_clicked, "Page_Down") create_shortcut("Previous", self.event_prev_clicked, "Page_Up") # Add the actiongroup to the uimanager uimanager.insert_action_group(actiongroup, 0) # Add a UI description uimanager.add_ui_from_string(self.ui) # Create a MenuBar menubar = uimanager.get_widget('/MenuBar') self.menu_vbox.pack_start(menubar, False) # Remember the Edit menu bar for future reference self.menu_edit = uimanager.get_widget('/MenuBar/Edit') self.menu_edit.set_sensitive(False) # Remember the Insert menu bar for future reference self.menu_insert = uimanager.get_widget('/MenuBar/Insert') self.menu_insert.set_sensitive(False) # Remember the Tools menu bar for future reference self.menu_tools = uimanager.get_widget('/MenuBar/Tools') self.menu_tools.set_sensitive(False) # Next/Previous HBox hbox = gtk.HBox(spacing=10) self.user_vbox.pack_start(hbox) hbox.show() self.button_first = gtk.Button(stock=gtk.STOCK_GOTO_FIRST) self.button_first.connect("clicked", self.event_first_clicked) hbox.pack_start(self.button_first) self.button_first.show() #self.button_prev = gtk.Button("<< Previous") self.button_prev = gtk.Button(stock=gtk.STOCK_GO_BACK) self.button_prev.connect("clicked", self.event_prev_clicked) hbox.pack_start(self.button_prev) self.button_prev.show() self.label_step = gtk.Label("Step:") hbox.pack_start(self.label_step, False) self.label_step.show() self.entry_step_num = gtk.Entry() self.entry_step_num.connect( "activate", self.event_entry_step_activated) self.entry_step_num.set_width_chars(3) hbox.pack_start(self.entry_step_num, False) self.entry_step_num.show() #self.button_next = gtk.Button("Next >>") self.button_next = gtk.Button(stock=gtk.STOCK_GO_FORWARD) self.button_next.connect("clicked", self.event_next_clicked) hbox.pack_start(self.button_next) self.button_next.show() self.button_last = gtk.Button(stock=gtk.STOCK_GOTO_LAST) self.button_last.connect("clicked", self.event_last_clicked) hbox.pack_start(self.button_last) self.button_last.show() # Save HBox hbox = gtk.HBox(spacing=10) self.user_vbox.pack_start(hbox) hbox.show() self.button_save = gtk.Button("_Save current step") self.button_save.connect("clicked", self.event_save_clicked) hbox.pack_start(self.button_save) self.button_save.show() self.button_remove = gtk.Button("_Delete current step") self.button_remove.connect("clicked", self.event_remove_clicked) hbox.pack_start(self.button_remove) self.button_remove.show() self.button_replace = gtk.Button("_Replace screendump") self.button_replace.connect("clicked", self.event_replace_clicked) hbox.pack_start(self.button_replace) self.button_replace.show() # Disable unused widgets self.button_capture.set_sensitive(False) self.spin_latency.set_sensitive(False) self.spin_sensitivity.set_sensitive(False) # Disable main vbox because no steps file is loaded self.main_vbox.set_sensitive(False) # Set title self.window.set_title("Step Editor") # Events def delete_event(self, widget, event): # Make sure the step is saved (if the user wants it to be) self.verify_save() def event_first_clicked(self, widget): if not self.steps: return # Make sure the step is saved (if the user wants it to be) self.verify_save() # Go to first step self.set_step(0) def event_last_clicked(self, widget): if not self.steps: return # Make sure the step is saved (if the user wants it to be) self.verify_save() # Go to last step self.set_step(len(self.steps) - 1) def event_prev_clicked(self, widget): if not self.steps: return # Make sure the step is saved (if the user wants it to be) self.verify_save() # Go to previous step index = self.current_step_index - 1 if self.steps: index = index % len(self.steps) self.set_step(index) def event_next_clicked(self, widget): if not self.steps: return # Make sure the step is saved (if the user wants it to be) self.verify_save() # Go to next step index = self.current_step_index + 1 if self.steps: index = index % len(self.steps) self.set_step(index) def event_entry_step_activated(self, widget): if not self.steps: return step_index = self.entry_step_num.get_text() if not step_index.isdigit(): return step_index = int(step_index) - 1 if step_index == self.current_step_index: return self.verify_save() self.set_step(step_index) def event_save_clicked(self, widget): if not self.steps: return self.save_step() def event_remove_clicked(self, widget): if not self.steps: return if not self.question_yes_no("This will modify the steps file." " Are you sure?", "Remove step?"): return # Remove step del self.steps[self.current_step_index] # Write changes to file self.write_steps_file(self.steps_filename) # Move to previous step self.set_step(self.current_step_index) def event_replace_clicked(self, widget): if not self.steps: return # Let the user choose a screendump file current_filename = os.path.join(self.steps_data_dir, self.entry_screendump.get_text()) filename = self.filedialog("Choose PPM image file", default_filename=current_filename) if not filename: return if not ppm_utils.image_verify_ppm_file(filename): self.message("Not a valid PPM image file.", "Error") return self.clear_image() self.clear_barrier_state() self.set_image_from_file(filename) self.update_screendump_id(self.steps_data_dir) # Menu actions def open_steps_file(self, action): # Make sure the step is saved (if the user wants it to be) self.verify_save() # Let the user choose a steps file current_filename = self.steps_filename filename = self.filedialog("Open steps file", default_filename=current_filename) if not filename: return self.set_steps_file(filename) def quit(self, action): # Make sure the step is saved (if the user wants it to be) self.verify_save() # Quit gtk.main_quit() def copy_step(self, action): if not self.steps: return self.verify_save() self.set_step(self.current_step_index) # Get the desired position step_index = self.inputdialog("Copy step to position:", "Copy step", str(self.current_step_index + 2)) if not step_index: return step_index = int(step_index) - 1 # Get the lines of the current step step = self.steps[self.current_step_index] # Insert new step at position step_index self.steps.insert(step_index, step) # Go to new step self.set_step(step_index) # Write changes to disk self.write_steps_file(self.steps_filename) def insert_before(self, action): if not self.steps_filename: return if not self.question_yes_no("This will modify the steps file." " Are you sure?", "Insert new step?"): return self.verify_save() step_index = self.current_step_index # Get the lines of a blank step self.clear_state() step = self.get_step_lines() # Insert new step at position step_index self.steps.insert(step_index, step) # Go to new step self.set_step(step_index) # Write changes to disk self.write_steps_file(self.steps_filename) def insert_after(self, action): if not self.steps_filename: return if not self.question_yes_no("This will modify the steps file." " Are you sure?", "Insert new step?"): return self.verify_save() step_index = self.current_step_index + 1 # Get the lines of a blank step self.clear_state() step = self.get_step_lines() # Insert new step at position step_index self.steps.insert(step_index, step) # Go to new step self.set_step(step_index) # Write changes to disk self.write_steps_file(self.steps_filename) def insert_steps(self, filename, index): # Read the steps file (steps, _) = self.read_steps_file(filename) data_dir = ppm_utils.get_data_dir(filename) for step in steps: self.set_state_from_step_lines(step, data_dir, warn=False) step = self.get_step_lines(self.steps_data_dir) # Insert steps into self.steps self.steps[index:index] = steps # Write changes to disk self.write_steps_file(self.steps_filename) def insert_steps_before(self, action): if not self.steps_filename: return # Let the user choose a steps file current_filename = self.steps_filename filename = self.filedialog("Choose steps file", default_filename=current_filename) if not filename: return self.verify_save() step_index = self.current_step_index # Insert steps at position step_index self.insert_steps(filename, step_index) # Go to new steps self.set_step(step_index) def insert_steps_after(self, action): if not self.steps_filename: return # Let the user choose a steps file current_filename = self.steps_filename filename = self.filedialog("Choose steps file", default_filename=current_filename) if not filename: return self.verify_save() step_index = self.current_step_index + 1 # Insert new steps at position step_index self.insert_steps(filename, step_index) # Go to new steps self.set_step(step_index) def cleanup(self, action): if not self.steps_filename: return if not self.question_yes_no("All unused PPM files will be moved to a" " backup directory. Are you sure?", "Clean up data directory?"): return # Remember the current step index current_step_index = self.current_step_index # Get the backup dir backup_dir = os.path.join(self.steps_data_dir, "backup") # Create it if it doesn't exist if not os.path.exists(backup_dir): os.makedirs(backup_dir) # Move all files to the backup dir for filename in glob.glob(os.path.join(self.steps_data_dir, "*.[Pp][Pp][Mm]")): shutil.move(filename, backup_dir) # Get the used files back for step in self.steps: self.set_state_from_step_lines(step, backup_dir, warn=False) self.get_step_lines(self.steps_data_dir) # Remove the used files from the backup dir used_files = os.listdir(self.steps_data_dir) for filename in os.listdir(backup_dir): if filename in used_files: os.unlink(os.path.join(backup_dir, filename)) # Restore step index self.set_step(current_step_index) # Inform the user self.message("All unused PPM files may be found at %s." % os.path.abspath(backup_dir), "Clean up data directory") # Methods def read_steps_file(self, filename): steps = [] header = "" fileobj = open(filename, "r") for line in fileobj.readlines(): words = line.split() if not words: continue if line.startswith("# ----"): continue if words[0] == "step": steps.append("") if steps: steps[-1] += line else: header += line fileobj.close() return (steps, header) def set_steps_file(self, filename): try: (self.steps, self.header) = self.read_steps_file(filename) except (TypeError, IOError): self.message("Cannot read file %s." % filename, "Error") return self.steps_filename = filename self.steps_data_dir = ppm_utils.get_data_dir(filename) # Go to step 0 self.set_step(0) def set_step(self, index): # Limit index to legal boundaries if index < 0: index = 0 if index > len(self.steps) - 1: index = len(self.steps) - 1 # Enable the menus self.menu_edit.set_sensitive(True) self.menu_insert.set_sensitive(True) self.menu_tools.set_sensitive(True) # If no steps exist... if self.steps == []: self.current_step_index = index self.current_step = None # Set window title self.window.set_title("Step Editor -- %s" % os.path.basename(self.steps_filename)) # Set step entry widget text self.entry_step_num.set_text("") # Clear the state of all widgets self.clear_state() # Disable the main vbox self.main_vbox.set_sensitive(False) return self.current_step_index = index self.current_step = self.steps[index] # Set window title self.window.set_title("Step Editor -- %s -- step %d" % (os.path.basename(self.steps_filename), index + 1)) # Set step entry widget text self.entry_step_num.set_text(str(self.current_step_index + 1)) # Load the state from the step lines self.set_state_from_step_lines(self.current_step, self.steps_data_dir) # Enable the main vbox self.main_vbox.set_sensitive(True) # Make sure the step lines in self.current_step are identical to the # output of self.get_step_lines self.current_step = self.get_step_lines() def verify_save(self): if not self.steps: return # See if the user changed anything if self.get_step_lines() != self.current_step: if self.question_yes_no("Step contents have been modified." " Save step?", "Save changes?"): self.save_step() def save_step(self): lines = self.get_step_lines(self.steps_data_dir) if lines is not None: self.steps[self.current_step_index] = lines self.current_step = lines self.write_steps_file(self.steps_filename) def write_steps_file(self, filename): fileobj = open(filename, "w") fileobj.write(self.header) for step in self.steps: fileobj.write("# " + "-" * 32 + "\n") fileobj.write(step) fileobj.close() if __name__ == "__main__": se = StepEditor() if len(sys.argv) > 1: se.set_steps_file(sys.argv[1]) gtk.main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 199, 7801, 570, 14875, 15, 7515, 14, 199, 199, 26, 7307, 26, 9572, 13002, 3277, 8937, 199, 26, 2502, 26, 32581, 393, 29159, 32, 17164, 14, 957, 334, 45, 11781, 598, 393, 29159, 9, 199, 624, 199, 199, 646, 747, 199, 646, 5739, 199, 646, 5145, 199, 646, 984, 199, 646, 2050, 199, 199, 646, 1134, 12275, 199, 646, 8116, 199, 199, 504, 12043, 396, 492, 299, 7073, 63, 1208, 199, 199, 647, 12275, 14, 4365, 360, 18, 14, 16, 358, 421, 199, 3, 1696, 15841, 199, 199, 318, 17703, 63, 460, 63, 890, 63, 7548, 1915, 8, 928, 1403, 12, 6037, 12, 10976, 304, 272, 286, 16, 275, 1343, 1403, 5873, 272, 286, 17, 275, 6037, 5873, 272, 340, 286, 16, 59, 16, 61, 665, 378, 26, 267, 286, 16, 59, 16, 61, 275, 378, 272, 340, 286, 16, 59, 17, 61, 665, 378, 26, 267, 286, 16, 59, 17, 61, 275, 378, 272, 340, 286, 17, 59, 16, 61, 665, 378, 26, 267, 286, 17, 59, 16, 61, 275, 378, 272, 340, 286, 17, 59, 17, 61, 665, 378, 26, 267, 286, 17, 59, 17, 61, 275, 378, 272, 340, 286, 16, 59, 16, 61, 690, 10976, 59, 16, 61, 446, 413, 26, 267, 286, 16, 59, 16, 61, 275, 10976, 59, 16, 61, 446, 413, 272, 340, 286, 16, 59, 17, 61, 690, 10976, 59, 17, 61, 446, 413, 26, 267, 286, 16, 59, 17, 61, 275, 10976, 59, 17, 61, 446, 413, 272, 340, 286, 17, 59, 16, 61, 690, 10976, 59, 16, 61, 446, 413, 26, 267, 286, 17, 59, 16, 61, 275, 10976, 59, 16, 61, 446, 413, 272, 340, 286, 17, 59, 17, 61, 690, 10976, 59, 17, 61, 446, 413, 26, 267, 286, 17, 59, 17, 61, 275, 10976, 59, 17, 61, 446, 413, 272, 372, 7287, 827, 8, 67, 16, 59, 16, 467, 286, 17, 59, 16, 2522, 1467, 1748, 8, 67, 16, 59, 17, 467, 286, 17, 59, 17, 27520, 288, 359, 2101, 8, 67, 17, 59, 16, 61, 446, 286, 16, 59, 16, 566, 435, 413, 12, 1467, 2853, 8, 67, 17, 59, 17, 61, 446, 286, 16, 59, 17, 566, 435, 413, 566, 421, 199, 318, 790, 63, 1430, 63, 475, 63, 19839, 63, 875, 8, 1430, 304, 272, 790, 1130, 275, 8116, 14, 24697, 14, 19624, 63, 362, 63, 885, 342, 272, 790, 3643, 275, 790, 1130, 14, 362, 63, 3189, 63, 509, 63, 498, 600, 8, 1430, 14, 16529, 63, 498, 600, 9, 272, 790, 637, 275, 790, 3643, 59, 16, 1527, 16, 61, 272, 790, 354, 275, 8116, 14, 24697, 14, 31217, 63, 354, 8, 31217, 9, 339, 790, 1130, 275, 2420, 1767, 582, 298, 3292, 401, 1598, 298, 7690, 582, 298, 2902, 401, 1598, 298, 2638, 582, 298, 681, 67, 401, 1598, 298, 8185, 582, 298, 3039, 401, 1598, 298, 9121, 582, 298, 1019, 401, 1598, 298, 1721, 582, 298, 384, 401, 1598, 298, 3514, 582, 298, 2110, 401, 1598, 298, 38, 17, 582, 298, 70, 17, 401, 1598, 298, 38, 18, 582, 298, 70, 18, 401, 1598, 298, 38, 19, 582, 298, 70, 19, 401, 1598, 298, 38, 20, 582, 298, 70, 20, 401, 1598, 298, 38, 21, 582, 298, 70, 21, 401, 1598, 298, 38, 22, 582, 298, 70, 22, 401, 1598, 298, 38, 23, 582, 298, 70, 23, 401, 1598, 298, 38, 24, 582, 298, 70, 24, 401, 1598, 298, 38, 25, 582, 298, 70, 25, 401, 1598, 298, 38, 709, 582, 298, 70, 709, 401, 1598, 298, 38, 845, 582, 298, 70, 845, 401, 1598, 298, 38, 713, 582, 298, 70, 713, 401, 1598, 298, 10260, 582, 298, 19303, 401, 1598, 298, 13084, 582, 298, 13084, 401, 1598, 298, 1452, 582, 298, 1452, 401, 1598, 298, 4540, 7643, 582, 298, 894, 2638, 401, 1598, 298, 13184, 582, 298, 13184, 401, 1598, 298, 5191, 582, 298, 3287, 401, 1598, 298, 7001, 582, 298, 7001, 401, 1598, 298, 9971, 582, 298, 3176, 401, 1598, 298, 5392, 582, 298, 1807, 401, 1598, 298, 12054, 582, 298, 4219, 401, 1598, 298, 3005, 582, 298, 500, 401, 1598, 298, 3276, 63, 1721, 582, 298, 4198, 384, 401, 1598, 298, 3276, 63, 3514, 582, 298, 4198, 4272, 401, 1598, 298, 5977, 582, 298, 4470, 401, 1598, 298, 19290, 12167, 582, 298, 16, 88, 1465, 401, 1598, 298, 21509, 582, 298, 16, 88, 18, 66, 401, 1598, 298, 439, 941, 2675, 426, 582, 298, 16, 88, 1651, 401, 1598, 298, 19612, 582, 298, 16, 88, 1398, 401, 1598, 298, 2003, 582, 298, 16, 88, 18, 66, 401, 1598, 298, 14594, 3039, 582, 298, 16, 88, 17, 65, 401, 1598, 298, 14594, 1019, 582, 298, 16, 88, 17, 66, 401, 1598, 298, 11823, 63, 44, 582, 298, 16, 10550, 401, 1598, 298, 11823, 63, 50, 582, 298, 16, 10719, 401, 1598, 789, 339, 340, 6206, 360, 65, 358, 2695, 790, 637, 2695, 6206, 360, 90, 358, 503, 6206, 360, 16, 358, 2695, 790, 637, 2695, 6206, 360, 25, 735, 267, 11483, 275, 790, 354, 272, 916, 790, 354, 315, 769, 8, 19624, 14, 1612, 5109, 267, 11483, 275, 790, 1130, 59, 30499, 61, 272, 587, 26, 267, 372, 3087, 339, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 13060, 63, 12880, 26, 267, 11483, 275, 298, 12476, 23245, 435, 620, 272, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 8816, 17, 63, 12880, 26, 267, 11483, 275, 298, 4478, 23245, 435, 620, 272, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 18013, 63, 12880, 26, 267, 11483, 275, 298, 4723, 23245, 435, 620, 339, 372, 11483, 421, 199, 533, 13382, 23560, 4301, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 327, 15689, 267, 291, 14, 3806, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 267, 291, 14, 3806, 14, 409, 63, 1213, 480, 7801, 603, 12630, 15689, 531, 267, 291, 14, 3806, 14, 2242, 480, 1807, 13, 1430, 401, 291, 14, 1807, 63, 1430, 9, 267, 291, 14, 3806, 14, 2242, 480, 7237, 401, 291, 14, 7237, 9, 267, 291, 14, 3806, 14, 409 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 199, 7801, 570, 14875, 15, 7515, 14, 199, 199, 26, 7307, 26, 9572, 13002, 3277, 8937, 199, 26, 2502, 26, 32581, 393, 29159, 32, 17164, 14, 957, 334, 45, 11781, 598, 393, 29159, 9, 199, 624, 199, 199, 646, 747, 199, 646, 5739, 199, 646, 5145, 199, 646, 984, 199, 646, 2050, 199, 199, 646, 1134, 12275, 199, 646, 8116, 199, 199, 504, 12043, 396, 492, 299, 7073, 63, 1208, 199, 199, 647, 12275, 14, 4365, 360, 18, 14, 16, 358, 421, 199, 3, 1696, 15841, 199, 199, 318, 17703, 63, 460, 63, 890, 63, 7548, 1915, 8, 928, 1403, 12, 6037, 12, 10976, 304, 272, 286, 16, 275, 1343, 1403, 5873, 272, 286, 17, 275, 6037, 5873, 272, 340, 286, 16, 59, 16, 61, 665, 378, 26, 267, 286, 16, 59, 16, 61, 275, 378, 272, 340, 286, 16, 59, 17, 61, 665, 378, 26, 267, 286, 16, 59, 17, 61, 275, 378, 272, 340, 286, 17, 59, 16, 61, 665, 378, 26, 267, 286, 17, 59, 16, 61, 275, 378, 272, 340, 286, 17, 59, 17, 61, 665, 378, 26, 267, 286, 17, 59, 17, 61, 275, 378, 272, 340, 286, 16, 59, 16, 61, 690, 10976, 59, 16, 61, 446, 413, 26, 267, 286, 16, 59, 16, 61, 275, 10976, 59, 16, 61, 446, 413, 272, 340, 286, 16, 59, 17, 61, 690, 10976, 59, 17, 61, 446, 413, 26, 267, 286, 16, 59, 17, 61, 275, 10976, 59, 17, 61, 446, 413, 272, 340, 286, 17, 59, 16, 61, 690, 10976, 59, 16, 61, 446, 413, 26, 267, 286, 17, 59, 16, 61, 275, 10976, 59, 16, 61, 446, 413, 272, 340, 286, 17, 59, 17, 61, 690, 10976, 59, 17, 61, 446, 413, 26, 267, 286, 17, 59, 17, 61, 275, 10976, 59, 17, 61, 446, 413, 272, 372, 7287, 827, 8, 67, 16, 59, 16, 467, 286, 17, 59, 16, 2522, 1467, 1748, 8, 67, 16, 59, 17, 467, 286, 17, 59, 17, 27520, 288, 359, 2101, 8, 67, 17, 59, 16, 61, 446, 286, 16, 59, 16, 566, 435, 413, 12, 1467, 2853, 8, 67, 17, 59, 17, 61, 446, 286, 16, 59, 17, 566, 435, 413, 566, 421, 199, 318, 790, 63, 1430, 63, 475, 63, 19839, 63, 875, 8, 1430, 304, 272, 790, 1130, 275, 8116, 14, 24697, 14, 19624, 63, 362, 63, 885, 342, 272, 790, 3643, 275, 790, 1130, 14, 362, 63, 3189, 63, 509, 63, 498, 600, 8, 1430, 14, 16529, 63, 498, 600, 9, 272, 790, 637, 275, 790, 3643, 59, 16, 1527, 16, 61, 272, 790, 354, 275, 8116, 14, 24697, 14, 31217, 63, 354, 8, 31217, 9, 339, 790, 1130, 275, 2420, 1767, 582, 298, 3292, 401, 1598, 298, 7690, 582, 298, 2902, 401, 1598, 298, 2638, 582, 298, 681, 67, 401, 1598, 298, 8185, 582, 298, 3039, 401, 1598, 298, 9121, 582, 298, 1019, 401, 1598, 298, 1721, 582, 298, 384, 401, 1598, 298, 3514, 582, 298, 2110, 401, 1598, 298, 38, 17, 582, 298, 70, 17, 401, 1598, 298, 38, 18, 582, 298, 70, 18, 401, 1598, 298, 38, 19, 582, 298, 70, 19, 401, 1598, 298, 38, 20, 582, 298, 70, 20, 401, 1598, 298, 38, 21, 582, 298, 70, 21, 401, 1598, 298, 38, 22, 582, 298, 70, 22, 401, 1598, 298, 38, 23, 582, 298, 70, 23, 401, 1598, 298, 38, 24, 582, 298, 70, 24, 401, 1598, 298, 38, 25, 582, 298, 70, 25, 401, 1598, 298, 38, 709, 582, 298, 70, 709, 401, 1598, 298, 38, 845, 582, 298, 70, 845, 401, 1598, 298, 38, 713, 582, 298, 70, 713, 401, 1598, 298, 10260, 582, 298, 19303, 401, 1598, 298, 13084, 582, 298, 13084, 401, 1598, 298, 1452, 582, 298, 1452, 401, 1598, 298, 4540, 7643, 582, 298, 894, 2638, 401, 1598, 298, 13184, 582, 298, 13184, 401, 1598, 298, 5191, 582, 298, 3287, 401, 1598, 298, 7001, 582, 298, 7001, 401, 1598, 298, 9971, 582, 298, 3176, 401, 1598, 298, 5392, 582, 298, 1807, 401, 1598, 298, 12054, 582, 298, 4219, 401, 1598, 298, 3005, 582, 298, 500, 401, 1598, 298, 3276, 63, 1721, 582, 298, 4198, 384, 401, 1598, 298, 3276, 63, 3514, 582, 298, 4198, 4272, 401, 1598, 298, 5977, 582, 298, 4470, 401, 1598, 298, 19290, 12167, 582, 298, 16, 88, 1465, 401, 1598, 298, 21509, 582, 298, 16, 88, 18, 66, 401, 1598, 298, 439, 941, 2675, 426, 582, 298, 16, 88, 1651, 401, 1598, 298, 19612, 582, 298, 16, 88, 1398, 401, 1598, 298, 2003, 582, 298, 16, 88, 18, 66, 401, 1598, 298, 14594, 3039, 582, 298, 16, 88, 17, 65, 401, 1598, 298, 14594, 1019, 582, 298, 16, 88, 17, 66, 401, 1598, 298, 11823, 63, 44, 582, 298, 16, 10550, 401, 1598, 298, 11823, 63, 50, 582, 298, 16, 10719, 401, 1598, 789, 339, 340, 6206, 360, 65, 358, 2695, 790, 637, 2695, 6206, 360, 90, 358, 503, 6206, 360, 16, 358, 2695, 790, 637, 2695, 6206, 360, 25, 735, 267, 11483, 275, 790, 354, 272, 916, 790, 354, 315, 769, 8, 19624, 14, 1612, 5109, 267, 11483, 275, 790, 1130, 59, 30499, 61, 272, 587, 26, 267, 372, 3087, 339, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 13060, 63, 12880, 26, 267, 11483, 275, 298, 12476, 23245, 435, 620, 272, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 8816, 17, 63, 12880, 26, 267, 11483, 275, 298, 4478, 23245, 435, 620, 272, 340, 1566, 14, 929, 1253, 8116, 14, 24697, 14, 18013, 63, 12880, 26, 267, 11483, 275, 298, 4723, 23245, 435, 620, 339, 372, 11483, 421, 199, 533, 13382, 23560, 4301, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 327, 15689, 267, 291, 14, 3806, 275, 8116, 14, 4301, 8, 12275, 14, 15480, 63, 11422, 11817, 9, 267, 291, 14, 3806, 14, 409, 63, 1213, 480, 7801, 603, 12630, 15689, 531, 267, 291, 14, 3806, 14, 2242, 480, 1807, 13, 1430, 401, 291, 14, 1807, 63, 1430, 9, 267, 291, 14, 3806, 14, 2242, 480, 7237, 401, 291, 14, 7237, 9, 267, 291, 14, 3806, 14, 409, 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 ]
joelgrus/data-science-from-scratch
first-edition/code/multiple_regression.py
60
8590
from __future__ import division from collections import Counter from functools import partial from linear_algebra import dot, vector_add from statistics import median, standard_deviation from probability import normal_cdf from gradient_descent import minimize_stochastic from simple_linear_regression import total_sum_of_squares import math, random def predict(x_i, beta): return dot(x_i, beta) def error(x_i, y_i, beta): return y_i - predict(x_i, beta) def squared_error(x_i, y_i, beta): return error(x_i, y_i, beta) ** 2 def squared_error_gradient(x_i, y_i, beta): """the gradient corresponding to the ith squared error term""" return [-2 * x_ij * error(x_i, y_i, beta) for x_ij in x_i] def estimate_beta(x, y): beta_initial = [random.random() for x_i in x[0]] return minimize_stochastic(squared_error, squared_error_gradient, x, y, beta_initial, 0.001) def multiple_r_squared(x, y, beta): sum_of_squared_errors = sum(error(x_i, y_i, beta) ** 2 for x_i, y_i in zip(x, y)) return 1.0 - sum_of_squared_errors / total_sum_of_squares(y) def bootstrap_sample(data): """randomly samples len(data) elements with replacement""" return [random.choice(data) for _ in data] def bootstrap_statistic(data, stats_fn, num_samples): """evaluates stats_fn on num_samples bootstrap samples from data""" return [stats_fn(bootstrap_sample(data)) for _ in range(num_samples)] def estimate_sample_beta(sample): x_sample, y_sample = zip(*sample) # magic unzipping trick return estimate_beta(x_sample, y_sample) def p_value(beta_hat_j, sigma_hat_j): if beta_hat_j > 0: return 2 * (1 - normal_cdf(beta_hat_j / sigma_hat_j)) else: return 2 * normal_cdf(beta_hat_j / sigma_hat_j) # # REGULARIZED REGRESSION # # alpha is a *hyperparameter* controlling how harsh the penalty is # sometimes it's called "lambda" but that already means something in Python def ridge_penalty(beta, alpha): return alpha * dot(beta[1:], beta[1:]) def squared_error_ridge(x_i, y_i, beta, alpha): """estimate error plus ridge penalty on beta""" return error(x_i, y_i, beta) ** 2 + ridge_penalty(beta, alpha) def ridge_penalty_gradient(beta, alpha): """gradient of just the ridge penalty""" return [0] + [2 * alpha * beta_j for beta_j in beta[1:]] def squared_error_ridge_gradient(x_i, y_i, beta, alpha): """the gradient corresponding to the ith squared error term including the ridge penalty""" return vector_add(squared_error_gradient(x_i, y_i, beta), ridge_penalty_gradient(beta, alpha)) def estimate_beta_ridge(x, y, alpha): """use gradient descent to fit a ridge regression with penalty alpha""" beta_initial = [random.random() for x_i in x[0]] return minimize_stochastic(partial(squared_error_ridge, alpha=alpha), partial(squared_error_ridge_gradient, alpha=alpha), x, y, beta_initial, 0.001) def lasso_penalty(beta, alpha): return alpha * sum(abs(beta_i) for beta_i in beta[1:]) if __name__ == "__main__": x = [[1,49,4,0],[1,41,9,0],[1,40,8,0],[1,25,6,0],[1,21,1,0],[1,21,0,0],[1,19,3,0],[1,19,0,0],[1,18,9,0],[1,18,8,0],[1,16,4,0],[1,15,3,0],[1,15,0,0],[1,15,2,0],[1,15,7,0],[1,14,0,0],[1,14,1,0],[1,13,1,0],[1,13,7,0],[1,13,4,0],[1,13,2,0],[1,12,5,0],[1,12,0,0],[1,11,9,0],[1,10,9,0],[1,10,1,0],[1,10,1,0],[1,10,7,0],[1,10,9,0],[1,10,1,0],[1,10,6,0],[1,10,6,0],[1,10,8,0],[1,10,10,0],[1,10,6,0],[1,10,0,0],[1,10,5,0],[1,10,3,0],[1,10,4,0],[1,9,9,0],[1,9,9,0],[1,9,0,0],[1,9,0,0],[1,9,6,0],[1,9,10,0],[1,9,8,0],[1,9,5,0],[1,9,2,0],[1,9,9,0],[1,9,10,0],[1,9,7,0],[1,9,2,0],[1,9,0,0],[1,9,4,0],[1,9,6,0],[1,9,4,0],[1,9,7,0],[1,8,3,0],[1,8,2,0],[1,8,4,0],[1,8,9,0],[1,8,2,0],[1,8,3,0],[1,8,5,0],[1,8,8,0],[1,8,0,0],[1,8,9,0],[1,8,10,0],[1,8,5,0],[1,8,5,0],[1,7,5,0],[1,7,5,0],[1,7,0,0],[1,7,2,0],[1,7,8,0],[1,7,10,0],[1,7,5,0],[1,7,3,0],[1,7,3,0],[1,7,6,0],[1,7,7,0],[1,7,7,0],[1,7,9,0],[1,7,3,0],[1,7,8,0],[1,6,4,0],[1,6,6,0],[1,6,4,0],[1,6,9,0],[1,6,0,0],[1,6,1,0],[1,6,4,0],[1,6,1,0],[1,6,0,0],[1,6,7,0],[1,6,0,0],[1,6,8,0],[1,6,4,0],[1,6,2,1],[1,6,1,1],[1,6,3,1],[1,6,6,1],[1,6,4,1],[1,6,4,1],[1,6,1,1],[1,6,3,1],[1,6,4,1],[1,5,1,1],[1,5,9,1],[1,5,4,1],[1,5,6,1],[1,5,4,1],[1,5,4,1],[1,5,10,1],[1,5,5,1],[1,5,2,1],[1,5,4,1],[1,5,4,1],[1,5,9,1],[1,5,3,1],[1,5,10,1],[1,5,2,1],[1,5,2,1],[1,5,9,1],[1,4,8,1],[1,4,6,1],[1,4,0,1],[1,4,10,1],[1,4,5,1],[1,4,10,1],[1,4,9,1],[1,4,1,1],[1,4,4,1],[1,4,4,1],[1,4,0,1],[1,4,3,1],[1,4,1,1],[1,4,3,1],[1,4,2,1],[1,4,4,1],[1,4,4,1],[1,4,8,1],[1,4,2,1],[1,4,4,1],[1,3,2,1],[1,3,6,1],[1,3,4,1],[1,3,7,1],[1,3,4,1],[1,3,1,1],[1,3,10,1],[1,3,3,1],[1,3,4,1],[1,3,7,1],[1,3,5,1],[1,3,6,1],[1,3,1,1],[1,3,6,1],[1,3,10,1],[1,3,2,1],[1,3,4,1],[1,3,2,1],[1,3,1,1],[1,3,5,1],[1,2,4,1],[1,2,2,1],[1,2,8,1],[1,2,3,1],[1,2,1,1],[1,2,9,1],[1,2,10,1],[1,2,9,1],[1,2,4,1],[1,2,5,1],[1,2,0,1],[1,2,9,1],[1,2,9,1],[1,2,0,1],[1,2,1,1],[1,2,1,1],[1,2,4,1],[1,1,0,1],[1,1,2,1],[1,1,2,1],[1,1,5,1],[1,1,3,1],[1,1,10,1],[1,1,6,1],[1,1,0,1],[1,1,8,1],[1,1,6,1],[1,1,4,1],[1,1,9,1],[1,1,9,1],[1,1,4,1],[1,1,2,1],[1,1,9,1],[1,1,0,1],[1,1,8,1],[1,1,6,1],[1,1,1,1],[1,1,1,1],[1,1,5,1]] daily_minutes_good = [68.77,51.25,52.08,38.36,44.54,57.13,51.4,41.42,31.22,34.76,54.01,38.79,47.59,49.1,27.66,41.03,36.73,48.65,28.12,46.62,35.57,32.98,35,26.07,23.77,39.73,40.57,31.65,31.21,36.32,20.45,21.93,26.02,27.34,23.49,46.94,30.5,33.8,24.23,21.4,27.94,32.24,40.57,25.07,19.42,22.39,18.42,46.96,23.72,26.41,26.97,36.76,40.32,35.02,29.47,30.2,31,38.11,38.18,36.31,21.03,30.86,36.07,28.66,29.08,37.28,15.28,24.17,22.31,30.17,25.53,19.85,35.37,44.6,17.23,13.47,26.33,35.02,32.09,24.81,19.33,28.77,24.26,31.98,25.73,24.86,16.28,34.51,15.23,39.72,40.8,26.06,35.76,34.76,16.13,44.04,18.03,19.65,32.62,35.59,39.43,14.18,35.24,40.13,41.82,35.45,36.07,43.67,24.61,20.9,21.9,18.79,27.61,27.21,26.61,29.77,20.59,27.53,13.82,33.2,25,33.1,36.65,18.63,14.87,22.2,36.81,25.53,24.62,26.25,18.21,28.08,19.42,29.79,32.8,35.99,28.32,27.79,35.88,29.06,36.28,14.1,36.63,37.49,26.9,18.58,38.48,24.48,18.95,33.55,14.24,29.04,32.51,25.63,22.22,19,32.73,15.16,13.9,27.2,32.01,29.27,33,13.74,20.42,27.32,18.23,35.35,28.48,9.08,24.62,20.12,35.26,19.92,31.02,16.49,12.16,30.7,31.22,34.65,13.13,27.51,33.2,31.57,14.1,33.42,17.44,10.12,24.42,9.82,23.39,30.93,15.03,21.67,31.09,33.29,22.61,26.89,23.48,8.38,27.81,32.35,23.84] random.seed(0) beta = estimate_beta(x, daily_minutes_good) # [30.63, 0.972, -1.868, 0.911] print "beta", beta print "r-squared", multiple_r_squared(x, daily_minutes_good, beta) print print "digression: the bootstrap" # 101 points all very close to 100 close_to_100 = [99.5 + random.random() for _ in range(101)] # 101 points, 50 of them near 0, 50 of them near 200 far_from_100 = ([99.5 + random.random()] + [random.random() for _ in range(50)] + [200 + random.random() for _ in range(50)]) print "bootstrap_statistic(close_to_100, median, 100):" print bootstrap_statistic(close_to_100, median, 100) print "bootstrap_statistic(far_from_100, median, 100):" print bootstrap_statistic(far_from_100, median, 100) print random.seed(0) # so that you get the same results as me bootstrap_betas = bootstrap_statistic(zip(x, daily_minutes_good), estimate_sample_beta, 100) bootstrap_standard_errors = [ standard_deviation([beta[i] for beta in bootstrap_betas]) for i in range(4)] print "bootstrap standard errors", bootstrap_standard_errors print print "p_value(30.63, 1.174)", p_value(30.63, 1.174) print "p_value(0.972, 0.079)", p_value(0.972, 0.079) print "p_value(-1.868, 0.131)", p_value(-1.868, 0.131) print "p_value(0.911, 0.990)", p_value(0.911, 0.990) print print "regularization" random.seed(0) for alpha in [0.0, 0.01, 0.1, 1, 10]: beta = estimate_beta_ridge(x, daily_minutes_good, alpha=alpha) print "alpha", alpha print "beta", beta print "dot(beta[1:],beta[1:])", dot(beta[1:], beta[1:]) print "r-squared", multiple_r_squared(x, daily_minutes_good, beta) print
mit
[ 504, 636, 2443, 363, 492, 4629, 199, 504, 5055, 492, 14427, 199, 504, 9143, 492, 7417, 199, 504, 7798, 63, 279, 19355, 492, 6308, 12, 5477, 63, 525, 199, 504, 11076, 492, 17312, 12, 4465, 63, 271, 12337, 199, 504, 12224, 492, 3293, 63, 10790, 199, 504, 6709, 63, 26269, 492, 24720, 63, 14308, 21913, 199, 504, 3486, 63, 6676, 63, 12513, 492, 3141, 63, 1838, 63, 1618, 63, 20956, 199, 646, 3473, 12, 2196, 421, 199, 318, 12610, 8, 88, 63, 73, 12, 8201, 304, 272, 372, 6308, 8, 88, 63, 73, 12, 8201, 9, 199, 199, 318, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 372, 612, 63, 73, 446, 12610, 8, 88, 63, 73, 12, 8201, 9, 1362, 199, 318, 20478, 63, 705, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 372, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 199, 199, 318, 20478, 63, 705, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 408, 1589, 6709, 5226, 370, 314, 284, 273, 20478, 1125, 6707, 624, 272, 372, 5243, 18, 627, 671, 63, 7879, 627, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 288, 367, 671, 63, 7879, 315, 671, 63, 73, 61, 199, 199, 318, 14497, 63, 5683, 8, 88, 12, 612, 304, 272, 8201, 63, 2747, 275, 359, 2355, 14, 2355, 342, 367, 671, 63, 73, 315, 671, 59, 16, 2677, 272, 372, 24720, 63, 14308, 21913, 8, 12973, 63, 705, 12, 221, 3044, 20478, 63, 705, 63, 7490, 12, 221, 3044, 671, 12, 612, 12, 221, 3044, 8201, 63, 2747, 12, 221, 3044, 378, 14, 4587, 9, 3777, 199, 199, 318, 3663, 63, 82, 63, 12973, 8, 88, 12, 612, 12, 8201, 304, 272, 3089, 63, 1618, 63, 12973, 63, 2550, 275, 3089, 8, 705, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 1816, 367, 671, 63, 73, 12, 612, 63, 73, 315, 3482, 8, 88, 12, 612, 430, 272, 372, 413, 14, 16, 446, 3089, 63, 1618, 63, 12973, 63, 2550, 1182, 3141, 63, 1838, 63, 1618, 63, 20956, 8, 89, 9, 199, 199, 318, 15865, 63, 3271, 8, 576, 304, 272, 408, 2355, 590, 5845, 822, 8, 576, 9, 4008, 543, 8343, 624, 272, 372, 359, 2355, 14, 5095, 8, 576, 9, 367, 485, 315, 666, 61, 1362, 199, 318, 15865, 63, 26065, 8, 576, 12, 5020, 63, 2324, 12, 1967, 63, 3356, 304, 272, 408, 2579, 85, 2335, 5020, 63, 2324, 641, 1967, 63, 3356, 15865, 5845, 687, 666, 624, 272, 372, 359, 3200, 63, 2324, 8, 11146, 63, 3271, 8, 576, 430, 7205, 367, 485, 315, 1425, 8, 1507, 63, 3356, 1874, 199, 199, 318, 14497, 63, 3271, 63, 5683, 8, 3271, 304, 272, 671, 63, 3271, 12, 612, 63, 3271, 275, 3482, 2031, 3271, 9, 327, 10628, 29379, 4073, 20907, 272, 372, 14497, 63, 5683, 8, 88, 63, 3271, 12, 612, 63, 3271, 9, 199, 199, 318, 299, 63, 585, 8, 5683, 63, 8554, 63, 74, 12, 10819, 63, 8554, 63, 74, 304, 272, 340, 8201, 63, 8554, 63, 74, 690, 378, 26, 267, 372, 499, 627, 334, 17, 446, 3293, 63, 10790, 8, 5683, 63, 8554, 63, 74, 1182, 10819, 63, 8554, 63, 74, 430, 272, 587, 26, 267, 372, 499, 627, 3293, 63, 10790, 8, 5683, 63, 8554, 63, 74, 1182, 10819, 63, 8554, 63, 74, 9, 199, 199, 3, 199, 3, 14142, 3038, 18732, 5363, 3975, 9577, 199, 3, 199, 199, 3, 5131, 365, 282, 627, 9547, 5329, 10, 30350, 4212, 12159, 609, 314, 21251, 365, 199, 3, 15026, 652, 1159, 2797, 298, 2734, 2, 1325, 626, 2575, 4910, 6020, 315, 2018, 199, 318, 31285, 63, 26264, 8, 5683, 12, 5131, 304, 523, 372, 5131, 627, 6308, 8, 5683, 59, 17, 8429, 8201, 59, 17, 5728, 199, 199, 318, 20478, 63, 705, 63, 5562, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 12, 5131, 304, 272, 408, 21196, 1125, 12254, 31285, 21251, 641, 8201, 624, 272, 372, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 435, 31285, 63, 26264, 8, 5683, 12, 5131, 9, 199, 199, 318, 31285, 63, 26264, 63, 7490, 8, 5683, 12, 5131, 304, 272, 408, 7490, 402, 2951, 314, 31285, 21251, 624, 272, 372, 359, 16, 61, 435, 359, 18, 627, 5131, 627, 8201, 63, 74, 367, 8201, 63, 74, 315, 8201, 59, 17, 21316, 199, 199, 318, 20478, 63, 705, 63, 5562, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 12, 5131, 304, 272, 408, 1589, 6709, 5226, 370, 314, 284, 273, 20478, 1125, 6707, 272, 5893, 314, 31285, 21251, 624, 272, 372, 5477, 63, 525, 8, 12973, 63, 705, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 395, 1993, 31285, 63, 26264, 63, 7490, 8, 5683, 12, 5131, 430, 199, 199, 318, 14497, 63, 5683, 63, 5562, 8, 88, 12, 612, 12, 5131, 304, 272, 408, 1180, 6709, 31518, 370, 5542, 282, 31285, 10864, 272, 543, 21251, 5131, 624, 272, 8201, 63, 2747, 275, 359, 2355, 14, 2355, 342, 367, 671, 63, 73, 315, 671, 59, 16, 2677, 272, 372, 24720, 63, 14308, 21913, 8, 6672, 8, 12973, 63, 705, 63, 5562, 12, 5131, 29, 4468, 395, 221, 3044, 7417, 8, 12973, 63, 705, 63, 5562, 63, 7490, 12, 221, 4318, 5131, 29, 4468, 395, 221, 3044, 671, 12, 612, 12, 221, 3044, 8201, 63, 2747, 12, 221, 3044, 378, 14, 4587, 9, 199, 199, 318, 634, 15923, 63, 26264, 8, 5683, 12, 5131, 304, 272, 372, 5131, 627, 3089, 8, 2101, 8, 5683, 63, 73, 9, 367, 8201, 63, 73, 315, 8201, 59, 17, 5728, 258, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 671, 275, 3474, 17, 12, 1887, 12, 20, 12, 16, 6922, 17, 12, 2953, 12, 25, 12, 16, 6922, 17, 12, 2167, 12, 24, 12, 16, 6922, 17, 12, 821, 12, 22, 12, 16, 6922, 17, 12, 2025, 12, 17, 12, 16, 6922, 17, 12, 2025, 12, 16, 12, 16 ]
[ 636, 2443, 363, 492, 4629, 199, 504, 5055, 492, 14427, 199, 504, 9143, 492, 7417, 199, 504, 7798, 63, 279, 19355, 492, 6308, 12, 5477, 63, 525, 199, 504, 11076, 492, 17312, 12, 4465, 63, 271, 12337, 199, 504, 12224, 492, 3293, 63, 10790, 199, 504, 6709, 63, 26269, 492, 24720, 63, 14308, 21913, 199, 504, 3486, 63, 6676, 63, 12513, 492, 3141, 63, 1838, 63, 1618, 63, 20956, 199, 646, 3473, 12, 2196, 421, 199, 318, 12610, 8, 88, 63, 73, 12, 8201, 304, 272, 372, 6308, 8, 88, 63, 73, 12, 8201, 9, 199, 199, 318, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 372, 612, 63, 73, 446, 12610, 8, 88, 63, 73, 12, 8201, 9, 1362, 199, 318, 20478, 63, 705, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 372, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 199, 199, 318, 20478, 63, 705, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 304, 272, 408, 1589, 6709, 5226, 370, 314, 284, 273, 20478, 1125, 6707, 624, 272, 372, 5243, 18, 627, 671, 63, 7879, 627, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 288, 367, 671, 63, 7879, 315, 671, 63, 73, 61, 199, 199, 318, 14497, 63, 5683, 8, 88, 12, 612, 304, 272, 8201, 63, 2747, 275, 359, 2355, 14, 2355, 342, 367, 671, 63, 73, 315, 671, 59, 16, 2677, 272, 372, 24720, 63, 14308, 21913, 8, 12973, 63, 705, 12, 221, 3044, 20478, 63, 705, 63, 7490, 12, 221, 3044, 671, 12, 612, 12, 221, 3044, 8201, 63, 2747, 12, 221, 3044, 378, 14, 4587, 9, 3777, 199, 199, 318, 3663, 63, 82, 63, 12973, 8, 88, 12, 612, 12, 8201, 304, 272, 3089, 63, 1618, 63, 12973, 63, 2550, 275, 3089, 8, 705, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 1816, 367, 671, 63, 73, 12, 612, 63, 73, 315, 3482, 8, 88, 12, 612, 430, 272, 372, 413, 14, 16, 446, 3089, 63, 1618, 63, 12973, 63, 2550, 1182, 3141, 63, 1838, 63, 1618, 63, 20956, 8, 89, 9, 199, 199, 318, 15865, 63, 3271, 8, 576, 304, 272, 408, 2355, 590, 5845, 822, 8, 576, 9, 4008, 543, 8343, 624, 272, 372, 359, 2355, 14, 5095, 8, 576, 9, 367, 485, 315, 666, 61, 1362, 199, 318, 15865, 63, 26065, 8, 576, 12, 5020, 63, 2324, 12, 1967, 63, 3356, 304, 272, 408, 2579, 85, 2335, 5020, 63, 2324, 641, 1967, 63, 3356, 15865, 5845, 687, 666, 624, 272, 372, 359, 3200, 63, 2324, 8, 11146, 63, 3271, 8, 576, 430, 7205, 367, 485, 315, 1425, 8, 1507, 63, 3356, 1874, 199, 199, 318, 14497, 63, 3271, 63, 5683, 8, 3271, 304, 272, 671, 63, 3271, 12, 612, 63, 3271, 275, 3482, 2031, 3271, 9, 327, 10628, 29379, 4073, 20907, 272, 372, 14497, 63, 5683, 8, 88, 63, 3271, 12, 612, 63, 3271, 9, 199, 199, 318, 299, 63, 585, 8, 5683, 63, 8554, 63, 74, 12, 10819, 63, 8554, 63, 74, 304, 272, 340, 8201, 63, 8554, 63, 74, 690, 378, 26, 267, 372, 499, 627, 334, 17, 446, 3293, 63, 10790, 8, 5683, 63, 8554, 63, 74, 1182, 10819, 63, 8554, 63, 74, 430, 272, 587, 26, 267, 372, 499, 627, 3293, 63, 10790, 8, 5683, 63, 8554, 63, 74, 1182, 10819, 63, 8554, 63, 74, 9, 199, 199, 3, 199, 3, 14142, 3038, 18732, 5363, 3975, 9577, 199, 3, 199, 199, 3, 5131, 365, 282, 627, 9547, 5329, 10, 30350, 4212, 12159, 609, 314, 21251, 365, 199, 3, 15026, 652, 1159, 2797, 298, 2734, 2, 1325, 626, 2575, 4910, 6020, 315, 2018, 199, 318, 31285, 63, 26264, 8, 5683, 12, 5131, 304, 523, 372, 5131, 627, 6308, 8, 5683, 59, 17, 8429, 8201, 59, 17, 5728, 199, 199, 318, 20478, 63, 705, 63, 5562, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 12, 5131, 304, 272, 408, 21196, 1125, 12254, 31285, 21251, 641, 8201, 624, 272, 372, 1125, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 9, 1011, 499, 435, 31285, 63, 26264, 8, 5683, 12, 5131, 9, 199, 199, 318, 31285, 63, 26264, 63, 7490, 8, 5683, 12, 5131, 304, 272, 408, 7490, 402, 2951, 314, 31285, 21251, 624, 272, 372, 359, 16, 61, 435, 359, 18, 627, 5131, 627, 8201, 63, 74, 367, 8201, 63, 74, 315, 8201, 59, 17, 21316, 199, 199, 318, 20478, 63, 705, 63, 5562, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 12, 5131, 304, 272, 408, 1589, 6709, 5226, 370, 314, 284, 273, 20478, 1125, 6707, 272, 5893, 314, 31285, 21251, 624, 272, 372, 5477, 63, 525, 8, 12973, 63, 705, 63, 7490, 8, 88, 63, 73, 12, 612, 63, 73, 12, 8201, 395, 1993, 31285, 63, 26264, 63, 7490, 8, 5683, 12, 5131, 430, 199, 199, 318, 14497, 63, 5683, 63, 5562, 8, 88, 12, 612, 12, 5131, 304, 272, 408, 1180, 6709, 31518, 370, 5542, 282, 31285, 10864, 272, 543, 21251, 5131, 624, 272, 8201, 63, 2747, 275, 359, 2355, 14, 2355, 342, 367, 671, 63, 73, 315, 671, 59, 16, 2677, 272, 372, 24720, 63, 14308, 21913, 8, 6672, 8, 12973, 63, 705, 63, 5562, 12, 5131, 29, 4468, 395, 221, 3044, 7417, 8, 12973, 63, 705, 63, 5562, 63, 7490, 12, 221, 4318, 5131, 29, 4468, 395, 221, 3044, 671, 12, 612, 12, 221, 3044, 8201, 63, 2747, 12, 221, 3044, 378, 14, 4587, 9, 199, 199, 318, 634, 15923, 63, 26264, 8, 5683, 12, 5131, 304, 272, 372, 5131, 627, 3089, 8, 2101, 8, 5683, 63, 73, 9, 367, 8201, 63, 73, 315, 8201, 59, 17, 5728, 258, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 671, 275, 3474, 17, 12, 1887, 12, 20, 12, 16, 6922, 17, 12, 2953, 12, 25, 12, 16, 6922, 17, 12, 2167, 12, 24, 12, 16, 6922, 17, 12, 821, 12, 22, 12, 16, 6922, 17, 12, 2025, 12, 17, 12, 16, 6922, 17, 12, 2025, 12, 16, 12, 16, 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,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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 ]
factorlibre/OCB
addons/mail/tests/test_mail_features.py
172
59265
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2012-TODAY OpenERP S.A. <http://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/>. # ############################################################################## from ..mail_mail import mail_mail from ..mail_thread import mail_thread from .common import TestMail from openerp.tools import mute_logger, email_split, html2plaintext from openerp.tools.mail import html_sanitize class test_mail(TestMail): def test_000_alias_setup(self): """ Test basic mail.alias setup works, before trying to use them for routing """ cr, uid = self.cr, self.uid self.user_valentin_id = self.res_users.create(cr, uid, {'name': 'Valentin Cognito', 'email': 'valentin.cognito@gmail.com', 'login': 'valentin.cognito', 'alias_name': 'valentin.cognito'}) self.user_valentin = self.res_users.browse(cr, uid, self.user_valentin_id) self.assertEquals(self.user_valentin.alias_name, self.user_valentin.login, "Login should be used as alias") self.user_pagan_id = self.res_users.create(cr, uid, {'name': 'Pagan Le Marchant', 'email': 'plmarchant@gmail.com', 'login': 'plmarchant@gmail.com', 'alias_name': 'plmarchant@gmail.com'}) self.user_pagan = self.res_users.browse(cr, uid, self.user_pagan_id) self.assertEquals(self.user_pagan.alias_name, 'plmarchant', "If login is an email, the alias should keep only the local part") self.user_barty_id = self.res_users.create(cr, uid, {'name': 'Bartholomew Ironside', 'email': 'barty@gmail.com', 'login': 'b4r+_#_R3wl$$', 'alias_name': 'b4r+_#_R3wl$$'}) self.user_barty = self.res_users.browse(cr, uid, self.user_barty_id) self.assertEquals(self.user_barty.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens') def test_00_followers_function_field(self): """ Tests designed for the many2many function field 'follower_ids'. We will test to perform writes using the many2many commands 0, 3, 4, 5 and 6. """ cr, uid, user_admin, partner_bert_id, group_pigs = self.cr, self.uid, self.user_admin, self.partner_bert_id, self.group_pigs # Data: create 'disturbing' values in mail.followers: same res_id, other res_model; same res_model, other res_id group_dummy_id = self.mail_group.create(cr, uid, {'name': 'Dummy group'}, {'mail_create_nolog': True}) self.mail_followers.create(cr, uid, {'res_model': 'mail.thread', 'res_id': self.group_pigs_id, 'partner_id': partner_bert_id}) self.mail_followers.create(cr, uid, {'res_model': 'mail.group', 'res_id': group_dummy_id, 'partner_id': partner_bert_id}) # Pigs just created: should be only Admin as follower follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertEqual(follower_ids, set([user_admin.partner_id.id]), 'Admin should be the only Pigs fan') # Subscribe Bert through a '4' command group_pigs.write({'message_follower_ids': [(4, partner_bert_id)]}) group_pigs.refresh() follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the only Pigs fans') # Unsubscribe Bert through a '3' command group_pigs.write({'message_follower_ids': [(3, partner_bert_id)]}) group_pigs.refresh() follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertEqual(follower_ids, set([user_admin.partner_id.id]), 'Admin should be the only Pigs fan') # Set followers through a '6' command group_pigs.write({'message_follower_ids': [(6, 0, [partner_bert_id])]}) group_pigs.refresh() follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertEqual(follower_ids, set([partner_bert_id]), 'Bert should be the only Pigs fan') # Add a follower created on the fly through a '0' command group_pigs.write({'message_follower_ids': [(0, 0, {'name': 'Patrick Fiori'})]}) partner_patrick_id = self.res_partner.search(cr, uid, [('name', '=', 'Patrick Fiori')])[0] group_pigs.refresh() follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertEqual(follower_ids, set([partner_bert_id, partner_patrick_id]), 'Bert and Patrick should be the only Pigs fans') # Finally, unlink through a '5' command group_pigs.write({'message_follower_ids': [(5, 0)]}) group_pigs.refresh() follower_ids = set([follower.id for follower in group_pigs.message_follower_ids]) self.assertFalse(follower_ids, 'Pigs group should not have fans anymore') # Test dummy data has not been altered fol_obj_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.thread'), ('res_id', '=', self.group_pigs_id)]) follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)]) self.assertEqual(follower_ids, set([partner_bert_id]), 'Bert should be the follower of dummy mail.thread data') fol_obj_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', group_dummy_id)]) follower_ids = set([follower.partner_id.id for follower in self.mail_followers.browse(cr, uid, fol_obj_ids)]) self.assertEqual(follower_ids, set([partner_bert_id, user_admin.partner_id.id]), 'Bert and Admin should be the followers of dummy mail.group data') def test_05_message_followers_and_subtypes(self): """ Tests designed for the subscriber API as well as message subtypes """ cr, uid, user_admin, user_raoul, group_pigs = self.cr, self.uid, self.user_admin, self.user_raoul, self.group_pigs # Data: message subtypes self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_def', 'default': True, 'res_model': 'mail.group'}) self.mail_message_subtype.create(cr, uid, {'name': 'mt_other_def', 'default': True, 'res_model': 'crm.lead'}) self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_def', 'default': True, 'res_model': False}) mt_mg_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_mg_nodef', 'default': False, 'res_model': 'mail.group'}) mt_all_nodef = self.mail_message_subtype.create(cr, uid, {'name': 'mt_all_nodef', 'default': False, 'res_model': False}) default_group_subtypes = self.mail_message_subtype.search(cr, uid, [('default', '=', True), '|', ('res_model', '=', 'mail.group'), ('res_model', '=', False)]) # ---------------------------------------- # CASE1: test subscriptions with subtypes # ---------------------------------------- # Do: subscribe Raoul, should have default subtypes group_pigs.message_subscribe_users([user_raoul.id]) group_pigs.refresh() # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'message_subscribe: Admin and Raoul should be the only 2 Pigs fans') # Raoul follows default subtypes fol_ids = self.mail_followers.search(cr, uid, [ ('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id) ]) fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) self.assertEqual(set(fol_subtype_ids), set(default_group_subtypes), 'message_subscribe: Raoul subscription subtypes are incorrect, should be all default ones') # Do: subscribe Raoul with specified new subtypes group_pigs.message_subscribe_users([user_raoul.id], subtype_ids=[mt_mg_nodef]) # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'message_subscribe: Admin and Raoul should be the only 2 Pigs fans') # Test: 2 lines in mail.followers (no duplicate for Raoul) fol_ids = self.mail_followers.search(cr, uid, [ ('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ]) self.assertEqual(len(fol_ids), 2, 'message_subscribe: subscribing an already-existing follower should not create new entries in mail.followers') # Test: Raoul follows only specified subtypes fol_ids = self.mail_followers.search(cr, uid, [ ('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id) ]) fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef]), 'message_subscribe: Raoul subscription subtypes are incorrect, should be only specified') # Do: Subscribe Raoul without specified subtypes: should not erase existing subscription subtypes group_pigs.message_subscribe_users([user_raoul.id, user_raoul.id]) group_pigs.message_subscribe_users([user_raoul.id]) group_pigs.refresh() # Test: 2 followers (Admin and Raoul) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(set(follower_ids), set([user_raoul.partner_id.id, user_admin.partner_id.id]), 'message_subscribe: Admin and Raoul should be the only 2 Pigs fans') # Test: Raoul follows default subtypes fol_ids = self.mail_followers.search(cr, uid, [ ('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_raoul.partner_id.id) ]) fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef]), 'message_subscribe: Raoul subscription subtypes are incorrect, should be only specified') # Do: Unsubscribe Raoul twice through message_unsubscribe_users group_pigs.message_unsubscribe_users([user_raoul.id, user_raoul.id]) group_pigs.refresh() # Test: 1 follower (Admin) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(follower_ids, [user_admin.partner_id.id], 'Admin must be the only Pigs fan') # Test: 1 lines in mail.followers (no duplicate for Raoul) fol_ids = self.mail_followers.search(cr, uid, [ ('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id) ]) self.assertEqual(len(fol_ids), 1, 'message_subscribe: group should have only 1 entry in mail.follower for 1 follower') # Do: subscribe Admin with subtype_ids group_pigs.message_subscribe_users([uid], [mt_mg_nodef, mt_all_nodef]) fol_ids = self.mail_followers.search(cr, uid, [('res_model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id), ('partner_id', '=', user_admin.partner_id.id)]) fol_obj = self.mail_followers.browse(cr, uid, fol_ids)[0] fol_subtype_ids = set([subtype.id for subtype in fol_obj.subtype_ids]) self.assertEqual(set(fol_subtype_ids), set([mt_mg_nodef, mt_all_nodef]), 'subscription subtypes are incorrect') # ---------------------------------------- # CASE2: test mail_thread fields # ---------------------------------------- subtype_data = group_pigs._get_subscription_data(None, None)[group_pigs.id]['message_subtype_data'] self.assertEqual(set(subtype_data.keys()), set(['Discussions', 'mt_mg_def', 'mt_all_def', 'mt_mg_nodef', 'mt_all_nodef']), 'mail.group available subtypes incorrect') self.assertFalse(subtype_data['Discussions']['followed'], 'Admin should not follow Discussions in pigs') self.assertTrue(subtype_data['mt_mg_nodef']['followed'], 'Admin should follow mt_mg_nodef in pigs') self.assertTrue(subtype_data['mt_all_nodef']['followed'], 'Admin should follow mt_all_nodef in pigs') def test_11_notification_url(self): """ Tests designed to test the URL added in notification emails. """ cr, uid, group_pigs = self.cr, self.uid, self.group_pigs # Test URL formatting base_url = self.registry('ir.config_parameter').get_param(cr, uid, 'web.base.url') # Partner data partner_raoul = self.res_partner.browse(cr, uid, self.partner_raoul_id) partner_bert_id = self.res_partner.create(cr, uid, {'name': 'bert'}) partner_bert = self.res_partner.browse(cr, uid, partner_bert_id) # Mail data mail_mail_id = self.mail_mail.create(cr, uid, {'state': 'exception'}) mail = self.mail_mail.browse(cr, uid, mail_mail_id) # Test: link for nobody -> None url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail) self.assertEqual(url, None, 'notification email: mails not send to a specific partner should not have any URL') # Test: link for partner -> None url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_bert) self.assertEqual(url, None, 'notification email: mails send to a not-user partner should not have any URL') # Test: link for user -> signin url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul) self.assertIn(base_url, url, 'notification email: link should contain web.base.url') self.assertIn('db=%s' % cr.dbname, url, 'notification email: link should contain database name') self.assertIn('action=mail.action_mail_redirect', url, 'notification email: link should contain the redirect action') self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url, 'notification email: link should contain the user login') # Test: link for user -> with model and res_id mail_mail_id = self.mail_mail.create(cr, uid, {'model': 'mail.group', 'res_id': group_pigs.id}) mail = self.mail_mail.browse(cr, uid, mail_mail_id) url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul) self.assertIn(base_url, url, 'notification email: link should contain web.base.url') self.assertIn('db=%s' % cr.dbname, url, 'notification email: link should contain database name') self.assertIn('action=mail.action_mail_redirect', url, 'notification email: link should contain the redirect action') self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url, 'notification email: link should contain the user login') self.assertIn('model=mail.group', url, 'notification email: link should contain the model when having not notification email on a record') self.assertIn('res_id=%s' % group_pigs.id, url, 'notification email: link should contain the res_id when having not notification email on a record') # Test: link for user -> with model and res_id mail_mail_id = self.mail_mail.create(cr, uid, {'notification': True, 'model': 'mail.group', 'res_id': group_pigs.id}) mail = self.mail_mail.browse(cr, uid, mail_mail_id) url = mail_mail._get_partner_access_link(self.mail_mail, cr, uid, mail, partner=partner_raoul) self.assertIn(base_url, url, 'notification email: link should contain web.base.url') self.assertIn('db=%s' % cr.dbname, url, 'notification email: link should contain database name') self.assertIn('action=mail.action_mail_redirect', url, 'notification email: link should contain the redirect action') self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url, 'notification email: link should contain the user login') self.assertIn('message_id=%s' % mail.mail_message_id.id, url, 'notification email: link based on message should contain the mail_message id') self.assertNotIn('model=mail.group', url, 'notification email: link based on message should not contain model') self.assertNotIn('res_id=%s' % group_pigs.id, url, 'notification email: link based on message should not contain res_id') @mute_logger('openerp.addons.mail.mail_thread', 'openerp.models') def test_12_inbox_redirection(self): """ Tests designed to test the inbox redirection of emails notification URLs. """ cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs model, act_id = self.ir_model_data.get_object_reference(cr, uid, 'mail', 'action_mail_inbox_feeds') # Data: post a message on pigs msg_id = self.group_pigs.message_post(body='My body', partner_ids=[self.partner_bert_id], type='comment', subtype='mail.mt_comment') # No specific parameters -> should redirect to Inbox action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {}}) self.assertEqual( action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox' ) self.assertEqual( action.get('id'), act_id, 'URL redirection: action without parameters should redirect to client action Inbox' ) # Raoul has read access to Pigs -> should redirect to form view of Pigs action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {'message_id': msg_id}}) self.assertEqual( action.get('type'), 'ir.actions.act_window', 'URL redirection: action with message_id for read-accredited user should redirect to Pigs' ) self.assertEqual( action.get('res_id'), group_pigs.id, 'URL redirection: action with message_id for read-accredited user should redirect to Pigs' ) action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_raoul_id, {'params': {'model': 'mail.group', 'res_id': group_pigs.id}}) self.assertEqual( action.get('type'), 'ir.actions.act_window', 'URL redirection: action with message_id for read-accredited user should redirect to Pigs' ) self.assertEqual( action.get('res_id'), group_pigs.id, 'URL redirection: action with message_id for read-accredited user should redirect to Pigs' ) # Bert has no read access to Pigs -> should redirect to Inbox action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_bert_id, {'params': {'message_id': msg_id}}) self.assertEqual( action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox' ) self.assertEqual( action.get('id'), act_id, 'URL redirection: action without parameters should redirect to client action Inbox' ) action = mail_thread.message_redirect_action(self.mail_thread, cr, self.user_bert_id, {'params': {'model': 'mail.group', 'res_id': group_pigs.id}}) self.assertEqual( action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox' ) self.assertEqual( action.get('id'), act_id, 'URL redirection: action without parameters should redirect to client action Inbox' ) def test_20_message_post(self): """ Tests designed for message_post. """ cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs # -------------------------------------------------- # Data creation # -------------------------------------------------- # 0 - Update existing users-partners self.res_users.write(cr, uid, [uid], {'email': 'a@a', 'notify_email': 'always'}) self.res_users.write(cr, uid, [self.user_raoul_id], {'email': 'r@r'}) # 1 - Bert Tartopoils, with email, should receive emails for comments and emails p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'}) # 2 - Carine Poilvache, with email, should receive emails for emails p_c_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c', 'notify_email': 'none'}) # 3 - Dédé Grosbedon, without email, to test email verification; should receive emails for every message p_d_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon', 'email': 'd@d', 'notify_email': 'always'}) # 4 - Attachments attach1_id = self.ir_attachment.create(cr, user_raoul.id, { 'name': 'Attach1', 'datas_fname': 'Attach1', 'datas': 'bWlncmF0aW9uIHRlc3Q=', 'res_model': 'mail.compose.message', 'res_id': 0}) attach2_id = self.ir_attachment.create(cr, user_raoul.id, { 'name': 'Attach2', 'datas_fname': 'Attach2', 'datas': 'bWlncmF0aW9uIHRlc3Q=', 'res_model': 'mail.compose.message', 'res_id': 0}) attach3_id = self.ir_attachment.create(cr, user_raoul.id, { 'name': 'Attach3', 'datas_fname': 'Attach3', 'datas': 'bWlncmF0aW9uIHRlc3Q=', 'res_model': 'mail.compose.message', 'res_id': 0}) # 5 - Mail data _subject = 'Pigs' _mail_subject = 'Re: %s' % (group_pigs.name) _body1 = '<p>Pigs rules</p>' _body2 = '<html>Pigs rocks</html>' _attachments = [ ('List1', 'My first attachment'), ('List2', 'My second attachment') ] # -------------------------------------------------- # CASE1: post comment + partners + attachments # -------------------------------------------------- # Data: set alias_domain to see emails with alias self.registry('ir.config_parameter').set_param(self.cr, self.uid, 'mail.catchall.domain', 'schlouby.fr') # Data: change Pigs name to test reply_to self.mail_group.write(cr, uid, [self.group_pigs_id], {'name': '"Pigs" !ù $%-'}) # Do: subscribe Raoul new_follower_ids = [self.partner_raoul_id] group_pigs.message_subscribe(new_follower_ids) # Test: group followers = Raoul + uid group_fids = [follower.id for follower in group_pigs.message_follower_ids] test_fids = new_follower_ids + [self.partner_admin_id] self.assertEqual(set(test_fids), set(group_fids), 'message_subscribe: incorrect followers after subscribe') # Do: Raoul message_post on Pigs self._init_mock_build_email() msg1_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id, body=_body1, subject=_subject, partner_ids=[p_b_id, p_c_id], attachment_ids=[attach1_id, attach2_id], attachments=_attachments, type='comment', subtype='mt_comment') msg = self.mail_message.browse(cr, uid, msg1_id) msg_message_id = msg.message_id msg_pids = [partner.id for partner in msg.notified_partner_ids] msg_aids = [attach.id for attach in msg.attachment_ids] sent_emails = self._build_email_kwargs_list # Test: mail_message: subject and body not modified self.assertEqual(_subject, msg.subject, 'message_post: mail.message subject incorrect') self.assertEqual(_body1, msg.body, 'message_post: mail.message body incorrect') # Test: mail_message: notified_partner_ids = group followers + partner_ids - author test_pids = set([self.partner_admin_id, p_b_id, p_c_id]) self.assertEqual(test_pids, set(msg_pids), 'message_post: mail.message notified partners incorrect') # Test: mail_message: attachments (4, attachment_ids + attachments) test_aids = set([attach1_id, attach2_id]) msg_attach_names = set([attach.name for attach in msg.attachment_ids]) test_attach_names = set(['Attach1', 'Attach2', 'List1', 'List2']) self.assertEqual(len(msg_aids), 4, 'message_post: mail.message wrong number of attachments') self.assertEqual(msg_attach_names, test_attach_names, 'message_post: mail.message attachments incorrectly added') self.assertTrue(test_aids.issubset(set(msg_aids)), 'message_post: mail.message attachments duplicated') for attach in msg.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'message_post: mail.message attachments were not linked to the document') self.assertEqual(attach.res_id, group_pigs.id, 'message_post: mail.message attachments were not linked to the document') if 'List' in attach.name: self.assertIn((attach.name, attach.datas.decode('base64')), _attachments, 'message_post: mail.message attachment name / data incorrect') dl_attach = self.mail_message.download_attachment(cr, user_raoul.id, id_message=msg.id, attachment_id=attach.id) self.assertIn((dl_attach['filename'], dl_attach['base64'].decode('base64')), _attachments, 'message_post: mail.message download_attachment is incorrect') # Test: followers: same as before (author was already subscribed) group_pigs.refresh() group_fids = [follower.id for follower in group_pigs.message_follower_ids] test_fids = new_follower_ids + [self.partner_admin_id] self.assertEqual(set(test_fids), set(group_fids), 'message_post: wrong followers after posting') # Test: mail_mail: notifications have been deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg1_id)]), 'message_post: mail.mail notifications should have been auto-deleted!') # Test: notifications emails: to a and b, c is email only, r is author test_emailto = ['Administrator <a@a>', 'Bert Tartopoils <b@b>'] # test_emailto = ['"Followers of -Pigs-" <a@a>', '"Followers of -Pigs-" <b@b>'] self.assertEqual(len(sent_emails), 2, 'message_post: notification emails wrong number of send emails') self.assertEqual(set([m['email_to'][0] for m in sent_emails]), set(test_emailto), 'message_post: notification emails wrong recipients (email_to)') for sent_email in sent_emails: self.assertEqual(sent_email['email_from'], 'Raoul Grosbedon <raoul@schlouby.fr>', 'message_post: notification email wrong email_from: should use alias of sender') self.assertEqual(len(sent_email['email_to']), 1, 'message_post: notification email sent to more than one email address instead of a precise partner') self.assertIn(sent_email['email_to'][0], test_emailto, 'message_post: notification email email_to incorrect') self.assertEqual(sent_email['reply_to'], u'"YourCompany \\"Pigs\\" !ù $%-" <group+pigs@schlouby.fr>', 'message_post: notification email reply_to incorrect') self.assertEqual(_subject, sent_email['subject'], 'message_post: notification email subject incorrect') self.assertIn(_body1, sent_email['body'], 'message_post: notification email body incorrect') self.assertIn('Pigs rules', sent_email['body_alternative'], 'message_post: notification email body alternative should contain the body') self.assertNotIn('<p>', sent_email['body_alternative'], 'message_post: notification email body alternative still contains html') self.assertFalse(sent_email['references'], 'message_post: references should be False when sending a message that is not a reply') # Test: notification linked to this message = group followers = notified_partner_ids notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg1_id)]) notif_pids = set([notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)]) self.assertEqual(notif_pids, test_pids, 'message_post: mail.message created mail.notification incorrect') # Data: Pigs name back to normal self.mail_group.write(cr, uid, [self.group_pigs_id], {'name': 'Pigs'}) # -------------------------------------------------- # CASE2: reply + parent_id + parent notification # -------------------------------------------------- # Data: remove alias_domain to see emails with alias param_ids = self.registry('ir.config_parameter').search(cr, uid, [('key', '=', 'mail.catchall.domain')]) self.registry('ir.config_parameter').unlink(cr, uid, param_ids) # Do: Raoul message_post on Pigs self._init_mock_build_email() msg2_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id, body=_body2, type='email', subtype='mt_comment', partner_ids=[p_d_id], parent_id=msg1_id, attachment_ids=[attach3_id], context={'mail_post_autofollow': True}) msg = self.mail_message.browse(cr, uid, msg2_id) msg_pids = [partner.id for partner in msg.notified_partner_ids] msg_aids = [attach.id for attach in msg.attachment_ids] sent_emails = self._build_email_kwargs_list # Test: mail_message: subject is False, body, parent_id is msg_id self.assertEqual(msg.subject, False, 'message_post: mail.message subject incorrect') self.assertEqual(msg.body, html_sanitize(_body2), 'message_post: mail.message body incorrect') self.assertEqual(msg.parent_id.id, msg1_id, 'message_post: mail.message parent_id incorrect') # Test: mail_message: notified_partner_ids = group followers test_pids = [self.partner_admin_id, p_d_id] self.assertEqual(set(test_pids), set(msg_pids), 'message_post: mail.message partners incorrect') # Test: mail_message: notifications linked to this message = group followers = notified_partner_ids notif_ids = self.mail_notification.search(cr, uid, [('message_id', '=', msg2_id)]) notif_pids = [notif.partner_id.id for notif in self.mail_notification.browse(cr, uid, notif_ids)] self.assertEqual(set(test_pids), set(notif_pids), 'message_post: mail.message notification partners incorrect') # Test: mail_mail: notifications deleted self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', msg2_id)]), 'mail.mail notifications should have been auto-deleted!') # Test: emails send by server (to a, b, c, d) test_emailto = [u'Administrator <a@a>', u'Bert Tartopoils <b@b>', u'Carine Poilvache <c@c>', u'D\xe9d\xe9 Grosbedon <d@d>'] # test_emailto = [u'"Followers of Pigs" <a@a>', u'"Followers of Pigs" <b@b>', u'"Followers of Pigs" <c@c>', u'"Followers of Pigs" <d@d>'] # self.assertEqual(len(sent_emails), 3, 'sent_email number of sent emails incorrect') for sent_email in sent_emails: self.assertEqual(sent_email['email_from'], 'Raoul Grosbedon <r@r>', 'message_post: notification email wrong email_from: should use email of sender when no alias domain set') self.assertEqual(len(sent_email['email_to']), 1, 'message_post: notification email sent to more than one email address instead of a precise partner') self.assertIn(sent_email['email_to'][0], test_emailto, 'message_post: notification email email_to incorrect') self.assertEqual(email_split(sent_email['reply_to']), ['r@r'], # was '"Followers of Pigs" <r@r>', but makes no sense 'message_post: notification email reply_to incorrect: should have raoul email') self.assertEqual(_mail_subject, sent_email['subject'], 'message_post: notification email subject incorrect') self.assertIn(html_sanitize(_body2), sent_email['body'], 'message_post: notification email does not contain the body') self.assertIn('Pigs rocks', sent_email['body_alternative'], 'message_post: notification email body alternative should contain the body') self.assertNotIn('<p>', sent_email['body_alternative'], 'message_post: notification email body alternative still contains html') self.assertIn(msg_message_id, sent_email['references'], 'message_post: notification email references lacks parent message message_id') # Test: attachments + download for attach in msg.attachment_ids: self.assertEqual(attach.res_model, 'mail.group', 'message_post: mail.message attachment res_model incorrect') self.assertEqual(attach.res_id, self.group_pigs_id, 'message_post: mail.message attachment res_id incorrect') # Test: Dédé has been notified -> should also have been notified of the parent message msg = self.mail_message.browse(cr, uid, msg1_id) msg_pids = set([partner.id for partner in msg.notified_partner_ids]) test_pids = set([self.partner_admin_id, p_b_id, p_c_id, p_d_id]) self.assertEqual(test_pids, msg_pids, 'message_post: mail.message parent notification not created') # Do: reply to last message msg3_id = self.mail_group.message_post(cr, user_raoul.id, self.group_pigs_id, body='Test', parent_id=msg2_id) msg = self.mail_message.browse(cr, uid, msg3_id) # Test: check that its parent will be the first message self.assertEqual(msg.parent_id.id, msg1_id, 'message_post did not flatten the thread structure') def test_25_message_compose_wizard(self): """ Tests designed for the mail.compose.message wizard. """ cr, uid, user_raoul, group_pigs = self.cr, self.uid, self.user_raoul, self.group_pigs mail_compose = self.registry('mail.compose.message') # -------------------------------------------------- # Data creation # -------------------------------------------------- # 0 - Update existing users-partners self.res_users.write(cr, uid, [uid], {'email': 'a@a'}) self.res_users.write(cr, uid, [self.user_raoul_id], {'email': 'r@r'}) # 1 - Bert Tartopoils, with email, should receive emails for comments and emails p_b_id = self.res_partner.create(cr, uid, {'name': 'Bert Tartopoils', 'email': 'b@b'}) # 2 - Carine Poilvache, with email, should receive emails for emails p_c_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c', 'notify_email': 'always'}) # 3 - Dédé Grosbedon, without email, to test email verification; should receive emails for every message p_d_id = self.res_partner.create(cr, uid, {'name': 'Dédé Grosbedon', 'email': 'd@d', 'notify_email': 'always'}) # 4 - Create a Bird mail.group, that will be used to test mass mailing group_bird_id = self.mail_group.create(cr, uid, { 'name': 'Bird', 'description': 'Bird resistance', }, context={'mail_create_nolog': True}) group_bird = self.mail_group.browse(cr, uid, group_bird_id) # 5 - Mail data _subject = 'Pigs' _body = 'Pigs <b>rule</b>' _reply_subject = 'Re: %s' % _subject _attachments = [ {'name': 'First', 'datas_fname': 'first.txt', 'datas': 'My first attachment'.encode('base64')}, {'name': 'Second', 'datas_fname': 'second.txt', 'datas': 'My second attachment'.encode('base64')} ] _attachments_test = [('first.txt', 'My first attachment'), ('second.txt', 'My second attachment')] # 6 - Subscribe Bert to Pigs group_pigs.message_subscribe([p_b_id]) # -------------------------------------------------- # CASE1: wizard + partners + context keys # -------------------------------------------------- # Do: Raoul wizard-composes on Pigs with auto-follow for partners, not for author compose_id = mail_compose.create(cr, user_raoul.id, { 'subject': _subject, 'body': _body, 'partner_ids': [(4, p_c_id), (4, p_d_id)], }, context={ 'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id, }) compose = mail_compose.browse(cr, uid, compose_id) # Test: mail.compose.message: composition_mode, model, res_id self.assertEqual(compose.composition_mode, 'comment', 'compose wizard: mail.compose.message incorrect composition_mode') self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model') self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id') # Do: Post the comment mail_compose.send_mail(cr, user_raoul.id, [compose_id], {'mail_post_autofollow': True, 'mail_create_nosubscribe': True}) group_pigs.refresh() message = group_pigs.message_ids[0] # Test: mail.group: followers (c and d added by auto follow key; raoul not added by nosubscribe key) pigs_pids = [p.id for p in group_pigs.message_follower_ids] test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id] self.assertEqual(set(pigs_pids), set(test_pids), 'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account') # Test: mail.message: subject, body inside p self.assertEqual(message.subject, _subject, 'compose wizard: mail.message incorrect subject') self.assertEqual(message.body, '<p>%s</p>' % _body, 'compose wizard: mail.message incorrect body') # Test: mail.message: notified_partner_ids = admin + bert (followers) + c + d (recipients) msg_pids = [partner.id for partner in message.notified_partner_ids] test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id] self.assertEqual(set(msg_pids), set(test_pids), 'compose wizard: mail.message notified_partner_ids incorrect') # -------------------------------------------------- # CASE2: reply + attachments # -------------------------------------------------- # Do: Reply with attachments compose_id = mail_compose.create(cr, user_raoul.id, { 'attachment_ids': [(0, 0, _attachments[0]), (0, 0, _attachments[1])] }, context={ 'default_composition_mode': 'comment', 'default_res_id': self.group_pigs_id, 'default_parent_id': message.id }) compose = mail_compose.browse(cr, uid, compose_id) # Test: mail.compose.message: model, res_id, parent_id self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model') self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id') self.assertEqual(compose.parent_id.id, message.id, 'compose wizard: mail.compose.message incorrect parent_id') # Test: mail.compose.message: subject as Re:.., body, parent_id self.assertEqual(compose.subject, _reply_subject, 'compose wizard: mail.compose.message incorrect subject') self.assertFalse(compose.body, 'compose wizard: mail.compose.message body should not contain parent message body') self.assertEqual(compose.parent_id and compose.parent_id.id, message.id, 'compose wizard: mail.compose.message parent_id incorrect') # Test: mail.compose.message: attachments for attach in compose.attachment_ids: self.assertIn((attach.datas_fname, attach.datas.decode('base64')), _attachments_test, 'compose wizard: mail.message attachment name / data incorrect') # -------------------------------------------------- # CASE3: mass_mail on Pigs and Bird # -------------------------------------------------- # Do: Compose in mass_mail_mode on pigs and bird compose_id = mail_compose.create( cr, user_raoul.id, { 'subject': _subject, 'body': '${object.description}', 'partner_ids': [(4, p_c_id), (4, p_d_id)], }, context={ 'default_composition_mode': 'mass_mail', 'default_model': 'mail.group', 'default_res_id': False, 'active_ids': [self.group_pigs_id, group_bird_id], }) compose = mail_compose.browse(cr, uid, compose_id) # Do: Post the comment, get created message for each group mail_compose.send_mail(cr, user_raoul.id, [compose_id], context={ 'default_res_id': -1, 'active_ids': [self.group_pigs_id, group_bird_id] }) # check mail_mail mail_mail_ids = self.mail_mail.search(cr, uid, [('subject', '=', _subject)]) for mail_mail in self.mail_mail.browse(cr, uid, mail_mail_ids): self.assertEqual(set([p.id for p in mail_mail.recipient_ids]), set([p_c_id, p_d_id]), 'compose wizard: mail_mail mass mailing: mail.mail in mass mail incorrect recipients') # check logged messages group_pigs.refresh() group_bird.refresh() message1 = group_pigs.message_ids[0] message2 = group_bird.message_ids[0] # Test: Pigs and Bird did receive their message test_msg_ids = self.mail_message.search(cr, uid, [], limit=2) self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message') self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message') # Test: mail.message: subject, body, subtype, notified partners (nobody + specific recipients) self.assertEqual(message1.subject, _subject, 'compose wizard: message_post: mail.message in mass mail subject incorrect') self.assertEqual(message1.body, '<p>%s</p>' % group_pigs.description, 'compose wizard: message_post: mail.message in mass mail body incorrect') # self.assertEqual(set([p.id for p in message1.notified_partner_ids]), set([p_c_id, p_d_id]), # 'compose wizard: message_post: mail.message in mass mail incorrect notified partners') self.assertEqual(message2.subject, _subject, 'compose wizard: message_post: mail.message in mass mail subject incorrect') self.assertEqual(message2.body, '<p>%s</p>' % group_bird.description, 'compose wizard: message_post: mail.message in mass mail body incorrect') # self.assertEqual(set([p.id for p in message2.notified_partner_ids]), set([p_c_id, p_d_id]), # 'compose wizard: message_post: mail.message in mass mail incorrect notified partners') # Test: mail.group followers: author not added as follower in mass mail mode pigs_pids = [p.id for p in group_pigs.message_follower_ids] test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id] self.assertEqual(set(pigs_pids), set(test_pids), 'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account') bird_pids = [p.id for p in group_bird.message_follower_ids] test_pids = [self.partner_admin_id] self.assertEqual(set(bird_pids), set(test_pids), 'compose wizard: mail_post_autofollow and mail_create_nosubscribe context keys not correctly taken into account') # Do: Compose in mass_mail, coming from list_view, we have an active_domain that should be supported compose_id = mail_compose.create(cr, user_raoul.id, { 'subject': _subject, 'body': '${object.description}', 'partner_ids': [(4, p_c_id), (4, p_d_id)], }, context={ 'default_composition_mode': 'mass_mail', 'default_model': 'mail.group', 'default_res_id': False, 'active_ids': [self.group_pigs_id], 'active_domain': [('name', 'in', ['Pigs', 'Bird'])], }) compose = mail_compose.browse(cr, uid, compose_id) # Do: Post the comment, get created message for each group mail_compose.send_mail( cr, user_raoul.id, [compose_id], context={ 'default_res_id': -1, 'active_ids': [self.group_pigs_id, group_bird_id] }) group_pigs.refresh() group_bird.refresh() message1 = group_pigs.message_ids[0] message2 = group_bird.message_ids[0] # Test: Pigs and Bird did receive their message test_msg_ids = self.mail_message.search(cr, uid, [], limit=2) self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message') self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message') def test_30_needaction(self): """ Tests for mail.message needaction. """ cr, uid, user_admin, user_raoul, group_pigs = self.cr, self.uid, self.user_admin, self.user_raoul, self.group_pigs na_admin_base = self.mail_message._needaction_count(cr, uid, domain=[]) na_demo_base = self.mail_message._needaction_count(cr, user_raoul.id, domain=[]) # Test: number of unread notification = needaction on mail.message notif_ids = self.mail_notification.search(cr, uid, [ ('partner_id', '=', user_admin.partner_id.id), ('is_read', '=', False) ]) na_count = self.mail_message._needaction_count(cr, uid, domain=[]) self.assertEqual(len(notif_ids), na_count, 'unread notifications count does not match needaction count') # Do: post 2 message on group_pigs as admin, 3 messages as demo user for dummy in range(2): group_pigs.message_post(body='My Body', subtype='mt_comment') raoul_pigs = group_pigs.sudo(user_raoul) for dummy in range(3): raoul_pigs.message_post(body='My Demo Body', subtype='mt_comment') # Test: admin has 3 new notifications (from demo), and 3 new needaction notif_ids = self.mail_notification.search(cr, uid, [ ('partner_id', '=', user_admin.partner_id.id), ('is_read', '=', False) ]) self.assertEqual(len(notif_ids), na_admin_base + 3, 'Admin should have 3 new unread notifications') na_admin = self.mail_message._needaction_count(cr, uid, domain=[]) na_admin_group = self.mail_message._needaction_count(cr, uid, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) self.assertEqual(na_admin, na_admin_base + 3, 'Admin should have 3 new needaction') self.assertEqual(na_admin_group, 3, 'Admin should have 3 needaction related to Pigs') # Test: demo has 0 new notifications (not a follower, not receiving its own messages), and 0 new needaction notif_ids = self.mail_notification.search(cr, uid, [ ('partner_id', '=', user_raoul.partner_id.id), ('is_read', '=', False) ]) self.assertEqual(len(notif_ids), na_demo_base + 0, 'Demo should have 0 new unread notifications') na_demo = self.mail_message._needaction_count(cr, user_raoul.id, domain=[]) na_demo_group = self.mail_message._needaction_count(cr, user_raoul.id, domain=[('model', '=', 'mail.group'), ('res_id', '=', self.group_pigs_id)]) self.assertEqual(na_demo, na_demo_base + 0, 'Demo should have 0 new needaction') self.assertEqual(na_demo_group, 0, 'Demo should have 0 needaction related to Pigs') def test_40_track_field(self): """ Testing auto tracking of fields. """ def _strip_string_spaces(body): return body.replace(' ', '').replace('\n', '') # Data: subscribe Raoul to Pigs, because he will change the public attribute and may loose access to the record cr, uid = self.cr, self.uid self.mail_group.message_subscribe_users(cr, uid, [self.group_pigs_id], [self.user_raoul_id]) # Data: res.users.group, to test group_public_id automatic logging group_system_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_system') group_system_id = group_system_ref and group_system_ref[1] or False # Data: custom subtypes mt_private_id = self.mail_message_subtype.create(cr, uid, {'name': 'private', 'description': 'Private public'}) self.ir_model_data.create(cr, uid, {'name': 'mt_private', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_private_id}) mt_name_supername_id = self.mail_message_subtype.create(cr, uid, {'name': 'name_supername', 'description': 'Supername name'}) self.ir_model_data.create(cr, uid, {'name': 'mt_name_supername', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_name_supername_id}) mt_group_public_set_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public_set', 'description': 'Group set'}) self.ir_model_data.create(cr, uid, {'name': 'mt_group_public_set', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_set_id}) mt_group_public_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public', 'description': 'Group changed'}) self.ir_model_data.create(cr, uid, {'name': 'mt_group_public', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_id}) # Data: alter mail_group model for testing purposes (test on classic, selection and many2one fields) cls = type(self.mail_group) self.assertNotIn('_track', cls.__dict__) cls._track = { 'public': { 'mail.mt_private': lambda self, cr, uid, obj, ctx=None: obj.public == 'private', }, 'name': { 'mail.mt_name_supername': lambda self, cr, uid, obj, ctx=None: obj.name == 'supername', }, 'group_public_id': { 'mail.mt_group_public_set': lambda self, cr, uid, obj, ctx=None: obj.group_public_id, 'mail.mt_group_public': lambda self, cr, uid, obj, ctx=None: True, }, } visibility = {'public': 'onchange', 'name': 'always', 'group_public_id': 'onchange'} for key in visibility: self.assertFalse(hasattr(getattr(cls, key), 'track_visibility')) getattr(cls, key).track_visibility = visibility[key] @self.addCleanup def cleanup(): delattr(cls, '_track') for key in visibility: del getattr(cls, key).track_visibility # Test: change name -> always tracked, not related to a subtype self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'public': 'public'}) self.group_pigs.refresh() self.assertEqual(len(self.group_pigs.message_ids), 1, 'tracked: a message should have been produced') # Test: first produced message: no subtype, name change tracked last_msg = self.group_pigs.message_ids[-1] self.assertFalse(last_msg.subtype_id, 'tracked: message should not have been linked to a subtype') self.assertIn(u'SelectedGroupOnly\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect') self.assertIn('Pigs', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field') # Test: change name as supername, public as private -> 2 subtypes self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'name': 'supername', 'public': 'private'}) self.group_pigs.refresh() self.assertEqual(len(self.group_pigs.message_ids), 3, 'tracked: two messages should have been produced') # Test: first produced message: mt_name_supername last_msg = self.group_pigs.message_ids[-2] self.assertEqual(last_msg.subtype_id.id, mt_private_id, 'tracked: message should be linked to mt_private subtype') self.assertIn('Private public', last_msg.body, 'tracked: message body does not hold the subtype description') self.assertIn(u'Pigs\u2192supername', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect') # Test: second produced message: mt_name_supername last_msg = self.group_pigs.message_ids[-3] self.assertEqual(last_msg.subtype_id.id, mt_name_supername_id, 'tracked: message should be linked to mt_name_supername subtype') self.assertIn('Supername name', last_msg.body, 'tracked: message body does not hold the subtype description') self.assertIn(u'Public\u2192Private', _strip_string_spaces(last_msg.body), 'tracked: message body incorrect') self.assertIn(u'Pigs\u2192supername', _strip_string_spaces(last_msg.body), 'tracked feature: message body does not hold always tracked field') # Test: change public as public, group_public_id -> 2 subtypes, name always tracked self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'public': 'public', 'group_public_id': group_system_id}) self.group_pigs.refresh() self.assertEqual(len(self.group_pigs.message_ids), 5, 'tracked: one message should have been produced') # Test: first produced message: mt_group_public_set_id, with name always tracked, public tracked on change last_msg = self.group_pigs.message_ids[-4] self.assertEqual(last_msg.subtype_id.id, mt_group_public_set_id, 'tracked: message should be linked to mt_group_public_set_id') self.assertIn('Group set', last_msg.body, 'tracked: message body does not hold the subtype description') self.assertIn(u'Private\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold changed tracked field') self.assertIn(u'HumanResources/Employee\u2192Administration/Settings', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field') # Test: second produced message: mt_group_public_id, with name always tracked, public tracked on change last_msg = self.group_pigs.message_ids[-5] self.assertEqual(last_msg.subtype_id.id, mt_group_public_id, 'tracked: message should be linked to mt_group_public_id') self.assertIn('Group changed', last_msg.body, 'tracked: message body does not hold the subtype description') self.assertIn(u'Private\u2192Public', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold changed tracked field') self.assertIn(u'HumanResources/Employee\u2192Administration/Settings', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field') # Test: change group_public_id to False -> 1 subtype, name always tracked self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'group_public_id': False}) self.group_pigs.refresh() self.assertEqual(len(self.group_pigs.message_ids), 6, 'tracked: one message should have been produced') # Test: first produced message: mt_group_public_set_id, with name always tracked, public tracked on change last_msg = self.group_pigs.message_ids[-6] self.assertEqual(last_msg.subtype_id.id, mt_group_public_id, 'tracked: message should be linked to mt_group_public_id') self.assertIn('Group changed', last_msg.body, 'tracked: message body does not hold the subtype description') self.assertIn(u'Administration/Settings\u2192', _strip_string_spaces(last_msg.body), 'tracked: message body does not hold always tracked field') # Test: change not tracked field, no tracking message self.mail_group.write(cr, self.user_raoul_id, [self.group_pigs_id], {'description': 'Dummy'}) self.group_pigs.refresh() self.assertEqual(len(self.group_pigs.message_ids), 6, 'tracked: No message should have been produced')
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 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, 504, 2508, 1198, 63, 1198, 492, 6016, 63, 1198, 199, 504, 2508, 1198, 63, 2671, 492, 6016, 63, 2671, 199, 504, 1275, 2330, 492, 1379, 13681, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 12, 3031, 63, 1294, 12, 3517, 18, 17426, 199, 504, 5166, 14, 2537, 14, 1198, 492, 3517, 63, 18177, 199, 199, 533, 511, 63, 1198, 8, 774, 13681, 304, 339, 347, 511, 63, 1493, 63, 3620, 63, 2758, 8, 277, 304, 267, 408, 1379, 5678, 6016, 14, 3620, 3272, 5419, 12, 2544, 9936, 370, 675, 3062, 367, 14870, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 751, 63, 86, 6078, 262, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 54, 6078, 262, 1849, 784, 24308, 297, 283, 2123, 356, 283, 86, 6078, 262, 14, 6862, 24308, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 86, 6078, 262, 14, 6862, 24308, 297, 283, 3620, 63, 354, 356, 283, 86, 6078, 262, 14, 6862, 24308, 3071, 267, 291, 14, 751, 63, 86, 6078, 262, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 86, 6078, 262, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 86, 6078, 262, 14, 3620, 63, 354, 12, 291, 14, 751, 63, 86, 6078, 262, 14, 2886, 12, 298, 8880, 1077, 506, 1202, 465, 5162, 531, 398, 291, 14, 751, 63, 15351, 290, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 23862, 290, 7005, 603, 1047, 867, 297, 283, 2123, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 297, 283, 3620, 63, 354, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 3071, 267, 291, 14, 751, 63, 15351, 290, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 15351, 290, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 15351, 290, 14, 3620, 63, 354, 12, 283, 1168, 77, 1047, 867, 297, 298, 3917, 4676, 365, 376, 3031, 12, 314, 5162, 1077, 4215, 1454, 314, 2257, 1777, 531, 398, 291, 14, 751, 63, 1700, 369, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 5281, 273, 79, 320, 278, 87, 473, 2641, 2441, 297, 283, 2123, 356, 283, 1700, 369, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 66, 20, 82, 6416, 20930, 50, 19, 20159, 4, 4268, 283, 3620, 63, 354, 356, 283, 66, 20, 82, 6416, 20930, 50, 19, 20159, 23174, 3071, 267, 291, 14, 751, 63, 1700, 369, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 1700, 369, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 1700, 369, 14, 3620, 63, 354, 12, 283, 66, 20, 82, 6416, 13, 63, 82, 19, 20159, 14382, 283, 2825, 6541, 8365, 1077, 506, 8717, 701, 7188, 27920, 358, 339, 347, 511, 63, 383, 63, 22648, 63, 1593, 63, 698, 8, 277, 304, 267, 408, 6496, 19829, 367, 314, 5002, 18, 3479, 805, 901, 283, 25615, 63, 1580, 1370, 288, 2136, 911, 511, 370, 5147, 14511, 1808, 314, 5002, 18, 3479, 3718, 378, 12, 650, 12, 841, 12, 288, 959, 436, 1227, 14, 408, 267, 2467, 12, 1747, 12, 922, 63, 2113, 12, 5854, 63, 12504, 63, 344, 12, 1572, 63, 20389, 275, 291, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 751, 63, 2113, 12, 291, 14, 3899, 63, 12504, 63, 344, 12, 291, 14, 923, 63, 20389, 398, 327, 3918, 26, 1218, 283, 2686, 300, 10911, 7, 1338, 315, 6016, 14, 22648, 26, 2011, 522, 63, 344, 12, 1163, 522, 63, 1238, 27, 2011, 522, 63, 1238, 12, 1163, 522, 63, 344, 267, 1572, 63, 5869, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 11324, 1572, 2267, 791, 1198, 63, 981, 63, 889, 793, 356, 715, 1552, 267, 291, 14, 1198, 63, 22648, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 470, 63, 1238, 356, 283, 1198, 14, 2671, 297, 283, 470, 63, 344, 356, 291, 14, 923, 63, 20389, 63, 344, 12, 283, 3899, 63, 344, 356, 5854, 63, 12504, 63, 344, 1552, 267, 291, 14, 1198, 63, 22648, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 470, 63, 1238, 356, 283, 1198, 14, 923, 297, 283, 470, 63, 344, 356, 1572, 63, 5869, 63, 344, 12, 283, 3899, 63, 344, 356, 5854, 63, 12504, 63, 344, 1552, 398, 327, 19835, 458, 2951, 2737, 26, 1077, 506 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 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, 504, 2508, 1198, 63, 1198, 492, 6016, 63, 1198, 199, 504, 2508, 1198, 63, 2671, 492, 6016, 63, 2671, 199, 504, 1275, 2330, 492, 1379, 13681, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 12, 3031, 63, 1294, 12, 3517, 18, 17426, 199, 504, 5166, 14, 2537, 14, 1198, 492, 3517, 63, 18177, 199, 199, 533, 511, 63, 1198, 8, 774, 13681, 304, 339, 347, 511, 63, 1493, 63, 3620, 63, 2758, 8, 277, 304, 267, 408, 1379, 5678, 6016, 14, 3620, 3272, 5419, 12, 2544, 9936, 370, 675, 3062, 367, 14870, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 291, 14, 751, 63, 86, 6078, 262, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 54, 6078, 262, 1849, 784, 24308, 297, 283, 2123, 356, 283, 86, 6078, 262, 14, 6862, 24308, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 86, 6078, 262, 14, 6862, 24308, 297, 283, 3620, 63, 354, 356, 283, 86, 6078, 262, 14, 6862, 24308, 3071, 267, 291, 14, 751, 63, 86, 6078, 262, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 86, 6078, 262, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 86, 6078, 262, 14, 3620, 63, 354, 12, 291, 14, 751, 63, 86, 6078, 262, 14, 2886, 12, 298, 8880, 1077, 506, 1202, 465, 5162, 531, 398, 291, 14, 751, 63, 15351, 290, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 23862, 290, 7005, 603, 1047, 867, 297, 283, 2123, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 297, 283, 3620, 63, 354, 356, 283, 1168, 77, 1047, 867, 32, 6799, 14, 957, 3071, 267, 291, 14, 751, 63, 15351, 290, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 15351, 290, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 15351, 290, 14, 3620, 63, 354, 12, 283, 1168, 77, 1047, 867, 297, 298, 3917, 4676, 365, 376, 3031, 12, 314, 5162, 1077, 4215, 1454, 314, 2257, 1777, 531, 398, 291, 14, 751, 63, 1700, 369, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 5281, 273, 79, 320, 278, 87, 473, 2641, 2441, 297, 283, 2123, 356, 283, 1700, 369, 32, 6799, 14, 957, 297, 283, 2886, 356, 283, 66, 20, 82, 6416, 20930, 50, 19, 20159, 4, 4268, 283, 3620, 63, 354, 356, 283, 66, 20, 82, 6416, 20930, 50, 19, 20159, 23174, 3071, 267, 291, 14, 751, 63, 1700, 369, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 1700, 369, 63, 344, 9, 267, 291, 14, 2947, 8, 277, 14, 751, 63, 1700, 369, 14, 3620, 63, 354, 12, 283, 66, 20, 82, 6416, 13, 63, 82, 19, 20159, 14382, 283, 2825, 6541, 8365, 1077, 506, 8717, 701, 7188, 27920, 358, 339, 347, 511, 63, 383, 63, 22648, 63, 1593, 63, 698, 8, 277, 304, 267, 408, 6496, 19829, 367, 314, 5002, 18, 3479, 805, 901, 283, 25615, 63, 1580, 1370, 288, 2136, 911, 511, 370, 5147, 14511, 1808, 314, 5002, 18, 3479, 3718, 378, 12, 650, 12, 841, 12, 288, 959, 436, 1227, 14, 408, 267, 2467, 12, 1747, 12, 922, 63, 2113, 12, 5854, 63, 12504, 63, 344, 12, 1572, 63, 20389, 275, 291, 14, 1556, 12, 291, 14, 1535, 12, 291, 14, 751, 63, 2113, 12, 291, 14, 3899, 63, 12504, 63, 344, 12, 291, 14, 923, 63, 20389, 398, 327, 3918, 26, 1218, 283, 2686, 300, 10911, 7, 1338, 315, 6016, 14, 22648, 26, 2011, 522, 63, 344, 12, 1163, 522, 63, 1238, 27, 2011, 522, 63, 1238, 12, 1163, 522, 63, 344, 267, 1572, 63, 5869, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 354, 356, 283, 11324, 1572, 2267, 791, 1198, 63, 981, 63, 889, 793, 356, 715, 1552, 267, 291, 14, 1198, 63, 22648, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 470, 63, 1238, 356, 283, 1198, 14, 2671, 297, 283, 470, 63, 344, 356, 291, 14, 923, 63, 20389, 63, 344, 12, 283, 3899, 63, 344, 356, 5854, 63, 12504, 63, 344, 1552, 267, 291, 14, 1198, 63, 22648, 14, 981, 8, 1556, 12, 1747, 12, 288, 791, 470, 63, 1238, 356, 283, 1198, 14, 923, 297, 283, 470, 63, 344, 356, 1572, 63, 5869, 63, 344, 12, 283, 3899, 63, 344, 356, 5854, 63, 12504, 63, 344, 1552, 398, 327, 19835, 458, 2951, 2737, 26, 1077, 506, 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,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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 ]
Belxjander/Kirito
Python-3.5.0-Amiga/Lib/test/test_funcattrs.py
10
13001
import types import unittest def global_function(): def inner_function(): class LocalClass: pass global inner_global_function def inner_global_function(): def inner_function2(): pass return inner_function2 return LocalClass return lambda: inner_function class FuncAttrsTest(unittest.TestCase): def setUp(self): class F: def a(self): pass def b(): return 3 self.fi = F() self.F = F self.b = b def cannot_set_attr(self, obj, name, value, exceptions): try: setattr(obj, name, value) except exceptions: pass else: self.fail("shouldn't be able to set %s to %r" % (name, value)) try: delattr(obj, name) except exceptions: pass else: self.fail("shouldn't be able to del %s" % name) class FunctionPropertiesTest(FuncAttrsTest): # Include the external setUp method that is common to all tests def test_module(self): self.assertEqual(self.b.__module__, __name__) def test_dir_includes_correct_attrs(self): self.b.known_attr = 7 self.assertIn('known_attr', dir(self.b), "set attributes not in dir listing of method") # Test on underlying function object of method self.F.a.known_attr = 7 self.assertIn('known_attr', dir(self.fi.a), "set attribute on function " "implementations, should show up in next dir") def test_duplicate_function_equality(self): # Body of `duplicate' is the exact same as self.b def duplicate(): 'my docstring' return 3 self.assertNotEqual(self.b, duplicate) def test_copying___code__(self): def test(): pass self.assertEqual(test(), None) test.__code__ = self.b.__code__ self.assertEqual(test(), 3) # self.b always returns 3, arbitrarily def test___globals__(self): self.assertIs(self.b.__globals__, globals()) self.cannot_set_attr(self.b, '__globals__', 2, (AttributeError, TypeError)) def test___closure__(self): a = 12 def f(): print(a) c = f.__closure__ self.assertIsInstance(c, tuple) self.assertEqual(len(c), 1) # don't have a type object handy self.assertEqual(c[0].__class__.__name__, "cell") self.cannot_set_attr(f, "__closure__", c, AttributeError) def test_empty_cell(self): def f(): print(a) try: f.__closure__[0].cell_contents except ValueError: pass else: self.fail("shouldn't be able to read an empty cell") a = 12 def test___name__(self): self.assertEqual(self.b.__name__, 'b') self.b.__name__ = 'c' self.assertEqual(self.b.__name__, 'c') self.b.__name__ = 'd' self.assertEqual(self.b.__name__, 'd') # __name__ and __name__ must be a string self.cannot_set_attr(self.b, '__name__', 7, TypeError) # __name__ must be available when in restricted mode. Exec will raise # AttributeError if __name__ is not available on f. s = """def f(): pass\nf.__name__""" exec(s, {'__builtins__': {}}) # Test on methods, too self.assertEqual(self.fi.a.__name__, 'a') self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError) def test___qualname__(self): # PEP 3155 self.assertEqual(self.b.__qualname__, 'FuncAttrsTest.setUp.<locals>.b') self.assertEqual(FuncAttrsTest.setUp.__qualname__, 'FuncAttrsTest.setUp') self.assertEqual(global_function.__qualname__, 'global_function') self.assertEqual(global_function().__qualname__, 'global_function.<locals>.<lambda>') self.assertEqual(global_function()().__qualname__, 'global_function.<locals>.inner_function') self.assertEqual(global_function()()().__qualname__, 'global_function.<locals>.inner_function.<locals>.LocalClass') self.assertEqual(inner_global_function.__qualname__, 'inner_global_function') self.assertEqual(inner_global_function().__qualname__, 'inner_global_function.<locals>.inner_function2') self.b.__qualname__ = 'c' self.assertEqual(self.b.__qualname__, 'c') self.b.__qualname__ = 'd' self.assertEqual(self.b.__qualname__, 'd') # __qualname__ must be a string self.cannot_set_attr(self.b, '__qualname__', 7, TypeError) def test___code__(self): num_one, num_two = 7, 8 def a(): pass def b(): return 12 def c(): return num_one def d(): return num_two def e(): return num_one, num_two for func in [a, b, c, d, e]: self.assertEqual(type(func.__code__), types.CodeType) self.assertEqual(c(), 7) self.assertEqual(d(), 8) d.__code__ = c.__code__ self.assertEqual(c.__code__, d.__code__) self.assertEqual(c(), 7) # self.assertEqual(d(), 7) try: b.__code__ = c.__code__ except ValueError: pass else: self.fail("__code__ with different numbers of free vars should " "not be possible") try: e.__code__ = d.__code__ except ValueError: pass else: self.fail("__code__ with different numbers of free vars should " "not be possible") def test_blank_func_defaults(self): self.assertEqual(self.b.__defaults__, None) del self.b.__defaults__ self.assertEqual(self.b.__defaults__, None) def test_func_default_args(self): def first_func(a, b): return a+b def second_func(a=1, b=2): return a+b self.assertEqual(first_func.__defaults__, None) self.assertEqual(second_func.__defaults__, (1, 2)) first_func.__defaults__ = (1, 2) self.assertEqual(first_func.__defaults__, (1, 2)) self.assertEqual(first_func(), 3) self.assertEqual(first_func(3), 5) self.assertEqual(first_func(3, 5), 8) del second_func.__defaults__ self.assertEqual(second_func.__defaults__, None) try: second_func() except TypeError: pass else: self.fail("__defaults__ does not update; deleting it does not " "remove requirement") class InstancemethodAttrTest(FuncAttrsTest): def test___class__(self): self.assertEqual(self.fi.a.__self__.__class__, self.F) self.cannot_set_attr(self.fi.a, "__class__", self.F, TypeError) def test___func__(self): self.assertEqual(self.fi.a.__func__, self.F.a) self.cannot_set_attr(self.fi.a, "__func__", self.F.a, AttributeError) def test___self__(self): self.assertEqual(self.fi.a.__self__, self.fi) self.cannot_set_attr(self.fi.a, "__self__", self.fi, AttributeError) def test___func___non_method(self): # Behavior should be the same when a method is added via an attr # assignment self.fi.id = types.MethodType(id, self.fi) self.assertEqual(self.fi.id(), id(self.fi)) # Test usage try: self.fi.id.unknown_attr except AttributeError: pass else: self.fail("using unknown attributes should raise AttributeError") # Test assignment and deletion self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError) class ArbitraryFunctionAttrTest(FuncAttrsTest): def test_set_attr(self): self.b.known_attr = 7 self.assertEqual(self.b.known_attr, 7) try: self.fi.a.known_attr = 7 except AttributeError: pass else: self.fail("setting attributes on methods should raise error") def test_delete_unknown_attr(self): try: del self.b.unknown_attr except AttributeError: pass else: self.fail("deleting unknown attribute should raise TypeError") def test_unset_attr(self): for func in [self.b, self.fi.a]: try: func.non_existent_attr except AttributeError: pass else: self.fail("using unknown attributes should raise " "AttributeError") class FunctionDictsTest(FuncAttrsTest): def test_setting_dict_to_invalid(self): self.cannot_set_attr(self.b, '__dict__', None, TypeError) from collections import UserDict d = UserDict({'known_attr': 7}) self.cannot_set_attr(self.fi.a.__func__, '__dict__', d, TypeError) def test_setting_dict_to_valid(self): d = {'known_attr': 7} self.b.__dict__ = d # Test assignment self.assertIs(d, self.b.__dict__) # ... and on all the different ways of referencing the method's func self.F.a.__dict__ = d self.assertIs(d, self.fi.a.__func__.__dict__) self.assertIs(d, self.fi.a.__dict__) # Test value self.assertEqual(self.b.known_attr, 7) self.assertEqual(self.b.__dict__['known_attr'], 7) # ... and again, on all the different method's names self.assertEqual(self.fi.a.__func__.known_attr, 7) self.assertEqual(self.fi.a.known_attr, 7) def test_delete___dict__(self): try: del self.b.__dict__ except TypeError: pass else: self.fail("deleting function dictionary should raise TypeError") def test_unassigned_dict(self): self.assertEqual(self.b.__dict__, {}) def test_func_as_dict_key(self): value = "Some string" d = {} d[self.b] = value self.assertEqual(d[self.b], value) class FunctionDocstringTest(FuncAttrsTest): def test_set_docstring_attr(self): self.assertEqual(self.b.__doc__, None) docstr = "A test method that does nothing" self.b.__doc__ = docstr self.F.a.__doc__ = docstr self.assertEqual(self.b.__doc__, docstr) self.assertEqual(self.fi.a.__doc__, docstr) self.cannot_set_attr(self.fi.a, "__doc__", docstr, AttributeError) def test_delete_docstring(self): self.b.__doc__ = "The docstring" del self.b.__doc__ self.assertEqual(self.b.__doc__, None) def cell(value): """Create a cell containing the given value.""" def f(): print(a) a = value return f.__closure__[0] def empty_cell(empty=True): """Create an empty cell.""" def f(): print(a) # the intent of the following line is simply "if False:"; it's # spelt this way to avoid the danger that a future optimization # might simply remove an "if False:" code block. if not empty: a = 1729 return f.__closure__[0] class CellTest(unittest.TestCase): def test_comparison(self): # These tests are here simply to exercise the comparison code; # their presence should not be interpreted as providing any # guarantees about the semantics (or even existence) of cell # comparisons in future versions of CPython. self.assertTrue(cell(2) < cell(3)) self.assertTrue(empty_cell() < cell('saturday')) self.assertTrue(empty_cell() == empty_cell()) self.assertTrue(cell(-36) == cell(-36.0)) self.assertTrue(cell(True) > empty_cell()) class StaticMethodAttrsTest(unittest.TestCase): def test_func_attribute(self): def f(): pass c = classmethod(f) self.assertTrue(c.__func__ is f) s = staticmethod(f) self.assertTrue(s.__func__ is f) class BuiltinFunctionPropertiesTest(unittest.TestCase): # XXX Not sure where this should really go since I can't find a # test module specifically for builtin_function_or_method. def test_builtin__qualname__(self): import time # builtin function: self.assertEqual(len.__qualname__, 'len') self.assertEqual(time.time.__qualname__, 'time') # builtin classmethod: self.assertEqual(dict.fromkeys.__qualname__, 'dict.fromkeys') self.assertEqual(float.__getformat__.__qualname__, 'float.__getformat__') # builtin staticmethod: self.assertEqual(str.maketrans.__qualname__, 'str.maketrans') self.assertEqual(bytes.maketrans.__qualname__, 'bytes.maketrans') # builtin bound instance method: self.assertEqual([1, 2, 3].append.__qualname__, 'list.append') self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop') if __name__ == "__main__": unittest.main()
gpl-3.0
[ 646, 2943, 199, 646, 2882, 421, 199, 318, 2288, 63, 1593, 837, 272, 347, 6506, 63, 1593, 837, 267, 1021, 10111, 2543, 26, 288, 986, 267, 2288, 6506, 63, 2966, 63, 1593, 267, 347, 6506, 63, 2966, 63, 1593, 837, 288, 347, 6506, 63, 1593, 18, 837, 355, 986, 288, 372, 6506, 63, 1593, 18, 267, 372, 10111, 2543, 272, 372, 2400, 26, 6506, 63, 1593, 421, 199, 533, 28794, 21368, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1021, 481, 26, 288, 347, 282, 8, 277, 304, 355, 986, 267, 347, 330, 837, 288, 372, 650, 267, 291, 14, 329, 275, 481, 342, 267, 291, 14, 38, 275, 481, 267, 291, 14, 66, 275, 330, 339, 347, 3913, 63, 409, 63, 962, 8, 277, 12, 1559, 12, 536, 12, 574, 12, 4967, 304, 267, 862, 26, 288, 5371, 8, 1113, 12, 536, 12, 574, 9, 267, 871, 4967, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 663, 450, 83, 370, 450, 82, 2, 450, 334, 354, 12, 574, 430, 267, 862, 26, 288, 24358, 8, 1113, 12, 536, 9, 267, 871, 4967, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 2150, 450, 83, 2, 450, 536, 9, 421, 199, 533, 6801, 8516, 774, 8, 7465, 21368, 774, 304, 272, 327, 15783, 314, 5957, 3613, 1083, 626, 365, 2863, 370, 1006, 2295, 272, 347, 511, 63, 578, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 855, 578, 3108, 636, 354, 3368, 339, 347, 511, 63, 694, 63, 9441, 63, 4525, 63, 3288, 8, 277, 304, 267, 291, 14, 66, 14, 3159, 63, 962, 275, 1520, 267, 291, 14, 4080, 360, 3159, 63, 962, 297, 2935, 8, 277, 14, 66, 395, 288, 298, 409, 3004, 440, 315, 2935, 13778, 402, 1083, 531, 267, 327, 1379, 641, 8793, 805, 909, 402, 1083, 267, 291, 14, 38, 14, 65, 14, 3159, 63, 962, 275, 1520, 267, 291, 14, 4080, 360, 3159, 63, 962, 297, 2935, 8, 277, 14, 329, 14, 65, 395, 298, 409, 2225, 641, 805, 298, 2151, 298, 21463, 1298, 12, 1077, 2498, 1536, 315, 2163, 2935, 531, 339, 347, 511, 63, 11081, 63, 1593, 63, 20982, 8, 277, 304, 267, 327, 29665, 402, 658, 11081, 7, 365, 314, 5835, 2011, 465, 291, 14, 66, 267, 347, 9250, 837, 288, 283, 1662, 9214, 7, 288, 372, 650, 267, 291, 14, 7418, 8, 277, 14, 66, 12, 9250, 9, 339, 347, 511, 63, 1574, 316, 8989, 600, 721, 277, 304, 267, 347, 511, 837, 986, 267, 291, 14, 629, 8, 396, 1062, 488, 9, 267, 511, 855, 600, 363, 275, 291, 14, 66, 855, 600, 363, 267, 291, 14, 629, 8, 396, 1062, 650, 9, 327, 291, 14, 66, 3544, 2529, 650, 12, 601, 2075, 82, 11406, 339, 347, 511, 8989, 8473, 721, 277, 304, 267, 291, 14, 3436, 8, 277, 14, 66, 855, 8473, 3108, 7992, 1012, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 66, 12, 2560, 8473, 7500, 499, 12, 2490, 334, 10227, 12, 3146, 430, 339, 347, 511, 8989, 13008, 721, 277, 304, 267, 282, 275, 3144, 267, 347, 289, 837, 870, 8, 65, 9, 267, 286, 275, 289, 855, 13008, 363, 267, 291, 14, 6926, 8, 67, 12, 2008, 9, 267, 291, 14, 629, 8, 552, 8, 67, 395, 413, 9, 267, 327, 2793, 1133, 1172, 282, 730, 909, 4926, 89, 267, 291, 14, 629, 8, 67, 59, 16, 17979, 533, 4914, 354, 3108, 298, 3890, 531, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 70, 12, 4396, 13008, 13915, 286, 12, 4281, 9, 339, 347, 511, 63, 1667, 63, 3890, 8, 277, 304, 267, 347, 289, 837, 870, 8, 65, 9, 267, 862, 26, 288, 289, 855, 13008, 12298, 16, 1055, 3890, 63, 4407, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 1586, 376, 2701, 4917, 531, 267, 282, 275, 3144, 339, 347, 511, 8989, 354, 721, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 66, 358, 267, 291, 14, 66, 855, 354, 363, 275, 283, 67, 7, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 67, 358, 267, 291, 14, 66, 855, 354, 363, 275, 283, 68, 7, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 68, 358, 267, 327, 636, 354, 363, 436, 636, 354, 363, 1471, 506, 282, 1059, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 66, 12, 2560, 354, 7500, 1520, 12, 3146, 9, 267, 327, 636, 354, 363, 1471, 506, 2808, 1380, 315, 15297, 818, 14, 9434, 911, 746, 267, 327, 4281, 340, 636, 354, 363, 365, 440, 2808, 641, 289, 14, 267, 308, 275, 408, 318, 289, 837, 986, 60, 9914, 855, 354, 363, 624, 267, 2146, 8, 83, 12, 791, 363, 10372, 3706, 1052, 1552, 267, 327, 1379, 641, 3102, 12, 4634, 267, 291, 14, 629, 8, 277, 14, 329, 14, 65, 855, 354, 3108, 283, 65, 358, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 329, 14, 65, 12, 4396, 354, 13915, 283, 65, 297, 4281, 9, 339, 347, 511, 8989, 537, 354, 721, 277, 304, 267, 327, 13663, 650, 11520, 267, 291, 14, 629, 8, 277, 14, 66, 855, 537, 354, 3108, 283, 7465, 21368, 774, 14, 5996, 21455, 9350, 10827, 66, 358, 267, 291, 14, 629, 8, 7465, 21368, 774, 14, 5996, 855, 537, 354, 3108, 283, 7465, 21368, 774, 14, 5996, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 855, 537, 354, 3108, 283, 2966, 63, 1593, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593, 21455, 9350, 10827, 28, 2734, 5971, 267, 291, 14, 629, 8, 2966, 63, 1593, 342, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593, 21455, 9350, 10827, 5216, 63, 1593, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 342, 342, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593 ]
[ 2943, 199, 646, 2882, 421, 199, 318, 2288, 63, 1593, 837, 272, 347, 6506, 63, 1593, 837, 267, 1021, 10111, 2543, 26, 288, 986, 267, 2288, 6506, 63, 2966, 63, 1593, 267, 347, 6506, 63, 2966, 63, 1593, 837, 288, 347, 6506, 63, 1593, 18, 837, 355, 986, 288, 372, 6506, 63, 1593, 18, 267, 372, 10111, 2543, 272, 372, 2400, 26, 6506, 63, 1593, 421, 199, 533, 28794, 21368, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1021, 481, 26, 288, 347, 282, 8, 277, 304, 355, 986, 267, 347, 330, 837, 288, 372, 650, 267, 291, 14, 329, 275, 481, 342, 267, 291, 14, 38, 275, 481, 267, 291, 14, 66, 275, 330, 339, 347, 3913, 63, 409, 63, 962, 8, 277, 12, 1559, 12, 536, 12, 574, 12, 4967, 304, 267, 862, 26, 288, 5371, 8, 1113, 12, 536, 12, 574, 9, 267, 871, 4967, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 663, 450, 83, 370, 450, 82, 2, 450, 334, 354, 12, 574, 430, 267, 862, 26, 288, 24358, 8, 1113, 12, 536, 9, 267, 871, 4967, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 2150, 450, 83, 2, 450, 536, 9, 421, 199, 533, 6801, 8516, 774, 8, 7465, 21368, 774, 304, 272, 327, 15783, 314, 5957, 3613, 1083, 626, 365, 2863, 370, 1006, 2295, 272, 347, 511, 63, 578, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 855, 578, 3108, 636, 354, 3368, 339, 347, 511, 63, 694, 63, 9441, 63, 4525, 63, 3288, 8, 277, 304, 267, 291, 14, 66, 14, 3159, 63, 962, 275, 1520, 267, 291, 14, 4080, 360, 3159, 63, 962, 297, 2935, 8, 277, 14, 66, 395, 288, 298, 409, 3004, 440, 315, 2935, 13778, 402, 1083, 531, 267, 327, 1379, 641, 8793, 805, 909, 402, 1083, 267, 291, 14, 38, 14, 65, 14, 3159, 63, 962, 275, 1520, 267, 291, 14, 4080, 360, 3159, 63, 962, 297, 2935, 8, 277, 14, 329, 14, 65, 395, 298, 409, 2225, 641, 805, 298, 2151, 298, 21463, 1298, 12, 1077, 2498, 1536, 315, 2163, 2935, 531, 339, 347, 511, 63, 11081, 63, 1593, 63, 20982, 8, 277, 304, 267, 327, 29665, 402, 658, 11081, 7, 365, 314, 5835, 2011, 465, 291, 14, 66, 267, 347, 9250, 837, 288, 283, 1662, 9214, 7, 288, 372, 650, 267, 291, 14, 7418, 8, 277, 14, 66, 12, 9250, 9, 339, 347, 511, 63, 1574, 316, 8989, 600, 721, 277, 304, 267, 347, 511, 837, 986, 267, 291, 14, 629, 8, 396, 1062, 488, 9, 267, 511, 855, 600, 363, 275, 291, 14, 66, 855, 600, 363, 267, 291, 14, 629, 8, 396, 1062, 650, 9, 327, 291, 14, 66, 3544, 2529, 650, 12, 601, 2075, 82, 11406, 339, 347, 511, 8989, 8473, 721, 277, 304, 267, 291, 14, 3436, 8, 277, 14, 66, 855, 8473, 3108, 7992, 1012, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 66, 12, 2560, 8473, 7500, 499, 12, 2490, 334, 10227, 12, 3146, 430, 339, 347, 511, 8989, 13008, 721, 277, 304, 267, 282, 275, 3144, 267, 347, 289, 837, 870, 8, 65, 9, 267, 286, 275, 289, 855, 13008, 363, 267, 291, 14, 6926, 8, 67, 12, 2008, 9, 267, 291, 14, 629, 8, 552, 8, 67, 395, 413, 9, 267, 327, 2793, 1133, 1172, 282, 730, 909, 4926, 89, 267, 291, 14, 629, 8, 67, 59, 16, 17979, 533, 4914, 354, 3108, 298, 3890, 531, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 70, 12, 4396, 13008, 13915, 286, 12, 4281, 9, 339, 347, 511, 63, 1667, 63, 3890, 8, 277, 304, 267, 347, 289, 837, 870, 8, 65, 9, 267, 862, 26, 288, 289, 855, 13008, 12298, 16, 1055, 3890, 63, 4407, 267, 871, 1722, 26, 288, 986, 267, 587, 26, 288, 291, 14, 1633, 480, 5626, 78, 1133, 506, 7688, 370, 1586, 376, 2701, 4917, 531, 267, 282, 275, 3144, 339, 347, 511, 8989, 354, 721, 277, 304, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 66, 358, 267, 291, 14, 66, 855, 354, 363, 275, 283, 67, 7, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 67, 358, 267, 291, 14, 66, 855, 354, 363, 275, 283, 68, 7, 267, 291, 14, 629, 8, 277, 14, 66, 855, 354, 3108, 283, 68, 358, 267, 327, 636, 354, 363, 436, 636, 354, 363, 1471, 506, 282, 1059, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 66, 12, 2560, 354, 7500, 1520, 12, 3146, 9, 267, 327, 636, 354, 363, 1471, 506, 2808, 1380, 315, 15297, 818, 14, 9434, 911, 746, 267, 327, 4281, 340, 636, 354, 363, 365, 440, 2808, 641, 289, 14, 267, 308, 275, 408, 318, 289, 837, 986, 60, 9914, 855, 354, 363, 624, 267, 2146, 8, 83, 12, 791, 363, 10372, 3706, 1052, 1552, 267, 327, 1379, 641, 3102, 12, 4634, 267, 291, 14, 629, 8, 277, 14, 329, 14, 65, 855, 354, 3108, 283, 65, 358, 267, 291, 14, 11250, 63, 409, 63, 962, 8, 277, 14, 329, 14, 65, 12, 4396, 354, 13915, 283, 65, 297, 4281, 9, 339, 347, 511, 8989, 537, 354, 721, 277, 304, 267, 327, 13663, 650, 11520, 267, 291, 14, 629, 8, 277, 14, 66, 855, 537, 354, 3108, 283, 7465, 21368, 774, 14, 5996, 21455, 9350, 10827, 66, 358, 267, 291, 14, 629, 8, 7465, 21368, 774, 14, 5996, 855, 537, 354, 3108, 283, 7465, 21368, 774, 14, 5996, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 855, 537, 354, 3108, 283, 2966, 63, 1593, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593, 21455, 9350, 10827, 28, 2734, 5971, 267, 291, 14, 629, 8, 2966, 63, 1593, 342, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593, 21455, 9350, 10827, 5216, 63, 1593, 358, 267, 291, 14, 629, 8, 2966, 63, 1593, 342, 342, 11027, 537, 354, 3108, 586, 283, 2966, 63, 1593, 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, 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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 ]
thanhacun/odoo
addons/l10n_us/__init__.py
893
1045
# -*- 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/>. # ############################################################################## # 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, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
waveaccounting/vero-python
docs/conf.py
2
7941
# -*- coding: utf-8 -*- # # vero documentation build configuration file, created by # sphinx-quickstart on Tue Jul 8 11:48:42 2015. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'vero' copyright = u'2013, Wave Accounting Inc.' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1.2.0' # The full version, including alpha/beta/rc tags. release = '1.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'verodoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'vero.tex', u'vero Documentation', u'Wave Accounting Inc.', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'vero', u'vero Documentation', [u'Wave Accounting Inc.'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'vero', u'vero Documentation', u'Wave Accounting Inc.', 'vero', 'Python client for Vero', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 809, 79, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 1603, 348, 221, 1695, 4119, 26, 2006, 26, 2260, 6900, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 9064, 293, 7, 199, 7307, 275, 399, 7, 6965, 12, 644, 811, 9973, 316, 3277, 3530, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 17, 14, 18, 14, 16, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 17, 14, 18, 14, 16, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 809, 79, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 1603, 348, 221, 1695, 4119, 26, 2006, 26, 2260, 6900, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 9064, 293, 7, 199, 7307, 275, 399, 7, 6965, 12, 644, 811, 9973, 316, 3277, 3530, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 17, 14, 18, 14, 16, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 17, 14, 18, 14, 16, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 4044, 1506, 418, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 199, 199, 3, 982, 2549, 12, 4215, 3598, 465, 298, 2253, 1245, 2, 26603, 315, 314, 6137, 8247, 14, 199, 3, 3250, 63, 5451, 275, 756, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 885, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 3, 1360, 63, 7915, 63, 515, 275, 942, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 3, 1360, 63, 1213, 275, 488, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275,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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 ]
osvalr/odoo
addons/payment_transfer/models/payment_acquirer.py
203
3767
# -*- coding: utf-'8' "-*-" from openerp.addons.payment.models.payment_acquirer import ValidationError from openerp.osv import osv from openerp.tools.float_utils import float_compare from openerp.tools.translate import _ import logging import pprint _logger = logging.getLogger(__name__) class TransferPaymentAcquirer(osv.Model): _inherit = 'payment.acquirer' def _get_providers(self, cr, uid, context=None): providers = super(TransferPaymentAcquirer, self)._get_providers(cr, uid, context=context) providers.append(['transfer', 'Wire Transfer']) return providers def transfer_get_form_action_url(self, cr, uid, id, context=None): return '/payment/transfer/feedback' def _format_transfer_data(self, cr, uid, context=None): bank_ids = [bank.id for bank in self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.bank_ids] # filter only bank accounts marked as visible bank_ids = self.pool['res.partner.bank'].search(cr, uid, [('id', 'in', bank_ids), ('footer', '=', True)], context=context) accounts = self.pool['res.partner.bank'].name_get(cr, uid, bank_ids, context=context) bank_title = _('Bank Accounts') if len(accounts) > 1 else _('Bank Account') bank_accounts = ''.join(['<ul>'] + ['<li>%s</li>' % name for id, name in accounts] + ['</ul>']) post_msg = '''<div> <h3>Please use the following transfer details</h3> <h4>%(bank_title)s</h4> %(bank_accounts)s <h4>Communication</h4> <p>Please use the order name as communication reference.</p> </div>''' % { 'bank_title': bank_title, 'bank_accounts': bank_accounts, } return post_msg def create(self, cr, uid, values, context=None): """ Hook in create to create a default post_msg. This is done in create to have access to the name and other creation values. If no post_msg or a void post_msg is given at creation, generate a default one. """ if values.get('provider') == 'transfer' and not values.get('post_msg'): values['post_msg'] = self._format_transfer_data(cr, uid, context=context) return super(TransferPaymentAcquirer, self).create(cr, uid, values, context=context) class TransferPaymentTransaction(osv.Model): _inherit = 'payment.transaction' def _transfer_form_get_tx_from_data(self, cr, uid, data, context=None): reference, amount, currency_name = data.get('reference'), data.get('amount'), data.get('currency_name') tx_ids = self.search( cr, uid, [ ('reference', '=', reference), ], context=context) if not tx_ids or len(tx_ids) > 1: error_msg = 'received data for reference %s' % (pprint.pformat(reference)) if not tx_ids: error_msg += '; no order found' else: error_msg += '; multiple order found' _logger.error(error_msg) raise ValidationError(error_msg) return self.browse(cr, uid, tx_ids[0], context=context) def _transfer_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if float_compare(float(data.get('amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append(('amount', data.get('amount'), '%.2f' % tx.amount)) if data.get('currency') != tx.currency_id.name: invalid_parameters.append(('currency', data.get('currency'), tx.currency_id.name)) return invalid_parameters def _transfer_form_validate(self, cr, uid, tx, data, context=None): _logger.info('Validated transfer payment for tx %s: set as pending' % (tx.reference)) return tx.write({'state': 'pending'})
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 15668, 24, 7, 3905, 1837, 2, 199, 199, 504, 5166, 14, 10788, 14, 7948, 14, 992, 14, 7948, 63, 28729, 492, 8505, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 1609, 63, 1208, 492, 2069, 63, 5785, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 646, 2050, 199, 646, 10933, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 27507, 22374, 1945, 2272, 82, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 7948, 14, 28729, 7, 339, 347, 485, 362, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 18032, 275, 1613, 8, 11761, 22374, 1945, 2272, 82, 12, 291, 10445, 362, 63, 9710, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 18032, 14, 740, 2941, 9609, 297, 283, 25791, 27507, 1105, 267, 372, 18032, 339, 347, 9307, 63, 362, 63, 964, 63, 1287, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 1305, 12, 1067, 29, 403, 304, 267, 372, 1994, 7948, 15, 9609, 15, 13485, 7, 339, 347, 485, 908, 63, 9609, 63, 576, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 16297, 63, 1580, 275, 359, 9860, 14, 344, 367, 16297, 315, 291, 14, 2293, 459, 470, 14, 3707, 2278, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 680, 4627, 63, 344, 14, 9860, 63, 1580, 61, 267, 327, 2457, 1454, 16297, 12639, 11584, 465, 8917, 267, 16297, 63, 1580, 275, 291, 14, 2293, 459, 470, 14, 3899, 14, 9860, 2278, 1733, 8, 1556, 12, 1747, 12, 4274, 344, 297, 283, 262, 297, 16297, 63, 1580, 395, 661, 12781, 297, 6291, 715, 4360, 1067, 29, 1100, 9, 267, 12639, 275, 291, 14, 2293, 459, 470, 14, 3899, 14, 9860, 2278, 354, 63, 362, 8, 1556, 12, 1747, 12, 16297, 63, 1580, 12, 1067, 29, 1100, 9, 267, 16297, 63, 1213, 275, 4018, 14814, 4473, 6851, 358, 340, 822, 8, 8370, 9, 690, 413, 587, 4018, 14814, 9973, 358, 267, 16297, 63, 8370, 275, 6522, 904, 2941, 28, 348, 18763, 435, 12329, 317, 6598, 83, 1108, 317, 3524, 450, 536, 367, 1305, 12, 536, 315, 12639, 61, 435, 788, 1108, 348, 24782, 267, 2963, 63, 1328, 275, 28827, 3015, 30, 199, 28, 72, 19, 30, 8254, 675, 314, 2569, 9307, 2436, 1108, 72, 19, 30, 199, 28, 72, 20, 19418, 9860, 63, 1213, 9, 83, 1108, 72, 20, 30, 199, 2840, 9860, 63, 8370, 9, 83, 199, 28, 72, 20, 30, 27258, 425, 1108, 72, 20, 30, 199, 28, 80, 30, 8254, 675, 314, 1865, 536, 465, 23506, 3659, 9758, 80, 30, 199, 1108, 3015, 26934, 450, 469, 288, 283, 9860, 63, 1213, 356, 16297, 63, 1213, 12, 288, 283, 9860, 63, 8370, 356, 16297, 63, 8370, 12, 267, 789, 267, 372, 2963, 63, 1328, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 1338, 12, 1067, 29, 403, 304, 267, 408, 24837, 315, 1218, 370, 1218, 282, 849, 2963, 63, 1328, 14, 961, 365, 4224, 315, 1218, 267, 370, 1172, 2879, 370, 314, 536, 436, 1163, 7143, 1338, 14, 982, 949, 2963, 63, 1328, 267, 503, 282, 2309, 2963, 63, 1328, 365, 1627, 737, 7143, 12, 3550, 282, 849, 1373, 14, 408, 267, 340, 1338, 14, 362, 360, 3780, 358, 508, 283, 9609, 7, 436, 440, 1338, 14, 362, 360, 1932, 63, 1328, 735, 288, 1338, 459, 1932, 63, 1328, 418, 275, 291, 423, 908, 63, 9609, 63, 576, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 372, 1613, 8, 11761, 22374, 1945, 2272, 82, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 1338, 12, 1067, 29, 1100, 9, 421, 199, 533, 27507, 22374, 10161, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 7948, 14, 5945, 7, 339, 347, 485, 9609, 63, 964, 63, 362, 63, 2347, 63, 504, 63, 576, 8, 277, 12, 2467, 12, 1747, 12, 666, 12, 1067, 29, 403, 304, 267, 3659, 12, 5982, 12, 9952, 63, 354, 275, 666, 14, 362, 360, 4443, 659, 666, 14, 362, 360, 4606, 659, 666, 14, 362, 360, 4968, 63, 354, 358, 267, 4773, 63, 1580, 275, 291, 14, 1733, 8, 288, 2467, 12, 1747, 12, 359, 355, 661, 4443, 297, 6291, 3659, 395, 288, 2156, 1067, 29, 1100, 9, 398, 340, 440, 4773, 63, 1580, 503, 822, 8, 2347, 63, 1580, 9, 690, 413, 26, 288, 1125, 63, 1328, 275, 283, 9226, 666, 367, 3659, 450, 83, 7, 450, 334, 15380, 14, 24225, 8, 4443, 430, 288, 340, 440, 4773, 63, 1580, 26, 355, 1125, 63, 1328, 847, 14289, 949, 1865, 1911, 7, 288, 587, 26, 355, 1125, 63, 1328, 847, 14289, 3663, 1865, 1911, 7, 288, 485, 2921, 14, 705, 8, 705, 63, 1328, 9, 288, 746, 8505, 8, 705, 63, 1328, 9, 398, 372, 291, 14, 4570, 8, 1556, 12, 1747, 12, 4773, 63, 1580, 59, 16, 467, 1067, 29, 1100, 9, 339, 347, 485, 9609, 63, 964, 63, 362, 63, 3197, 63, 3214, 8, 277, 12, 2467, 12, 1747, 12, 4773, 12, 666, 12, 1067, 29, 403, 304, 267, 3866, 63, 3214, 275, 942, 398, 340, 2069, 63, 5785, 8, 1609, 8, 576, 14, 362, 360, 4606, 297, 283, 16, 14, 16, 3855, 4773, 14, 4606, 12, 499, 9, 1137, 378, 26, 288, 3866, 63, 3214, 14, 740, 4725, 4606, 297, 666, 14, 362, 360, 4606, 659, 22769, 18, 70, 7, 450, 4773, 14, 4606, 430, 267, 340, 666, 14, 362, 360, 4968, 358, 1137, 4773, 14, 4968, 63, 344, 14, 354, 26, 288, 3866, 63, 3214, 14, 740, 4725, 4968, 297, 666, 14, 362, 360, 4968, 659, 4773, 14, 4968, 63, 344, 14, 354, 430, 398, 372, 3866, 63, 3214, 339, 347, 485, 9609, 63, 964, 63, 3502, 8, 277, 12, 2467, 12, 1747, 12, 4773, 12, 666, 12, 1067, 29, 403, 304, 267, 485, 2921, 14, 815, 360, 3490, 972, 9307, 11628, 367, 4773, 450, 83, 26, 663, 465, 9413, 7, 450, 334, 2347, 14, 4443, 430, 267, 372, 4773, 14, 952, 3252, 929, 356, 283, 6455, 3071, 199, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 15668, 24, 7, 3905, 1837, 2, 199, 199, 504, 5166, 14, 10788, 14, 7948, 14, 992, 14, 7948, 63, 28729, 492, 8505, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 1609, 63, 1208, 492, 2069, 63, 5785, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 646, 2050, 199, 646, 10933, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 27507, 22374, 1945, 2272, 82, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 7948, 14, 28729, 7, 339, 347, 485, 362, 63, 9710, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 18032, 275, 1613, 8, 11761, 22374, 1945, 2272, 82, 12, 291, 10445, 362, 63, 9710, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 18032, 14, 740, 2941, 9609, 297, 283, 25791, 27507, 1105, 267, 372, 18032, 339, 347, 9307, 63, 362, 63, 964, 63, 1287, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 1305, 12, 1067, 29, 403, 304, 267, 372, 1994, 7948, 15, 9609, 15, 13485, 7, 339, 347, 485, 908, 63, 9609, 63, 576, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 16297, 63, 1580, 275, 359, 9860, 14, 344, 367, 16297, 315, 291, 14, 2293, 459, 470, 14, 3707, 2278, 4570, 8, 1556, 12, 1747, 12, 1747, 12, 1067, 29, 1100, 680, 4627, 63, 344, 14, 9860, 63, 1580, 61, 267, 327, 2457, 1454, 16297, 12639, 11584, 465, 8917, 267, 16297, 63, 1580, 275, 291, 14, 2293, 459, 470, 14, 3899, 14, 9860, 2278, 1733, 8, 1556, 12, 1747, 12, 4274, 344, 297, 283, 262, 297, 16297, 63, 1580, 395, 661, 12781, 297, 6291, 715, 4360, 1067, 29, 1100, 9, 267, 12639, 275, 291, 14, 2293, 459, 470, 14, 3899, 14, 9860, 2278, 354, 63, 362, 8, 1556, 12, 1747, 12, 16297, 63, 1580, 12, 1067, 29, 1100, 9, 267, 16297, 63, 1213, 275, 4018, 14814, 4473, 6851, 358, 340, 822, 8, 8370, 9, 690, 413, 587, 4018, 14814, 9973, 358, 267, 16297, 63, 8370, 275, 6522, 904, 2941, 28, 348, 18763, 435, 12329, 317, 6598, 83, 1108, 317, 3524, 450, 536, 367, 1305, 12, 536, 315, 12639, 61, 435, 788, 1108, 348, 24782, 267, 2963, 63, 1328, 275, 28827, 3015, 30, 199, 28, 72, 19, 30, 8254, 675, 314, 2569, 9307, 2436, 1108, 72, 19, 30, 199, 28, 72, 20, 19418, 9860, 63, 1213, 9, 83, 1108, 72, 20, 30, 199, 2840, 9860, 63, 8370, 9, 83, 199, 28, 72, 20, 30, 27258, 425, 1108, 72, 20, 30, 199, 28, 80, 30, 8254, 675, 314, 1865, 536, 465, 23506, 3659, 9758, 80, 30, 199, 1108, 3015, 26934, 450, 469, 288, 283, 9860, 63, 1213, 356, 16297, 63, 1213, 12, 288, 283, 9860, 63, 8370, 356, 16297, 63, 8370, 12, 267, 789, 267, 372, 2963, 63, 1328, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 1338, 12, 1067, 29, 403, 304, 267, 408, 24837, 315, 1218, 370, 1218, 282, 849, 2963, 63, 1328, 14, 961, 365, 4224, 315, 1218, 267, 370, 1172, 2879, 370, 314, 536, 436, 1163, 7143, 1338, 14, 982, 949, 2963, 63, 1328, 267, 503, 282, 2309, 2963, 63, 1328, 365, 1627, 737, 7143, 12, 3550, 282, 849, 1373, 14, 408, 267, 340, 1338, 14, 362, 360, 3780, 358, 508, 283, 9609, 7, 436, 440, 1338, 14, 362, 360, 1932, 63, 1328, 735, 288, 1338, 459, 1932, 63, 1328, 418, 275, 291, 423, 908, 63, 9609, 63, 576, 8, 1556, 12, 1747, 12, 1067, 29, 1100, 9, 267, 372, 1613, 8, 11761, 22374, 1945, 2272, 82, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 1338, 12, 1067, 29, 1100, 9, 421, 199, 533, 27507, 22374, 10161, 8, 4795, 14, 1685, 304, 272, 485, 6486, 275, 283, 7948, 14, 5945, 7, 339, 347, 485, 9609, 63, 964, 63, 362, 63, 2347, 63, 504, 63, 576, 8, 277, 12, 2467, 12, 1747, 12, 666, 12, 1067, 29, 403, 304, 267, 3659, 12, 5982, 12, 9952, 63, 354, 275, 666, 14, 362, 360, 4443, 659, 666, 14, 362, 360, 4606, 659, 666, 14, 362, 360, 4968, 63, 354, 358, 267, 4773, 63, 1580, 275, 291, 14, 1733, 8, 288, 2467, 12, 1747, 12, 359, 355, 661, 4443, 297, 6291, 3659, 395, 288, 2156, 1067, 29, 1100, 9, 398, 340, 440, 4773, 63, 1580, 503, 822, 8, 2347, 63, 1580, 9, 690, 413, 26, 288, 1125, 63, 1328, 275, 283, 9226, 666, 367, 3659, 450, 83, 7, 450, 334, 15380, 14, 24225, 8, 4443, 430, 288, 340, 440, 4773, 63, 1580, 26, 355, 1125, 63, 1328, 847, 14289, 949, 1865, 1911, 7, 288, 587, 26, 355, 1125, 63, 1328, 847, 14289, 3663, 1865, 1911, 7, 288, 485, 2921, 14, 705, 8, 705, 63, 1328, 9, 288, 746, 8505, 8, 705, 63, 1328, 9, 398, 372, 291, 14, 4570, 8, 1556, 12, 1747, 12, 4773, 63, 1580, 59, 16, 467, 1067, 29, 1100, 9, 339, 347, 485, 9609, 63, 964, 63, 362, 63, 3197, 63, 3214, 8, 277, 12, 2467, 12, 1747, 12, 4773, 12, 666, 12, 1067, 29, 403, 304, 267, 3866, 63, 3214, 275, 942, 398, 340, 2069, 63, 5785, 8, 1609, 8, 576, 14, 362, 360, 4606, 297, 283, 16, 14, 16, 3855, 4773, 14, 4606, 12, 499, 9, 1137, 378, 26, 288, 3866, 63, 3214, 14, 740, 4725, 4606, 297, 666, 14, 362, 360, 4606, 659, 22769, 18, 70, 7, 450, 4773, 14, 4606, 430, 267, 340, 666, 14, 362, 360, 4968, 358, 1137, 4773, 14, 4968, 63, 344, 14, 354, 26, 288, 3866, 63, 3214, 14, 740, 4725, 4968, 297, 666, 14, 362, 360, 4968, 659, 4773, 14, 4968, 63, 344, 14, 354, 430, 398, 372, 3866, 63, 3214, 339, 347, 485, 9609, 63, 964, 63, 3502, 8, 277, 12, 2467, 12, 1747, 12, 4773, 12, 666, 12, 1067, 29, 403, 304, 267, 485, 2921, 14, 815, 360, 3490, 972, 9307, 11628, 367, 4773, 450, 83, 26, 663, 465, 9413, 7, 450, 334, 2347, 14, 4443, 430, 267, 372, 4773, 14, 952, 3252, 929, 356, 283, 6455, 3071, 199, 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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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, 0, 0, 0, 0, 0 ]
kilon/sverchok
nodes/generator/plane.py
1
5388
# ##### BEGIN GPL LICENSE BLOCK ##### # # 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. # # 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, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### import bpy from bpy.props import BoolProperty, IntProperty, FloatProperty from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode, fullList, match_long_repeat from mathutils import Vector def make_plane(int_x, int_y, step_x, step_y, separate): vertices = [(0.0, 0.0, 0.0)] vertices_S = [] int_x = [int(int_x) if type(int_x) is not list else int(int_x[0])] int_y = [int(int_y) if type(int_y) is not list else int(int_y[0])] if type(step_x) is not list: step_x = [step_x] if type(step_y) is not list: step_y = [step_y] fullList(step_x, int_x[0]) fullList(step_y, int_y[0]) for i in range(int_x[0]-1): v = Vector(vertices[i]) + Vector((step_x[i], 0.0, 0.0)) vertices.append(v[:]) a = [int_y[0] if separate else int_y[0]-1] for i in range(a[0]): out = [] for j in range(int_x[0]): out.append(vertices[j+int_x[0]*i]) for j in out: v = Vector(j) + Vector((0.0, step_y[i], 0.0)) vertices.append(v[:]) if separate: vertices_S.append(out) edges = [] edges_S = [] for i in range(int_y[0]): for j in range(int_x[0]-1): edges.append((int_x[0]*i+j, int_x[0]*i+j+1)) if separate: out = [] for i in range(int_x[0]-1): out.append(edges[i]) edges_S.append(out) for i in range(int_y[0]-1): edges_S.append(edges_S[0]) else: for i in range(int_x[0]): for j in range(int_y[0]-1): edges.append((int_x[0]*j+i, int_x[0]*j+i+int_x[0])) polygons = [] for i in range(int_x[0]-1): for j in range(int_y[0]-1): polygons.append((int_x[0]*j+i, int_x[0]*j+i+1, int_x[0]*j+i+int_x[0]+1, int_x[0]*j+i+int_x[0])) if separate: return vertices_S, edges_S, [] else: return vertices, edges, polygons class PlaneNode(bpy.types.Node, SverchCustomTreeNode): ''' Plane ''' bl_idname = 'PlaneNode' bl_label = 'Plane' bl_icon = 'OUTLINER_OB_EMPTY' int_X = IntProperty(name='N Vert X', description='Nº Vertices X', default=2, min=2, options={'ANIMATABLE'}, update=updateNode) int_Y = IntProperty(name='N Vert Y', description='Nº Vertices Y', default=2, min=2, options={'ANIMATABLE'}, update=updateNode) step_X = FloatProperty(name='Step X', description='Step length X', default=1.0, options={'ANIMATABLE'}, update=updateNode) step_Y = FloatProperty(name='Step Y', description='Step length Y', default=1.0, options={'ANIMATABLE'}, update=updateNode) Separate = BoolProperty(name='Separate', description='Separate UV coords', default=False, update=updateNode) def sv_init(self, context): self.inputs.new('StringsSocket', "Nº Vertices X").prop_name = 'int_X' self.inputs.new('StringsSocket', "Nº Vertices Y").prop_name = 'int_Y' self.inputs.new('StringsSocket', "Step X").prop_name = 'step_X' self.inputs.new('StringsSocket', "Step Y").prop_name = 'step_Y' self.outputs.new('VerticesSocket', "Vertices") self.outputs.new('StringsSocket', "Edges") self.outputs.new('StringsSocket', "Polygons") def draw_buttons(self, context, layout): layout.prop(self, "Separate", text="Separate") def process(self): inputs = self.inputs outputs = self.outputs if not 'Polygons' in outputs: return int_x = inputs["Nº Vertices X"].sv_get() int_y = inputs["Nº Vertices Y"].sv_get() step_x = inputs["Step X"].sv_get() step_y = inputs["Step Y"].sv_get() params = match_long_repeat([int_x, int_y, step_x, step_y, [self.Separate]]) out = [a for a in (zip(*[make_plane(i_x, i_y, s_x, s_y, s) for i_x, i_y, s_x, s_y, s in zip(*params)]))] # outputs if outputs['Vertices'].is_linked: outputs['Vertices'].sv_set(out[0]) if outputs['Edges'].is_linked: outputs['Edges'].sv_set(out[1]) if outputs['Polygons'].is_linked: outputs['Polygons'].sv_set(out[2]) def update_socket(self, context): self.update() def register(): bpy.utils.register_class(PlaneNode) def unregister(): bpy.utils.unregister_class(PlaneNode)
gpl-3.0
[ 3, 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 199, 646, 20575, 199, 504, 20575, 14, 6750, 492, 19287, 3697, 12, 9805, 3697, 12, 11140, 3697, 199, 199, 504, 308, 422, 335, 745, 14, 932, 63, 2350, 492, 428, 422, 335, 7223, 26749, 199, 504, 308, 422, 335, 745, 14, 576, 63, 6976, 492, 1678, 1716, 12, 2615, 1296, 12, 1336, 63, 2809, 63, 8755, 199, 199, 504, 3473, 1208, 492, 11388, 421, 199, 318, 1852, 63, 15365, 8, 442, 63, 88, 12, 1109, 63, 89, 12, 3650, 63, 88, 12, 3650, 63, 89, 12, 7396, 304, 272, 14971, 275, 3842, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 1874, 272, 14971, 63, 51, 275, 942, 272, 1109, 63, 88, 275, 359, 442, 8, 442, 63, 88, 9, 340, 730, 8, 442, 63, 88, 9, 365, 440, 769, 587, 1109, 8, 442, 63, 88, 59, 16, 12457, 272, 1109, 63, 89, 275, 359, 442, 8, 442, 63, 89, 9, 340, 730, 8, 442, 63, 89, 9, 365, 440, 769, 587, 1109, 8, 442, 63, 89, 59, 16, 12457, 339, 340, 730, 8, 2926, 63, 88, 9, 365, 440, 769, 26, 267, 3650, 63, 88, 275, 359, 2926, 63, 88, 61, 272, 340, 730, 8, 2926, 63, 89, 9, 365, 440, 769, 26, 267, 3650, 63, 89, 275, 359, 2926, 63, 89, 61, 272, 2615, 1296, 8, 2926, 63, 88, 12, 1109, 63, 88, 59, 16, 566, 272, 2615, 1296, 8, 2926, 63, 89, 12, 1109, 63, 89, 59, 16, 566, 339, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 267, 373, 275, 11388, 8, 12637, 59, 73, 566, 435, 11388, 1332, 2926, 63, 88, 59, 73, 467, 378, 14, 16, 12, 378, 14, 16, 430, 267, 14971, 14, 740, 8, 86, 1491, 566, 339, 282, 275, 359, 442, 63, 89, 59, 16, 61, 340, 7396, 587, 1109, 63, 89, 59, 16, 11285, 17, 61, 272, 367, 284, 315, 1425, 8, 65, 59, 16, 4682, 267, 734, 275, 942, 267, 367, 1335, 315, 1425, 8, 442, 63, 88, 59, 16, 4682, 288, 734, 14, 740, 8, 12637, 59, 74, 11, 442, 63, 88, 59, 16, 3672, 73, 566, 267, 367, 1335, 315, 734, 26, 288, 373, 275, 11388, 8, 74, 9, 435, 11388, 1332, 16, 14, 16, 12, 3650, 63, 89, 59, 73, 467, 378, 14, 16, 430, 288, 14971, 14, 740, 8, 86, 1491, 566, 267, 340, 7396, 26, 288, 14971, 63, 51, 14, 740, 8, 548, 9, 339, 8207, 275, 942, 272, 8207, 63, 51, 275, 942, 272, 367, 284, 315, 1425, 8, 442, 63, 89, 59, 16, 4682, 267, 367, 1335, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 288, 8207, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 73, 11, 74, 12, 1109, 63, 88, 59, 16, 3672, 73, 11, 74, 11, 17, 430, 339, 340, 7396, 26, 267, 734, 275, 942, 267, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 288, 734, 14, 740, 8, 6929, 59, 73, 566, 267, 8207, 63, 51, 14, 740, 8, 548, 9, 267, 367, 284, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 288, 8207, 63, 51, 14, 740, 8, 6929, 63, 51, 59, 16, 566, 272, 587, 26, 267, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 4682, 288, 367, 1335, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 355, 8207, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 74, 11, 73, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2459, 339, 30658, 275, 942, 272, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 267, 367, 1335, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 288, 30658, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 74, 11, 73, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 17, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2807, 17, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2459, 339, 340, 7396, 26, 267, 372, 14971, 63, 51, 12, 8207, 63, 51, 12, 942, 272, 587, 26, 267, 372, 14971, 12, 8207, 12, 30658, 421, 199, 533, 510, 24064, 1716, 8, 66, 647, 14, 1313, 14, 1716, 12, 428, 422, 335, 7223, 26749, 304, 272, 1449, 510, 24064, 1449, 272, 6826, 63, 344, 354, 275, 283, 23363, 1716, 7, 272, 6826, 63, 1302, 275, 283, 23363, 7, 272, 6826, 63, 4677, 275, 283, 1877, 6143, 540, 63, 5488, 63, 13993, 7, 339, 1109, 63, 56, 275, 9805, 3697, 8, 354, 534, 46, 5444, 84, 1323, 297, 1369, 534, 46, 127, 119, 5444, 7724, 1323, 297, 717, 849, 29, 18, 12, 1748, 29, 18, 12, 717, 1511, 3713, 32560, 619, 2617, 2267, 1678, 29, 873, 1716, 9, 272, 1109, 63, 57, 275, 9805, 3697, 8, 354, 534, 46, 5444, 84 ]
[ 22906, 16427, 14629, 5113, 8068, 22906, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 221, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 199, 3, 221, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 3, 22906, 7729, 14629, 5113, 8068, 22906, 199, 199, 646, 20575, 199, 504, 20575, 14, 6750, 492, 19287, 3697, 12, 9805, 3697, 12, 11140, 3697, 199, 199, 504, 308, 422, 335, 745, 14, 932, 63, 2350, 492, 428, 422, 335, 7223, 26749, 199, 504, 308, 422, 335, 745, 14, 576, 63, 6976, 492, 1678, 1716, 12, 2615, 1296, 12, 1336, 63, 2809, 63, 8755, 199, 199, 504, 3473, 1208, 492, 11388, 421, 199, 318, 1852, 63, 15365, 8, 442, 63, 88, 12, 1109, 63, 89, 12, 3650, 63, 88, 12, 3650, 63, 89, 12, 7396, 304, 272, 14971, 275, 3842, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 1874, 272, 14971, 63, 51, 275, 942, 272, 1109, 63, 88, 275, 359, 442, 8, 442, 63, 88, 9, 340, 730, 8, 442, 63, 88, 9, 365, 440, 769, 587, 1109, 8, 442, 63, 88, 59, 16, 12457, 272, 1109, 63, 89, 275, 359, 442, 8, 442, 63, 89, 9, 340, 730, 8, 442, 63, 89, 9, 365, 440, 769, 587, 1109, 8, 442, 63, 89, 59, 16, 12457, 339, 340, 730, 8, 2926, 63, 88, 9, 365, 440, 769, 26, 267, 3650, 63, 88, 275, 359, 2926, 63, 88, 61, 272, 340, 730, 8, 2926, 63, 89, 9, 365, 440, 769, 26, 267, 3650, 63, 89, 275, 359, 2926, 63, 89, 61, 272, 2615, 1296, 8, 2926, 63, 88, 12, 1109, 63, 88, 59, 16, 566, 272, 2615, 1296, 8, 2926, 63, 89, 12, 1109, 63, 89, 59, 16, 566, 339, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 267, 373, 275, 11388, 8, 12637, 59, 73, 566, 435, 11388, 1332, 2926, 63, 88, 59, 73, 467, 378, 14, 16, 12, 378, 14, 16, 430, 267, 14971, 14, 740, 8, 86, 1491, 566, 339, 282, 275, 359, 442, 63, 89, 59, 16, 61, 340, 7396, 587, 1109, 63, 89, 59, 16, 11285, 17, 61, 272, 367, 284, 315, 1425, 8, 65, 59, 16, 4682, 267, 734, 275, 942, 267, 367, 1335, 315, 1425, 8, 442, 63, 88, 59, 16, 4682, 288, 734, 14, 740, 8, 12637, 59, 74, 11, 442, 63, 88, 59, 16, 3672, 73, 566, 267, 367, 1335, 315, 734, 26, 288, 373, 275, 11388, 8, 74, 9, 435, 11388, 1332, 16, 14, 16, 12, 3650, 63, 89, 59, 73, 467, 378, 14, 16, 430, 288, 14971, 14, 740, 8, 86, 1491, 566, 267, 340, 7396, 26, 288, 14971, 63, 51, 14, 740, 8, 548, 9, 339, 8207, 275, 942, 272, 8207, 63, 51, 275, 942, 272, 367, 284, 315, 1425, 8, 442, 63, 89, 59, 16, 4682, 267, 367, 1335, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 288, 8207, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 73, 11, 74, 12, 1109, 63, 88, 59, 16, 3672, 73, 11, 74, 11, 17, 430, 339, 340, 7396, 26, 267, 734, 275, 942, 267, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 288, 734, 14, 740, 8, 6929, 59, 73, 566, 267, 8207, 63, 51, 14, 740, 8, 548, 9, 267, 367, 284, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 288, 8207, 63, 51, 14, 740, 8, 6929, 63, 51, 59, 16, 566, 272, 587, 26, 267, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 4682, 288, 367, 1335, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 355, 8207, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 74, 11, 73, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2459, 339, 30658, 275, 942, 272, 367, 284, 315, 1425, 8, 442, 63, 88, 59, 16, 11285, 17, 304, 267, 367, 1335, 315, 1425, 8, 442, 63, 89, 59, 16, 11285, 17, 304, 288, 30658, 14, 740, 1332, 442, 63, 88, 59, 16, 3672, 74, 11, 73, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 17, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2807, 17, 12, 1109, 63, 88, 59, 16, 3672, 74, 11, 73, 11, 442, 63, 88, 59, 16, 2459, 339, 340, 7396, 26, 267, 372, 14971, 63, 51, 12, 8207, 63, 51, 12, 942, 272, 587, 26, 267, 372, 14971, 12, 8207, 12, 30658, 421, 199, 533, 510, 24064, 1716, 8, 66, 647, 14, 1313, 14, 1716, 12, 428, 422, 335, 7223, 26749, 304, 272, 1449, 510, 24064, 1449, 272, 6826, 63, 344, 354, 275, 283, 23363, 1716, 7, 272, 6826, 63, 1302, 275, 283, 23363, 7, 272, 6826, 63, 4677, 275, 283, 1877, 6143, 540, 63, 5488, 63, 13993, 7, 339, 1109, 63, 56, 275, 9805, 3697, 8, 354, 534, 46, 5444, 84, 1323, 297, 1369, 534, 46, 127, 119, 5444, 7724, 1323, 297, 717, 849, 29, 18, 12, 1748, 29, 18, 12, 717, 1511, 3713, 32560, 619, 2617, 2267, 1678, 29, 873, 1716, 9, 272, 1109, 63, 57, 275, 9805, 3697, 8, 354, 534, 46, 5444, 84, 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,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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 ]
bgr/mingus
unittest/test_instrument.py
12
1957
#!/usr/bin/python # -*- coding: utf-8 -*- import sys sys.path += ['../'] from mingus.containers.instrument import Instrument, Piano, Guitar from mingus.containers.note_container import NoteContainer import unittest class test_Instrument(unittest.TestCase): def setUp(self): self.i = Instrument() self.p = Piano() self.g = Guitar() self.notes = NoteContainer(['A', 'B', 'C', 'D', 'E']) self.noteslow = NoteContainer(['C-0', 'D-0', 'E-0']) self.noteshigh = NoteContainer(['A-12', 'B-12', 'C-12', 'D-12', 'E-12']) def test_note_in_range(self): for x in self.notes: self.assert_(self.i.note_in_range(x)) self.assert_(self.p.note_in_range(x)) self.assert_(self.g.note_in_range(x)) for x in self.noteslow + self.noteshigh: self.assertEqual(False, self.p.note_in_range(x), '%s should not be able to be played by a Piano' % x) self.assertEqual(False, self.g.note_in_range(x), '%s should not be able to be played by a Guitar' % x) def test_can_play_notes(self): self.assert_(self.i.can_play_notes(self.notes)) self.assert_(self.p.can_play_notes(self.notes)) self.assert_(self.g.can_play_notes(self.notes)) self.assertEqual(False, self.p.can_play_notes(self.noteslow)) self.assertEqual(False, self.g.can_play_notes(self.noteslow)) self.assertEqual(False, self.p.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(self.noteshigh)) self.assertEqual(False, self.g.can_play_notes(NoteContainer([ 'A', 'B', 'C', 'D', 'E', 'F', 'G', ]))) def suite(): return unittest.TestLoader().loadTestsFromTestCase(test_Instrument)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 984, 199, 1274, 14, 515, 847, 788, 5093, 418, 199, 504, 333, 316, 527, 14, 13577, 14, 13321, 492, 25767, 12, 510, 5653, 79, 12, 598, 4993, 285, 199, 504, 333, 316, 527, 14, 13577, 14, 4610, 63, 3600, 492, 3390, 4076, 199, 646, 2882, 421, 199, 533, 511, 63, 14915, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 73, 275, 25767, 342, 267, 291, 14, 80, 275, 510, 5653, 79, 342, 267, 291, 14, 71, 275, 598, 4993, 285, 342, 267, 291, 14, 5983, 275, 3390, 4076, 2941, 33, 297, 283, 34, 297, 283, 35, 297, 283, 36, 297, 283, 37, 1105, 267, 291, 14, 5983, 674, 275, 3390, 4076, 2941, 35, 13, 16, 297, 283, 36, 13, 16, 297, 283, 37, 13, 16, 1105, 267, 291, 14, 4610, 609, 2056, 275, 3390, 4076, 2941, 33, 13, 713, 297, 283, 34, 13, 713, 297, 283, 35, 13, 713, 297, 283, 36, 13, 713, 297, 283, 37, 13, 713, 1105, 339, 347, 511, 63, 4610, 63, 262, 63, 1842, 8, 277, 304, 267, 367, 671, 315, 291, 14, 5983, 26, 288, 291, 14, 479, 2531, 277, 14, 73, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 288, 291, 14, 479, 2531, 277, 14, 80, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 288, 291, 14, 479, 2531, 277, 14, 71, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 267, 367, 671, 315, 291, 14, 5983, 674, 435, 291, 14, 4610, 609, 2056, 26, 288, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 4610, 63, 262, 63, 1842, 8, 88, 395, 2490, 1543, 83, 1077, 440, 506, 7688, 370, 506, 5232, 379, 701, 282, 510, 5653, 79, 7, 2892, 450, 671, 9, 288, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 4610, 63, 262, 63, 1842, 8, 88, 395, 2490, 1543, 83, 1077, 440, 506, 7688, 370, 506, 5232, 379, 701, 282, 598, 4993, 285, 7, 2892, 450, 671, 9, 339, 347, 511, 63, 2425, 63, 2802, 63, 5983, 8, 277, 304, 267, 291, 14, 479, 2531, 277, 14, 73, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 479, 2531, 277, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 479, 2531, 277, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 674, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 674, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 4610, 609, 2056, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 4610, 609, 2056, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 7443, 4076, 779, 288, 283, 33, 297, 288, 283, 34, 297, 288, 283, 35, 297, 288, 283, 36, 297, 288, 283, 37, 297, 288, 283, 38, 297, 288, 283, 39, 297, 288, 1622, 1724, 421, 199, 318, 5241, 837, 272, 372, 2882, 14, 15824, 1252, 26946, 8, 396, 63, 14915, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 984, 199, 1274, 14, 515, 847, 788, 5093, 418, 199, 504, 333, 316, 527, 14, 13577, 14, 13321, 492, 25767, 12, 510, 5653, 79, 12, 598, 4993, 285, 199, 504, 333, 316, 527, 14, 13577, 14, 4610, 63, 3600, 492, 3390, 4076, 199, 646, 2882, 421, 199, 533, 511, 63, 14915, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 73, 275, 25767, 342, 267, 291, 14, 80, 275, 510, 5653, 79, 342, 267, 291, 14, 71, 275, 598, 4993, 285, 342, 267, 291, 14, 5983, 275, 3390, 4076, 2941, 33, 297, 283, 34, 297, 283, 35, 297, 283, 36, 297, 283, 37, 1105, 267, 291, 14, 5983, 674, 275, 3390, 4076, 2941, 35, 13, 16, 297, 283, 36, 13, 16, 297, 283, 37, 13, 16, 1105, 267, 291, 14, 4610, 609, 2056, 275, 3390, 4076, 2941, 33, 13, 713, 297, 283, 34, 13, 713, 297, 283, 35, 13, 713, 297, 283, 36, 13, 713, 297, 283, 37, 13, 713, 1105, 339, 347, 511, 63, 4610, 63, 262, 63, 1842, 8, 277, 304, 267, 367, 671, 315, 291, 14, 5983, 26, 288, 291, 14, 479, 2531, 277, 14, 73, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 288, 291, 14, 479, 2531, 277, 14, 80, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 288, 291, 14, 479, 2531, 277, 14, 71, 14, 4610, 63, 262, 63, 1842, 8, 88, 430, 267, 367, 671, 315, 291, 14, 5983, 674, 435, 291, 14, 4610, 609, 2056, 26, 288, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 4610, 63, 262, 63, 1842, 8, 88, 395, 2490, 1543, 83, 1077, 440, 506, 7688, 370, 506, 5232, 379, 701, 282, 510, 5653, 79, 7, 2892, 450, 671, 9, 288, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 4610, 63, 262, 63, 1842, 8, 88, 395, 2490, 1543, 83, 1077, 440, 506, 7688, 370, 506, 5232, 379, 701, 282, 598, 4993, 285, 7, 2892, 450, 671, 9, 339, 347, 511, 63, 2425, 63, 2802, 63, 5983, 8, 277, 304, 267, 291, 14, 479, 2531, 277, 14, 73, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 479, 2531, 277, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 479, 2531, 277, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 674, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 5983, 674, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 80, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 4610, 609, 2056, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 277, 14, 4610, 609, 2056, 430, 267, 291, 14, 629, 8, 797, 12, 291, 14, 71, 14, 2425, 63, 2802, 63, 5983, 8, 7443, 4076, 779, 288, 283, 33, 297, 288, 283, 34, 297, 288, 283, 35, 297, 288, 283, 36, 297, 288, 283, 37, 297, 288, 283, 38, 297, 288, 283, 39, 297, 288, 1622, 1724, 421, 199, 318, 5241, 837, 272, 372, 2882, 14, 15824, 1252, 26946, 8, 396, 63, 14915, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
wemanuel/smry
server-auth/ls/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/core/workspaces.py
4
14876
# Copyright 2013 Google Inc. All Rights Reserved. """Manage gcloud workspaces. A gcloud workspace is a directory that contains a .gcloud folder. This module does manipulations of the gcloud workspace, including creation and component importing. """ import errno import os import os.path import re import subprocess import textwrap from googlecloudsdk.core.util import compat26 from googlecloudsdk.core.util import files from googlecloudsdk.core.util import platforms import uritemplate from googlecloudsdk.core import config from googlecloudsdk.core import log from googlecloudsdk.core import properties # This regular expression is used to extract the URL of the 'origin' remote by # scraping 'git remote show origin'. _ORIGIN_URL_RE = re.compile(r'remote origin\n.*Fetch URL: (?P<url>.+)\n', re.M) # This is the minimum version of git required to use credential helpers. _HELPER_MIN = (1, 7, 9) DEFAULT_REPOSITORY_ALIAS = 'default' class Error(Exception): """Exceptions for this module.""" class UnknownRepositoryAliasException(Error): """Exception to be thrown when a repository alias provided cannot be found.""" class CannotInitRepositoryException(Error): """Exception to be thrown when a repository cannot be created.""" class CannotFetchRepositoryException(Error): """Exception to be thrown when a repository cannot be fetched.""" class NoSuchCategoryException(Error): """Exception to be thrown when a category is unknown.""" def __init__(self, category): super(NoSuchCategoryException, self).__init__( 'Unknown category "{category}".'.format(category)) self.category = category class InvalidWorkspaceException(Error): def __init__(self, path, gcloud_path): """Creates a new InvalidWorkspaceException. Used when it is impossible to create a gcloud workspace because it would be contained in another gcloud workspace. Args: path: The path that cannot be a new gcloud workspace. gcloud_path: The gcloud workspace that blocks path. """ message = ('Cannot initialize gcloud workspace in [{0}] (blocked by [{1}]).' .format(path, gcloud_path)) super(InvalidWorkspaceException, self).__init__(message) self.blocking_path = gcloud_path self.path = path class NoWorkspaceException(Error): def __init__(self, path): """Creates a new NoWorkspaceException. Used when there is no workspace at the provided path. Args: path: The path that is not in a gcloud workspace. """ message = 'Cannot find workspace in [{0}].'.format(path) super(NoWorkspaceException, self).__init__(message) self.path = path class CannotCreateWorkspaceException(Error): def __init__(self, path): """Creates a new CannotCreateWorkspaceException. Args: path: The path that cannot be used to create a gcloud workspace. """ message = 'Cannot create workspace at [{0}].'.format(path) super(CannotCreateWorkspaceException, self).__init__(message) class NoContainingWorkspaceException(Error): def __init__(self, path): """Creates a new NoContainingWorkspaceException. Args: path: The path that is not in a gcloud workspace. """ message = ('Cannot find workspace containing [{0}].' .format(path)) super(NoContainingWorkspaceException, self).__init__(message) class GitVersionException(Error): """Exceptions for when git version is too old.""" def __init__(self, fmtstr, cur_version, min_version): super(GitVersionException, self).__init__( fmtstr.format(cur_version=cur_version, min_version=min_version)) class InvalidGitException(Error): """Exceptions for when git version is empty or invalid.""" def __init__(self, message): super(InvalidGitException, self).__init__(message) def CheckGitVersion(version_lower_bound): """Returns true when version of git is >= min_version. Args: version_lower_bound: (int,int,int), The lowest allowed version. Returns: True if version >= min_version. """ try: output = compat26.subprocess.check_output(['git', 'version']) if not output: raise InvalidGitException('The git version string is empty.') if not output.startswith('git version '): raise InvalidGitException(('The git version string must start with ' 'git version .')) match = re.search(r'(\d+)\.(\d+)\.(\d+)', output) if not match: raise InvalidGitException('The git version string must contain a ' 'version number.') cur_version = match.group(1, 2, 3) current_version = tuple([int(item) for item in cur_version]) if current_version < version_lower_bound: min_version = '.'.join(str(i) for i in version_lower_bound) raise GitVersionException( ('Your git version {cur_version} is older than the minimum version ' '{min_version}. Please install a newer version of git.'), output, min_version) except OSError as e: if e.errno == errno.ENOENT: raise NoGitException() raise return True class NoGitException(Error): """Exceptions for when git is not available.""" def __init__(self): super(NoGitException, self).__init__( textwrap.dedent("""\ Cannot find git. Please install git and try again. You can find git installers at [http://git-scm.com/downloads], or use your favorite package manager to install it on your computer. """)) def EnsureGit(func): """Wrap a function that uses subprocess to invoke git, make it check for git. Args: func: func, A function that uses subprocess to invoke git. Returns: The decorated function. Raises: NoGitException: If git cannot be run. """ def GitFunc(*args, **kwargs): CheckGitVersion((0, 0, 0)) try: return func(*args, **kwargs) except OSError as e: if e.errno == errno.ENOENT: raise NoGitException() else: raise return GitFunc def _GetRepositoryURI(project, alias): """Get the URI for a repository, given its project and alias. Args: project: str, The project name. alias: str, The repository alias. Returns: str, The repository URI. Or None, if it's not a valid repository. """ if alias != DEFAULT_REPOSITORY_ALIAS: return None return uritemplate.expand( 'https://source.developers.google.com/p/{project}/r/{alias}', {'project': project, 'alias': alias}) def Create(root_directory): """Create a workspace at the provided root directory and return it. Args: root_directory: str, Where to root the new workspace. Returns: The Workspace. Raises: InvalidWorkspaceException: If the desired directory is already in an existing gcloud workspace. CannotCreateWorkspaceException: If the directory for the workspace does not exist. """ containing_workspace = files.FindDirectoryContaining( root_directory, config.Paths.CLOUDSDK_WORKSPACE_CONFIG_DIR_NAME) if containing_workspace: raise InvalidWorkspaceException(root_directory, containing_workspace) if not os.path.exists(root_directory): raise CannotCreateWorkspaceException(root_directory) workspace_config_path = os.path.join( root_directory, config.Paths.CLOUDSDK_WORKSPACE_CONFIG_DIR_NAME) files.MakeDir(workspace_config_path) log.status.write('Initialized gcloud directory in [{path}].\n'.format( path=workspace_config_path)) return Workspace(root_directory=root_directory) def FromCWD(): """Get a workspace containing the current working directory. Returns: Workspace, The Workspace object. Raises: NoContainingWorkspaceException: If no workspace can be found containing current working direction. """ workspace_dir = config.Paths().workspace_dir if not workspace_dir: raise NoContainingWorkspaceException(os.getcwd()) return Workspace(workspace_dir) class Workspace(object): """gcloud workspace. Attributes: root_directory: str, The path to the directory containing this workspace. Contains a subdirectory '.gcloud'. """ def __init__(self, root_directory): """Get an existing workspace. Args: root_directory: str, The path to the root directory, which must contain a '.gcloud' directory. Raises: NoWorkspaceException: If root_directory is not None and is not the root of a workspace. NoContainingWorkspaceException: If root_directory is None and the cwd is not contained in a workspace. """ if not os.path.isdir( os.path.join(root_directory, config.Paths.CLOUDSDK_WORKSPACE_CONFIG_DIR_NAME)): raise NoWorkspaceException(root_directory) self.root_directory = root_directory def CloneProjectRepository( self, project, alias=DEFAULT_REPOSITORY_ALIAS, uri=None): """Clone a repository associated with a Google Cloud Project. Looks up the URL of the indicated repository, and clones it to WORKSPACE/PROJECT/ALIAS. Args: project: str, The name of the project that has a repository associated with it. alias: str, The alias of the repository to clone. uri: str, The URI of the repository to clone, or None if it must be inferred from the alias. Returns: str, The relative path of the repository, from the workspace root. Raises: UnknownRepositoryAliasException: If the alias is not known to be associated with the project. """ uri = uri or _GetRepositoryURI(project, alias) if not uri: raise UnknownRepositoryAliasException() log.status.write('Cloning [{uri}] into [{path}].\n'.format( uri=uri, path=alias)) self.CloneGitRepository(uri, alias) def GetProperty(self, prop): """Get a property defined in only this workspace. Ignores the global properties, or properties defined in the workspace for your current directory. Args: prop: properties._Property, The property for which you want the value. Returns: """ # TODO(user): Update the properties package to make this easier. prop_file = os.path.join(self.root_directory, config.Paths.CLOUDSDK_WORKSPACE_CONFIG_DIR_NAME, 'properties') # pylint:disable=protected-access pfile = properties._PropertiesFile([prop_file]) return pfile.Get(prop) def SetProperty(self, prop, value): """Set a property defined in only this workspace. Ignores the global properties, or properties defined in the workspace for your current directory. Args: prop: properties._Property, The property you want to set. value: str, The value to set the property to. """ prop_file = os.path.join(self.root_directory, config.Paths.CLOUDSDK_WORKSPACE_CONFIG_DIR_NAME, 'properties') properties.PersistProperty(prop, value, properties_file=prop_file) @EnsureGit def CloneGitRepository(self, repository_url, repository_path): """Clone a git repository into a gcloud workspace. If the resulting clone does not have a .gcloud directory, create one. Also, sets the credential.helper to use the gcloud credential helper. Args: repository_url: str, The URL of the repository to clone. repository_path: str, The relative path from the root of the workspace to the repository clone. Raises: InvalidWorkspaceException: If workspace_dir_path is not a workspace. CannotInitRepositoryException: If there is already a file or directory in the way of creating this repository. CannotFetchRepositoryException: If there is a problem fetching the repository from the remote host, or if the repository is otherwise misconfigured. """ abs_repository_path = os.path.join(self.root_directory, repository_path) if os.path.exists(abs_repository_path): # First check if it's already the repository we're looking for. with files.ChDir(abs_repository_path) as _: try: output = compat26.subprocess.check_output( ['git', 'remote', 'show', 'origin']) except subprocess.CalledProcessError: raise CannotFetchRepositoryException( 'Repository in [{path}] is misconfigured.'.format( path=abs_repository_path)) output_match = _ORIGIN_URL_RE.search(output) if not output_match or output_match.group('url') != repository_url: raise CannotInitRepositoryException( ('Repository [{url}] cannot be cloned to [{path}]: there' ' is something already there.').format( url=repository_url, path=os.path.join(self.root_directory, repository_path))) else: # Repository exists and is correctly configured: abort. log.err.Print( ('Repository in [{path}] exists and is correctly configured.' .format(path=abs_repository_path))) return # Nothing is there, make a brand new repository. try: if (repository_url.startswith('https://code.google.com') or repository_url.startswith('https://source.developers.google.com')): # If this is a Google-hosted repo, clone with the cred helper. try: CheckGitVersion(_HELPER_MIN) except GitVersionException: log.warn(textwrap.dedent("""\ You are cloning a Google-hosted repository with a version of git older than 1.7.9. If you upgrade to 1.7.9 or later, gcloud can handle authentication to this repository. Otherwise, to authenticate, use your Google account and the password found by running the following command. $ gcloud auth print-refresh-token """)) subprocess.check_call( ['git', 'clone', repository_url, abs_repository_path]) else: if (platforms.OperatingSystem.Current() == platforms.OperatingSystem.WINDOWS): helper_name = 'gcloud.cmd' else: helper_name = 'gcloud.sh' subprocess.check_call( ['git', 'clone', repository_url, abs_repository_path, '--config', 'credential.helper=%s' % helper_name]) else: # Otherwise, just do a simple clone. We do this clone, without the # credential helper, because a user may have already set a default # credential helper that would know the repo's auth info. subprocess.check_call( ['git', 'clone', repository_url, abs_repository_path]) except subprocess.CalledProcessError as e: raise CannotFetchRepositoryException(e)
apache-2.0
[ 3, 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 199, 624, 20588, 486, 4091, 1736, 10749, 14, 199, 199, 33, 486, 4091, 14466, 365, 282, 2082, 626, 3509, 282, 1275, 71, 4091, 4922, 14, 961, 859, 199, 9105, 13335, 21429, 402, 314, 486, 4091, 14466, 12, 5893, 7143, 436, 3931, 199, 646, 316, 14, 199, 624, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 3873, 199, 646, 13390, 421, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 8434, 1479, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 1584, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 10677, 199, 646, 5108, 1160, 199, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 1101, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 943, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 4382, 421, 199, 3, 961, 5578, 3965, 365, 1202, 370, 5536, 314, 2851, 402, 314, 283, 6493, 7, 3982, 701, 199, 3, 4061, 1330, 316, 283, 3187, 3982, 2498, 6330, 1370, 199, 63, 24832, 63, 2632, 63, 907, 275, 295, 14, 2014, 8, 82, 3984, 2137, 6330, 60, 78, 2795, 11135, 2851, 26, 7558, 48, 28, 633, 31411, 2862, 78, 297, 295, 14, 45, 9, 199, 3, 961, 365, 314, 7481, 1015, 402, 6135, 1415, 370, 675, 16338, 10897, 14, 199, 63, 24771, 4227, 63, 4896, 275, 334, 17, 12, 1520, 12, 1749, 9, 199, 199, 3472, 63, 907, 27998, 5347, 63, 12644, 275, 283, 885, 7, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 16836, 367, 642, 859, 1041, 421, 199, 533, 14831, 15614, 14149, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 5162, 2741, 3913, 506, 1911, 1041, 421, 199, 533, 18435, 9346, 15614, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 3913, 506, 2737, 1041, 421, 199, 533, 18435, 11135, 15614, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 3913, 506, 19251, 1041, 421, 199, 533, 23798, 7841, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 4637, 365, 5809, 1041, 819, 347, 636, 826, 721, 277, 12, 4637, 304, 272, 1613, 8, 30049, 7841, 1726, 12, 291, 2843, 826, 721, 267, 283, 5912, 4637, 5310, 3710, 5469, 1370, 908, 8, 3710, 430, 272, 291, 14, 3710, 275, 4637, 421, 199, 533, 6378, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 12, 486, 4091, 63, 515, 304, 272, 408, 10607, 282, 892, 6378, 21058, 1726, 14, 339, 8051, 1380, 652, 365, 26847, 370, 1218, 282, 486, 4091, 14466, 2952, 652, 3955, 506, 272, 10470, 315, 4573, 486, 4091, 14466, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 3913, 506, 282, 892, 486, 4091, 14466, 14, 489, 486, 4091, 63, 515, 26, 710, 486, 4091, 14466, 626, 5664, 931, 14, 272, 408, 272, 1245, 275, 661, 6612, 8265, 486, 4091, 14466, 315, 8910, 16, 11049, 334, 17726, 701, 8910, 17, 29810, 3530, 2049, 1275, 908, 8, 515, 12, 486, 4091, 63, 515, 430, 272, 1613, 8, 3364, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 272, 291, 14, 13091, 63, 515, 275, 486, 4091, 63, 515, 272, 291, 14, 515, 275, 931, 421, 199, 533, 3091, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 3091, 21058, 1726, 14, 339, 8051, 1380, 2337, 365, 949, 14466, 737, 314, 2741, 931, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 365, 440, 315, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 283, 6612, 2342, 14466, 315, 8910, 16, 93, 1055, 1370, 908, 8, 515, 9, 272, 1613, 8, 1944, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 272, 291, 14, 515, 275, 931, 421, 199, 533, 18435, 2499, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 18435, 2499, 21058, 1726, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 3913, 506, 1202, 370, 1218, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 283, 6612, 1218, 14466, 737, 8910, 16, 93, 1055, 1370, 908, 8, 515, 9, 272, 1613, 8, 6612, 2499, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 533, 3091, 714, 24522, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 3091, 714, 24522, 21058, 1726, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 365, 440, 315, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 661, 6612, 2342, 14466, 3035, 8910, 16, 93, 1055, 7, 2049, 1275, 908, 8, 515, 430, 272, 1613, 8, 1944, 714, 24522, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 533, 12579, 3353, 1726, 8, 547, 304, 523, 408, 16836, 367, 1380, 6135, 1015, 365, 4634, 2269, 1041, 819, 347, 636, 826, 721, 277, 12, 7104, 495, 12, 1094, 63, 1023, 12, 1748, 63, 1023, 304, 272, 1613, 8, 14686, 3353, 1726, 12, 291, 2843, 826, 721, 267, 7104, 495, 14, 908, 8, 895, 63, 1023, 29, 895, 63, 1023, 12, 1748, 63, 1023, 29, 827, 63, 1023, 430, 421, 199, 533, 6378, 14686, 1726, 8, 547, 304, 523, 408, 16836, 367, 1380, 6135, 1015, 365, 2701, 503, 3866, 1041, 819, 347, 636, 826, 721, 277, 12, 1245, 304, 272, 1613, 8, 3364, 14686, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 318, 2670, 14686, 3353, 8, 1023, 63, 2325, 63, 3556, 304, 523, 408, 3407, 2549, 1380, 1015, 402, 6135, 365, 2356, 1748, 63, 1023, 14, 819, 3033, 26, 272, 1015, 63, 2325, 63, 3556, 26, 334, 442, 12, 442, 12, 442, 395, 710, 18966, 4370, 1015, 14, 819, 1803, 26, 272, 715, 340, 1015, 2356, 1748, 63, 1023, 14, 523, 408, 523, 862, 26, 272, 1072, 275, 8434, 1479, 14, 5781, 14, 1074, 63, 1199, 2941, 3187, 297, 283, 1023, 1105, 272, 340, 440, 1072, 26, 489, 746, 6378, 14686, 1726, 360, 1918, 6135, 1015, 1059, 365, 2701, 2659, 272, 340, 440, 1072 ]
[ 1898, 6171, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 199, 624, 20588, 486, 4091, 1736, 10749, 14, 199, 199, 33, 486, 4091, 14466, 365, 282, 2082, 626, 3509, 282, 1275, 71, 4091, 4922, 14, 961, 859, 199, 9105, 13335, 21429, 402, 314, 486, 4091, 14466, 12, 5893, 7143, 436, 3931, 199, 646, 316, 14, 199, 624, 199, 199, 646, 7554, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 3873, 199, 646, 13390, 421, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 8434, 1479, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 1584, 199, 504, 6233, 29691, 6341, 14, 1018, 14, 1974, 492, 10677, 199, 646, 5108, 1160, 199, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 1101, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 943, 199, 504, 6233, 29691, 6341, 14, 1018, 492, 4382, 421, 199, 3, 961, 5578, 3965, 365, 1202, 370, 5536, 314, 2851, 402, 314, 283, 6493, 7, 3982, 701, 199, 3, 4061, 1330, 316, 283, 3187, 3982, 2498, 6330, 1370, 199, 63, 24832, 63, 2632, 63, 907, 275, 295, 14, 2014, 8, 82, 3984, 2137, 6330, 60, 78, 2795, 11135, 2851, 26, 7558, 48, 28, 633, 31411, 2862, 78, 297, 295, 14, 45, 9, 199, 3, 961, 365, 314, 7481, 1015, 402, 6135, 1415, 370, 675, 16338, 10897, 14, 199, 63, 24771, 4227, 63, 4896, 275, 334, 17, 12, 1520, 12, 1749, 9, 199, 199, 3472, 63, 907, 27998, 5347, 63, 12644, 275, 283, 885, 7, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 16836, 367, 642, 859, 1041, 421, 199, 533, 14831, 15614, 14149, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 5162, 2741, 3913, 506, 1911, 1041, 421, 199, 533, 18435, 9346, 15614, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 3913, 506, 2737, 1041, 421, 199, 533, 18435, 11135, 15614, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 7611, 3913, 506, 19251, 1041, 421, 199, 533, 23798, 7841, 1726, 8, 547, 304, 523, 408, 1726, 370, 506, 14031, 1380, 282, 4637, 365, 5809, 1041, 819, 347, 636, 826, 721, 277, 12, 4637, 304, 272, 1613, 8, 30049, 7841, 1726, 12, 291, 2843, 826, 721, 267, 283, 5912, 4637, 5310, 3710, 5469, 1370, 908, 8, 3710, 430, 272, 291, 14, 3710, 275, 4637, 421, 199, 533, 6378, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 12, 486, 4091, 63, 515, 304, 272, 408, 10607, 282, 892, 6378, 21058, 1726, 14, 339, 8051, 1380, 652, 365, 26847, 370, 1218, 282, 486, 4091, 14466, 2952, 652, 3955, 506, 272, 10470, 315, 4573, 486, 4091, 14466, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 3913, 506, 282, 892, 486, 4091, 14466, 14, 489, 486, 4091, 63, 515, 26, 710, 486, 4091, 14466, 626, 5664, 931, 14, 272, 408, 272, 1245, 275, 661, 6612, 8265, 486, 4091, 14466, 315, 8910, 16, 11049, 334, 17726, 701, 8910, 17, 29810, 3530, 2049, 1275, 908, 8, 515, 12, 486, 4091, 63, 515, 430, 272, 1613, 8, 3364, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 272, 291, 14, 13091, 63, 515, 275, 486, 4091, 63, 515, 272, 291, 14, 515, 275, 931, 421, 199, 533, 3091, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 3091, 21058, 1726, 14, 339, 8051, 1380, 2337, 365, 949, 14466, 737, 314, 2741, 931, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 365, 440, 315, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 283, 6612, 2342, 14466, 315, 8910, 16, 93, 1055, 1370, 908, 8, 515, 9, 272, 1613, 8, 1944, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 272, 291, 14, 515, 275, 931, 421, 199, 533, 18435, 2499, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 18435, 2499, 21058, 1726, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 3913, 506, 1202, 370, 1218, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 283, 6612, 1218, 14466, 737, 8910, 16, 93, 1055, 1370, 908, 8, 515, 9, 272, 1613, 8, 6612, 2499, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 533, 3091, 714, 24522, 21058, 1726, 8, 547, 304, 819, 347, 636, 826, 721, 277, 12, 931, 304, 272, 408, 10607, 282, 892, 3091, 714, 24522, 21058, 1726, 14, 339, 3033, 26, 489, 931, 26, 710, 931, 626, 365, 440, 315, 282, 486, 4091, 14466, 14, 272, 408, 272, 1245, 275, 661, 6612, 2342, 14466, 3035, 8910, 16, 93, 1055, 7, 2049, 1275, 908, 8, 515, 430, 272, 1613, 8, 1944, 714, 24522, 21058, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 533, 12579, 3353, 1726, 8, 547, 304, 523, 408, 16836, 367, 1380, 6135, 1015, 365, 4634, 2269, 1041, 819, 347, 636, 826, 721, 277, 12, 7104, 495, 12, 1094, 63, 1023, 12, 1748, 63, 1023, 304, 272, 1613, 8, 14686, 3353, 1726, 12, 291, 2843, 826, 721, 267, 7104, 495, 14, 908, 8, 895, 63, 1023, 29, 895, 63, 1023, 12, 1748, 63, 1023, 29, 827, 63, 1023, 430, 421, 199, 533, 6378, 14686, 1726, 8, 547, 304, 523, 408, 16836, 367, 1380, 6135, 1015, 365, 2701, 503, 3866, 1041, 819, 347, 636, 826, 721, 277, 12, 1245, 304, 272, 1613, 8, 3364, 14686, 1726, 12, 291, 2843, 826, 721, 1188, 9, 421, 199, 318, 2670, 14686, 3353, 8, 1023, 63, 2325, 63, 3556, 304, 523, 408, 3407, 2549, 1380, 1015, 402, 6135, 365, 2356, 1748, 63, 1023, 14, 819, 3033, 26, 272, 1015, 63, 2325, 63, 3556, 26, 334, 442, 12, 442, 12, 442, 395, 710, 18966, 4370, 1015, 14, 819, 1803, 26, 272, 715, 340, 1015, 2356, 1748, 63, 1023, 14, 523, 408, 523, 862, 26, 272, 1072, 275, 8434, 1479, 14, 5781, 14, 1074, 63, 1199, 2941, 3187, 297, 283, 1023, 1105, 272, 340, 440, 1072, 26, 489, 746, 6378, 14686, 1726, 360, 1918, 6135, 1015, 1059, 365, 2701, 2659, 272, 340, 440, 1072, 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,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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 ]
santisiri/popego
envs/ALPHA-POPEGO/lib/python2.5/site-packages/twisted/internet/threads.py
20
1442
# Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. """Extended thread dispatching support. For basic support see reactor threading API docs. API Stability: stable Maintainer: U{Itamar Shtull-Trauring<mailto:twisted@itamarst.org>} """ # twisted imports from twisted.python import log, failure # sibling imports from twisted.internet import defer def _putResultInDeferred(deferred, f, args, kwargs): """Run a function and give results to a Deferred.""" from twisted.internet import reactor try: result = f(*args, **kwargs) except: f = failure.Failure() reactor.callFromThread(deferred.errback, f) else: reactor.callFromThread(deferred.callback, result) def deferToThread(f, *args, **kwargs): """Run function in thread and return result as Deferred.""" d = defer.Deferred() from twisted.internet import reactor reactor.callInThread(_putResultInDeferred, d, f, args, kwargs) return d def _runMultiple(tupleList): """Run a list of functions.""" for f, args, kwargs in tupleList: f(*args, **kwargs) def callMultipleInThread(tupleList): """Run a list of functions in the same thread. tupleList should be a list of (function, argsList, kwargsDict) tuples. """ from twisted.internet import reactor reactor.callInThread(_runMultiple, tupleList) __all__ = ["deferToThread", "callMultipleInThread"]
bsd-3-clause
[ 3, 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 14107, 2462, 7634, 316, 2291, 14, 199, 199, 1858, 5678, 2291, 1937, 9655, 5796, 3261, 9149, 14, 199, 199, 3735, 1933, 3616, 26, 17830, 199, 199, 11903, 8368, 281, 26, 738, 91, 7940, 455, 285, 428, 517, 979, 13, 2437, 4039, 28, 26206, 26, 12145, 32, 390, 455, 285, 270, 14, 1308, 23307, 199, 624, 199, 199, 3, 7390, 8925, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 199, 199, 3, 24238, 8925, 199, 504, 7390, 14, 4901, 492, 10133, 421, 199, 318, 485, 524, 2889, 607, 9937, 8, 12116, 12, 289, 12, 1249, 12, 2074, 304, 272, 408, 2540, 282, 805, 436, 8120, 2058, 370, 282, 17448, 1041, 272, 687, 7390, 14, 4901, 492, 9655, 272, 862, 26, 267, 754, 275, 289, 2031, 589, 12, 1011, 958, 9, 272, 871, 26, 267, 289, 275, 5988, 14, 6782, 342, 267, 9655, 14, 1250, 2532, 4436, 8, 12116, 14, 28940, 12, 289, 9, 272, 587, 26, 267, 9655, 14, 1250, 2532, 4436, 8, 12116, 14, 3058, 12, 754, 9, 199, 199, 318, 10133, 1378, 4436, 8, 70, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 2540, 805, 315, 2462, 436, 372, 754, 465, 17448, 1041, 272, 366, 275, 10133, 14, 9937, 342, 272, 687, 7390, 14, 4901, 492, 9655, 272, 9655, 14, 1250, 607, 4436, 1547, 524, 2889, 607, 9937, 12, 366, 12, 289, 12, 1249, 12, 2074, 9, 272, 372, 366, 421, 199, 318, 485, 1065, 8433, 8, 2960, 1296, 304, 272, 408, 2540, 282, 769, 402, 3423, 1041, 272, 367, 289, 12, 1249, 12, 2074, 315, 2008, 1296, 26, 267, 289, 2031, 589, 12, 1011, 958, 9, 199, 199, 318, 1240, 8433, 607, 4436, 8, 2960, 1296, 304, 272, 408, 2540, 282, 769, 402, 3423, 315, 314, 2011, 2462, 14, 339, 2008, 1296, 1077, 506, 282, 769, 402, 334, 1593, 12, 1249, 1296, 12, 2074, 2141, 9, 6346, 14, 272, 408, 272, 687, 7390, 14, 4901, 492, 9655, 272, 9655, 14, 1250, 607, 4436, 1547, 1065, 8433, 12, 2008, 1296, 9, 421, 199, 363, 452, 363, 275, 2097, 11610, 1378, 4436, 401, 298, 1250, 8433, 607, 4436, 937, 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 ]
[ 1898, 334, 67, 9, 12521, 13, 15431, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 14107, 2462, 7634, 316, 2291, 14, 199, 199, 1858, 5678, 2291, 1937, 9655, 5796, 3261, 9149, 14, 199, 199, 3735, 1933, 3616, 26, 17830, 199, 199, 11903, 8368, 281, 26, 738, 91, 7940, 455, 285, 428, 517, 979, 13, 2437, 4039, 28, 26206, 26, 12145, 32, 390, 455, 285, 270, 14, 1308, 23307, 199, 624, 199, 199, 3, 7390, 8925, 199, 504, 7390, 14, 1548, 492, 943, 12, 5988, 199, 199, 3, 24238, 8925, 199, 504, 7390, 14, 4901, 492, 10133, 421, 199, 318, 485, 524, 2889, 607, 9937, 8, 12116, 12, 289, 12, 1249, 12, 2074, 304, 272, 408, 2540, 282, 805, 436, 8120, 2058, 370, 282, 17448, 1041, 272, 687, 7390, 14, 4901, 492, 9655, 272, 862, 26, 267, 754, 275, 289, 2031, 589, 12, 1011, 958, 9, 272, 871, 26, 267, 289, 275, 5988, 14, 6782, 342, 267, 9655, 14, 1250, 2532, 4436, 8, 12116, 14, 28940, 12, 289, 9, 272, 587, 26, 267, 9655, 14, 1250, 2532, 4436, 8, 12116, 14, 3058, 12, 754, 9, 199, 199, 318, 10133, 1378, 4436, 8, 70, 12, 627, 589, 12, 1011, 958, 304, 272, 408, 2540, 805, 315, 2462, 436, 372, 754, 465, 17448, 1041, 272, 366, 275, 10133, 14, 9937, 342, 272, 687, 7390, 14, 4901, 492, 9655, 272, 9655, 14, 1250, 607, 4436, 1547, 524, 2889, 607, 9937, 12, 366, 12, 289, 12, 1249, 12, 2074, 9, 272, 372, 366, 421, 199, 318, 485, 1065, 8433, 8, 2960, 1296, 304, 272, 408, 2540, 282, 769, 402, 3423, 1041, 272, 367, 289, 12, 1249, 12, 2074, 315, 2008, 1296, 26, 267, 289, 2031, 589, 12, 1011, 958, 9, 199, 199, 318, 1240, 8433, 607, 4436, 8, 2960, 1296, 304, 272, 408, 2540, 282, 769, 402, 3423, 315, 314, 2011, 2462, 14, 339, 2008, 1296, 1077, 506, 282, 769, 402, 334, 1593, 12, 1249, 1296, 12, 2074, 2141, 9, 6346, 14, 272, 408, 272, 687, 7390, 14, 4901, 492, 9655, 272, 9655, 14, 1250, 607, 4436, 1547, 1065, 8433, 12, 2008, 1296, 9, 421, 199, 363, 452, 363, 275, 2097, 11610, 1378, 4436, 401, 298, 1250, 8433, 607, 4436, 937, 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, 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 ]
nekulin/arangodb
3rdParty/V8-4.3.61/third_party/python_26/Tools/scripts/finddiv.py
102
2518
#! /usr/bin/env python """finddiv - a grep-like tool that looks for division operators. Usage: finddiv [-l] file_or_directory ... For directory arguments, all files in the directory whose name ends in .py are processed, and subdirectories are processed recursively. This actually tokenizes the files to avoid false hits in comments or strings literals. By default, this prints all lines containing a / or /= operator, in grep -n style. With the -l option specified, it prints the filename of files that contain at least one / or /= operator. """ import os import sys import getopt import tokenize def main(): try: opts, args = getopt.getopt(sys.argv[1:], "lh") except getopt.error, msg: usage(msg) return 2 if not args: usage("at least one file argument is required") return 2 listnames = 0 for o, a in opts: if o == "-h": print __doc__ return if o == "-l": listnames = 1 exit = None for filename in args: x = process(filename, listnames) exit = exit or x return exit def usage(msg): sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Usage: %s [-l] file ...\n" % sys.argv[0]) sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) def process(filename, listnames): if os.path.isdir(filename): return processdir(filename, listnames) try: fp = open(filename) except IOError, msg: sys.stderr.write("Can't open: %s\n" % msg) return 1 g = tokenize.generate_tokens(fp.readline) lastrow = None for type, token, (row, col), end, line in g: if token in ("/", "/="): if listnames: print filename break if row != lastrow: lastrow = row print "%s:%d:%s" % (filename, row, line), fp.close() def processdir(dir, listnames): try: names = os.listdir(dir) except os.error, msg: sys.stderr.write("Can't list directory: %s\n" % dir) return 1 files = [] for name in names: fn = os.path.join(dir, name) if os.path.normcase(fn).endswith(".py") or os.path.isdir(fn): files.append(fn) files.sort(lambda a, b: cmp(os.path.normcase(a), os.path.normcase(b))) exit = None for fn in files: x = process(fn, listnames) exit = exit or x return exit if __name__ == "__main__": sys.exit(main())
apache-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 1623, 3015, 446, 282, 20595, 13, 2930, 4744, 626, 10734, 367, 4629, 10211, 14, 199, 199, 7692, 26, 2342, 3015, 5243, 76, 61, 570, 63, 269, 63, 3619, 2263, 199, 199, 1858, 2082, 2368, 12, 1006, 1584, 315, 314, 2082, 7447, 536, 11187, 315, 199, 14, 647, 787, 7686, 12, 436, 24799, 787, 7686, 15035, 14, 199, 199, 2765, 5965, 1526, 6491, 314, 1584, 370, 5126, 3055, 19745, 315, 6786, 503, 199, 5465, 18041, 14, 199, 199, 2175, 849, 12, 642, 14767, 1006, 2385, 3035, 282, 1182, 503, 12257, 4182, 12, 315, 199, 25914, 446, 78, 3449, 14, 221, 8777, 314, 446, 76, 945, 2013, 12, 652, 14767, 314, 1788, 199, 1618, 1584, 626, 1395, 737, 5210, 1373, 1182, 503, 12257, 4182, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 13343, 199, 199, 318, 2446, 837, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 298, 25514, 531, 272, 871, 12733, 14, 705, 12, 1499, 26, 267, 4503, 8, 1328, 9, 267, 372, 499, 272, 340, 440, 1249, 26, 267, 4503, 480, 292, 5210, 1373, 570, 1423, 365, 1415, 531, 267, 372, 499, 272, 769, 1247, 275, 378, 272, 367, 312, 12, 282, 315, 3999, 26, 267, 340, 312, 508, 3905, 72, 582, 288, 870, 636, 1301, 363, 288, 372, 267, 340, 312, 508, 3905, 76, 582, 288, 769, 1247, 275, 413, 272, 4458, 275, 488, 272, 367, 1788, 315, 1249, 26, 267, 671, 275, 2112, 8, 1501, 12, 769, 1247, 9, 267, 4458, 275, 4458, 503, 671, 272, 372, 4458, 199, 199, 318, 4503, 8, 1328, 304, 272, 984, 14, 3083, 14, 952, 3647, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 1499, 430, 272, 984, 14, 3083, 14, 952, 480, 7692, 26, 450, 83, 5243, 76, 61, 570, 2263, 60, 78, 2, 450, 984, 14, 3020, 59, 16, 566, 272, 984, 14, 3083, 14, 952, 480, 12357, 18633, 83, 446, 72, 7, 367, 1655, 2556, 3134, 78, 2, 450, 984, 14, 3020, 59, 16, 566, 199, 199, 318, 2112, 8, 1501, 12, 769, 1247, 304, 272, 340, 747, 14, 515, 14, 6027, 8, 1501, 304, 267, 372, 2112, 694, 8, 1501, 12, 769, 1247, 9, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 12, 1499, 26, 267, 984, 14, 3083, 14, 952, 480, 6049, 1133, 1551, 26, 450, 83, 60, 78, 2, 450, 1499, 9, 267, 372, 413, 272, 486, 275, 13343, 14, 4208, 63, 4504, 8, 3997, 14, 6407, 9, 272, 2061, 1143, 275, 488, 272, 367, 730, 12, 1526, 12, 334, 1143, 12, 1048, 395, 1284, 12, 1004, 315, 486, 26, 267, 340, 1526, 315, 1689, 10665, 3286, 628, 304, 288, 340, 769, 1247, 26, 355, 870, 1788, 355, 2059, 288, 340, 1962, 1137, 2061, 1143, 26, 355, 2061, 1143, 275, 1962, 355, 870, 2071, 83, 2689, 68, 2689, 83, 2, 450, 334, 1501, 12, 1962, 12, 1004, 395, 272, 4090, 14, 1600, 342, 199, 199, 318, 2112, 694, 8, 694, 12, 769, 1247, 304, 272, 862, 26, 267, 1561, 275, 747, 14, 7374, 8, 694, 9, 272, 871, 747, 14, 705, 12, 1499, 26, 267, 984, 14, 3083, 14, 952, 480, 6049, 1133, 769, 2082, 26, 450, 83, 60, 78, 2, 450, 2935, 9, 267, 372, 413, 272, 1584, 275, 942, 272, 367, 536, 315, 1561, 26, 267, 4325, 275, 747, 14, 515, 14, 904, 8, 694, 12, 536, 9, 267, 340, 747, 14, 515, 14, 21288, 8, 2324, 680, 4130, 9520, 647, 531, 503, 747, 14, 515, 14, 6027, 8, 2324, 304, 288, 1584, 14, 740, 8, 2324, 9, 272, 1584, 14, 3191, 8, 2734, 282, 12, 330, 26, 10467, 8, 736, 14, 515, 14, 21288, 8, 65, 395, 747, 14, 515, 14, 21288, 8, 66, 1724, 272, 4458, 275, 488, 272, 367, 4325, 315, 1584, 26, 267, 671, 275, 2112, 8, 2324, 12, 769, 1247, 9, 267, 4458, 275, 4458, 503, 671, 272, 372, 4458, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 984, 14, 2224, 8, 973, 1012, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 1623, 3015, 446, 282, 20595, 13, 2930, 4744, 626, 10734, 367, 4629, 10211, 14, 199, 199, 7692, 26, 2342, 3015, 5243, 76, 61, 570, 63, 269, 63, 3619, 2263, 199, 199, 1858, 2082, 2368, 12, 1006, 1584, 315, 314, 2082, 7447, 536, 11187, 315, 199, 14, 647, 787, 7686, 12, 436, 24799, 787, 7686, 15035, 14, 199, 199, 2765, 5965, 1526, 6491, 314, 1584, 370, 5126, 3055, 19745, 315, 6786, 503, 199, 5465, 18041, 14, 199, 199, 2175, 849, 12, 642, 14767, 1006, 2385, 3035, 282, 1182, 503, 12257, 4182, 12, 315, 199, 25914, 446, 78, 3449, 14, 221, 8777, 314, 446, 76, 945, 2013, 12, 652, 14767, 314, 1788, 199, 1618, 1584, 626, 1395, 737, 5210, 1373, 1182, 503, 12257, 4182, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 646, 13343, 199, 199, 318, 2446, 837, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 298, 25514, 531, 272, 871, 12733, 14, 705, 12, 1499, 26, 267, 4503, 8, 1328, 9, 267, 372, 499, 272, 340, 440, 1249, 26, 267, 4503, 480, 292, 5210, 1373, 570, 1423, 365, 1415, 531, 267, 372, 499, 272, 769, 1247, 275, 378, 272, 367, 312, 12, 282, 315, 3999, 26, 267, 340, 312, 508, 3905, 72, 582, 288, 870, 636, 1301, 363, 288, 372, 267, 340, 312, 508, 3905, 76, 582, 288, 769, 1247, 275, 413, 272, 4458, 275, 488, 272, 367, 1788, 315, 1249, 26, 267, 671, 275, 2112, 8, 1501, 12, 769, 1247, 9, 267, 4458, 275, 4458, 503, 671, 272, 372, 4458, 199, 199, 318, 4503, 8, 1328, 304, 272, 984, 14, 3083, 14, 952, 3647, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 1499, 430, 272, 984, 14, 3083, 14, 952, 480, 7692, 26, 450, 83, 5243, 76, 61, 570, 2263, 60, 78, 2, 450, 984, 14, 3020, 59, 16, 566, 272, 984, 14, 3083, 14, 952, 480, 12357, 18633, 83, 446, 72, 7, 367, 1655, 2556, 3134, 78, 2, 450, 984, 14, 3020, 59, 16, 566, 199, 199, 318, 2112, 8, 1501, 12, 769, 1247, 304, 272, 340, 747, 14, 515, 14, 6027, 8, 1501, 304, 267, 372, 2112, 694, 8, 1501, 12, 769, 1247, 9, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 12, 1499, 26, 267, 984, 14, 3083, 14, 952, 480, 6049, 1133, 1551, 26, 450, 83, 60, 78, 2, 450, 1499, 9, 267, 372, 413, 272, 486, 275, 13343, 14, 4208, 63, 4504, 8, 3997, 14, 6407, 9, 272, 2061, 1143, 275, 488, 272, 367, 730, 12, 1526, 12, 334, 1143, 12, 1048, 395, 1284, 12, 1004, 315, 486, 26, 267, 340, 1526, 315, 1689, 10665, 3286, 628, 304, 288, 340, 769, 1247, 26, 355, 870, 1788, 355, 2059, 288, 340, 1962, 1137, 2061, 1143, 26, 355, 2061, 1143, 275, 1962, 355, 870, 2071, 83, 2689, 68, 2689, 83, 2, 450, 334, 1501, 12, 1962, 12, 1004, 395, 272, 4090, 14, 1600, 342, 199, 199, 318, 2112, 694, 8, 694, 12, 769, 1247, 304, 272, 862, 26, 267, 1561, 275, 747, 14, 7374, 8, 694, 9, 272, 871, 747, 14, 705, 12, 1499, 26, 267, 984, 14, 3083, 14, 952, 480, 6049, 1133, 769, 2082, 26, 450, 83, 60, 78, 2, 450, 2935, 9, 267, 372, 413, 272, 1584, 275, 942, 272, 367, 536, 315, 1561, 26, 267, 4325, 275, 747, 14, 515, 14, 904, 8, 694, 12, 536, 9, 267, 340, 747, 14, 515, 14, 21288, 8, 2324, 680, 4130, 9520, 647, 531, 503, 747, 14, 515, 14, 6027, 8, 2324, 304, 288, 1584, 14, 740, 8, 2324, 9, 272, 1584, 14, 3191, 8, 2734, 282, 12, 330, 26, 10467, 8, 736, 14, 515, 14, 21288, 8, 65, 395, 747, 14, 515, 14, 21288, 8, 66, 1724, 272, 4458, 275, 488, 272, 367, 4325, 315, 1584, 26, 267, 671, 275, 2112, 8, 2324, 12, 769, 1247, 9, 267, 4458, 275, 4458, 503, 671, 272, 372, 4458, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 984, 14, 2224, 8, 973, 1012, 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, 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, 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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 ]
evanma92/routeh
flask/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py
153
9905
'''SSL with SNI_-support for Python 2. Follow these instructions if you would like to verify SSL certificates in Python 2. Note, the default libraries do *not* do certificate checking; you need to do additional work to validate certificates yourself. This needs the following packages installed: * pyOpenSSL (tested with 0.13) * ndg-httpsclient (tested with 0.3.2) * pyasn1 (tested with 0.1.6) You can install them with the following command: pip install pyopenssl ndg-httpsclient pyasn1 To activate certificate checking, call :func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code before you begin making HTTP requests. This can be done in a ``sitecustomize`` module, or at any other time before your application begins using ``urllib3``, like this:: try: import urllib3.contrib.pyopenssl urllib3.contrib.pyopenssl.inject_into_urllib3() except ImportError: pass Now you can use :mod:`urllib3` as you normally would, and it will support SNI when the required modules are installed. Activating this module also has the positive side effect of disabling SSL/TLS compression in Python 2 (see `CRIME attack`_). If you want to configure the default list of supported cipher suites, you can set the ``urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST`` variable. Module Variables ---------------- :var DEFAULT_SSL_CIPHER_LIST: The list of supported SSL/TLS cipher suites. Default: ``ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES: ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS`` .. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication .. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit) ''' try: from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT from ndg.httpsclient.subj_alt_name import SubjectAltName as BaseSubjectAltName except SyntaxError as e: raise ImportError(e) import OpenSSL.SSL from pyasn1.codec.der import decoder as der_decoder from pyasn1.type import univ, constraint from socket import _fileobject, timeout import ssl import select from .. import connection from .. import util __all__ = ['inject_into_urllib3', 'extract_from_urllib3'] # SNI only *really* works if we can read the subjectAltName of certificates. HAS_SNI = SUBJ_ALT_NAME_SUPPORT # Map from urllib3 to PyOpenSSL compatible parameter-values. _openssl_versions = { ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD, ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD, } try: _openssl_versions.update({ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD}) except AttributeError: pass _openssl_verify = { ssl.CERT_NONE: OpenSSL.SSL.VERIFY_NONE, ssl.CERT_OPTIONAL: OpenSSL.SSL.VERIFY_PEER, ssl.CERT_REQUIRED: OpenSSL.SSL.VERIFY_PEER + OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT, } # A secure default. # Sources for more information on TLS ciphers: # # - https://wiki.mozilla.org/Security/Server_Side_TLS # - https://www.ssllabs.com/projects/best-practices/index.html # - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ # # The general intent is: # - Prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE), # - prefer ECDHE over DHE for better performance, # - prefer any AES-GCM over any AES-CBC for better performance and security, # - use 3DES as fallback which is secure but slow, # - disable NULL authentication, MD5 MACs and DSS for security reasons. DEFAULT_SSL_CIPHER_LIST = "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:" + \ "ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:" + \ "!aNULL:!MD5:!DSS" orig_util_HAS_SNI = util.HAS_SNI orig_connection_ssl_wrap_socket = connection.ssl_wrap_socket def inject_into_urllib3(): 'Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.' connection.ssl_wrap_socket = ssl_wrap_socket util.HAS_SNI = HAS_SNI def extract_from_urllib3(): 'Undo monkey-patching by :func:`inject_into_urllib3`.' connection.ssl_wrap_socket = orig_connection_ssl_wrap_socket util.HAS_SNI = orig_util_HAS_SNI ### Note: This is a slightly bug-fixed version of same from ndg-httpsclient. class SubjectAltName(BaseSubjectAltName): '''ASN.1 implementation for subjectAltNames support''' # There is no limit to how many SAN certificates a certificate may have, # however this needs to have some limit so we'll set an arbitrarily high # limit. sizeSpec = univ.SequenceOf.sizeSpec + \ constraint.ValueSizeConstraint(1, 1024) ### Note: This is a slightly bug-fixed version of same from ndg-httpsclient. def get_subj_alt_name(peer_cert): # Search through extensions dns_name = [] if not SUBJ_ALT_NAME_SUPPORT: return dns_name general_names = SubjectAltName() for i in range(peer_cert.get_extension_count()): ext = peer_cert.get_extension(i) ext_name = ext.get_short_name() if ext_name != 'subjectAltName': continue # PyOpenSSL returns extension data in ASN.1 encoded form ext_dat = ext.get_data() decoded_dat = der_decoder.decode(ext_dat, asn1Spec=general_names) for name in decoded_dat: if not isinstance(name, SubjectAltName): continue for entry in range(len(name)): component = name.getComponentByPosition(entry) if component.getName() != 'dNSName': continue dns_name.append(str(component.getComponent())) return dns_name class WrappedSocket(object): '''API-compatibility wrapper for Python OpenSSL's Connection-class. Note: _makefile_refs, _drop() and _reuse() are needed for the garbage collector of pypy. ''' def __init__(self, connection, socket, suppress_ragged_eofs=True): self.connection = connection self.socket = socket self.suppress_ragged_eofs = suppress_ragged_eofs self._makefile_refs = 0 def fileno(self): return self.socket.fileno() def makefile(self, mode, bufsize=-1): self._makefile_refs += 1 return _fileobject(self, mode, bufsize, close=True) def recv(self, *args, **kwargs): try: data = self.connection.recv(*args, **kwargs) except OpenSSL.SSL.SysCallError as e: if self.suppress_ragged_eofs and e.args == (-1, 'Unexpected EOF'): return b'' else: raise except OpenSSL.SSL.WantReadError: rd, wd, ed = select.select( [self.socket], [], [], self.socket.gettimeout()) if not rd: raise timeout('The read operation timed out') else: return self.recv(*args, **kwargs) else: return data def settimeout(self, timeout): return self.socket.settimeout(timeout) def _send_until_done(self, data): while True: try: return self.connection.send(data) except OpenSSL.SSL.WantWriteError: _, wlist, _ = select.select([], [self.socket], [], self.socket.gettimeout()) if not wlist: raise timeout() continue def sendall(self, data): while len(data): sent = self._send_until_done(data) data = data[sent:] def close(self): if self._makefile_refs < 1: return self.connection.shutdown() else: self._makefile_refs -= 1 def getpeercert(self, binary_form=False): x509 = self.connection.get_peer_certificate() if not x509: return x509 if binary_form: return OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_ASN1, x509) return { 'subject': ( (('commonName', x509.get_subject().CN),), ), 'subjectAltName': [ ('DNS', value) for value in get_subj_alt_name(x509) ] } def _reuse(self): self._makefile_refs += 1 def _drop(self): if self._makefile_refs < 1: self.close() else: self._makefile_refs -= 1 def _verify_callback(cnx, x509, err_no, err_depth, return_code): return err_no == 0 def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None): ctx = OpenSSL.SSL.Context(_openssl_versions[ssl_version]) if certfile: keyfile = keyfile or certfile # Match behaviour of the normal python ssl library ctx.use_certificate_file(certfile) if keyfile: ctx.use_privatekey_file(keyfile) if cert_reqs != ssl.CERT_NONE: ctx.set_verify(_openssl_verify[cert_reqs], _verify_callback) if ca_certs: try: ctx.load_verify_locations(ca_certs, None) except OpenSSL.SSL.Error as e: raise ssl.SSLError('bad ca_certs: %r' % ca_certs, e) else: ctx.set_default_verify_paths() # Disable TLS compression to migitate CRIME attack (issue #309) OP_NO_COMPRESSION = 0x20000 ctx.set_options(OP_NO_COMPRESSION) # Set list of supported ciphersuites. ctx.set_cipher_list(DEFAULT_SSL_CIPHER_LIST) cnx = OpenSSL.SSL.Connection(ctx, sock) cnx.set_tlsext_host_name(server_hostname) cnx.set_connect_state() while True: try: cnx.do_handshake() except OpenSSL.SSL.WantReadError: select.select([sock], [], []) continue except OpenSSL.SSL.Error as e: raise ssl.SSLError('bad handshake', e) break return WrappedSocket(cnx, sock)
bsd-3-clause
[ 2344, 5413, 543, 428, 16730, 32069, 4058, 367, 2018, 499, 14, 21876, 3520, 15794, 340, 1265, 3955, 199, 2930, 370, 4911, 7799, 14512, 315, 2018, 499, 14, 3390, 12, 314, 849, 8363, 886, 199, 10, 1397, 10, 886, 5897, 7907, 27, 1265, 1929, 370, 886, 4722, 1736, 370, 4107, 199, 16159, 28225, 14, 199, 199, 2765, 4839, 314, 2569, 6117, 4903, 26, 199, 199, 10, 1134, 22791, 334, 10453, 543, 378, 14, 969, 9, 199, 10, 5222, 71, 13, 1014, 551, 864, 334, 10453, 543, 378, 14, 19, 14, 18, 9, 199, 10, 1134, 6228, 17, 334, 10453, 543, 378, 14, 17, 14, 22, 9, 199, 199, 5556, 883, 3907, 3062, 543, 314, 2569, 1414, 26, 339, 7305, 3907, 1134, 14837, 5222, 71, 13, 1014, 551, 864, 1134, 6228, 17, 199, 199, 1378, 15422, 5897, 7907, 12, 1240, 199, 26, 1532, 6054, 4078, 19, 14, 2828, 14, 647, 14837, 14, 14815, 63, 9924, 63, 4078, 19, 64, 687, 2195, 2018, 1233, 199, 5182, 1265, 5386, 10663, 3101, 4145, 14, 961, 883, 506, 4224, 315, 282, 1124, 2124, 26660, 1040, 199, 578, 12, 503, 737, 1263, 1163, 900, 2544, 2195, 4223, 22241, 1808, 1124, 4078, 19, 4542, 199, 2930, 642, 447, 339, 862, 26, 267, 492, 4011, 19, 14, 2828, 14, 647, 14837, 267, 4011, 19, 14, 2828, 14, 647, 14837, 14, 14815, 63, 9924, 63, 4078, 19, 342, 272, 871, 3545, 26, 267, 986, 199, 199, 14351, 1265, 883, 675, 520, 1494, 1705, 4078, 19, 64, 465, 1265, 12252, 3955, 12, 436, 652, 911, 2291, 428, 16730, 199, 6526, 314, 1415, 4621, 787, 4903, 14, 199, 199, 13767, 86, 1958, 642, 859, 2597, 965, 314, 7317, 5366, 7763, 402, 30723, 7799, 15, 10224, 199, 12849, 315, 2018, 499, 334, 3239, 658, 2944, 3465, 23326, 18417, 680, 199, 199, 3917, 1265, 2934, 370, 7908, 314, 849, 769, 402, 3748, 10830, 24203, 12, 1265, 883, 199, 409, 314, 1124, 4078, 19, 14, 2828, 14, 647, 14837, 14, 3472, 63, 5413, 63, 35, 1772, 3452, 63, 4924, 1040, 1750, 14, 199, 199, 2377, 17198, 199, 777, 199, 199, 26, 1391, 6186, 63, 5413, 63, 35, 1772, 3452, 63, 4924, 26, 710, 769, 402, 3748, 7799, 15, 10224, 10830, 24203, 14, 272, 3758, 26, 1124, 4220, 13860, 11, 14494, 29009, 26, 13860, 11, 14494, 29009, 26, 4220, 13860, 11, 14494, 3912, 26, 13860, 11, 14494, 3912, 26, 4220, 13860, 11, 14494, 3933, 26, 13860, 11, 14494, 26, 272, 662, 7695, 40, 11, 19, 4448, 26, 13860, 11, 19, 4448, 26, 12115, 11, 14494, 29009, 26, 12115, 11, 14494, 26, 12115, 11, 19, 4448, 26, 1, 65, 8084, 26, 1, 5127, 21, 26, 1, 36, 2300, 1040, 199, 199, 703, 485, 5167, 73, 26, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 3120, 63, 985, 63, 607, 21171, 199, 703, 485, 1408, 278, 23326, 26, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 2944, 3465, 2531, 4416, 63, 16971, 390, 9, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 5222, 71, 14, 1014, 551, 864, 14, 4266, 63, 7866, 63, 16257, 492, 7605, 42, 63, 19600, 63, 2339, 63, 10640, 272, 687, 5222, 71, 14, 1014, 551, 864, 14, 954, 74, 63, 4478, 63, 354, 492, 26793, 29171, 465, 3523, 13528, 29171, 199, 2590, 12053, 465, 325, 26, 272, 746, 3545, 8, 69, 9, 199, 199, 646, 14296, 14, 5413, 199, 504, 1134, 6228, 17, 14, 9276, 14, 424, 492, 10334, 465, 16921, 63, 8813, 199, 504, 1134, 6228, 17, 14, 466, 492, 17225, 12, 5828, 199, 504, 2838, 492, 485, 493, 785, 12, 2653, 199, 646, 6149, 199, 646, 3504, 199, 199, 504, 2508, 492, 1950, 199, 504, 2508, 492, 4884, 199, 199, 363, 452, 363, 275, 788, 14815, 63, 9924, 63, 4078, 19, 297, 283, 5005, 63, 504, 63, 4078, 19, 418, 199, 199, 3, 428, 16730, 1454, 627, 29428, 10, 5419, 340, 781, 883, 1586, 314, 5420, 29171, 402, 14512, 14, 199, 13533, 63, 8199, 41, 275, 7605, 42, 63, 19600, 63, 2339, 63, 10640, 199, 199, 3, 9672, 687, 4011, 19, 370, 1611, 22791, 9025, 2725, 13, 1459, 14, 199, 63, 14837, 63, 6234, 275, 469, 272, 6149, 14, 9583, 63, 21082, 1789, 26, 14296, 14, 5413, 14, 21082, 1789, 63, 9977, 12, 272, 6149, 14, 9583, 63, 10224, 86, 17, 26, 14296, 14, 5413, 14, 10224, 86, 17, 63, 9977, 12, 199, 93, 199, 199, 893, 26, 272, 485, 14837, 63, 6234, 14, 873, 2561, 4266, 14, 9583, 63, 21082, 19, 26, 14296, 14, 5413, 14, 21082, 19, 63, 9977, 1552, 199, 2590, 4281, 26, 272, 986, 199, 199, 63, 14837, 63, 4712, 275, 469, 272, 6149, 14, 11163, 63, 9185, 26, 14296, 14, 5413, 14, 22443, 63, 9185, 12, 272, 6149, 14, 11163, 63, 21008, 26, 14296, 14, 5413, 14, 22443, 63, 31560, 12, 272, 6149, 14, 11163, 63, 12496, 26, 14296, 14, 5413, 14, 22443, 63, 31560, 2432, 435, 14296, 14, 5413, 14, 22443, 63, 8784, 63, 4656, 63, 2826, 63, 31560, 63, 11163, 12, 199, 93, 199, 199, 3, 437, 11153, 849, 14, 199, 3, 5800, 83, 367, 1655, 2556, 641, 12213, 30377, 26, 199, 3, 199, 3, 446, 4178, 921, 6797, 14, 12102, 14, 1308, 15, 7676, 15, 3120, 63, 15414, 63, 10224, 199, 3, 446, 4178, 921, 1544, 14, 385, 914, 2101, 14, 957, 15, 6776, 15, 7010, 13, 80, 6457, 7724, 15, 1080, 14, 1360, 199, 3, 446, 4178, 921, 3577, 685, 75, 14, 278, 15, 19813, 15, 8210, 848, 316, 13, 12695, 13, 2520, 13, 5871, 13, 4266, 13, 27426, 15, 199, 3, 199, 3, 710, 8605, 21020, 365, 26, 199, 3, 446, 510, 21928, 10830, 24203, 626, 19793, 23668, 7568, 542, 1353, 1480, 334, 23520, 15, 4220, 23520, 395, 199, 3, 446, 16602, 662, 7695, 1645, 1806, 577, 1645, 367, 8034, 10238, 12, 199, 3, 446, 16602, 1263, 19093, 13, 29009, 1806, 1263, 19093, 13, 18255, 367, 8034, 10238, 436, 6391, 12, 199, 3, 446, 675, 650, 4448, 465, 9567, 1314, 365, 11153, 1325, 11999, 12, 199, 3, 446, 3507, 5962, 6299, 12, 15830, 21, 13347, 83, 436, 577, 2300, 367, 6391, 14872, 14, 199, 3472, 63, 5413, 63, 35, 1772 ]
[ 5413, 543, 428, 16730, 32069, 4058, 367, 2018, 499, 14, 21876, 3520, 15794, 340, 1265, 3955, 199, 2930, 370, 4911, 7799, 14512, 315, 2018, 499, 14, 3390, 12, 314, 849, 8363, 886, 199, 10, 1397, 10, 886, 5897, 7907, 27, 1265, 1929, 370, 886, 4722, 1736, 370, 4107, 199, 16159, 28225, 14, 199, 199, 2765, 4839, 314, 2569, 6117, 4903, 26, 199, 199, 10, 1134, 22791, 334, 10453, 543, 378, 14, 969, 9, 199, 10, 5222, 71, 13, 1014, 551, 864, 334, 10453, 543, 378, 14, 19, 14, 18, 9, 199, 10, 1134, 6228, 17, 334, 10453, 543, 378, 14, 17, 14, 22, 9, 199, 199, 5556, 883, 3907, 3062, 543, 314, 2569, 1414, 26, 339, 7305, 3907, 1134, 14837, 5222, 71, 13, 1014, 551, 864, 1134, 6228, 17, 199, 199, 1378, 15422, 5897, 7907, 12, 1240, 199, 26, 1532, 6054, 4078, 19, 14, 2828, 14, 647, 14837, 14, 14815, 63, 9924, 63, 4078, 19, 64, 687, 2195, 2018, 1233, 199, 5182, 1265, 5386, 10663, 3101, 4145, 14, 961, 883, 506, 4224, 315, 282, 1124, 2124, 26660, 1040, 199, 578, 12, 503, 737, 1263, 1163, 900, 2544, 2195, 4223, 22241, 1808, 1124, 4078, 19, 4542, 199, 2930, 642, 447, 339, 862, 26, 267, 492, 4011, 19, 14, 2828, 14, 647, 14837, 267, 4011, 19, 14, 2828, 14, 647, 14837, 14, 14815, 63, 9924, 63, 4078, 19, 342, 272, 871, 3545, 26, 267, 986, 199, 199, 14351, 1265, 883, 675, 520, 1494, 1705, 4078, 19, 64, 465, 1265, 12252, 3955, 12, 436, 652, 911, 2291, 428, 16730, 199, 6526, 314, 1415, 4621, 787, 4903, 14, 199, 199, 13767, 86, 1958, 642, 859, 2597, 965, 314, 7317, 5366, 7763, 402, 30723, 7799, 15, 10224, 199, 12849, 315, 2018, 499, 334, 3239, 658, 2944, 3465, 23326, 18417, 680, 199, 199, 3917, 1265, 2934, 370, 7908, 314, 849, 769, 402, 3748, 10830, 24203, 12, 1265, 883, 199, 409, 314, 1124, 4078, 19, 14, 2828, 14, 647, 14837, 14, 3472, 63, 5413, 63, 35, 1772, 3452, 63, 4924, 1040, 1750, 14, 199, 199, 2377, 17198, 199, 777, 199, 199, 26, 1391, 6186, 63, 5413, 63, 35, 1772, 3452, 63, 4924, 26, 710, 769, 402, 3748, 7799, 15, 10224, 10830, 24203, 14, 272, 3758, 26, 1124, 4220, 13860, 11, 14494, 29009, 26, 13860, 11, 14494, 29009, 26, 4220, 13860, 11, 14494, 3912, 26, 13860, 11, 14494, 3912, 26, 4220, 13860, 11, 14494, 3933, 26, 13860, 11, 14494, 26, 272, 662, 7695, 40, 11, 19, 4448, 26, 13860, 11, 19, 4448, 26, 12115, 11, 14494, 29009, 26, 12115, 11, 14494, 26, 12115, 11, 19, 4448, 26, 1, 65, 8084, 26, 1, 5127, 21, 26, 1, 36, 2300, 1040, 199, 199, 703, 485, 5167, 73, 26, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 3120, 63, 985, 63, 607, 21171, 199, 703, 485, 1408, 278, 23326, 26, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 2944, 3465, 2531, 4416, 63, 16971, 390, 9, 199, 199, 2344, 199, 199, 893, 26, 272, 687, 5222, 71, 14, 1014, 551, 864, 14, 4266, 63, 7866, 63, 16257, 492, 7605, 42, 63, 19600, 63, 2339, 63, 10640, 272, 687, 5222, 71, 14, 1014, 551, 864, 14, 954, 74, 63, 4478, 63, 354, 492, 26793, 29171, 465, 3523, 13528, 29171, 199, 2590, 12053, 465, 325, 26, 272, 746, 3545, 8, 69, 9, 199, 199, 646, 14296, 14, 5413, 199, 504, 1134, 6228, 17, 14, 9276, 14, 424, 492, 10334, 465, 16921, 63, 8813, 199, 504, 1134, 6228, 17, 14, 466, 492, 17225, 12, 5828, 199, 504, 2838, 492, 485, 493, 785, 12, 2653, 199, 646, 6149, 199, 646, 3504, 199, 199, 504, 2508, 492, 1950, 199, 504, 2508, 492, 4884, 199, 199, 363, 452, 363, 275, 788, 14815, 63, 9924, 63, 4078, 19, 297, 283, 5005, 63, 504, 63, 4078, 19, 418, 199, 199, 3, 428, 16730, 1454, 627, 29428, 10, 5419, 340, 781, 883, 1586, 314, 5420, 29171, 402, 14512, 14, 199, 13533, 63, 8199, 41, 275, 7605, 42, 63, 19600, 63, 2339, 63, 10640, 199, 199, 3, 9672, 687, 4011, 19, 370, 1611, 22791, 9025, 2725, 13, 1459, 14, 199, 63, 14837, 63, 6234, 275, 469, 272, 6149, 14, 9583, 63, 21082, 1789, 26, 14296, 14, 5413, 14, 21082, 1789, 63, 9977, 12, 272, 6149, 14, 9583, 63, 10224, 86, 17, 26, 14296, 14, 5413, 14, 10224, 86, 17, 63, 9977, 12, 199, 93, 199, 199, 893, 26, 272, 485, 14837, 63, 6234, 14, 873, 2561, 4266, 14, 9583, 63, 21082, 19, 26, 14296, 14, 5413, 14, 21082, 19, 63, 9977, 1552, 199, 2590, 4281, 26, 272, 986, 199, 199, 63, 14837, 63, 4712, 275, 469, 272, 6149, 14, 11163, 63, 9185, 26, 14296, 14, 5413, 14, 22443, 63, 9185, 12, 272, 6149, 14, 11163, 63, 21008, 26, 14296, 14, 5413, 14, 22443, 63, 31560, 12, 272, 6149, 14, 11163, 63, 12496, 26, 14296, 14, 5413, 14, 22443, 63, 31560, 2432, 435, 14296, 14, 5413, 14, 22443, 63, 8784, 63, 4656, 63, 2826, 63, 31560, 63, 11163, 12, 199, 93, 199, 199, 3, 437, 11153, 849, 14, 199, 3, 5800, 83, 367, 1655, 2556, 641, 12213, 30377, 26, 199, 3, 199, 3, 446, 4178, 921, 6797, 14, 12102, 14, 1308, 15, 7676, 15, 3120, 63, 15414, 63, 10224, 199, 3, 446, 4178, 921, 1544, 14, 385, 914, 2101, 14, 957, 15, 6776, 15, 7010, 13, 80, 6457, 7724, 15, 1080, 14, 1360, 199, 3, 446, 4178, 921, 3577, 685, 75, 14, 278, 15, 19813, 15, 8210, 848, 316, 13, 12695, 13, 2520, 13, 5871, 13, 4266, 13, 27426, 15, 199, 3, 199, 3, 710, 8605, 21020, 365, 26, 199, 3, 446, 510, 21928, 10830, 24203, 626, 19793, 23668, 7568, 542, 1353, 1480, 334, 23520, 15, 4220, 23520, 395, 199, 3, 446, 16602, 662, 7695, 1645, 1806, 577, 1645, 367, 8034, 10238, 12, 199, 3, 446, 16602, 1263, 19093, 13, 29009, 1806, 1263, 19093, 13, 18255, 367, 8034, 10238, 436, 6391, 12, 199, 3, 446, 675, 650, 4448, 465, 9567, 1314, 365, 11153, 1325, 11999, 12, 199, 3, 446, 3507, 5962, 6299, 12, 15830, 21, 13347, 83, 436, 577, 2300, 367, 6391, 14872, 14, 199, 3472, 63, 5413, 63, 35, 1772, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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/tnetstrings.py
64
2966
# Note this implementation is more strict than necessary to demonstrate # minimum restrictions on types allowed in dictionaries. def dump(data): if type(data) is long or type(data) is int: out = str(data) return '%d:%s#' % (len(out), out) elif type(data) is float: out = '%f' % data return '%d:%s^' % (len(out), out) elif type(data) is str: return '%d:' % len(data) + data + ',' elif type(data) is dict: return dump_dict(data) elif type(data) is list: return dump_list(data) elif data == None: return '0:~' elif type(data) is bool: out = repr(data).lower() return '%d:%s!' % (len(out), out) else: assert False, "Can't serialize stuff that's %s." % type(data) def parse(data): payload, payload_type, remain = parse_payload(data) if payload_type == '#': value = int(payload) elif payload_type == '}': value = parse_dict(payload) elif payload_type == ']': value = parse_list(payload) elif payload_type == '!': value = payload == 'true' elif payload_type == '^': value = float(payload) elif payload_type == '~': assert len(payload) == 0, "Payload must be 0 length for null." value = None elif payload_type == ',': value = payload else: assert False, "Invalid payload type: %r" % payload_type return value, remain def parse_payload(data): assert data, "Invalid data to parse, it's empty." length, extra = data.split(':', 1) length = int(length) payload, extra = extra[:length], extra[length:] assert extra, "No payload type: %r, %r" % (payload, extra) payload_type, remain = extra[0], extra[1:] assert len(payload) == length, "Data is wrong length %d vs %d" % (length, len(payload)) return payload, payload_type, remain def parse_list(data): if len(data) == 0: return [] result = [] value, extra = parse(data) result.append(value) while extra: value, extra = parse(extra) result.append(value) return result def parse_pair(data): key, extra = parse(data) assert extra, "Unbalanced dictionary store." value, extra = parse(extra) return key, value, extra def parse_dict(data): if len(data) == 0: return {} key, value, extra = parse_pair(data) assert type(key) is str, "Keys can only be strings." result = {key: value} while extra: key, value, extra = parse_pair(extra) result[key] = value return result def dump_dict(data): result = [] for k,v in data.items(): result.append(dump(str(k))) result.append(dump(v)) payload = ''.join(result) return '%d:' % len(payload) + payload + '}' def dump_list(data): result = [] for i in data: result.append(dump(i)) payload = ''.join(result) return '%d:' % len(payload) + payload + ']'
bsd-3-clause
[ 3, 3390, 642, 4514, 365, 1655, 7478, 2419, 5784, 370, 23789, 18161, 199, 3, 7481, 24488, 641, 2943, 4370, 315, 11196, 14, 199, 199, 318, 5461, 8, 576, 304, 272, 340, 730, 8, 576, 9, 365, 1846, 503, 730, 8, 576, 9, 365, 1109, 26, 267, 734, 275, 620, 8, 576, 9, 267, 372, 1543, 68, 2689, 83, 19367, 450, 334, 552, 8, 548, 395, 734, 9, 272, 916, 730, 8, 576, 9, 365, 2069, 26, 267, 734, 275, 1543, 70, 7, 450, 666, 267, 372, 1543, 68, 2689, 83, 62, 7, 450, 334, 552, 8, 548, 395, 734, 9, 272, 916, 730, 8, 576, 9, 365, 620, 26, 267, 372, 1543, 68, 4881, 450, 822, 8, 576, 9, 435, 666, 435, 13647, 5591, 916, 730, 8, 576, 9, 365, 1211, 26, 267, 372, 5461, 63, 807, 8, 576, 9, 272, 916, 730, 8, 576, 9, 365, 769, 26, 267, 372, 5461, 63, 513, 8, 576, 9, 272, 916, 666, 508, 488, 26, 267, 372, 283, 16, 26, 94, 7, 272, 916, 730, 8, 576, 9, 365, 2155, 26, 267, 734, 275, 4700, 8, 576, 680, 2325, 342, 267, 372, 1543, 68, 2689, 83, 11213, 450, 334, 552, 8, 548, 395, 734, 9, 272, 587, 26, 267, 702, 756, 12, 298, 6049, 1133, 8437, 8292, 626, 1159, 450, 83, 2122, 450, 730, 8, 576, 9, 421, 199, 318, 2198, 8, 576, 304, 272, 4886, 12, 4886, 63, 466, 12, 5706, 275, 2198, 63, 4749, 8, 576, 9, 339, 340, 4886, 63, 466, 508, 32326, 267, 574, 275, 1109, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 28544, 356, 267, 574, 275, 2198, 63, 807, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 24710, 356, 267, 574, 275, 2198, 63, 513, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 14597, 356, 267, 574, 275, 4886, 508, 283, 2052, 7, 272, 916, 4886, 63, 466, 508, 14452, 356, 267, 574, 275, 2069, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 17352, 356, 267, 702, 822, 8, 4749, 9, 508, 378, 12, 298, 17215, 1471, 506, 378, 2582, 367, 2973, 2122, 267, 574, 275, 488, 272, 916, 4886, 63, 466, 508, 1656, 356, 267, 574, 275, 4886, 272, 587, 26, 267, 702, 756, 12, 298, 3364, 4886, 730, 26, 450, 82, 2, 450, 4886, 63, 466, 339, 372, 574, 12, 5706, 199, 199, 318, 2198, 63, 4749, 8, 576, 304, 272, 702, 666, 12, 298, 3364, 666, 370, 2198, 12, 652, 1159, 2701, 2122, 272, 2582, 12, 2402, 275, 666, 14, 1294, 16451, 413, 9, 272, 2582, 275, 1109, 8, 1267, 9, 339, 4886, 12, 2402, 275, 2402, 1491, 1267, 467, 2402, 59, 1267, 2938, 272, 702, 2402, 12, 298, 1944, 4886, 730, 26, 450, 82, 12, 450, 82, 2, 450, 334, 4749, 12, 2402, 9, 272, 4886, 63, 466, 12, 5706, 275, 2402, 59, 16, 467, 2402, 59, 17, 2938, 339, 702, 822, 8, 4749, 9, 508, 2582, 12, 298, 1451, 365, 6835, 2582, 450, 68, 8118, 450, 68, 2, 450, 334, 1267, 12, 822, 8, 4749, 430, 272, 372, 4886, 12, 4886, 63, 466, 12, 5706, 199, 199, 318, 2198, 63, 513, 8, 576, 304, 272, 340, 822, 8, 576, 9, 508, 378, 26, 372, 942, 339, 754, 275, 942, 272, 574, 12, 2402, 275, 2198, 8, 576, 9, 272, 754, 14, 740, 8, 585, 9, 339, 1830, 2402, 26, 267, 574, 12, 2402, 275, 2198, 8, 2911, 9, 267, 754, 14, 740, 8, 585, 9, 339, 372, 754, 199, 199, 318, 2198, 63, 3852, 8, 576, 304, 272, 790, 12, 2402, 275, 2198, 8, 576, 9, 272, 702, 2402, 12, 298, 1358, 18923, 2600, 3877, 2122, 272, 574, 12, 2402, 275, 2198, 8, 2911, 9, 339, 372, 790, 12, 574, 12, 2402, 199, 199, 318, 2198, 63, 807, 8, 576, 304, 272, 340, 822, 8, 576, 9, 508, 378, 26, 372, 1052, 339, 790, 12, 574, 12, 2402, 275, 2198, 63, 3852, 8, 576, 9, 272, 702, 730, 8, 498, 9, 365, 620, 12, 298, 6340, 883, 1454, 506, 3326, 2122, 339, 754, 275, 469, 498, 26, 574, 93, 339, 1830, 2402, 26, 267, 790, 12, 574, 12, 2402, 275, 2198, 63, 3852, 8, 2911, 9, 267, 754, 59, 498, 61, 275, 574, 2043, 272, 372, 754, 1362, 421, 199, 318, 5461, 63, 807, 8, 576, 304, 272, 754, 275, 942, 272, 367, 1022, 12, 86, 315, 666, 14, 1744, 837, 267, 754, 14, 740, 8, 2724, 8, 495, 8, 75, 1724, 267, 754, 14, 740, 8, 2724, 8, 86, 430, 339, 4886, 275, 6522, 904, 8, 1099, 9, 272, 372, 1543, 68, 4881, 450, 822, 8, 4749, 9, 435, 4886, 435, 23618, 421, 199, 318, 5461, 63, 513, 8, 576, 304, 272, 754, 275, 942, 272, 367, 284, 315, 666, 26, 267, 754, 14, 740, 8, 2724, 8, 73, 430, 339, 4886, 275, 6522, 904, 8, 1099, 9, 272, 372, 1543, 68, 4881, 450, 822, 8, 4749, 9, 435, 4886, 435, 24840, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3390, 642, 4514, 365, 1655, 7478, 2419, 5784, 370, 23789, 18161, 199, 3, 7481, 24488, 641, 2943, 4370, 315, 11196, 14, 199, 199, 318, 5461, 8, 576, 304, 272, 340, 730, 8, 576, 9, 365, 1846, 503, 730, 8, 576, 9, 365, 1109, 26, 267, 734, 275, 620, 8, 576, 9, 267, 372, 1543, 68, 2689, 83, 19367, 450, 334, 552, 8, 548, 395, 734, 9, 272, 916, 730, 8, 576, 9, 365, 2069, 26, 267, 734, 275, 1543, 70, 7, 450, 666, 267, 372, 1543, 68, 2689, 83, 62, 7, 450, 334, 552, 8, 548, 395, 734, 9, 272, 916, 730, 8, 576, 9, 365, 620, 26, 267, 372, 1543, 68, 4881, 450, 822, 8, 576, 9, 435, 666, 435, 13647, 5591, 916, 730, 8, 576, 9, 365, 1211, 26, 267, 372, 5461, 63, 807, 8, 576, 9, 272, 916, 730, 8, 576, 9, 365, 769, 26, 267, 372, 5461, 63, 513, 8, 576, 9, 272, 916, 666, 508, 488, 26, 267, 372, 283, 16, 26, 94, 7, 272, 916, 730, 8, 576, 9, 365, 2155, 26, 267, 734, 275, 4700, 8, 576, 680, 2325, 342, 267, 372, 1543, 68, 2689, 83, 11213, 450, 334, 552, 8, 548, 395, 734, 9, 272, 587, 26, 267, 702, 756, 12, 298, 6049, 1133, 8437, 8292, 626, 1159, 450, 83, 2122, 450, 730, 8, 576, 9, 421, 199, 318, 2198, 8, 576, 304, 272, 4886, 12, 4886, 63, 466, 12, 5706, 275, 2198, 63, 4749, 8, 576, 9, 339, 340, 4886, 63, 466, 508, 32326, 267, 574, 275, 1109, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 28544, 356, 267, 574, 275, 2198, 63, 807, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 24710, 356, 267, 574, 275, 2198, 63, 513, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 14597, 356, 267, 574, 275, 4886, 508, 283, 2052, 7, 272, 916, 4886, 63, 466, 508, 14452, 356, 267, 574, 275, 2069, 8, 4749, 9, 272, 916, 4886, 63, 466, 508, 17352, 356, 267, 702, 822, 8, 4749, 9, 508, 378, 12, 298, 17215, 1471, 506, 378, 2582, 367, 2973, 2122, 267, 574, 275, 488, 272, 916, 4886, 63, 466, 508, 1656, 356, 267, 574, 275, 4886, 272, 587, 26, 267, 702, 756, 12, 298, 3364, 4886, 730, 26, 450, 82, 2, 450, 4886, 63, 466, 339, 372, 574, 12, 5706, 199, 199, 318, 2198, 63, 4749, 8, 576, 304, 272, 702, 666, 12, 298, 3364, 666, 370, 2198, 12, 652, 1159, 2701, 2122, 272, 2582, 12, 2402, 275, 666, 14, 1294, 16451, 413, 9, 272, 2582, 275, 1109, 8, 1267, 9, 339, 4886, 12, 2402, 275, 2402, 1491, 1267, 467, 2402, 59, 1267, 2938, 272, 702, 2402, 12, 298, 1944, 4886, 730, 26, 450, 82, 12, 450, 82, 2, 450, 334, 4749, 12, 2402, 9, 272, 4886, 63, 466, 12, 5706, 275, 2402, 59, 16, 467, 2402, 59, 17, 2938, 339, 702, 822, 8, 4749, 9, 508, 2582, 12, 298, 1451, 365, 6835, 2582, 450, 68, 8118, 450, 68, 2, 450, 334, 1267, 12, 822, 8, 4749, 430, 272, 372, 4886, 12, 4886, 63, 466, 12, 5706, 199, 199, 318, 2198, 63, 513, 8, 576, 304, 272, 340, 822, 8, 576, 9, 508, 378, 26, 372, 942, 339, 754, 275, 942, 272, 574, 12, 2402, 275, 2198, 8, 576, 9, 272, 754, 14, 740, 8, 585, 9, 339, 1830, 2402, 26, 267, 574, 12, 2402, 275, 2198, 8, 2911, 9, 267, 754, 14, 740, 8, 585, 9, 339, 372, 754, 199, 199, 318, 2198, 63, 3852, 8, 576, 304, 272, 790, 12, 2402, 275, 2198, 8, 576, 9, 272, 702, 2402, 12, 298, 1358, 18923, 2600, 3877, 2122, 272, 574, 12, 2402, 275, 2198, 8, 2911, 9, 339, 372, 790, 12, 574, 12, 2402, 199, 199, 318, 2198, 63, 807, 8, 576, 304, 272, 340, 822, 8, 576, 9, 508, 378, 26, 372, 1052, 339, 790, 12, 574, 12, 2402, 275, 2198, 63, 3852, 8, 576, 9, 272, 702, 730, 8, 498, 9, 365, 620, 12, 298, 6340, 883, 1454, 506, 3326, 2122, 339, 754, 275, 469, 498, 26, 574, 93, 339, 1830, 2402, 26, 267, 790, 12, 574, 12, 2402, 275, 2198, 63, 3852, 8, 2911, 9, 267, 754, 59, 498, 61, 275, 574, 2043, 272, 372, 754, 1362, 421, 199, 318, 5461, 63, 807, 8, 576, 304, 272, 754, 275, 942, 272, 367, 1022, 12, 86, 315, 666, 14, 1744, 837, 267, 754, 14, 740, 8, 2724, 8, 495, 8, 75, 1724, 267, 754, 14, 740, 8, 2724, 8, 86, 430, 339, 4886, 275, 6522, 904, 8, 1099, 9, 272, 372, 1543, 68, 4881, 450, 822, 8, 4749, 9, 435, 4886, 435, 23618, 421, 199, 318, 5461, 63, 513, 8, 576, 304, 272, 754, 275, 942, 272, 367, 284, 315, 666, 26, 267, 754, 14, 740, 8, 2724, 8, 73, 430, 339, 4886, 275, 6522, 904, 8, 1099, 9, 272, 372, 1543, 68, 4881, 450, 822, 8, 4749, 9, 435, 4886, 435, 24840, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
trezorg/django
tests/regressiontests/string_lookup/models.py
92
1199
# -*- coding: utf-8 -*- from django.db import models class Foo(models.Model): name = models.CharField(max_length=50) friend = models.CharField(max_length=50, blank=True) def __unicode__(self): return "Foo %s" % self.name class Bar(models.Model): name = models.CharField(max_length=50) normal = models.ForeignKey(Foo, related_name='normal_foo') fwd = models.ForeignKey("Whiz") back = models.ForeignKey("Foo") def __unicode__(self): return "Bar %s" % self.place.name class Whiz(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return "Whiz %s" % self.name class Child(models.Model): parent = models.OneToOneField('Base') name = models.CharField(max_length=50) def __unicode__(self): return "Child %s" % self.name class Base(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return "Base %s" % self.name class Article(models.Model): name = models.CharField(max_length=50) text = models.TextField() submitted_from = models.IPAddressField(blank=True, null=True) def __str__(self): return "Article %s" % self.name
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 8024, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 32506, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 4596, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5686, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 12377, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 3293, 275, 1709, 14, 3190, 8, 5686, 12, 4048, 63, 354, 534, 3302, 63, 1421, 358, 272, 31336, 275, 1709, 14, 3190, 480, 5879, 565, 531, 272, 1771, 275, 1709, 14, 3190, 480, 5686, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5281, 450, 83, 2, 450, 291, 14, 2778, 14, 354, 199, 199, 533, 2816, 565, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5879, 565, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 12988, 8, 992, 14, 1685, 304, 272, 1676, 275, 1709, 14, 14298, 360, 1563, 358, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 3493, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 3523, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 1563, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1318, 275, 1709, 14, 6254, 342, 272, 16930, 63, 504, 275, 1709, 14, 26969, 8, 2500, 29, 549, 12, 2973, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 7221, 450, 83, 2, 450, 291, 14, 354, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 8024, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 32506, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 4596, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5686, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 12377, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 3293, 275, 1709, 14, 3190, 8, 5686, 12, 4048, 63, 354, 534, 3302, 63, 1421, 358, 272, 31336, 275, 1709, 14, 3190, 480, 5879, 565, 531, 272, 1771, 275, 1709, 14, 3190, 480, 5686, 531, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5281, 450, 83, 2, 450, 291, 14, 2778, 14, 354, 199, 199, 533, 2816, 565, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 5879, 565, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 12988, 8, 992, 14, 1685, 304, 272, 1676, 275, 1709, 14, 14298, 360, 1563, 358, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 3493, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 3523, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 298, 1563, 450, 83, 2, 450, 291, 14, 354, 199, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1318, 275, 1709, 14, 6254, 342, 272, 16930, 63, 504, 275, 1709, 14, 26969, 8, 2500, 29, 549, 12, 2973, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 298, 7221, 450, 83, 2, 450, 291, 14, 354, 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, 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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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 ]
josibarns/paparazzi
sw/tools/dfu/stm32_mem.py
1
6679
#!/usr/bin/env python # # stm32_mem.py: STM32 memory access using USB DFU class # Copyright (C) 2011 Black Sphere Technologies # Written by Gareth McMullin <gareth@blacksphere.co.nz> # Modified by Felix Ruess <felix.ruess@gmail.com> # # 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 from time import sleep import struct from sys import stdout, argv from os import path from optparse import OptionParser import usb import dfu APP_ADDRESS = 0x08002000 SECTOR_SIZE = 2048 CMD_GETCOMMANDS = 0x00 CMD_SETADDRESSPOINTER = 0x21 CMD_ERASE = 0x41 def stm32_erase(dev, addr): erase_cmd = struct.pack("<BL", CMD_ERASE, addr) dev.download(0, erase_cmd) while True: status = dev.get_status() if status.bState == dfu.STATE_DFU_DOWNLOAD_BUSY: sleep(status.bwPollTimeout / 1000.0) if status.bState == dfu.STATE_DFU_DOWNLOAD_IDLE: break def stm32_write(dev, data): dev.download(2, data) while True: status = dev.get_status() if status.bState == dfu.STATE_DFU_DOWNLOAD_BUSY: sleep(status.bwPollTimeout / 1000.0) if status.bState == dfu.STATE_DFU_DOWNLOAD_IDLE: break def stm32_manifest(dev): dev.download(0, "") while True: try: status = dev.get_status() except: return sleep(status.bwPollTimeout / 1000.0) if status.bState == dfu.STATE_DFU_MANIFEST: break def print_copyright(): print("") print("USB Device Firmware Upgrade - Host Utility -- version 1.3") print("Copyright (C) 2011 Black Sphere Technologies") print("Copyright (C) 2012 Transition Robotics Inc.") print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>") print("") if __name__ == "__main__": usage = "Usage: %prog [options] firmware.bin" + "\n" + "Run %prog --help to list the options." parser = OptionParser(usage, version='%prog version 1.3') parser.add_option("-v", "--verbose", action="store_true", dest="verbose") parser.add_option("--product", type="choice", choices=["any", "Lisa/Lia"], action="store", default="Lisa/Lia", help="only upload to device where idProduct contains PRODUCT\n" "choices: (any, Lisa/Lia), default: Lisa/Lia") parser.add_option("-n", "--dry-run", action="store_true", help="Dry run to check which board is found without actually flashing.") (options, args) = parser.parse_args() if len(args) != 1: parser.error("incorrect number of arguments") else: if path.isfile(args[0]): binfile = args[0] else: parser.error("Binary file " + args[0] + " not found") if options.verbose: print_copyright() devs = dfu.finddevs() if not devs: print("No DFU devices found!") exit(1) elif options.verbose: print("Found %i DFU devices." % len(devs)) valid_manufacturers = [] valid_manufacturers.append("Transition Robotics Inc.") valid_manufacturers.append("STMicroelectronics") valid_manufacturers.append("Black Sphere Technologies") # list of tuples with possible stm32 (autopilot) devices stm32devs = [] for dev in devs: try: dfudev = dfu.dfu_device(*dev) except: if options.verbose: print("Could not open DFU device %s ID %04x:%04x " "Maybe the OS driver is claiming it?" % (dev[0].filename, dev[0].idVendor, dev[0].idProduct)) continue try: man = dfudev.handle.getString(dfudev.dev.iManufacturer, 30) product = dfudev.handle.getString(dfudev.dev.iProduct, 30) serial = dfudev.handle.getString(dfudev.dev.iSerialNumber, 40) except: print("Whoops... could not get device description.") continue if options.verbose: print("Found DFU device %s: ID %04x:%04x %s - %s - %s" % (dfudev.dev.filename, dfudev.dev.idVendor, dfudev.dev.idProduct, man, product, serial)) if man in valid_manufacturers: if options.product == "any": stm32devs.append((dfudev, man, product, serial)) elif options.product == "Lisa/Lia": if "Lisa/M" in product or "Lia" in product: stm32devs.append((dfudev, man, product, serial)) if not stm32devs: print("Could not find STM32 (autopilot) device.") exit(1) if len(stm32devs) > 1: print("Warning: Found more than one potential board to flash.") for (d, m, p, s) in stm32devs: print("Found possible STM32 (autopilot) device %s: ID %04x:%04x %s - %s - %s" % (d.dev.filename, d.dev.idVendor, d.dev.idProduct, m, p, s)) # use first potential board as target target = stm32devs[0][0] print("Using device %s: ID %04x:%04x %s - %s - %s" % (target.dev.filename, target.dev.idVendor, target.dev.idProduct, man, product, serial)) # if it's a dry run only, don't actually flash, just exit now if options.dry_run: print("Dry run, done.") exit(0) try: state = target.get_state() except: print("Failed to read device state! Assuming APP_IDLE") state = dfu.STATE_APP_IDLE if state == dfu.STATE_APP_IDLE: target.detach() print("Run again to upgrade firmware.") exit(0) target.make_idle() try: bin = open(binfile, "rb").read() except: print("Could not open binary file.") raise addr = APP_ADDRESS while bin: print("Programming memory at 0x%08X\r" % addr) stdout.flush() stm32_erase(target, addr) stm32_write(target, bin[:SECTOR_SIZE]) bin = bin[SECTOR_SIZE:] addr += SECTOR_SIZE stm32_manifest(target) print("\nAll operations complete!\n")
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 410, 77, 708, 63, 5286, 14, 647, 26, 4384, 45, 708, 4402, 2879, 1808, 28655, 577, 30294, 1021, 199, 3, 1898, 334, 35, 9, 7760, 221, 30593, 8360, 1681, 19215, 199, 3, 27694, 701, 598, 1530, 273, 22895, 16867, 472, 665, 71, 1530, 273, 32, 8399, 14980, 14, 331, 14, 15291, 30, 199, 3, 22016, 701, 7949, 20528, 820, 6103, 665, 771, 20528, 14, 431, 385, 32, 6799, 14, 957, 30, 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, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 900, 492, 9435, 199, 646, 2702, 199, 504, 984, 492, 3839, 12, 9238, 199, 504, 747, 492, 931, 199, 199, 504, 8691, 492, 13491, 199, 199, 646, 27923, 199, 646, 4051, 85, 199, 199, 7121, 63, 12368, 275, 378, 88, 2036, 7432, 1493, 199, 32379, 726, 63, 4305, 275, 18427, 199, 199, 9744, 63, 2970, 28442, 275, 378, 88, 383, 199, 9744, 63, 3597, 12368, 11260, 275, 378, 88, 2025, 199, 9744, 63, 540, 8162, 275, 378, 88, 2953, 199, 199, 318, 410, 77, 708, 63, 22087, 8, 2374, 12, 5552, 304, 272, 28343, 63, 1760, 275, 2702, 14, 1389, 6757, 7847, 401, 25548, 63, 540, 8162, 12, 5552, 9, 272, 4866, 14, 4249, 8, 16, 12, 28343, 63, 1760, 9, 272, 1830, 715, 26, 267, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 24753, 57, 26, 288, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 23715, 26, 288, 2059, 199, 199, 318, 410, 77, 708, 63, 952, 8, 2374, 12, 666, 304, 272, 4866, 14, 4249, 8, 18, 12, 666, 9, 272, 1830, 715, 26, 267, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 24753, 57, 26, 288, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 23715, 26, 288, 2059, 199, 199, 318, 410, 77, 708, 63, 6418, 8, 2374, 304, 272, 4866, 14, 4249, 8, 16, 12, 6899, 272, 1830, 715, 26, 267, 862, 26, 288, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 871, 26, 288, 372, 267, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24067, 26, 288, 2059, 199, 199, 318, 870, 63, 7307, 837, 272, 870, 10804, 272, 870, 480, 19919, 12272, 481, 20678, 4949, 4523, 446, 10891, 20511, 1553, 1015, 413, 14, 19, 531, 272, 870, 480, 7384, 334, 35, 9, 7760, 221, 30593, 8360, 1681, 19215, 531, 272, 870, 480, 7384, 334, 35, 9, 6029, 221, 19894, 1588, 6848, 656, 7769, 3277, 2685, 272, 870, 480, 3761, 14629, 86, 19, 11, 26, 1664, 14629, 1015, 650, 503, 2945, 665, 1014, 921, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 9579, 272, 870, 10804, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4503, 275, 298, 7692, 26, 450, 6595, 359, 1419, 61, 27969, 14, 1393, 2, 435, 1867, 78, 2, 435, 298, 2540, 450, 6595, 1553, 3437, 370, 769, 314, 1511, 2122, 272, 1798, 275, 13491, 8, 3807, 12, 1015, 9569, 6595, 1015, 413, 14, 19, 358, 272, 1798, 14, 525, 63, 1422, 6096, 86, 401, 4320, 3832, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 3832, 531, 272, 1798, 14, 525, 63, 1422, 6739, 2558, 401, 730, 628, 5095, 401, 3415, 6270, 1629, 401, 298, 44, 13655, 15, 44, 4674, 2255, 1993, 1595, 628, 1617, 401, 849, 628, 44, 13655, 15, 44, 4674, 401, 1993, 1720, 628, 2118, 5802, 370, 2243, 2382, 1305, 5884, 3509, 3611, 13461, 60, 78, 2, 1993, 298, 4577, 26, 334, 1629, 12, 491, 13655, 15, 44, 4674, 395, 849, 26, 491, 13655, 15, 44, 4674, 531, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 10481, 13, 1065, 401, 1595, 628, 1617, 63, 2052, 401, 1993, 1720, 628, 36, 651, 1255, 370, 1104, 1314, 13811, 365, 1911, 1928, 5965, 14775, 316, 2685, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 822, 8, 589, 9, 1137, 413, 26, 267, 1798, 14, 705, 480, 15448, 1329, 402, 2368, 531, 272, 587, 26, 267, 340, 931, 14, 6292, 8, 589, 59, 16, 4682, 288, 2517, 493, 275, 1249, 59, 16, 61, 267, 587, 26, 288, 1798, 14, 705, 480, 6636, 570, 298, 435, 1249, 59, 16, 61, 435, 298, 440, 1911, 531, 339, 340, 1511, 14, 3832, 26, 267, 870, 63, 7307, 342, 339, 477, 3122, 275, 4051, 85, 14, 1623, 18804, 342, 272, 340, 440, 477, 3122, 26, 267, 870, 480, 1944, 577, 30294, 7256, 1911, 9124, 267, 4458, 8, 17, 9, 272, 916, 1511, 14, 3832, 26, 267, 870, 480, 3601, 450, 73, 577, 30294, 7256, 2122, 450, 822, 8, 18804, 430, 339, 1686, 63, 1237, 17391, 2393, 275, 942, 272, 1686, 63, 1237, 17391, 2393 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 410, 77, 708, 63, 5286, 14, 647, 26, 4384, 45, 708, 4402, 2879, 1808, 28655, 577, 30294, 1021, 199, 3, 1898, 334, 35, 9, 7760, 221, 30593, 8360, 1681, 19215, 199, 3, 27694, 701, 598, 1530, 273, 22895, 16867, 472, 665, 71, 1530, 273, 32, 8399, 14980, 14, 331, 14, 15291, 30, 199, 3, 22016, 701, 7949, 20528, 820, 6103, 665, 771, 20528, 14, 431, 385, 32, 6799, 14, 957, 30, 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, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 900, 492, 9435, 199, 646, 2702, 199, 504, 984, 492, 3839, 12, 9238, 199, 504, 747, 492, 931, 199, 199, 504, 8691, 492, 13491, 199, 199, 646, 27923, 199, 646, 4051, 85, 199, 199, 7121, 63, 12368, 275, 378, 88, 2036, 7432, 1493, 199, 32379, 726, 63, 4305, 275, 18427, 199, 199, 9744, 63, 2970, 28442, 275, 378, 88, 383, 199, 9744, 63, 3597, 12368, 11260, 275, 378, 88, 2025, 199, 9744, 63, 540, 8162, 275, 378, 88, 2953, 199, 199, 318, 410, 77, 708, 63, 22087, 8, 2374, 12, 5552, 304, 272, 28343, 63, 1760, 275, 2702, 14, 1389, 6757, 7847, 401, 25548, 63, 540, 8162, 12, 5552, 9, 272, 4866, 14, 4249, 8, 16, 12, 28343, 63, 1760, 9, 272, 1830, 715, 26, 267, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 24753, 57, 26, 288, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 23715, 26, 288, 2059, 199, 199, 318, 410, 77, 708, 63, 952, 8, 2374, 12, 666, 304, 272, 4866, 14, 4249, 8, 18, 12, 666, 9, 272, 1830, 715, 26, 267, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 24753, 57, 26, 288, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24930, 63, 23715, 26, 288, 2059, 199, 199, 318, 410, 77, 708, 63, 6418, 8, 2374, 304, 272, 4866, 14, 4249, 8, 16, 12, 6899, 272, 1830, 715, 26, 267, 862, 26, 288, 2004, 275, 4866, 14, 362, 63, 1205, 342, 267, 871, 26, 288, 372, 267, 9435, 8, 1205, 14, 12415, 24022, 6372, 1182, 5198, 14, 16, 9, 267, 340, 2004, 14, 66, 2223, 508, 4051, 85, 14, 6689, 63, 3888, 53, 63, 24067, 26, 288, 2059, 199, 199, 318, 870, 63, 7307, 837, 272, 870, 10804, 272, 870, 480, 19919, 12272, 481, 20678, 4949, 4523, 446, 10891, 20511, 1553, 1015, 413, 14, 19, 531, 272, 870, 480, 7384, 334, 35, 9, 7760, 221, 30593, 8360, 1681, 19215, 531, 272, 870, 480, 7384, 334, 35, 9, 6029, 221, 19894, 1588, 6848, 656, 7769, 3277, 2685, 272, 870, 480, 3761, 14629, 86, 19, 11, 26, 1664, 14629, 1015, 650, 503, 2945, 665, 1014, 921, 3689, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 9579, 272, 870, 10804, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 4503, 275, 298, 7692, 26, 450, 6595, 359, 1419, 61, 27969, 14, 1393, 2, 435, 1867, 78, 2, 435, 298, 2540, 450, 6595, 1553, 3437, 370, 769, 314, 1511, 2122, 272, 1798, 275, 13491, 8, 3807, 12, 1015, 9569, 6595, 1015, 413, 14, 19, 358, 272, 1798, 14, 525, 63, 1422, 6096, 86, 401, 4320, 3832, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 3832, 531, 272, 1798, 14, 525, 63, 1422, 6739, 2558, 401, 730, 628, 5095, 401, 3415, 6270, 1629, 401, 298, 44, 13655, 15, 44, 4674, 2255, 1993, 1595, 628, 1617, 401, 849, 628, 44, 13655, 15, 44, 4674, 401, 1993, 1720, 628, 2118, 5802, 370, 2243, 2382, 1305, 5884, 3509, 3611, 13461, 60, 78, 2, 1993, 298, 4577, 26, 334, 1629, 12, 491, 13655, 15, 44, 4674, 395, 849, 26, 491, 13655, 15, 44, 4674, 531, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 10481, 13, 1065, 401, 1595, 628, 1617, 63, 2052, 401, 1993, 1720, 628, 36, 651, 1255, 370, 1104, 1314, 13811, 365, 1911, 1928, 5965, 14775, 316, 2685, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 822, 8, 589, 9, 1137, 413, 26, 267, 1798, 14, 705, 480, 15448, 1329, 402, 2368, 531, 272, 587, 26, 267, 340, 931, 14, 6292, 8, 589, 59, 16, 4682, 288, 2517, 493, 275, 1249, 59, 16, 61, 267, 587, 26, 288, 1798, 14, 705, 480, 6636, 570, 298, 435, 1249, 59, 16, 61, 435, 298, 440, 1911, 531, 339, 340, 1511, 14, 3832, 26, 267, 870, 63, 7307, 342, 339, 477, 3122, 275, 4051, 85, 14, 1623, 18804, 342, 272, 340, 440, 477, 3122, 26, 267, 870, 480, 1944, 577, 30294, 7256, 1911, 9124, 267, 4458, 8, 17, 9, 272, 916, 1511, 14, 3832, 26, 267, 870, 480, 3601, 450, 73, 577, 30294, 7256, 2122, 450, 822, 8, 18804, 430, 339, 1686, 63, 1237, 17391, 2393, 275, 942, 272, 1686, 63, 1237, 17391, 2393, 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,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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 ]
maxdeliso/elevatorSim
Lib/test/test_osx_env.py
6
1321
""" Test suite for OS X interpreter environment variables. """ from test.support import EnvironmentVarGuard, run_unittest import subprocess import sys import sysconfig import unittest class OSXEnvironmentVariableTestCase(unittest.TestCase): def _check_sys(self, ev, cond, sv, val = sys.executable + 'dummy'): with EnvironmentVarGuard() as evg: subpc = [str(sys.executable), '-c', 'import sys; sys.exit(2 if "%s" %s %s else 3)' % (val, cond, sv)] # ensure environment variable does not exist evg.unset(ev) # test that test on sys.xxx normally fails rc = subprocess.call(subpc) self.assertEqual(rc, 3, "expected %s not %s %s" % (ev, cond, sv)) # set environ variable evg.set(ev, val) # test that sys.xxx has been influenced by the environ value rc = subprocess.call(subpc) self.assertEqual(rc, 2, "expected %s %s %s" % (ev, cond, sv)) def test_pythonexecutable_sets_sys_executable(self): self._check_sys('PYTHONEXECUTABLE', '==', 'sys.executable') def test_main(): if sys.platform == 'darwin' and sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'): run_unittest(OSXEnvironmentVariableTestCase) if __name__ == "__main__": test_main()
bsd-2-clause
[ 624, 199, 774, 5241, 367, 4403, 1323, 12693, 3734, 2860, 14, 199, 624, 199, 199, 504, 511, 14, 4058, 492, 9711, 5894, 18183, 12, 1255, 63, 2796, 199, 646, 3873, 199, 646, 984, 199, 646, 22381, 199, 646, 2882, 199, 199, 533, 32144, 8263, 2773, 1746, 8, 2796, 14, 1746, 304, 272, 347, 485, 1074, 63, 1274, 8, 277, 12, 8145, 12, 9288, 12, 19291, 12, 1139, 275, 984, 14, 5904, 435, 283, 5869, 735, 267, 543, 9711, 5894, 18183, 342, 465, 8145, 71, 26, 288, 1007, 2352, 275, 359, 495, 8, 1274, 14, 5904, 395, 2475, 67, 297, 355, 283, 646, 984, 27, 984, 14, 2224, 8, 18, 340, 2071, 83, 2, 450, 83, 450, 83, 587, 650, 3171, 450, 334, 637, 12, 9288, 12, 19291, 1874, 288, 327, 4868, 3734, 1750, 1630, 440, 2187, 288, 8145, 71, 14, 16787, 8, 6857, 9, 288, 327, 511, 626, 511, 641, 984, 14, 10013, 12252, 6918, 288, 4819, 275, 3873, 14, 1250, 8, 954, 2352, 9, 288, 291, 14, 629, 8, 1195, 12, 650, 12, 298, 2062, 450, 83, 440, 450, 83, 450, 83, 2, 450, 334, 6857, 12, 9288, 12, 19291, 430, 288, 327, 663, 6160, 1750, 288, 8145, 71, 14, 409, 8, 6857, 12, 1139, 9, 288, 327, 511, 626, 984, 14, 10013, 965, 2757, 315, 24585, 68, 701, 314, 6160, 574, 288, 4819, 275, 3873, 14, 1250, 8, 954, 2352, 9, 288, 291, 14, 629, 8, 1195, 12, 499, 12, 298, 2062, 450, 83, 450, 83, 450, 83, 2, 450, 334, 6857, 12, 9288, 12, 19291, 430, 339, 347, 511, 63, 647, 273, 368, 9542, 2964, 63, 2193, 63, 1274, 63, 5904, 8, 277, 304, 267, 291, 423, 1074, 63, 1274, 360, 11720, 21623, 297, 283, 389, 297, 283, 1274, 14, 5904, 358, 199, 199, 318, 511, 63, 973, 837, 272, 340, 984, 14, 3246, 508, 283, 13245, 7, 436, 22381, 14, 362, 63, 888, 63, 1391, 360, 9139, 63, 21917, 63, 12683, 8406, 735, 267, 1255, 63, 2796, 8, 25160, 8263, 2773, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 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 ]
[ 199, 774, 5241, 367, 4403, 1323, 12693, 3734, 2860, 14, 199, 624, 199, 199, 504, 511, 14, 4058, 492, 9711, 5894, 18183, 12, 1255, 63, 2796, 199, 646, 3873, 199, 646, 984, 199, 646, 22381, 199, 646, 2882, 199, 199, 533, 32144, 8263, 2773, 1746, 8, 2796, 14, 1746, 304, 272, 347, 485, 1074, 63, 1274, 8, 277, 12, 8145, 12, 9288, 12, 19291, 12, 1139, 275, 984, 14, 5904, 435, 283, 5869, 735, 267, 543, 9711, 5894, 18183, 342, 465, 8145, 71, 26, 288, 1007, 2352, 275, 359, 495, 8, 1274, 14, 5904, 395, 2475, 67, 297, 355, 283, 646, 984, 27, 984, 14, 2224, 8, 18, 340, 2071, 83, 2, 450, 83, 450, 83, 587, 650, 3171, 450, 334, 637, 12, 9288, 12, 19291, 1874, 288, 327, 4868, 3734, 1750, 1630, 440, 2187, 288, 8145, 71, 14, 16787, 8, 6857, 9, 288, 327, 511, 626, 511, 641, 984, 14, 10013, 12252, 6918, 288, 4819, 275, 3873, 14, 1250, 8, 954, 2352, 9, 288, 291, 14, 629, 8, 1195, 12, 650, 12, 298, 2062, 450, 83, 440, 450, 83, 450, 83, 2, 450, 334, 6857, 12, 9288, 12, 19291, 430, 288, 327, 663, 6160, 1750, 288, 8145, 71, 14, 409, 8, 6857, 12, 1139, 9, 288, 327, 511, 626, 984, 14, 10013, 965, 2757, 315, 24585, 68, 701, 314, 6160, 574, 288, 4819, 275, 3873, 14, 1250, 8, 954, 2352, 9, 288, 291, 14, 629, 8, 1195, 12, 499, 12, 298, 2062, 450, 83, 450, 83, 450, 83, 2, 450, 334, 6857, 12, 9288, 12, 19291, 430, 339, 347, 511, 63, 647, 273, 368, 9542, 2964, 63, 2193, 63, 1274, 63, 5904, 8, 277, 304, 267, 291, 423, 1074, 63, 1274, 360, 11720, 21623, 297, 283, 389, 297, 283, 1274, 14, 5904, 358, 199, 199, 318, 511, 63, 973, 837, 272, 340, 984, 14, 3246, 508, 283, 13245, 7, 436, 22381, 14, 362, 63, 888, 63, 1391, 360, 9139, 63, 21917, 63, 12683, 8406, 735, 267, 1255, 63, 2796, 8, 25160, 8263, 2773, 1746, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 511, 63, 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, 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, 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datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Source.storage_hash' db.add_column('easy_thumbnails_source', 'storage_hash', self.gf('django.db.models.fields.CharField')(default='', max_length=40), keep_default=False) # Adding field 'Thumbnail.storage_hash' db.add_column('easy_thumbnails_thumbnail', 'storage_hash', self.gf('django.db.models.fields.CharField')(default='', max_length=40), keep_default=False) def backwards(self, orm): # Deleting field 'Source.storage_hash' db.delete_column('easy_thumbnails_source', 'storage_hash') # Deleting field 'Thumbnail.storage_hash' db.delete_column('easy_thumbnails_thumbnail', 'storage_hash') models = { 'easy_thumbnails.source': { 'Meta': {'object_name': 'Source'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 9, 8, 0, 31, 16, 27396)'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'storage': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['easy_thumbnails.Storage']"}), 'storage_hash': ('django.db.models.fields.CharField', [], {'max_length': '40'}) }, 'easy_thumbnails.storage': { 'Meta': {'object_name': 'Storage'}, 'hash': ('django.db.models.fields.CharField', [], {'max_length': '40', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'pickle': ('django.db.models.fields.TextField', [], {}) }, 'easy_thumbnails.thumbnail': { 'Meta': {'object_name': 'Thumbnail'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2010, 9, 8, 0, 31, 16, 27396)'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'source': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'thumbnails'", 'to': "orm['easy_thumbnails.Source']"}), 'storage': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['easy_thumbnails.Storage']"}), 'storage_hash': ('django.db.models.fields.CharField', [], {'max_length': '40'}) } } complete_apps = ['easy_thumbnails']
bsd-3-clause
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 901, 283, 2980, 14, 3494, 63, 2227, 7, 267, 1592, 14, 525, 63, 2301, 360, 13581, 63, 8311, 83, 63, 1365, 297, 283, 3494, 63, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 4581, 1390, 63, 1267, 29, 2167, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 2719, 5820, 14, 3494, 63, 2227, 7, 267, 1592, 14, 525, 63, 2301, 360, 13581, 63, 8311, 83, 63, 8311, 297, 283, 3494, 63, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 4581, 1390, 63, 1267, 29, 2167, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 901, 283, 2980, 14, 3494, 63, 2227, 7, 267, 1592, 14, 1807, 63, 2301, 360, 13581, 63, 8311, 83, 63, 1365, 297, 283, 3494, 63, 2227, 358, 398, 327, 15920, 901, 283, 2719, 5820, 14, 3494, 63, 2227, 7, 267, 1592, 14, 1807, 63, 2301, 360, 13581, 63, 8311, 83, 63, 8311, 297, 283, 3494, 63, 2227, 358, 2378, 1709, 275, 469, 267, 283, 13581, 63, 8311, 83, 14, 1365, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2980, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 5540, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 8, 6542, 12, 1749, 12, 1695, 12, 378, 12, 7105, 12, 3193, 12, 8087, 13443, 9, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 3494, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 6408, 6097, 288, 283, 3494, 63, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 3071, 267, 1660, 267, 283, 13581, 63, 8311, 83, 14, 3494, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6408, 2267, 288, 283, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 8092, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 5009, 267, 1660, 267, 283, 13581, 63, 8311, 83, 14, 8311, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2719, 5820, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 5540, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 8, 6542, 12, 1749, 12, 1695, 12, 378, 12, 7105, 12, 3193, 12, 8087, 13443, 9, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1365, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 8311, 83, 4662, 283, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 2980, 6097, 288, 283, 3494, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 6408, 6097, 288, 283, 3494, 63, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 13581, 63, 8311, 83, 418, 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 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 901, 283, 2980, 14, 3494, 63, 2227, 7, 267, 1592, 14, 525, 63, 2301, 360, 13581, 63, 8311, 83, 63, 1365, 297, 283, 3494, 63, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 4581, 1390, 63, 1267, 29, 2167, 395, 4215, 63, 885, 29, 797, 9, 398, 327, 12934, 901, 283, 2719, 5820, 14, 3494, 63, 2227, 7, 267, 1592, 14, 525, 63, 2301, 360, 13581, 63, 8311, 83, 63, 8311, 297, 283, 3494, 63, 2227, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 4581, 1390, 63, 1267, 29, 2167, 395, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 901, 283, 2980, 14, 3494, 63, 2227, 7, 267, 1592, 14, 1807, 63, 2301, 360, 13581, 63, 8311, 83, 63, 1365, 297, 283, 3494, 63, 2227, 358, 398, 327, 15920, 901, 283, 2719, 5820, 14, 3494, 63, 2227, 7, 267, 1592, 14, 1807, 63, 2301, 360, 13581, 63, 8311, 83, 63, 8311, 297, 283, 3494, 63, 2227, 358, 2378, 1709, 275, 469, 267, 283, 13581, 63, 8311, 83, 14, 1365, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2980, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 5540, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 8, 6542, 12, 1749, 12, 1695, 12, 378, 12, 7105, 12, 3193, 12, 8087, 13443, 9, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 3494, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 6408, 6097, 288, 283, 3494, 63, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 3071, 267, 1660, 267, 283, 13581, 63, 8311, 83, 14, 3494, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6408, 2267, 288, 283, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 8092, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 297, 990, 5009, 267, 1660, 267, 283, 13581, 63, 8311, 83, 14, 8311, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2719, 5820, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 5540, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 8, 6542, 12, 1749, 12, 1695, 12, 378, 12, 7105, 12, 3193, 12, 8087, 13443, 9, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2299, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1365, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 2407, 63, 354, 356, 3546, 8311, 83, 4662, 283, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 2980, 6097, 288, 283, 3494, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 13581, 63, 8311, 83, 14, 6408, 6097, 288, 283, 3494, 63, 2227, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 3071, 267, 789, 272, 789, 339, 4890, 63, 5181, 275, 788, 13581, 63, 8311, 83, 418, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nvoron23/scikit-learn
sklearn/feature_extraction/image.py
263
17600
""" The :mod:`sklearn.feature_extraction.image` submodule gathers utilities to extract features from images. """ # Authors: Emmanuelle Gouillart <emmanuelle.gouillart@normalesup.org> # Gael Varoquaux <gael.varoquaux@normalesup.org> # Olivier Grisel # Vlad Niculae # License: BSD 3 clause from itertools import product import numbers import numpy as np from scipy import sparse from numpy.lib.stride_tricks import as_strided from ..utils import check_array, check_random_state from ..utils.fixes import astype from ..base import BaseEstimator __all__ = ['PatchExtractor', 'extract_patches_2d', 'grid_to_graph', 'img_to_graph', 'reconstruct_from_patches_2d'] ############################################################################### # From an image to a graph def _make_edges_3d(n_x, n_y, n_z=1): """Returns a list of edges for a 3D image. Parameters =========== n_x: integer The size of the grid in the x direction. n_y: integer The size of the grid in the y direction. n_z: integer, optional The size of the grid in the z direction, defaults to 1 """ vertices = np.arange(n_x * n_y * n_z).reshape((n_x, n_y, n_z)) edges_deep = np.vstack((vertices[:, :, :-1].ravel(), vertices[:, :, 1:].ravel())) edges_right = np.vstack((vertices[:, :-1].ravel(), vertices[:, 1:].ravel())) edges_down = np.vstack((vertices[:-1].ravel(), vertices[1:].ravel())) edges = np.hstack((edges_deep, edges_right, edges_down)) return edges def _compute_gradient_3d(edges, img): n_x, n_y, n_z = img.shape gradient = np.abs(img[edges[0] // (n_y * n_z), (edges[0] % (n_y * n_z)) // n_z, (edges[0] % (n_y * n_z)) % n_z] - img[edges[1] // (n_y * n_z), (edges[1] % (n_y * n_z)) // n_z, (edges[1] % (n_y * n_z)) % n_z]) return gradient # XXX: Why mask the image after computing the weights? def _mask_edges_weights(mask, edges, weights=None): """Apply a mask to edges (weighted or not)""" inds = np.arange(mask.size) inds = inds[mask.ravel()] ind_mask = np.logical_and(np.in1d(edges[0], inds), np.in1d(edges[1], inds)) edges = edges[:, ind_mask] if weights is not None: weights = weights[ind_mask] if len(edges.ravel()): maxval = edges.max() else: maxval = 0 order = np.searchsorted(np.unique(edges.ravel()), np.arange(maxval + 1)) edges = order[edges] if weights is None: return edges else: return edges, weights def _to_graph(n_x, n_y, n_z, mask=None, img=None, return_as=sparse.coo_matrix, dtype=None): """Auxiliary function for img_to_graph and grid_to_graph """ edges = _make_edges_3d(n_x, n_y, n_z) if dtype is None: if img is None: dtype = np.int else: dtype = img.dtype if img is not None: img = np.atleast_3d(img) weights = _compute_gradient_3d(edges, img) if mask is not None: edges, weights = _mask_edges_weights(mask, edges, weights) diag = img.squeeze()[mask] else: diag = img.ravel() n_voxels = diag.size else: if mask is not None: mask = astype(mask, dtype=np.bool, copy=False) mask = np.asarray(mask, dtype=np.bool) edges = _mask_edges_weights(mask, edges) n_voxels = np.sum(mask) else: n_voxels = n_x * n_y * n_z weights = np.ones(edges.shape[1], dtype=dtype) diag = np.ones(n_voxels, dtype=dtype) diag_idx = np.arange(n_voxels) i_idx = np.hstack((edges[0], edges[1])) j_idx = np.hstack((edges[1], edges[0])) graph = sparse.coo_matrix((np.hstack((weights, weights, diag)), (np.hstack((i_idx, diag_idx)), np.hstack((j_idx, diag_idx)))), (n_voxels, n_voxels), dtype=dtype) if return_as is np.ndarray: return graph.toarray() return return_as(graph) def img_to_graph(img, mask=None, return_as=sparse.coo_matrix, dtype=None): """Graph of the pixel-to-pixel gradient connections Edges are weighted with the gradient values. Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- img : ndarray, 2D or 3D 2D or 3D image mask : ndarray of booleans, optional An optional mask of the image, to consider only part of the pixels. return_as : np.ndarray or a sparse matrix class, optional The class to use to build the returned adjacency matrix. dtype : None or dtype, optional The data of the returned sparse matrix. By default it is the dtype of img Notes ----- For sklearn versions 0.14.1 and prior, return_as=np.ndarray was handled by returning a dense np.matrix instance. Going forward, np.ndarray returns an np.ndarray, as expected. For compatibility, user code relying on this method should wrap its calls in ``np.asarray`` to avoid type issues. """ img = np.atleast_3d(img) n_x, n_y, n_z = img.shape return _to_graph(n_x, n_y, n_z, mask, img, return_as, dtype) def grid_to_graph(n_x, n_y, n_z=1, mask=None, return_as=sparse.coo_matrix, dtype=np.int): """Graph of the pixel-to-pixel connections Edges exist if 2 voxels are connected. Parameters ---------- n_x : int Dimension in x axis n_y : int Dimension in y axis n_z : int, optional, default 1 Dimension in z axis mask : ndarray of booleans, optional An optional mask of the image, to consider only part of the pixels. return_as : np.ndarray or a sparse matrix class, optional The class to use to build the returned adjacency matrix. dtype : dtype, optional, default int The data of the returned sparse matrix. By default it is int Notes ----- For sklearn versions 0.14.1 and prior, return_as=np.ndarray was handled by returning a dense np.matrix instance. Going forward, np.ndarray returns an np.ndarray, as expected. For compatibility, user code relying on this method should wrap its calls in ``np.asarray`` to avoid type issues. """ return _to_graph(n_x, n_y, n_z, mask=mask, return_as=return_as, dtype=dtype) ############################################################################### # From an image to a set of small image patches def _compute_n_patches(i_h, i_w, p_h, p_w, max_patches=None): """Compute the number of patches that will be extracted in an image. Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- i_h : int The image height i_w : int The image with p_h : int The height of a patch p_w : int The width of a patch max_patches : integer or float, optional default is None The maximum number of patches to extract. If max_patches is a float between 0 and 1, it is taken to be a proportion of the total number of patches. """ n_h = i_h - p_h + 1 n_w = i_w - p_w + 1 all_patches = n_h * n_w if max_patches: if (isinstance(max_patches, (numbers.Integral)) and max_patches < all_patches): return max_patches elif (isinstance(max_patches, (numbers.Real)) and 0 < max_patches < 1): return int(max_patches * all_patches) else: raise ValueError("Invalid value for max_patches: %r" % max_patches) else: return all_patches def extract_patches(arr, patch_shape=8, extraction_step=1): """Extracts patches of any n-dimensional array in place using strides. Given an n-dimensional array it will return a 2n-dimensional array with the first n dimensions indexing patch position and the last n indexing the patch content. This operation is immediate (O(1)). A reshape performed on the first n dimensions will cause numpy to copy data, leading to a list of extracted patches. Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- arr : ndarray n-dimensional array of which patches are to be extracted patch_shape : integer or tuple of length arr.ndim Indicates the shape of the patches to be extracted. If an integer is given, the shape will be a hypercube of sidelength given by its value. extraction_step : integer or tuple of length arr.ndim Indicates step size at which extraction shall be performed. If integer is given, then the step is uniform in all dimensions. Returns ------- patches : strided ndarray 2n-dimensional array indexing patches on first n dimensions and containing patches on the last n dimensions. These dimensions are fake, but this way no data is copied. A simple reshape invokes a copying operation to obtain a list of patches: result.reshape([-1] + list(patch_shape)) """ arr_ndim = arr.ndim if isinstance(patch_shape, numbers.Number): patch_shape = tuple([patch_shape] * arr_ndim) if isinstance(extraction_step, numbers.Number): extraction_step = tuple([extraction_step] * arr_ndim) patch_strides = arr.strides slices = [slice(None, None, st) for st in extraction_step] indexing_strides = arr[slices].strides patch_indices_shape = ((np.array(arr.shape) - np.array(patch_shape)) // np.array(extraction_step)) + 1 shape = tuple(list(patch_indices_shape) + list(patch_shape)) strides = tuple(list(indexing_strides) + list(patch_strides)) patches = as_strided(arr, shape=shape, strides=strides) return patches def extract_patches_2d(image, patch_size, max_patches=None, random_state=None): """Reshape a 2D image into a collection of patches The resulting patches are allocated in a dedicated array. Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- image : array, shape = (image_height, image_width) or (image_height, image_width, n_channels) The original image data. For color images, the last dimension specifies the channel: a RGB image would have `n_channels=3`. patch_size : tuple of ints (patch_height, patch_width) the dimensions of one patch max_patches : integer or float, optional default is None The maximum number of patches to extract. If max_patches is a float between 0 and 1, it is taken to be a proportion of the total number of patches. random_state : int or RandomState Pseudo number generator state used for random sampling to use if `max_patches` is not None. Returns ------- patches : array, shape = (n_patches, patch_height, patch_width) or (n_patches, patch_height, patch_width, n_channels) The collection of patches extracted from the image, where `n_patches` is either `max_patches` or the total number of patches that can be extracted. Examples -------- >>> from sklearn.feature_extraction import image >>> one_image = np.arange(16).reshape((4, 4)) >>> one_image array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> patches = image.extract_patches_2d(one_image, (2, 2)) >>> print(patches.shape) (9, 2, 2) >>> patches[0] array([[0, 1], [4, 5]]) >>> patches[1] array([[1, 2], [5, 6]]) >>> patches[8] array([[10, 11], [14, 15]]) """ i_h, i_w = image.shape[:2] p_h, p_w = patch_size if p_h > i_h: raise ValueError("Height of the patch should be less than the height" " of the image.") if p_w > i_w: raise ValueError("Width of the patch should be less than the width" " of the image.") image = check_array(image, allow_nd=True) image = image.reshape((i_h, i_w, -1)) n_colors = image.shape[-1] extracted_patches = extract_patches(image, patch_shape=(p_h, p_w, n_colors), extraction_step=1) n_patches = _compute_n_patches(i_h, i_w, p_h, p_w, max_patches) if max_patches: rng = check_random_state(random_state) i_s = rng.randint(i_h - p_h + 1, size=n_patches) j_s = rng.randint(i_w - p_w + 1, size=n_patches) patches = extracted_patches[i_s, j_s, 0] else: patches = extracted_patches patches = patches.reshape(-1, p_h, p_w, n_colors) # remove the color dimension if useless if patches.shape[-1] == 1: return patches.reshape((n_patches, p_h, p_w)) else: return patches def reconstruct_from_patches_2d(patches, image_size): """Reconstruct the image from all of its patches. Patches are assumed to overlap and the image is constructed by filling in the patches from left to right, top to bottom, averaging the overlapping regions. Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- patches : array, shape = (n_patches, patch_height, patch_width) or (n_patches, patch_height, patch_width, n_channels) The complete set of patches. If the patches contain colour information, channels are indexed along the last dimension: RGB patches would have `n_channels=3`. image_size : tuple of ints (image_height, image_width) or (image_height, image_width, n_channels) the size of the image that will be reconstructed Returns ------- image : array, shape = image_size the reconstructed image """ i_h, i_w = image_size[:2] p_h, p_w = patches.shape[1:3] img = np.zeros(image_size) # compute the dimensions of the patches array n_h = i_h - p_h + 1 n_w = i_w - p_w + 1 for p, (i, j) in zip(patches, product(range(n_h), range(n_w))): img[i:i + p_h, j:j + p_w] += p for i in range(i_h): for j in range(i_w): # divide by the amount of overlap # XXX: is this the most efficient way? memory-wise yes, cpu wise? img[i, j] /= float(min(i + 1, p_h, i_h - i) * min(j + 1, p_w, i_w - j)) return img class PatchExtractor(BaseEstimator): """Extracts patches from a collection of images Read more in the :ref:`User Guide <image_feature_extraction>`. Parameters ---------- patch_size : tuple of ints (patch_height, patch_width) the dimensions of one patch max_patches : integer or float, optional default is None The maximum number of patches per image to extract. If max_patches is a float in (0, 1), it is taken to mean a proportion of the total number of patches. random_state : int or RandomState Pseudo number generator state used for random sampling. """ def __init__(self, patch_size=None, max_patches=None, random_state=None): self.patch_size = patch_size self.max_patches = max_patches self.random_state = random_state def fit(self, X, y=None): """Do nothing and return the estimator unchanged This method is just there to implement the usual API and hence work in pipelines. """ return self def transform(self, X): """Transforms the image samples in X into a matrix of patch data. Parameters ---------- X : array, shape = (n_samples, image_height, image_width) or (n_samples, image_height, image_width, n_channels) Array of images from which to extract patches. For color images, the last dimension specifies the channel: a RGB image would have `n_channels=3`. Returns ------- patches: array, shape = (n_patches, patch_height, patch_width) or (n_patches, patch_height, patch_width, n_channels) The collection of patches extracted from the images, where `n_patches` is either `n_samples * max_patches` or the total number of patches that can be extracted. """ self.random_state = check_random_state(self.random_state) n_images, i_h, i_w = X.shape[:3] X = np.reshape(X, (n_images, i_h, i_w, -1)) n_channels = X.shape[-1] if self.patch_size is None: patch_size = i_h // 10, i_w // 10 else: patch_size = self.patch_size # compute the dimensions of the patches array p_h, p_w = patch_size n_patches = _compute_n_patches(i_h, i_w, p_h, p_w, self.max_patches) patches_shape = (n_images * n_patches,) + patch_size if n_channels > 1: patches_shape += (n_channels,) # extract the patches patches = np.empty(patches_shape) for ii, image in enumerate(X): patches[ii * n_patches:(ii + 1) * n_patches] = extract_patches_2d( image, patch_size, self.max_patches, self.random_state) return patches
bsd-3-clause
[ 624, 199, 1918, 520, 1494, 1705, 27993, 14, 4445, 63, 24020, 14, 1569, 64, 22988, 13082, 83, 15841, 370, 199, 5005, 4534, 687, 5935, 14, 199, 624, 199, 199, 3, 6642, 26, 662, 596, 290, 13086, 274, 598, 810, 778, 580, 665, 69, 596, 290, 13086, 274, 14, 71, 810, 778, 580, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 3515, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 199, 3, 3515, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 504, 7975, 492, 3336, 199, 646, 5579, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5178, 199, 504, 2680, 14, 773, 14, 12318, 63, 599, 5618, 492, 465, 63, 816, 770, 199, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 14, 26205, 492, 6073, 514, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 199, 363, 452, 363, 275, 788, 11173, 11039, 297, 1779, 283, 5005, 63, 11350, 63, 18, 68, 297, 1779, 283, 3825, 63, 475, 63, 2180, 297, 1779, 283, 4060, 63, 475, 63, 2180, 297, 1779, 283, 264, 8514, 63, 504, 63, 11350, 63, 18, 68, 418, 199, 199, 11490, 199, 3, 11606, 376, 1834, 370, 282, 3343, 421, 199, 318, 485, 1875, 63, 6929, 63, 19, 68, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 29, 17, 304, 272, 408, 3407, 282, 769, 402, 8207, 367, 282, 650, 36, 1834, 14, 339, 3897, 272, 275, 17575, 272, 302, 63, 88, 26, 3000, 267, 710, 1568, 402, 314, 6068, 315, 314, 671, 7581, 14, 272, 302, 63, 89, 26, 3000, 267, 710, 1568, 402, 314, 6068, 315, 314, 612, 7581, 14, 272, 302, 63, 90, 26, 3000, 12, 2716, 267, 710, 1568, 402, 314, 6068, 315, 314, 1315, 7581, 12, 4243, 370, 413, 272, 408, 272, 14971, 275, 980, 14, 5605, 8, 78, 63, 88, 627, 302, 63, 89, 627, 302, 63, 90, 680, 5217, 1332, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 430, 272, 8207, 63, 16131, 275, 980, 14, 20221, 1332, 12637, 3981, 13785, 22901, 17, 1055, 11186, 1062, 1169, 14971, 3981, 13785, 413, 11455, 11186, 4059, 272, 8207, 63, 1019, 275, 980, 14, 20221, 1332, 12637, 3981, 22901, 17, 1055, 11186, 1062, 2490, 14971, 3981, 413, 11455, 11186, 4059, 272, 8207, 63, 2110, 275, 980, 14, 20221, 1332, 12637, 4439, 17, 1055, 11186, 1062, 14971, 59, 17, 11455, 11186, 4059, 272, 8207, 275, 980, 14, 20949, 1332, 6929, 63, 16131, 12, 8207, 63, 1019, 12, 8207, 63, 2110, 430, 272, 372, 8207, 421, 199, 318, 485, 3357, 63, 7490, 63, 19, 68, 8, 6929, 12, 6050, 304, 272, 302, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 275, 6050, 14, 1392, 272, 6709, 275, 980, 14, 2101, 8, 4060, 59, 6929, 59, 16, 61, 5001, 334, 78, 63, 89, 627, 302, 63, 90, 395, 1993, 334, 6929, 59, 16, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 5001, 302, 63, 90, 12, 1993, 334, 6929, 59, 16, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 450, 302, 63, 90, 61, 446, 1993, 6050, 59, 6929, 59, 17, 61, 5001, 334, 78, 63, 89, 627, 302, 63, 90, 395, 1993, 334, 6929, 59, 17, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 5001, 302, 63, 90, 12, 1993, 334, 6929, 59, 17, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 450, 302, 63, 90, 566, 272, 372, 6709, 421, 199, 3, 5787, 26, 6827, 3656, 314, 1834, 2410, 17226, 314, 4931, 31, 199, 199, 318, 485, 2629, 63, 6929, 63, 4916, 8, 2629, 12, 8207, 12, 4931, 29, 403, 304, 272, 408, 16581, 282, 3656, 370, 8207, 334, 13522, 503, 440, 9471, 272, 315, 795, 275, 980, 14, 5605, 8, 2629, 14, 890, 9, 272, 315, 795, 275, 315, 795, 59, 2629, 14, 11186, 5106, 272, 7654, 63, 2629, 275, 980, 14, 7954, 63, 460, 8, 1590, 14, 262, 17, 68, 8, 6929, 59, 16, 467, 315, 795, 395, 2892, 980, 14, 262, 17, 68, 8, 6929, 59, 17, 467, 315, 795, 430, 272, 8207, 275, 8207, 3981, 7654, 63, 2629, 61, 272, 340, 4931, 365, 440, 488, 26, 267, 4931, 275, 4931, 59, 688, 63, 2629, 61, 272, 340, 822, 8, 6929, 14, 11186, 5109, 267, 23291, 275, 8207, 14, 988, 342, 272, 587, 26, 267, 23291, 275, 378, 272, 1865, 275, 980, 14, 31698, 8, 1590, 14, 3235, 8, 6929, 14, 11186, 4000, 980, 14, 5605, 8, 30909, 435, 413, 430, 272, 8207, 275, 1865, 59, 6929, 61, 272, 340, 4931, 365, 488, 26, 267, 372, 8207, 272, 587, 26, 267, 372, 8207, 12, 4931, 421, 199, 318, 485, 475, 63, 2180, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 12, 3656, 29, 403, 12, 6050, 29, 403, 12, 1598, 372, 63, 305, 29, 4421, 14, 22684, 63, 3642, 12, 2152, 29, 403, 304, 272, 408, 30731, 20524, 805, 367, 6050, 63, 475, 63, 2180, 436, 6068, 63, 475, 63, 2180, 272, 408, 272, 8207, 275, 485, 1875, 63, 6929, 63, 19, 68, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 9, 339, 340, 2152, 365, 488, 26, 267, 340, 6050, 365, 488, 26, 288, 2152, 275, 980, 14, 442, 267, 587, 26, 288, 2152, 275, 6050, 14, 2271, 339, 340, 6050, 365, 440, 488, 26, 267, 6050, 275, 980, 14, 22900, 63, 19, 68, 8, 4060, 9, 267, 4931, 275, 485, 3357, 63, 7490, 63, 19, 68, 8, 6929, 12, 6050, 9, 267, 340, 3656, 365, 440, 488, 26, 288, 8207, 12, 4931, 275, 485, 2629, 63, 6929, 63, 4916, 8, 2629, 12, 8207, 12, 4931, 9, 288, 8348, 275, 6050, 14, 16597, 3430, 2629, 61, 267, 587, 26, 288, 8348, 275, 6050, 14, 11186, 342, 267, 302, 63, 2392, 88, 18099, 275, 8348, 14, 890, 272, 587, 26, 267, 340, 3656, 365, 440, 488 ]
[ 199, 1918, 520, 1494, 1705, 27993, 14, 4445, 63, 24020, 14, 1569, 64, 22988, 13082, 83, 15841, 370, 199, 5005, 4534, 687, 5935, 14, 199, 624, 199, 199, 3, 6642, 26, 662, 596, 290, 13086, 274, 598, 810, 778, 580, 665, 69, 596, 290, 13086, 274, 14, 71, 810, 778, 580, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 3515, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 199, 3, 3515, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 504, 7975, 492, 3336, 199, 646, 5579, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5178, 199, 504, 2680, 14, 773, 14, 12318, 63, 599, 5618, 492, 465, 63, 816, 770, 199, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 12, 1104, 63, 2355, 63, 929, 199, 504, 2508, 1208, 14, 26205, 492, 6073, 514, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 199, 363, 452, 363, 275, 788, 11173, 11039, 297, 1779, 283, 5005, 63, 11350, 63, 18, 68, 297, 1779, 283, 3825, 63, 475, 63, 2180, 297, 1779, 283, 4060, 63, 475, 63, 2180, 297, 1779, 283, 264, 8514, 63, 504, 63, 11350, 63, 18, 68, 418, 199, 199, 11490, 199, 3, 11606, 376, 1834, 370, 282, 3343, 421, 199, 318, 485, 1875, 63, 6929, 63, 19, 68, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 29, 17, 304, 272, 408, 3407, 282, 769, 402, 8207, 367, 282, 650, 36, 1834, 14, 339, 3897, 272, 275, 17575, 272, 302, 63, 88, 26, 3000, 267, 710, 1568, 402, 314, 6068, 315, 314, 671, 7581, 14, 272, 302, 63, 89, 26, 3000, 267, 710, 1568, 402, 314, 6068, 315, 314, 612, 7581, 14, 272, 302, 63, 90, 26, 3000, 12, 2716, 267, 710, 1568, 402, 314, 6068, 315, 314, 1315, 7581, 12, 4243, 370, 413, 272, 408, 272, 14971, 275, 980, 14, 5605, 8, 78, 63, 88, 627, 302, 63, 89, 627, 302, 63, 90, 680, 5217, 1332, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 430, 272, 8207, 63, 16131, 275, 980, 14, 20221, 1332, 12637, 3981, 13785, 22901, 17, 1055, 11186, 1062, 1169, 14971, 3981, 13785, 413, 11455, 11186, 4059, 272, 8207, 63, 1019, 275, 980, 14, 20221, 1332, 12637, 3981, 22901, 17, 1055, 11186, 1062, 2490, 14971, 3981, 413, 11455, 11186, 4059, 272, 8207, 63, 2110, 275, 980, 14, 20221, 1332, 12637, 4439, 17, 1055, 11186, 1062, 14971, 59, 17, 11455, 11186, 4059, 272, 8207, 275, 980, 14, 20949, 1332, 6929, 63, 16131, 12, 8207, 63, 1019, 12, 8207, 63, 2110, 430, 272, 372, 8207, 421, 199, 318, 485, 3357, 63, 7490, 63, 19, 68, 8, 6929, 12, 6050, 304, 272, 302, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 275, 6050, 14, 1392, 272, 6709, 275, 980, 14, 2101, 8, 4060, 59, 6929, 59, 16, 61, 5001, 334, 78, 63, 89, 627, 302, 63, 90, 395, 1993, 334, 6929, 59, 16, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 5001, 302, 63, 90, 12, 1993, 334, 6929, 59, 16, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 450, 302, 63, 90, 61, 446, 1993, 6050, 59, 6929, 59, 17, 61, 5001, 334, 78, 63, 89, 627, 302, 63, 90, 395, 1993, 334, 6929, 59, 17, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 5001, 302, 63, 90, 12, 1993, 334, 6929, 59, 17, 61, 450, 334, 78, 63, 89, 627, 302, 63, 90, 430, 450, 302, 63, 90, 566, 272, 372, 6709, 421, 199, 3, 5787, 26, 6827, 3656, 314, 1834, 2410, 17226, 314, 4931, 31, 199, 199, 318, 485, 2629, 63, 6929, 63, 4916, 8, 2629, 12, 8207, 12, 4931, 29, 403, 304, 272, 408, 16581, 282, 3656, 370, 8207, 334, 13522, 503, 440, 9471, 272, 315, 795, 275, 980, 14, 5605, 8, 2629, 14, 890, 9, 272, 315, 795, 275, 315, 795, 59, 2629, 14, 11186, 5106, 272, 7654, 63, 2629, 275, 980, 14, 7954, 63, 460, 8, 1590, 14, 262, 17, 68, 8, 6929, 59, 16, 467, 315, 795, 395, 2892, 980, 14, 262, 17, 68, 8, 6929, 59, 17, 467, 315, 795, 430, 272, 8207, 275, 8207, 3981, 7654, 63, 2629, 61, 272, 340, 4931, 365, 440, 488, 26, 267, 4931, 275, 4931, 59, 688, 63, 2629, 61, 272, 340, 822, 8, 6929, 14, 11186, 5109, 267, 23291, 275, 8207, 14, 988, 342, 272, 587, 26, 267, 23291, 275, 378, 272, 1865, 275, 980, 14, 31698, 8, 1590, 14, 3235, 8, 6929, 14, 11186, 4000, 980, 14, 5605, 8, 30909, 435, 413, 430, 272, 8207, 275, 1865, 59, 6929, 61, 272, 340, 4931, 365, 488, 26, 267, 372, 8207, 272, 587, 26, 267, 372, 8207, 12, 4931, 421, 199, 318, 485, 475, 63, 2180, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 12, 3656, 29, 403, 12, 6050, 29, 403, 12, 1598, 372, 63, 305, 29, 4421, 14, 22684, 63, 3642, 12, 2152, 29, 403, 304, 272, 408, 30731, 20524, 805, 367, 6050, 63, 475, 63, 2180, 436, 6068, 63, 475, 63, 2180, 272, 408, 272, 8207, 275, 485, 1875, 63, 6929, 63, 19, 68, 8, 78, 63, 88, 12, 302, 63, 89, 12, 302, 63, 90, 9, 339, 340, 2152, 365, 488, 26, 267, 340, 6050, 365, 488, 26, 288, 2152, 275, 980, 14, 442, 267, 587, 26, 288, 2152, 275, 6050, 14, 2271, 339, 340, 6050, 365, 440, 488, 26, 267, 6050, 275, 980, 14, 22900, 63, 19, 68, 8, 4060, 9, 267, 4931, 275, 485, 3357, 63, 7490, 63, 19, 68, 8, 6929, 12, 6050, 9, 267, 340, 3656, 365, 440, 488, 26, 288, 8207, 12, 4931, 275, 485, 2629, 63, 6929, 63, 4916, 8, 2629, 12, 8207, 12, 4931, 9, 288, 8348, 275, 6050, 14, 16597, 3430, 2629, 61, 267, 587, 26, 288, 8348, 275, 6050, 14, 11186, 342, 267, 302, 63, 2392, 88, 18099, 275, 8348, 14, 890, 272, 587, 26, 267, 340, 3656, 365, 440, 488, 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, 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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 ]
rosmo/ansible
lib/ansible/modules/packaging/os/urpmi.py
43
6462
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Philippe Makowski # Written by Philippe Makowski <philippem@mageia.org> # Based on apt module written by Matthew Williams <matthew@flowroute.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: urpmi short_description: Urpmi manager description: - Manages packages with I(urpmi) (such as for Mageia or Mandriva) version_added: "1.3.4" options: name: description: - A list of package names to install, upgrade or remove. required: yes version_added: "2.6" aliases: [ package, pkg ] state: description: - Indicates the desired package state. choices: [ absent, present ] default: present update_cache: description: - Update the package database first C(urpmi.update -a). type: bool default: 'no' no-recommends: description: - Corresponds to the C(--no-recommends) option for I(urpmi). type: bool default: 'yes' aliases: ['no-recommends'] force: description: - Assume "yes" is the answer to any question urpmi has to ask. Corresponds to the C(--force) option for I(urpmi). type: bool default: 'yes' root: description: - Specifies an alternative install root, relative to which all packages will be installed. Corresponds to the C(--root) option for I(urpmi). default: / version_added: "2.4" aliases: [ installroot ] author: - Philippe Makowski (@pmakowski) ''' EXAMPLES = ''' - name: Install package foo urpmi: pkg: foo state: present - name: Remove package foo urpmi: pkg: foo state: absent - name: Remove packages foo and bar urpmi: pkg: foo,bar state: absent - name: Update the package database (urpmi.update -a -q) and install bar (bar will be the updated if a newer version exists) - urpmi: name: bar state: present update_cache: yes ''' import os import shlex import sys from ansible.module_utils.basic import AnsibleModule def query_package(module, name, root): # rpm -q returns 0 if the package is installed, # 1 if it is not installed rpm_path = module.get_bin_path("rpm", True) cmd = "%s -q %s %s" % (rpm_path, name, root_option(root)) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc == 0: return True else: return False def query_package_provides(module, name, root): # rpm -q returns 0 if the package is installed, # 1 if it is not installed rpm_path = module.get_bin_path("rpm", True) cmd = "%s -q --whatprovides %s %s" % (rpm_path, name, root_option(root)) rc, stdout, stderr = module.run_command(cmd, check_rc=False) return rc == 0 def update_package_db(module): urpmiupdate_path = module.get_bin_path("urpmi.update", True) cmd = "%s -a -q" % (urpmiupdate_path,) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="could not update package db") def remove_packages(module, packages, root): remove_c = 0 # Using a for loop in case of error, we can report the package that failed for package in packages: # Query the package first, to see if we even need to remove if not query_package(module, package, root): continue urpme_path = module.get_bin_path("urpme", True) cmd = "%s --auto %s %s" % (urpme_path, root_option(root), package) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="failed to remove %s" % (package)) remove_c += 1 if remove_c > 0: module.exit_json(changed=True, msg="removed %s package(s)" % remove_c) module.exit_json(changed=False, msg="package(s) already absent") def install_packages(module, pkgspec, root, force=True, no_recommends=True): packages = "" for package in pkgspec: if not query_package_provides(module, package, root): packages += "'%s' " % package if len(packages) != 0: if no_recommends: no_recommends_yes = '--no-recommends' else: no_recommends_yes = '' if force: force_yes = '--force' else: force_yes = '' urpmi_path = module.get_bin_path("urpmi", True) cmd = ("%s --auto %s --quiet %s %s %s" % (urpmi_path, force_yes, no_recommends_yes, root_option(root), packages)) rc, out, err = module.run_command(cmd) for package in pkgspec: if not query_package_provides(module, package, root): module.fail_json(msg="'urpmi %s' failed: %s" % (package, err)) # urpmi always have 0 for exit code if --force is used if rc: module.fail_json(msg="'urpmi %s' failed: %s" % (packages, err)) else: module.exit_json(changed=True, msg="%s present(s)" % packages) else: module.exit_json(changed=False) def root_option(root): if (root): return "--root=%s" % (root) else: return "" def main(): module = AnsibleModule( argument_spec=dict( state=dict(type='str', default='installed', choices=['absent', 'installed', 'present', 'removed']), update_cache=dict(type='bool', default=False, aliases=['update-cache']), force=dict(type='bool', default=True), no_recommends=dict(type='bool', default=True, aliases=['no-recommends']), name=dict(type='list', required=True, aliases=['package', 'pkg']), root=dict(type='str', aliases=['installroot']), ), ) p = module.params if p['update_cache']: update_package_db(module) if p['state'] in ['installed', 'present']: install_packages(module, p['name'], p['root'], p['force'], p['no_recommends']) elif p['state'] in ['removed', 'absent']: remove_packages(module, p['name'], p['root']) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6171, 12, 11308, 1638, 80, 321, 603, 1151, 19844, 199, 3, 27694, 701, 11308, 1638, 80, 321, 603, 1151, 19844, 665, 838, 1638, 80, 13102, 32, 960, 4674, 14, 1308, 30, 199, 3, 21311, 641, 20932, 859, 5313, 701, 18619, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 30, 199, 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, 199, 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, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7629, 80, 2664, 199, 3612, 63, 1802, 26, 738, 4599, 2664, 5256, 199, 1802, 26, 523, 446, 21612, 6117, 543, 473, 8, 300, 80, 2664, 9, 334, 10180, 465, 367, 603, 474, 4674, 503, 603, 460, 322, 3042, 9, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 14, 20, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2559, 1561, 370, 3907, 12, 10754, 503, 2813, 14, 272, 1415, 26, 9456, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 272, 5481, 26, 359, 2559, 12, 5496, 1622, 523, 1174, 26, 272, 1369, 26, 489, 446, 19334, 314, 6387, 2559, 1174, 14, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 523, 1678, 63, 1637, 26, 272, 1369, 26, 489, 446, 6162, 314, 2559, 3050, 1642, 445, 8, 300, 80, 2664, 14, 873, 446, 65, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 523, 949, 13, 264, 9847, 795, 26, 272, 1369, 26, 489, 446, 7499, 3853, 795, 370, 314, 445, 8, 306, 889, 13, 264, 9847, 795, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 5066, 7, 272, 5481, 26, 788, 889, 13, 264, 9847, 795, 418, 523, 3542, 26, 272, 1369, 26, 489, 446, 16269, 298, 5066, 2, 365, 314, 6385, 370, 1263, 7894, 7629, 80, 2664, 965, 370, 7198, 14, 267, 7499, 3853, 795, 370, 314, 445, 8, 306, 3990, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 5066, 7, 523, 1738, 26, 272, 1369, 26, 489, 446, 11015, 376, 13943, 3907, 1738, 12, 3847, 370, 1314, 1006, 6117, 911, 506, 4903, 14, 267, 7499, 3853, 795, 370, 314, 445, 8, 306, 1231, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 849, 26, 1182, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 5481, 26, 359, 3907, 1231, 1622, 199, 2502, 26, 199, 13, 11308, 1638, 80, 321, 603, 1151, 19844, 8593, 80, 22191, 19844, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 13276, 2559, 3925, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 2559, 3925, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 5852, 6117, 3925, 436, 4681, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 12, 1700, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 6162, 314, 2559, 3050, 334, 300, 80, 2664, 14, 873, 446, 65, 446, 81, 9, 436, 3907, 4681, 334, 1700, 911, 506, 314, 4588, 340, 282, 15666, 1015, 3495, 9, 199, 13, 7629, 80, 2664, 26, 272, 536, 26, 4681, 272, 1174, 26, 3451, 272, 1678, 63, 1637, 26, 9456, 199, 2344, 421, 199, 646, 747, 199, 646, 16701, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 536, 12, 1738, 304, 272, 327, 21980, 446, 81, 2529, 378, 340, 314, 2559, 365, 4903, 12, 272, 327, 413, 340, 652, 365, 440, 4903, 272, 21980, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 14191, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 81, 450, 83, 450, 83, 2, 450, 334, 14191, 63, 515, 12, 536, 12, 1738, 63, 1422, 8, 1231, 430, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 340, 4819, 508, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 318, 1827, 63, 2491, 63, 20121, 8, 578, 12, 536, 12, 1738, 304, 272, 327, 21980, 446, 81, 2529, 378, 340, 314, 2559, 365, 4903, 12, 272, 327, 413, 340, 652, 365, 440, 4903, 272, 21980, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 14191, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 81, 1553, 10058, 20121, 450, 83, 450, 83, 2, 450, 334, 14191, 63, 515, 12, 536, 12, 1738, 63, 1422, 8, 1231, 430, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 372, 4819, 508, 378, 421, 199, 318, 1678, 63, 2491, 63, 697, 8, 578, 304, 339, 7629, 80, 2664, 873, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 300, 80, 2664, 14, 873, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 65, 446, 81, 2, 450, 334, 300, 80, 2664, 873, 63, 515, 4258, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 340, 4819, 1137, 378, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 15153, 440, 1678, 2559, 1592, 531, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 6117, 12, 1738, 304, 339, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 1930, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6171, 12, 11308, 1638, 80, 321, 603, 1151, 19844, 199, 3, 27694, 701, 11308, 1638, 80, 321, 603, 1151, 19844, 665, 838, 1638, 80, 13102, 32, 960, 4674, 14, 1308, 30, 199, 3, 21311, 641, 20932, 859, 5313, 701, 18619, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 30, 199, 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, 199, 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, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 7629, 80, 2664, 199, 3612, 63, 1802, 26, 738, 4599, 2664, 5256, 199, 1802, 26, 523, 446, 21612, 6117, 543, 473, 8, 300, 80, 2664, 9, 334, 10180, 465, 367, 603, 474, 4674, 503, 603, 460, 322, 3042, 9, 199, 1023, 63, 3270, 26, 298, 17, 14, 19, 14, 20, 2, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 437, 769, 402, 2559, 1561, 370, 3907, 12, 10754, 503, 2813, 14, 272, 1415, 26, 9456, 272, 1015, 63, 3270, 26, 298, 18, 14, 22, 2, 272, 5481, 26, 359, 2559, 12, 5496, 1622, 523, 1174, 26, 272, 1369, 26, 489, 446, 19334, 314, 6387, 2559, 1174, 14, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 523, 1678, 63, 1637, 26, 272, 1369, 26, 489, 446, 6162, 314, 2559, 3050, 1642, 445, 8, 300, 80, 2664, 14, 873, 446, 65, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 523, 949, 13, 264, 9847, 795, 26, 272, 1369, 26, 489, 446, 7499, 3853, 795, 370, 314, 445, 8, 306, 889, 13, 264, 9847, 795, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 5066, 7, 272, 5481, 26, 788, 889, 13, 264, 9847, 795, 418, 523, 3542, 26, 272, 1369, 26, 489, 446, 16269, 298, 5066, 2, 365, 314, 6385, 370, 1263, 7894, 7629, 80, 2664, 965, 370, 7198, 14, 267, 7499, 3853, 795, 370, 314, 445, 8, 306, 3990, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 730, 26, 2155, 272, 849, 26, 283, 5066, 7, 523, 1738, 26, 272, 1369, 26, 489, 446, 11015, 376, 13943, 3907, 1738, 12, 3847, 370, 1314, 1006, 6117, 911, 506, 4903, 14, 267, 7499, 3853, 795, 370, 314, 445, 8, 306, 1231, 9, 945, 367, 473, 8, 300, 80, 2664, 680, 272, 849, 26, 1182, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 272, 5481, 26, 359, 3907, 1231, 1622, 199, 2502, 26, 199, 13, 11308, 1638, 80, 321, 603, 1151, 19844, 8593, 80, 22191, 19844, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 13276, 2559, 3925, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 2559, 3925, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 5852, 6117, 3925, 436, 4681, 523, 7629, 80, 2664, 26, 272, 5496, 26, 3925, 12, 1700, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 6162, 314, 2559, 3050, 334, 300, 80, 2664, 14, 873, 446, 65, 446, 81, 9, 436, 3907, 4681, 334, 1700, 911, 506, 314, 4588, 340, 282, 15666, 1015, 3495, 9, 199, 13, 7629, 80, 2664, 26, 272, 536, 26, 4681, 272, 1174, 26, 3451, 272, 1678, 63, 1637, 26, 9456, 199, 2344, 421, 199, 646, 747, 199, 646, 16701, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 421, 199, 318, 1827, 63, 2491, 8, 578, 12, 536, 12, 1738, 304, 272, 327, 21980, 446, 81, 2529, 378, 340, 314, 2559, 365, 4903, 12, 272, 327, 413, 340, 652, 365, 440, 4903, 272, 21980, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 14191, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 81, 450, 83, 450, 83, 2, 450, 334, 14191, 63, 515, 12, 536, 12, 1738, 63, 1422, 8, 1231, 430, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 340, 4819, 508, 378, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 421, 199, 318, 1827, 63, 2491, 63, 20121, 8, 578, 12, 536, 12, 1738, 304, 272, 327, 21980, 446, 81, 2529, 378, 340, 314, 2559, 365, 4903, 12, 272, 327, 413, 340, 652, 365, 440, 4903, 272, 21980, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 14191, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 81, 1553, 10058, 20121, 450, 83, 450, 83, 2, 450, 334, 14191, 63, 515, 12, 536, 12, 1738, 63, 1422, 8, 1231, 430, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 372, 4819, 508, 378, 421, 199, 318, 1678, 63, 2491, 63, 697, 8, 578, 304, 339, 7629, 80, 2664, 873, 63, 515, 275, 859, 14, 362, 63, 1393, 63, 515, 480, 300, 80, 2664, 14, 873, 401, 715, 9, 272, 2088, 275, 2071, 83, 446, 65, 446, 81, 2, 450, 334, 300, 80, 2664, 873, 63, 515, 4258, 272, 4819, 12, 3839, 12, 4635, 275, 859, 14, 1065, 63, 1531, 8, 1760, 12, 1104, 63, 1195, 29, 797, 9, 272, 340, 4819, 1137, 378, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 628, 15153, 440, 1678, 2559, 1592, 531, 421, 199, 318, 2813, 63, 5154, 8, 578, 12, 6117, 12, 1738, 304, 339, 2813, 63, 67, 275, 378, 272, 327, 11719, 282, 367, 4438, 315, 1930, 402, 1125, 12, 781, 883, 3622, 314, 2559, 626, 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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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 ]
QuLogic/iris
lib/iris/tests/integration/test_regrid_equivalence.py
5
9580
# (C) British Crown Copyright 2016 - 2017, Met Office # # This file is part of Iris. # # Iris is free software: you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the # Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Iris 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 Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Iris. If not, see <http://www.gnu.org/licenses/>. """ Tests to check the validity of replacing "iris.analysis._interpolate.regrid`('nearest')" with "iris.cube.Cube.regrid(scheme=iris.analysis.Nearest())". """ from __future__ import (absolute_import, division, print_function) from six.moves import (filter, input, map, range, zip) # noqa # Import iris.tests first so that some things can be initialised before # importing anything else. import iris.tests as tests import numpy as np import iris from iris.analysis import Nearest from iris.cube import Cube from iris.coords import AuxCoord, DimCoord def grid_cube(xx, yy, data=None): nx, ny = len(xx), len(yy) if data is not None: data = np.array(data).reshape((ny, nx)) else: data = np.zeros((ny, nx)) cube = Cube(data) y_coord = DimCoord(yy, standard_name='latitude', units='degrees') x_coord = DimCoord(xx, standard_name='longitude', units='degrees') cube.add_dim_coord(y_coord, 0) cube.add_dim_coord(x_coord, 1) return cube ENABLE_DEBUG_OUTPUT = False def _debug_data(cube, test_id): if ENABLE_DEBUG_OUTPUT: print data = cube.data print('CUBE: {}'.format(test_id)) print(' x={!r}'.format(cube.coord('longitude').points)) print(' y={!r}'.format(cube.coord('latitude').points)) print('data[{}]:'.format(type(data))) print(repr(data)) class MixinCheckingCode(object): def test_basic(self): src_x = [30., 40., 50.] dst_x = [32., 42.] src_y = [-10., 0., 10.] dst_y = [-8., 2.] data = [[3., 4., 5.], [23., 24., 25.], [43., 44., 45.]] expected_result = [[3., 4.], [23., 24.]] src_cube = grid_cube(src_x, src_y, data) _debug_data(src_cube, "basic SOURCE") dst_cube = grid_cube(dst_x, dst_y) result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "basic RESULT") self.assertArrayAllClose(result_cube.data, expected_result) def test_src_extrapolation(self): src_x = [30., 40., 50.] dst_x = [0., 29.0, 39.0] src_y = [-10., 0., 10.] dst_y = [-50., -9., -1.] data = [[3., 4., 5.], [23., 24., 25.], [43., 44., 45.]] expected_result = [[3., 3., 4.], [3., 3., 4.], [23., 23., 24.]] src_cube = grid_cube(src_x, src_y, data) _debug_data(src_cube, "extrapolate SOURCE") dst_cube = grid_cube(dst_x, dst_y) result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "extrapolate RESULT") self.assertArrayAllClose(result_cube.data, expected_result) def test_exact_matching_points(self): src_x = [10.0, 20.0, 30.0] src_y = [10.0, 20.0, 30.0] dst_x = [14.9, 15.1, 20.0, 24.9, 25.1] dst_y = [14.9, 15.1, 20.0, 24.9, 25.1] data = [[3., 4., 5.], [23., 24., 25.], [43., 44., 45.]] expected_result = [[3., 4., 4., 4., 5.], [23., 24., 24., 24., 25.], [23., 24., 24., 24., 25.], [23., 24., 24., 24., 25.], [43., 44., 44., 44., 45.]] src_cube = grid_cube(src_x, src_y, data) _debug_data(src_cube, "matching SOURCE") dst_cube = grid_cube(dst_x, dst_y) result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "matching RESULt") self.assertArrayAllClose(result_cube.data, expected_result) def test_source_mask(self): src_x = [40.0, 50.0, 60.0] src_y = [40.0, 50.0, 60.0] dst_x = [44.99, 45.01, 48.0, 50.0, 52.0, 54.99, 55.01] dst_y = [44.99, 45.01, 48.0, 50.0, 52.0, 54.99, 55.01] data = np.ma.masked_equal([[3., 4., 5.], [23., 999, 25.], [43., 44., 45.]], 999) expected_result = np.ma.masked_equal( [[3., 4., 4., 4., 4., 4., 5.], [23., 999, 999, 999, 999, 999, 25.], [23., 999, 999, 999, 999, 999, 25.], [23., 999, 999, 999, 999, 999, 25.], [23., 999, 999, 999, 999, 999, 25.], [23., 999, 999, 999, 999, 999, 25.], [43., 44., 44., 44., 44., 44., 45.]], 999) src_cube = grid_cube(src_x, src_y, data) src_cube.data = np.ma.masked_array(src_cube.data) src_cube.data[1, 1] = np.ma.masked _debug_data(src_cube, "masked SOURCE") dst_cube = grid_cube(dst_x, dst_y) result_cube = self.regrid(src_cube, dst_cube, translate_nans_to_mask=True) _debug_data(result_cube, "masked RESULT") self.assertMaskedArrayEqual(result_cube.data, expected_result) def test_wrapping_non_circular(self): src_x = [-10., 0., 10.] dst_x = [-360.0, -170., -1.0, 1.0, 50.0, 170.0, 352.0, 720.0] src_y = [0., 10.] dst_y = [0., 10.] data = [[3., 4., 5.], [3., 4., 5.]] src_cube = grid_cube(src_x, src_y, data) dst_cube = grid_cube(dst_x, dst_y) expected_result = [[4., 3., 4., 4., 5., 5., 3., 4.], [4., 3., 4., 4., 5., 5., 3., 4.]] _debug_data(src_cube, "noncircular SOURCE") result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "noncircular RESULT") self.assertArrayAllClose(result_cube.data, expected_result) def test_wrapping_circular(self): # When x-coord is "circular", the above distinction does not apply : # results are the same for both calculations. src_x = [-10., 0., 10.] dst_x = [-360.0, -170., -1.0, 1.0, 50.0, 170.0, 352.0, 720.0] src_y = [0., 10.] dst_y = [0., 10.] data = [[3., 4., 5.], [3., 4., 5.]] src_cube = grid_cube(src_x, src_y, data) dst_cube = grid_cube(dst_x, dst_y) src_cube.coord('longitude').circular = True expected_result = [[4., 3., 4., 4., 5., 5., 3., 4.], [4., 3., 4., 4., 5., 5., 3., 4.]] _debug_data(src_cube, "circular SOURCE") result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "circular RESULT") self.assertArrayAllClose(result_cube.data, expected_result) def test_wrapping_non_angular(self): src_x = [-10., 0., 10.] dst_x = [-360.0, -170., -1.0, 1.0, 50.0, 170.0, 352.0, 720.0] src_y = [0., 10.] dst_y = [0., 10.] data = [[3., 4., 5.], [3., 4., 5.]] src_cube = grid_cube(src_x, src_y, data) dst_cube = grid_cube(dst_x, dst_y) for co_name in ('longitude', 'latitude'): for cube in (src_cube, dst_cube): coord = cube.coord(co_name) coord.coord_system = None coord.convert_units('1') # interpolate.regrid --> Wrapping-free results (non-circular). expected_result = [[3., 3., 4., 4., 5., 5., 5., 5.], [3., 3., 4., 4., 5., 5., 5., 5.]] _debug_data(src_cube, "non-angle-lons SOURCE") result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "non-angle-lons RESULT") self.assertArrayAllClose(result_cube.data, expected_result) def test_source_nan(self): src_x = [40.0, 50.0, 60.0] src_y = [40.0, 50.0, 60.0] dst_x = [44.99, 45.01, 48.0, 50.0, 52.0, 54.99, 55.01] dst_y = [44.99, 45.01, 48.0, 50.0, 52.0, 54.99, 55.01] nan = np.nan data = [[3., 4., 5.], [23., nan, 25.], [43., 44., 45.]] expected_result = [[3., 4., 4., 4., 4., 4., 5.], [23., nan, nan, nan, nan, nan, 25.], [23., nan, nan, nan, nan, nan, 25.], [23., nan, nan, nan, nan, nan, 25.], [23., nan, nan, nan, nan, nan, 25.], [23., nan, nan, nan, nan, nan, 25.], [43., 44., 44., 44., 44., 44., 45.]] src_cube = grid_cube(src_x, src_y, data) _debug_data(src_cube, "nan SOURCE") dst_cube = grid_cube(dst_x, dst_y) result_cube = self.regrid(src_cube, dst_cube) _debug_data(result_cube, "nan RESULT") self.assertArrayEqual(result_cube.data, expected_result) class TestCubeRegridNearest(MixinCheckingCode, tests.IrisTest): scheme = Nearest(extrapolation_mode='extrapolate') def regrid(self, src_cube, dst_cube, **kwargs): return src_cube.regrid(dst_cube, scheme=self.scheme) if __name__ == '__main__': tests.main()
gpl-3.0
[ 3, 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 7800, 446, 9708, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 2925, 370, 1104, 314, 25667, 402, 15810, 199, 2, 11885, 14, 10466, 423, 21294, 14, 1135, 1677, 64, 360, 16615, 19124, 543, 199, 2, 11885, 14, 11477, 14, 25043, 14, 1135, 1677, 8, 5512, 29, 11885, 14, 10466, 14, 4698, 9540, 1012, 1674, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 504, 3816, 14, 4912, 492, 334, 1541, 12, 1324, 12, 2341, 12, 1425, 12, 3482, 9, 221, 327, 8151, 199, 199, 3, 3161, 12192, 14, 2219, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 2544, 199, 3, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 646, 2680, 465, 980, 199, 199, 646, 12192, 199, 504, 12192, 14, 10466, 492, 5612, 9540, 199, 504, 12192, 14, 11477, 492, 445, 3375, 199, 504, 12192, 14, 8032, 492, 437, 2521, 14957, 12, 577, 1017, 14957, 421, 199, 318, 6068, 63, 11477, 8, 2154, 12, 20435, 12, 666, 29, 403, 304, 272, 8484, 12, 25758, 275, 822, 8, 2154, 395, 822, 8, 7566, 9, 272, 340, 666, 365, 440, 488, 26, 267, 666, 275, 980, 14, 1144, 8, 576, 680, 5217, 1332, 9745, 12, 8484, 430, 272, 587, 26, 267, 666, 275, 980, 14, 4250, 1332, 9745, 12, 8484, 430, 272, 15681, 275, 445, 3375, 8, 576, 9, 272, 612, 63, 7988, 275, 577, 1017, 14957, 8, 7566, 12, 4465, 63, 354, 534, 13331, 297, 6204, 534, 20251, 358, 272, 671, 63, 7988, 275, 577, 1017, 14957, 8, 2154, 12, 4465, 63, 354, 534, 13803, 297, 6204, 534, 20251, 358, 272, 15681, 14, 525, 63, 3572, 63, 7988, 8, 89, 63, 7988, 12, 378, 9, 272, 15681, 14, 525, 63, 3572, 63, 7988, 8, 88, 63, 7988, 12, 413, 9, 272, 372, 15681, 421, 199, 8898, 63, 5287, 63, 8414, 275, 756, 421, 199, 318, 485, 1757, 63, 576, 8, 11477, 12, 511, 63, 344, 304, 272, 340, 27926, 63, 5287, 63, 8414, 26, 267, 870, 267, 666, 275, 15681, 14, 576, 267, 870, 360, 35, 21857, 26, 9499, 908, 8, 396, 63, 344, 430, 267, 870, 360, 221, 671, 3126, 1, 82, 5285, 908, 8, 11477, 14, 7988, 360, 13803, 1959, 3438, 430, 267, 870, 360, 221, 612, 3126, 1, 82, 5285, 908, 8, 11477, 14, 7988, 360, 13331, 1959, 3438, 430, 267, 870, 360, 576, 59, 2440, 2189, 1370, 908, 8, 466, 8, 576, 1724, 267, 870, 8, 2722, 8, 576, 430, 421, 199, 533, 28438, 14740, 3034, 8, 785, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 2928, 63, 88, 275, 359, 1216, 2020, 6335, 2020, 5238, 19784, 267, 5042, 63, 88, 275, 359, 708, 2020, 5685, 19784, 267, 2928, 63, 89, 275, 5243, 709, 2020, 378, 2020, 1616, 19784, 267, 5042, 63, 89, 275, 5243, 24, 2020, 499, 19784, 267, 666, 275, 3474, 19, 2020, 841, 2020, 959, 8333, 355, 359, 1789, 2020, 5504, 2020, 5661, 8333, 355, 359, 2824, 2020, 10868, 2020, 10416, 28132, 267, 1420, 63, 1099, 275, 3474, 19, 2020, 841, 8333, 2574, 359, 1789, 2020, 5504, 28132, 267, 2928, 63, 11477, 275, 6068, 63, 11477, 8, 2164, 63, 88, 12, 2928, 63, 89, 12, 666, 9, 267, 485, 1757, 63, 576, 8, 2164, 63, 11477, 12, 298, 4316, 25470, 531, 267, 5042, 63, 11477, 275, 6068, 63, 11477, 8, 5119, 63, 88, 12, 5042, 63, 89, 9, 267, 754, 63, 11477, 275, 291, 14, 1135, 1677, 8, 2164, 63, 11477, 12, 5042, 63, 11477, 9, 267, 485, 1757, 63, 576, 8, 1099, 63, 11477, 12, 298, 4316, 20668, 531, 267, 291, 14, 479, 3836, 2422, 4724, 8, 1099, 63, 11477, 14, 576, 12, 1420, 63, 1099, 9, 339, 347, 511, 63, 2164, 63, 832, 1330, 10410, 8, 277, 304, 267, 2928, 63, 88, 275, 359, 1216, 2020, 6335, 2020, 5238, 19784, 267, 5042, 63, 88, 275, 359, 16, 2020, 7349, 14, 16, 12, 10551, 14, 16, 61, 267, 2928, 63, 89, 275, 5243, 709, 2020, 378, 2020, 1616, 19784, 267, 5042, 63, 89, 275, 5243, 1400, 2020, 446, 25, 2020, 446, 17, 19784, 267, 666, 275, 3474, 19, 2020, 841, 2020, 959, 8333, 355, 359, 1789, 2020, 5504, 2020, 5661, 8333, 355, 359, 2824, 2020, 10868, 2020, 10416, 28132, 267, 1420, 63, 1099, 275, 3474, 19, 2020, 650, 2020, 841, 8333, 2574, 359, 19, 2020, 650, 2020, 841, 8333, 2574, 359, 1789, 2020, 6546, 2020, 5504, 28132, 267, 2928, 63, 11477, 275, 6068, 63, 11477, 8, 2164, 63, 88, 12, 2928, 63, 89, 12, 666, 9, 267, 485, 1757, 63, 576, 8, 2164, 63, 11477, 12, 298, 832, 1330, 16288, 25470, 531, 267, 5042, 63, 11477, 275, 6068, 63, 11477, 8, 5119, 63, 88, 12, 5042, 63, 89, 9, 267, 754, 63, 11477, 275, 291, 14, 1135, 1677, 8, 2164, 63, 11477, 12, 5042, 63, 11477, 9, 267, 485, 1757, 63, 576, 8, 1099, 63, 11477, 12, 298, 832, 1330, 16288, 20668, 531, 267, 291, 14, 479, 3836, 2422, 4724, 8, 1099, 63, 11477, 14, 576, 12, 1420, 63, 1099, 9 ]
[ 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 7800, 446, 9708, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 2925, 370, 1104, 314, 25667, 402, 15810, 199, 2, 11885, 14, 10466, 423, 21294, 14, 1135, 1677, 64, 360, 16615, 19124, 543, 199, 2, 11885, 14, 11477, 14, 25043, 14, 1135, 1677, 8, 5512, 29, 11885, 14, 10466, 14, 4698, 9540, 1012, 1674, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 504, 3816, 14, 4912, 492, 334, 1541, 12, 1324, 12, 2341, 12, 1425, 12, 3482, 9, 221, 327, 8151, 199, 199, 3, 3161, 12192, 14, 2219, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 2544, 199, 3, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 646, 2680, 465, 980, 199, 199, 646, 12192, 199, 504, 12192, 14, 10466, 492, 5612, 9540, 199, 504, 12192, 14, 11477, 492, 445, 3375, 199, 504, 12192, 14, 8032, 492, 437, 2521, 14957, 12, 577, 1017, 14957, 421, 199, 318, 6068, 63, 11477, 8, 2154, 12, 20435, 12, 666, 29, 403, 304, 272, 8484, 12, 25758, 275, 822, 8, 2154, 395, 822, 8, 7566, 9, 272, 340, 666, 365, 440, 488, 26, 267, 666, 275, 980, 14, 1144, 8, 576, 680, 5217, 1332, 9745, 12, 8484, 430, 272, 587, 26, 267, 666, 275, 980, 14, 4250, 1332, 9745, 12, 8484, 430, 272, 15681, 275, 445, 3375, 8, 576, 9, 272, 612, 63, 7988, 275, 577, 1017, 14957, 8, 7566, 12, 4465, 63, 354, 534, 13331, 297, 6204, 534, 20251, 358, 272, 671, 63, 7988, 275, 577, 1017, 14957, 8, 2154, 12, 4465, 63, 354, 534, 13803, 297, 6204, 534, 20251, 358, 272, 15681, 14, 525, 63, 3572, 63, 7988, 8, 89, 63, 7988, 12, 378, 9, 272, 15681, 14, 525, 63, 3572, 63, 7988, 8, 88, 63, 7988, 12, 413, 9, 272, 372, 15681, 421, 199, 8898, 63, 5287, 63, 8414, 275, 756, 421, 199, 318, 485, 1757, 63, 576, 8, 11477, 12, 511, 63, 344, 304, 272, 340, 27926, 63, 5287, 63, 8414, 26, 267, 870, 267, 666, 275, 15681, 14, 576, 267, 870, 360, 35, 21857, 26, 9499, 908, 8, 396, 63, 344, 430, 267, 870, 360, 221, 671, 3126, 1, 82, 5285, 908, 8, 11477, 14, 7988, 360, 13803, 1959, 3438, 430, 267, 870, 360, 221, 612, 3126, 1, 82, 5285, 908, 8, 11477, 14, 7988, 360, 13331, 1959, 3438, 430, 267, 870, 360, 576, 59, 2440, 2189, 1370, 908, 8, 466, 8, 576, 1724, 267, 870, 8, 2722, 8, 576, 430, 421, 199, 533, 28438, 14740, 3034, 8, 785, 304, 272, 347, 511, 63, 4316, 8, 277, 304, 267, 2928, 63, 88, 275, 359, 1216, 2020, 6335, 2020, 5238, 19784, 267, 5042, 63, 88, 275, 359, 708, 2020, 5685, 19784, 267, 2928, 63, 89, 275, 5243, 709, 2020, 378, 2020, 1616, 19784, 267, 5042, 63, 89, 275, 5243, 24, 2020, 499, 19784, 267, 666, 275, 3474, 19, 2020, 841, 2020, 959, 8333, 355, 359, 1789, 2020, 5504, 2020, 5661, 8333, 355, 359, 2824, 2020, 10868, 2020, 10416, 28132, 267, 1420, 63, 1099, 275, 3474, 19, 2020, 841, 8333, 2574, 359, 1789, 2020, 5504, 28132, 267, 2928, 63, 11477, 275, 6068, 63, 11477, 8, 2164, 63, 88, 12, 2928, 63, 89, 12, 666, 9, 267, 485, 1757, 63, 576, 8, 2164, 63, 11477, 12, 298, 4316, 25470, 531, 267, 5042, 63, 11477, 275, 6068, 63, 11477, 8, 5119, 63, 88, 12, 5042, 63, 89, 9, 267, 754, 63, 11477, 275, 291, 14, 1135, 1677, 8, 2164, 63, 11477, 12, 5042, 63, 11477, 9, 267, 485, 1757, 63, 576, 8, 1099, 63, 11477, 12, 298, 4316, 20668, 531, 267, 291, 14, 479, 3836, 2422, 4724, 8, 1099, 63, 11477, 14, 576, 12, 1420, 63, 1099, 9, 339, 347, 511, 63, 2164, 63, 832, 1330, 10410, 8, 277, 304, 267, 2928, 63, 88, 275, 359, 1216, 2020, 6335, 2020, 5238, 19784, 267, 5042, 63, 88, 275, 359, 16, 2020, 7349, 14, 16, 12, 10551, 14, 16, 61, 267, 2928, 63, 89, 275, 5243, 709, 2020, 378, 2020, 1616, 19784, 267, 5042, 63, 89, 275, 5243, 1400, 2020, 446, 25, 2020, 446, 17, 19784, 267, 666, 275, 3474, 19, 2020, 841, 2020, 959, 8333, 355, 359, 1789, 2020, 5504, 2020, 5661, 8333, 355, 359, 2824, 2020, 10868, 2020, 10416, 28132, 267, 1420, 63, 1099, 275, 3474, 19, 2020, 650, 2020, 841, 8333, 2574, 359, 19, 2020, 650, 2020, 841, 8333, 2574, 359, 1789, 2020, 6546, 2020, 5504, 28132, 267, 2928, 63, 11477, 275, 6068, 63, 11477, 8, 2164, 63, 88, 12, 2928, 63, 89, 12, 666, 9, 267, 485, 1757, 63, 576, 8, 2164, 63, 11477, 12, 298, 832, 1330, 16288, 25470, 531, 267, 5042, 63, 11477, 275, 6068, 63, 11477, 8, 5119, 63, 88, 12, 5042, 63, 89, 9, 267, 754, 63, 11477, 275, 291, 14, 1135, 1677, 8, 2164, 63, 11477, 12, 5042, 63, 11477, 9, 267, 485, 1757, 63, 576, 8, 1099, 63, 11477, 12, 298, 832, 1330, 16288, 20668, 531, 267, 291, 14, 479, 3836, 2422, 4724, 8, 1099, 63, 11477, 14, 576, 12, 1420, 63, 1099, 9, 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,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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 ]
ChinaQuants/PTVS
Python/Product/Django/Templates/Projects/DjangoWebRole/settings.py
36
5582
""" Django settings for $safeprojectname$ project. """ DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.', # Or path to database file if using sqlite3. 'NAME': '', # Not used with sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Set to empty string for localhost. Not used with sqlite3. 'HOST': '', # Set to empty string for default. Not used with sqlite3. 'PORT': '', } } # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/Chicago' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = 'n(bd1f1c%e8=_xad02x5qtfn%wgwpi492e$8_erx+d)!tpeoim' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = '$safeprojectname$.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = '$safeprojectname$.wsgi.application' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or # "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } # Specify the default test runner. TEST_RUNNER = 'django.test.runner.DiscoverRunner'
apache-2.0
[ 624, 202, 199, 9323, 2202, 367, 2672, 3489, 1715, 354, 4, 2199, 14, 202, 199, 624, 2999, 199, 5287, 275, 715, 202, 199, 7433, 63, 5287, 275, 10990, 2999, 199, 14288, 51, 275, 334, 1128, 327, 661, 14398, 2812, 297, 283, 12695, 63, 2123, 32, 2694, 14, 957, 659, 202, 199, 9, 2999, 199, 20600, 3960, 275, 29948, 51, 2999, 199, 27260, 275, 469, 1128, 283, 885, 356, 469, 1039, 327, 2654, 283, 15437, 63, 20270, 18, 297, 283, 8644, 297, 283, 10659, 19, 7, 503, 283, 16404, 1370, 1039, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 3130, 1039, 327, 4236, 931, 370, 3050, 570, 340, 1808, 11723, 19, 14, 1039, 283, 2339, 356, 3260, 1039, 327, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 3791, 356, 3260, 1039, 327, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 9032, 356, 3260, 1039, 327, 2494, 370, 2701, 1059, 367, 11667, 14, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 5449, 356, 3260, 1039, 327, 2494, 370, 2701, 1059, 367, 849, 14, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 3657, 356, 3260, 1128, 789, 202, 199, 93, 2999, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 202, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 202, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 202, 199, 3, 4068, 13074, 10460, 12, 282, 574, 402, 488, 911, 7675, 5634, 370, 675, 314, 2011, 202, 199, 3, 7137, 465, 314, 17406, 2656, 14, 202, 199, 3, 982, 3879, 315, 282, 5417, 3734, 642, 1471, 506, 663, 370, 314, 2011, 465, 2195, 202, 199, 3, 2656, 900, 5718, 14, 202, 199, 4961, 63, 15353, 275, 283, 8841, 15, 28796, 7, 2999, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 202, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 202, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 2999, 199, 7917, 63, 998, 275, 413, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 202, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 202, 199, 4701, 63, 41, 1085, 46, 275, 715, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 202, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 14, 202, 199, 4701, 63, 44, 709, 46, 275, 715, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 675, 7137, 13, 14600, 29297, 14, 202, 199, 4701, 63, 14226, 275, 715, 2999, 199, 3, 24964, 10036, 931, 370, 314, 2082, 626, 911, 10266, 922, 13, 19044, 1584, 14, 202, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 6687, 202, 199, 13669, 63, 5441, 275, 2125, 2999, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 202, 199, 3, 8520, 14457, 14, 202, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 10665, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 202, 199, 13669, 63, 2632, 275, 2125, 2999, 199, 3, 24964, 931, 370, 314, 2082, 2955, 1584, 1077, 506, 13736, 370, 14, 202, 199, 3, 7529, 1133, 5324, 7003, 315, 642, 2082, 28225, 27, 3877, 2195, 2955, 1584, 202, 199, 3, 315, 8686, 7, 298, 1986, 6687, 24799, 436, 315, 27815, 9472, 63, 14455, 14, 202, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 202, 199, 10449, 63, 5441, 275, 2125, 2999, 199, 3, 2851, 2403, 367, 2955, 1584, 14, 202, 199, 3, 5679, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 202, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 2999, 199, 3, 10961, 9918, 402, 2955, 1584, 202, 199, 10449, 9472, 63, 14455, 275, 334, 1128, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 1128, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 1128, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 202, 199, 9, 2999, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 202, 199, 3, 7750, 9918, 14, 202, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 1128, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 1128, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 202, 199, 3, 259, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2698, 6408, 11791, 297, 202, 199, 9, 2999, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 202, 199, 12961, 63, 3078, 275, 283, 78, 8, 3691, 17, 70, 17, 67, 5, 69, 24, 3699, 10135, 996, 88, 21, 8440, 2324, 5, 87, 8392, 1038, 25722, 69, 4, 24, 63, 281, 88, 11, 68, 9, 1, 84, 321, 79, 1017, 7, 2999, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 202, 199, 7433, 63, 7405, 3960, 275, 334, 1128, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 1128, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 202, 199, 3, 258, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 202, 199, 9, 2999, 199, 19987, 63, 13748, 275, 334, 1128, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 1128, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 1128, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 1128, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 1128, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 1128, 327, 1910, 3349, 314, 2163, 1004, 367 ]
[ 202, 199, 9323, 2202, 367, 2672, 3489, 1715, 354, 4, 2199, 14, 202, 199, 624, 2999, 199, 5287, 275, 715, 202, 199, 7433, 63, 5287, 275, 10990, 2999, 199, 14288, 51, 275, 334, 1128, 327, 661, 14398, 2812, 297, 283, 12695, 63, 2123, 32, 2694, 14, 957, 659, 202, 199, 9, 2999, 199, 20600, 3960, 275, 29948, 51, 2999, 199, 27260, 275, 469, 1128, 283, 885, 356, 469, 1039, 327, 2654, 283, 15437, 63, 20270, 18, 297, 283, 8644, 297, 283, 10659, 19, 7, 503, 283, 16404, 1370, 1039, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 3130, 1039, 327, 4236, 931, 370, 3050, 570, 340, 1808, 11723, 19, 14, 1039, 283, 2339, 356, 3260, 1039, 327, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 3791, 356, 3260, 1039, 327, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 9032, 356, 3260, 1039, 327, 2494, 370, 2701, 1059, 367, 11667, 14, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 5449, 356, 3260, 1039, 327, 2494, 370, 2701, 1059, 367, 849, 14, 2832, 1202, 543, 11723, 19, 14, 1039, 283, 3657, 356, 3260, 1128, 789, 202, 199, 93, 2999, 199, 3, 10111, 900, 5718, 367, 642, 12096, 14, 8802, 2370, 883, 506, 1911, 2348, 26, 202, 199, 3, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 3903, 63, 13325, 63, 991, 63, 354, 202, 199, 3, 22160, 440, 1006, 3415, 1443, 506, 2808, 641, 1006, 17406, 10460, 14, 202, 199, 3, 4068, 13074, 10460, 12, 282, 574, 402, 488, 911, 7675, 5634, 370, 675, 314, 2011, 202, 199, 3, 7137, 465, 314, 17406, 2656, 14, 202, 199, 3, 982, 3879, 315, 282, 5417, 3734, 642, 1471, 506, 663, 370, 314, 2011, 465, 2195, 202, 199, 3, 2656, 900, 5718, 14, 202, 199, 4961, 63, 15353, 275, 283, 8841, 15, 28796, 7, 2999, 199, 3, 8466, 1233, 367, 642, 12096, 14, 2900, 3415, 883, 506, 1911, 2348, 26, 202, 199, 3, 1455, 921, 1544, 14, 73, 1085, 2753, 29514, 14, 957, 15, 2975, 15, 3671, 13, 14227, 14, 1360, 202, 199, 13947, 63, 6012, 275, 283, 287, 13, 527, 7, 2999, 199, 7917, 63, 998, 275, 413, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 1852, 2005, 5323, 12270, 880, 465, 440, 202, 199, 3, 370, 2248, 314, 10757, 6279, 2072, 28540, 14, 202, 199, 4701, 63, 41, 1085, 46, 275, 715, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 1475, 10831, 12, 5579, 436, 202, 199, 3, 1704, 31276, 7182, 370, 314, 1453, 5867, 14, 202, 199, 4701, 63, 44, 709, 46, 275, 715, 2999, 199, 3, 982, 1265, 663, 642, 370, 756, 12, 5634, 911, 440, 675, 7137, 13, 14600, 29297, 14, 202, 199, 4701, 63, 14226, 275, 715, 2999, 199, 3, 24964, 10036, 931, 370, 314, 2082, 626, 911, 10266, 922, 13, 19044, 1584, 14, 202, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 6687, 202, 199, 13669, 63, 5441, 275, 2125, 2999, 199, 3, 2851, 626, 10022, 314, 5898, 19733, 687, 31460, 63, 5441, 14, 4155, 3238, 370, 675, 282, 202, 199, 3, 8520, 14457, 14, 202, 199, 3, 6058, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 4603, 10665, 298, 1014, 921, 2694, 14, 957, 15, 4603, 6687, 202, 199, 13669, 63, 2632, 275, 2125, 2999, 199, 3, 24964, 931, 370, 314, 2082, 2955, 1584, 1077, 506, 13736, 370, 14, 202, 199, 3, 7529, 1133, 5324, 7003, 315, 642, 2082, 28225, 27, 3877, 2195, 2955, 1584, 202, 199, 3, 315, 8686, 7, 298, 1986, 6687, 24799, 436, 315, 27815, 9472, 63, 14455, 14, 202, 199, 3, 5679, 26, 3286, 4219, 15, 4603, 15, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 202, 199, 10449, 63, 5441, 275, 2125, 2999, 199, 3, 2851, 2403, 367, 2955, 1584, 14, 202, 199, 3, 5679, 26, 298, 1014, 921, 4603, 14, 22277, 4646, 14, 957, 15, 1986, 6687, 202, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 2999, 199, 3, 10961, 9918, 402, 2955, 1584, 202, 199, 10449, 9472, 63, 14455, 275, 334, 1128, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 1128, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 1128, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 202, 199, 9, 2999, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 202, 199, 3, 7750, 9918, 14, 202, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 1128, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 1128, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 202, 199, 3, 259, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2698, 6408, 11791, 297, 202, 199, 9, 2999, 199, 3, 4155, 642, 3747, 12, 436, 2793, 1133, 8663, 652, 543, 1263, 2030, 14, 202, 199, 12961, 63, 3078, 275, 283, 78, 8, 3691, 17, 70, 17, 67, 5, 69, 24, 3699, 10135, 996, 88, 21, 8440, 2324, 5, 87, 8392, 1038, 25722, 69, 4, 24, 63, 281, 88, 11, 68, 9, 1, 84, 321, 79, 1017, 7, 2999, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 202, 199, 7433, 63, 7405, 3960, 275, 334, 1128, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 1128, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 202, 199, 3, 258, 283, 1176, 14, 1160, 14, 16370, 14, 14488, 14, 5455, 297, 202, 199, 9, 2999, 199, 19987, 63, 13748, 275, 334, 1128, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 1128, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 1128, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 1128, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 1128, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 1128, 327, 1910, 3349, 314, 2163, 1004, 367, 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,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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 ]
TomasTomecek/docker-scripts
docker_scripts/cli.py
1
3534
# -*- coding: utf-8 -*- import argparse import logging import sys from docker_scripts import squash, layers from docker_scripts.version import version class MyParser(argparse.ArgumentParser): def error(self, message): self.print_help() sys.stderr.write('\nError: %s\n' % message) sys.exit(2) class CLI(object): def __init__(self): self.log = logging.getLogger() handler = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') handler.setFormatter(formatter) self.log.addHandler(handler) def run_squash(self, args): squash.Squash(log=self.log, image=args.image, from_layer=args.from_layer, tag=args.tag, output_path=args.output_path).run() def run_layers(self, args): layers.Layers(log=self.log, image=args.image, dockerfile=args.dockerfile, tags=args.tags, machine=args.machine, commands=args.commands).run() def run(self): parser = MyParser( description='Set of helpers scripts fo Docker') parser.add_argument( '-v', '--verbose', action='store_true', help='Verbose output') parser.add_argument( '--version', action='version', help='Show version and exit', version=version) subparsers = parser.add_subparsers(title='Available commands') # Squash parser_squash = subparsers.add_parser( 'squash', help='Squash layers in the specified image') parser_squash.set_defaults(func=self.run_squash) parser_squash.add_argument('image', help='Image to be squashed') parser_squash.add_argument( '-f', '--from-layer', help='ID of the layer or image ID or image name. If not specified will squash up to last layer (FROM instruction)') parser_squash.add_argument( '-t', '--tag', help="Specify the tag to be used for the new image. By default it'll be set to 'image' argument") parser_squash.add_argument( '--tmp-dir', help='Temporary directory to be used') parser_squash.add_argument( '--output-path', help='Path where the image should be stored after squashing. If not provided, image will be loaded into Docker daemon') # Layers parser_layers = subparsers.add_parser( 'layers', help='Show layers in the specified image') parser_layers.set_defaults(func=self.run_layers) parser_layers.add_argument( 'image', help='ID of the layer or image ID or image name') parser_layers.add_argument('-c', '--commands', action='store_true', help='Show commands executed to create the layer (if any)') parser_layers.add_argument('-d', '--dockerfile', action='store_true', help='Create Dockerfile out of the layers [EXPERIMENTAL!]') parser_layers.add_argument( '-m', '--machine', action='store_true', help='Machine parseable output') parser_layers.add_argument( '-t', '--tags', action='store_true', help='Print layer tags if available') args = parser.parse_args() if args.verbose: self.log.setLevel(logging.DEBUG) else: self.log.setLevel(logging.INFO) self.log.debug("Running version %s", version) args.func(args) def run(): cli = CLI() cli.run() if __name__ == "__main__": run()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 7534, 199, 646, 2050, 199, 646, 984, 199, 199, 504, 12424, 63, 6429, 492, 12345, 1119, 12, 9393, 199, 504, 12424, 63, 6429, 14, 1023, 492, 1015, 421, 199, 533, 4932, 2842, 8, 18978, 14, 10730, 304, 339, 347, 1125, 8, 277, 12, 1245, 304, 267, 291, 14, 1361, 63, 3437, 342, 267, 984, 14, 3083, 14, 952, 2258, 78, 547, 26, 450, 83, 60, 78, 7, 450, 1245, 9, 267, 984, 14, 2224, 8, 18, 9, 421, 199, 533, 14214, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 793, 275, 2050, 14, 5572, 342, 267, 3016, 275, 2050, 14, 22482, 342, 267, 9698, 275, 2050, 14, 7772, 8, 288, 9487, 18331, 9, 83, 2818, 354, 7216, 713, 83, 2818, 20056, 7216, 24, 83, 2818, 1188, 9, 83, 358, 267, 3016, 14, 26076, 8, 8911, 9, 267, 291, 14, 793, 14, 18826, 8, 2232, 9, 339, 347, 1255, 63, 8471, 1119, 8, 277, 12, 1249, 304, 267, 12345, 1119, 14, 51, 392, 1119, 8, 793, 29, 277, 14, 793, 12, 1834, 29, 589, 14, 1569, 12, 1993, 687, 63, 1897, 29, 589, 14, 504, 63, 1897, 12, 1947, 29, 589, 14, 1450, 12, 1072, 63, 515, 29, 589, 14, 1199, 63, 515, 680, 1065, 342, 339, 347, 1255, 63, 4359, 8, 277, 12, 1249, 304, 267, 9393, 14, 16862, 8, 793, 29, 277, 14, 793, 12, 1834, 29, 589, 14, 1569, 12, 1993, 12424, 493, 29, 589, 14, 9991, 493, 12, 3762, 29, 589, 14, 2969, 12, 6844, 29, 589, 14, 6744, 12, 3718, 29, 589, 14, 4405, 680, 1065, 342, 339, 347, 1255, 8, 277, 304, 267, 1798, 275, 4932, 2842, 8, 288, 1369, 534, 1084, 402, 10897, 10554, 7090, 22067, 358, 398, 1798, 14, 525, 63, 2094, 8, 288, 2475, 86, 297, 2850, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 21879, 1072, 358, 398, 1798, 14, 525, 63, 2094, 8, 288, 2850, 1023, 297, 1595, 534, 1023, 297, 1720, 534, 6824, 1015, 436, 4458, 297, 1015, 29, 1023, 9, 398, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 1213, 534, 11464, 3718, 358, 398, 327, 428, 392, 1119, 267, 1798, 63, 8471, 1119, 275, 26763, 14, 525, 63, 2087, 8, 288, 283, 8471, 1119, 297, 1720, 534, 51, 392, 1119, 9393, 315, 314, 2013, 1834, 358, 267, 1798, 63, 8471, 1119, 14, 409, 63, 4322, 8, 1532, 29, 277, 14, 1065, 63, 8471, 1119, 9, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 360, 1569, 297, 1720, 534, 3491, 370, 506, 12345, 21189, 358, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2475, 70, 297, 2850, 504, 13, 1897, 297, 1720, 534, 998, 402, 314, 4045, 503, 1834, 2870, 503, 1834, 536, 14, 982, 440, 2013, 911, 12345, 1119, 1536, 370, 2061, 4045, 334, 12491, 16329, 5942, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2475, 84, 297, 2850, 1450, 297, 1720, 628, 17768, 314, 1947, 370, 506, 1202, 367, 314, 892, 1834, 14, 4885, 849, 652, 7171, 506, 663, 370, 283, 1569, 7, 1423, 531, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2850, 2791, 13, 694, 297, 1720, 534, 11360, 2082, 370, 506, 1202, 358, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2850, 1199, 13, 515, 297, 1720, 534, 2042, 2382, 314, 1834, 1077, 506, 5489, 2410, 12345, 1119, 316, 14, 982, 440, 2741, 12, 1834, 911, 506, 6511, 1901, 22067, 11128, 358, 398, 327, 9366, 1192, 267, 1798, 63, 4359, 275, 26763, 14, 525, 63, 2087, 8, 288, 283, 4359, 297, 1720, 534, 6824, 9393, 315, 314, 2013, 1834, 358, 267, 1798, 63, 4359, 14, 409, 63, 4322, 8, 1532, 29, 277, 14, 1065, 63, 4359, 9, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 283, 1569, 297, 1720, 534, 998, 402, 314, 4045, 503, 1834, 2870, 503, 1834, 536, 358, 267, 1798, 63, 4359, 14, 525, 63, 2094, 3654, 67, 297, 2850, 4405, 297, 1595, 534, 1617, 63, 2052, 297, 3521, 1720, 534, 6824, 3718, 7934, 370, 1218, 314, 4045, 334, 692, 1263, 5942, 267, 1798, 63, 4359, 14, 525, 63, 2094, 3654, 68, 297, 2850, 9991, 493, 297, 1595, 534, 1617, 63, 2052, 297, 3521, 1720, 534, 2499, 22067, 493, 734, 402, 314, 9393, 359, 28722, 1309, 748, 1, 10374, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 2475, 77, 297, 2850, 6744, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 8412, 2198, 461, 1072, 358, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 2475, 84, 297, 2850, 2969, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 5375, 4045, 3762, 340, 2808, 358, 398, 1249, 275, 1798, 14, 1122, 63, 589, 342, 398, 340, 1249, 14, 3832, 26, 288, 291, 14, 793, 14, 13548, 8, 4806, 14, 5287, 9, 267, 587, 26, 288, 291, 14, 793, 14, 13548, 8, 4806, 14, 4531, 9, 398, 291, 14, 793, 14, 1757, 480, 9602, 1015, 450, 83, 401, 1015, 9, 398, 1249, 14, 1532, 8, 589, 9, 421, 199, 318, 1255, 837, 272, 5053, 275, 14214, 342, 272, 5053, 14, 1065, 342, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1255, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 7534, 199, 646, 2050, 199, 646, 984, 199, 199, 504, 12424, 63, 6429, 492, 12345, 1119, 12, 9393, 199, 504, 12424, 63, 6429, 14, 1023, 492, 1015, 421, 199, 533, 4932, 2842, 8, 18978, 14, 10730, 304, 339, 347, 1125, 8, 277, 12, 1245, 304, 267, 291, 14, 1361, 63, 3437, 342, 267, 984, 14, 3083, 14, 952, 2258, 78, 547, 26, 450, 83, 60, 78, 7, 450, 1245, 9, 267, 984, 14, 2224, 8, 18, 9, 421, 199, 533, 14214, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 793, 275, 2050, 14, 5572, 342, 267, 3016, 275, 2050, 14, 22482, 342, 267, 9698, 275, 2050, 14, 7772, 8, 288, 9487, 18331, 9, 83, 2818, 354, 7216, 713, 83, 2818, 20056, 7216, 24, 83, 2818, 1188, 9, 83, 358, 267, 3016, 14, 26076, 8, 8911, 9, 267, 291, 14, 793, 14, 18826, 8, 2232, 9, 339, 347, 1255, 63, 8471, 1119, 8, 277, 12, 1249, 304, 267, 12345, 1119, 14, 51, 392, 1119, 8, 793, 29, 277, 14, 793, 12, 1834, 29, 589, 14, 1569, 12, 1993, 687, 63, 1897, 29, 589, 14, 504, 63, 1897, 12, 1947, 29, 589, 14, 1450, 12, 1072, 63, 515, 29, 589, 14, 1199, 63, 515, 680, 1065, 342, 339, 347, 1255, 63, 4359, 8, 277, 12, 1249, 304, 267, 9393, 14, 16862, 8, 793, 29, 277, 14, 793, 12, 1834, 29, 589, 14, 1569, 12, 1993, 12424, 493, 29, 589, 14, 9991, 493, 12, 3762, 29, 589, 14, 2969, 12, 6844, 29, 589, 14, 6744, 12, 3718, 29, 589, 14, 4405, 680, 1065, 342, 339, 347, 1255, 8, 277, 304, 267, 1798, 275, 4932, 2842, 8, 288, 1369, 534, 1084, 402, 10897, 10554, 7090, 22067, 358, 398, 1798, 14, 525, 63, 2094, 8, 288, 2475, 86, 297, 2850, 3832, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 21879, 1072, 358, 398, 1798, 14, 525, 63, 2094, 8, 288, 2850, 1023, 297, 1595, 534, 1023, 297, 1720, 534, 6824, 1015, 436, 4458, 297, 1015, 29, 1023, 9, 398, 26763, 275, 1798, 14, 525, 63, 954, 11531, 8, 1213, 534, 11464, 3718, 358, 398, 327, 428, 392, 1119, 267, 1798, 63, 8471, 1119, 275, 26763, 14, 525, 63, 2087, 8, 288, 283, 8471, 1119, 297, 1720, 534, 51, 392, 1119, 9393, 315, 314, 2013, 1834, 358, 267, 1798, 63, 8471, 1119, 14, 409, 63, 4322, 8, 1532, 29, 277, 14, 1065, 63, 8471, 1119, 9, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 360, 1569, 297, 1720, 534, 3491, 370, 506, 12345, 21189, 358, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2475, 70, 297, 2850, 504, 13, 1897, 297, 1720, 534, 998, 402, 314, 4045, 503, 1834, 2870, 503, 1834, 536, 14, 982, 440, 2013, 911, 12345, 1119, 1536, 370, 2061, 4045, 334, 12491, 16329, 5942, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2475, 84, 297, 2850, 1450, 297, 1720, 628, 17768, 314, 1947, 370, 506, 1202, 367, 314, 892, 1834, 14, 4885, 849, 652, 7171, 506, 663, 370, 283, 1569, 7, 1423, 531, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2850, 2791, 13, 694, 297, 1720, 534, 11360, 2082, 370, 506, 1202, 358, 267, 1798, 63, 8471, 1119, 14, 525, 63, 2094, 8, 288, 2850, 1199, 13, 515, 297, 1720, 534, 2042, 2382, 314, 1834, 1077, 506, 5489, 2410, 12345, 1119, 316, 14, 982, 440, 2741, 12, 1834, 911, 506, 6511, 1901, 22067, 11128, 358, 398, 327, 9366, 1192, 267, 1798, 63, 4359, 275, 26763, 14, 525, 63, 2087, 8, 288, 283, 4359, 297, 1720, 534, 6824, 9393, 315, 314, 2013, 1834, 358, 267, 1798, 63, 4359, 14, 409, 63, 4322, 8, 1532, 29, 277, 14, 1065, 63, 4359, 9, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 283, 1569, 297, 1720, 534, 998, 402, 314, 4045, 503, 1834, 2870, 503, 1834, 536, 358, 267, 1798, 63, 4359, 14, 525, 63, 2094, 3654, 67, 297, 2850, 4405, 297, 1595, 534, 1617, 63, 2052, 297, 3521, 1720, 534, 6824, 3718, 7934, 370, 1218, 314, 4045, 334, 692, 1263, 5942, 267, 1798, 63, 4359, 14, 525, 63, 2094, 3654, 68, 297, 2850, 9991, 493, 297, 1595, 534, 1617, 63, 2052, 297, 3521, 1720, 534, 2499, 22067, 493, 734, 402, 314, 9393, 359, 28722, 1309, 748, 1, 10374, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 2475, 77, 297, 2850, 6744, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 8412, 2198, 461, 1072, 358, 267, 1798, 63, 4359, 14, 525, 63, 2094, 8, 288, 2475, 84, 297, 2850, 2969, 297, 1595, 534, 1617, 63, 2052, 297, 1720, 534, 5375, 4045, 3762, 340, 2808, 358, 398, 1249, 275, 1798, 14, 1122, 63, 589, 342, 398, 340, 1249, 14, 3832, 26, 288, 291, 14, 793, 14, 13548, 8, 4806, 14, 5287, 9, 267, 587, 26, 288, 291, 14, 793, 14, 13548, 8, 4806, 14, 4531, 9, 398, 291, 14, 793, 14, 1757, 480, 9602, 1015, 450, 83, 401, 1015, 9, 398, 1249, 14, 1532, 8, 589, 9, 421, 199, 318, 1255, 837, 272, 5053, 275, 14214, 342, 272, 5053, 14, 1065, 342, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1255, 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, 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, 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