Browse Source

Initial commit

Yann Weber 9 years ago
commit
358652e442
14 changed files with 363938 additions and 0 deletions
  1. 1
    0
      AUTHORS
  2. 640
    0
      COPYING
  3. 1
    0
      NEWS
  4. 5
    0
      clean.sh
  5. 33
    0
      main.py
  6. 1
    0
      mapData/SOURCES
  7. BIN
      mapData/borders_s.dat.gz
  8. 362141
    0
      mapData/borders_xl.dat
  9. BIN
      mapData/borders_xlshuf.dat.gz
  10. BIN
      mapData/borders_xs.dat.gz
  11. BIN
      mapData/borders_xsmall.dat.gz
  12. 337
    0
      tracer.py
  13. 445
    0
      vtracemap.py
  14. 334
    0
      vtracert.py

+ 1
- 0
AUTHORS View File

@@ -0,0 +1 @@
1
+Weber Yann <yann.weber@member.fsf.org>

+ 640
- 0
COPYING View File

@@ -0,0 +1,640 @@
1
+                    GNU GENERAL PUBLIC LICENSE
2
+                       Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+                            Preamble
9
+
10
+  The GNU General Public License is a free, copyleft license for
11
+software and other kinds of works.
12
+
13
+  The licenses for most software and other practical works are designed
14
+to take away your freedom to share and change the works.  By contrast,
15
+the GNU General Public License is intended to guarantee your freedom to
16
+share and change all versions of a program--to make sure it remains free
17
+software for all its users.  We, the Free Software Foundation, use the
18
+GNU General Public License for most of our software; it applies also to
19
+any other work released this way by its authors.  You can apply it to
20
+your programs, too.
21
+
22
+  When we speak of free software, we are referring to freedom, not
23
+price.  Our General Public Licenses are designed to make sure that you
24
+have the freedom to distribute copies of free software (and charge for
25
+them if you wish), that you receive source code or can get it if you
26
+want it, that you can change the software or use pieces of it in new
27
+free programs, and that you know you can do these things.
28
+
29
+  To protect your rights, we need to prevent others from denying you
30
+these rights or asking you to surrender the rights.  Therefore, you have
31
+certain responsibilities if you distribute copies of the software, or if
32
+you modify it: responsibilities to respect the freedom of others.
33
+
34
+  For example, if you distribute copies of such a program, whether
35
+gratis or for a fee, you must pass on to the recipients the same
36
+freedoms that you received.  You must make sure that they, too, receive
37
+or can get the source code.  And you must show them these terms so they
38
+know their rights.
39
+
40
+  Developers that use the GNU GPL protect your rights with two steps:
41
+(1) assert copyright on the software, and (2) offer you this License
42
+giving you legal permission to copy, distribute and/or modify it.
43
+
44
+  For the developers' and authors' protection, the GPL clearly explains
45
+that there is no warranty for this free software.  For both users' and
46
+authors' sake, the GPL requires that modified versions be marked as
47
+changed, so that their problems will not be attributed erroneously to
48
+authors of previous versions.
49
+
50
+  Some devices are designed to deny users access to install or run
51
+modified versions of the software inside them, although the manufacturer
52
+can do so.  This is fundamentally incompatible with the aim of
53
+protecting users' freedom to change the software.  The systematic
54
+pattern of such abuse occurs in the area of products for individuals to
55
+use, which is precisely where it is most unacceptable.  Therefore, we
56
+have designed this version of the GPL to prohibit the practice for those
57
+products.  If such problems arise substantially in other domains, we
58
+stand ready to extend this provision to those domains in future versions
59
+of the GPL, as needed to protect the freedom of users.
60
+
61
+  Finally, every program is threatened constantly by software patents.
62
+States should not allow patents to restrict development and use of
63
+software on general-purpose computers, but in those that do, we wish to
64
+avoid the special danger that patents applied to a free program could
65
+make it effectively proprietary.  To prevent this, the GPL assures that
66
+patents cannot be used to render the program non-free.
67
+
68
+  The precise terms and conditions for copying, distribution and
69
+modification follow.
70
+
71
+                       TERMS AND CONDITIONS
72
+
73
+  0. Definitions.
74
+
75
+  "This License" refers to version 3 of the GNU General Public License.
76
+
77
+  "Copyright" also means copyright-like laws that apply to other kinds of
78
+works, such as semiconductor masks.
79
+
80
+  "The Program" refers to any copyrightable work licensed under this
81
+License.  Each licensee is addressed as "you".  "Licensees" and
82
+"recipients" may be individuals or organizations.
83
+
84
+  To "modify" a work means to copy from or adapt all or part of the work
85
+in a fashion requiring copyright permission, other than the making of an
86
+exact copy.  The resulting work is called a "modified version" of the
87
+earlier work or a work "based on" the earlier work.
88
+
89
+  A "covered work" means either the unmodified Program or a work based
90
+on the Program.
91
+
92
+  To "propagate" a work means to do anything with it that, without
93
+permission, would make you directly or secondarily liable for
94
+infringement under applicable copyright law, except executing it on a
95
+computer or modifying a private copy.  Propagation includes copying,
96
+distribution (with or without modification), making available to the
97
+public, and in some countries other activities as well.
98
+
99
+  To "convey" a work means any kind of propagation that enables other
100
+parties to make or receive copies.  Mere interaction with a user through
101
+a computer network, with no transfer of a copy, is not conveying.
102
+
103
+  An interactive user interface displays "Appropriate Legal Notices"
104
+to the extent that it includes a convenient and prominently visible
105
+feature that (1) displays an appropriate copyright notice, and (2)
106
+tells the user that there is no warranty for the work (except to the
107
+extent that warranties are provided), that licensees may convey the
108
+work under this License, and how to view a copy of this License.  If
109
+the interface presents a list of user commands or options, such as a
110
+menu, a prominent item in the list meets this criterion.
111
+
112
+  1. Source Code.
113
+
114
+  The "source code" for a work means the preferred form of the work
115
+for making modifications to it.  "Object code" means any non-source
116
+form of a work.
117
+
118
+  A "Standard Interface" means an interface that either is an official
119
+standard defined by a recognized standards body, or, in the case of
120
+interfaces specified for a particular programming language, one that
121
+is widely used among developers working in that language.
122
+
123
+  The "System Libraries" of an executable work include anything, other
124
+than the work as a whole, that (a) is included in the normal form of
125
+packaging a Major Component, but which is not part of that Major
126
+Component, and (b) serves only to enable use of the work with that
127
+Major Component, or to implement a Standard Interface for which an
128
+implementation is available to the public in source code form.  A
129
+"Major Component", in this context, means a major essential component
130
+(kernel, window system, and so on) of the specific operating system
131
+(if any) on which the executable work runs, or a compiler used to
132
+produce the work, or an object code interpreter used to run it.
133
+
134
+  The "Corresponding Source" for a work in object code form means all
135
+the source code needed to generate, install, and (for an executable
136
+work) run the object code and to modify the work, including scripts to
137
+control those activities.  However, it does not include the work's
138
+System Libraries, or general-purpose tools or generally available free
139
+programs which are used unmodified in performing those activities but
140
+which are not part of the work.  For example, Corresponding Source
141
+includes interface definition files associated with source files for
142
+the work, and the source code for shared libraries and dynamically
143
+linked subprograms that the work is specifically designed to require,
144
+such as by intimate data communication or control flow between those
145
+subprograms and other parts of the work.
146
+
147
+  The Corresponding Source need not include anything that users
148
+can regenerate automatically from other parts of the Corresponding
149
+Source.
150
+
151
+  The Corresponding Source for a work in source code form is that
152
+same work.
153
+
154
+  2. Basic Permissions.
155
+
156
+  All rights granted under this License are granted for the term of
157
+copyright on the Program, and are irrevocable provided the stated
158
+conditions are met.  This License explicitly affirms your unlimited
159
+permission to run the unmodified Program.  The output from running a
160
+covered work is covered by this License only if the output, given its
161
+content, constitutes a covered work.  This License acknowledges your
162
+rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+  You may make, run and propagate covered works that you do not
165
+convey, without conditions so long as your license otherwise remains
166
+in force.  You may convey covered works to others for the sole purpose
167
+of having them make modifications exclusively for you, or provide you
168
+with facilities for running those works, provided that you comply with
169
+the terms of this License in conveying all material for which you do
170
+not control copyright.  Those thus making or running the covered works
171
+for you must do so exclusively on your behalf, under your direction
172
+and control, on terms that prohibit them from making any copies of
173
+your copyrighted material outside their relationship with you.
174
+
175
+  Conveying under any other circumstances is permitted solely under
176
+the conditions stated below.  Sublicensing is not allowed; section 10
177
+makes it unnecessary.
178
+
179
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+  No covered work shall be deemed part of an effective technological
182
+measure under any applicable law fulfilling obligations under article
183
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+similar laws prohibiting or restricting circumvention of such
185
+measures.
186
+
187
+  When you convey a covered work, you waive any legal power to forbid
188
+circumvention of technological measures to the extent such circumvention
189
+is effected by exercising rights under this License with respect to
190
+the covered work, and you disclaim any intention to limit operation or
191
+modification of the work as a means of enforcing, against the work's
192
+users, your or third parties' legal rights to forbid circumvention of
193
+technological measures.
194
+
195
+  4. Conveying Verbatim Copies.
196
+
197
+  You may convey verbatim copies of the Program's source code as you
198
+receive it, in any medium, provided that you conspicuously and
199
+appropriately publish on each copy an appropriate copyright notice;
200
+keep intact all notices stating that this License and any
201
+non-permissive terms added in accord with section 7 apply to the code;
202
+keep intact all notices of the absence of any warranty; and give all
203
+recipients a copy of this License along with the Program.
204
+
205
+  You may charge any price or no price for each copy that you convey,
206
+and you may offer support or warranty protection for a fee.
207
+
208
+  5. Conveying Modified Source Versions.
209
+
210
+  You may convey a work based on the Program, or the modifications to
211
+produce it from the Program, in the form of source code under the
212
+terms of section 4, provided that you also meet all of these conditions:
213
+
214
+    a) The work must carry prominent notices stating that you modified
215
+    it, and giving a relevant date.
216
+
217
+    b) The work must carry prominent notices stating that it is
218
+    released under this License and any conditions added under section
219
+    7.  This requirement modifies the requirement in section 4 to
220
+    "keep intact all notices".
221
+
222
+    c) You must license the entire work, as a whole, under this
223
+    License to anyone who comes into possession of a copy.  This
224
+    License will therefore apply, along with any applicable section 7
225
+    additional terms, to the whole of the work, and all its parts,
226
+    regardless of how they are packaged.  This License gives no
227
+    permission to license the work in any other way, but it does not
228
+    invalidate such permission if you have separately received it.
229
+
230
+    d) If the work has interactive user interfaces, each must display
231
+    Appropriate Legal Notices; however, if the Program has interactive
232
+    interfaces that do not display Appropriate Legal Notices, your
233
+    work need not make them do so.
234
+
235
+  A compilation of a covered work with other separate and independent
236
+works, which are not by their nature extensions of the covered work,
237
+and which are not combined with it such as to form a larger program,
238
+in or on a volume of a storage or distribution medium, is called an
239
+"aggregate" if the compilation and its resulting copyright are not
240
+used to limit the access or legal rights of the compilation's users
241
+beyond what the individual works permit.  Inclusion of a covered work
242
+in an aggregate does not cause this License to apply to the other
243
+parts of the aggregate.
244
+
245
+  6. Conveying Non-Source Forms.
246
+
247
+  You may convey a covered work in object code form under the terms
248
+of sections 4 and 5, provided that you also convey the
249
+machine-readable Corresponding Source under the terms of this License,
250
+in one of these ways:
251
+
252
+    a) Convey the object code in, or embodied in, a physical product
253
+    (including a physical distribution medium), accompanied by the
254
+    Corresponding Source fixed on a durable physical medium
255
+    customarily used for software interchange.
256
+
257
+    b) Convey the object code in, or embodied in, a physical product
258
+    (including a physical distribution medium), accompanied by a
259
+    written offer, valid for at least three years and valid for as
260
+    long as you offer spare parts or customer support for that product
261
+    model, to give anyone who possesses the object code either (1) a
262
+    copy of the Corresponding Source for all the software in the
263
+    product that is covered by this License, on a durable physical
264
+    medium customarily used for software interchange, for a price no
265
+    more than your reasonable cost of physically performing this
266
+    conveying of source, or (2) access to copy the
267
+    Corresponding Source from a network server at no charge.
268
+
269
+    c) Convey individual copies of the object code with a copy of the
270
+    written offer to provide the Corresponding Source.  This
271
+    alternative is allowed only occasionally and noncommercially, and
272
+    only if you received the object code with such an offer, in accord
273
+    with subsection 6b.
274
+
275
+    d) Convey the object code by offering access from a designated
276
+    place (gratis or for a charge), and offer equivalent access to the
277
+    Corresponding Source in the same way through the same place at no
278
+    further charge.  You need not require recipients to copy the
279
+    Corresponding Source along with the object code.  If the place to
280
+    copy the object code is a network server, the Corresponding Source
281
+    may be on a different server (operated by you or a third party)
282
+    that supports equivalent copying facilities, provided you maintain
283
+    clear directions next to the object code saying where to find the
284
+    Corresponding Source.  Regardless of what server hosts the
285
+    Corresponding Source, you remain obligated to ensure that it is
286
+    available for as long as needed to satisfy these requirements.
287
+
288
+    e) Convey the object code using peer-to-peer transmission, provided
289
+    you inform other peers where the object code and Corresponding
290
+    Source of the work are being offered to the general public at no
291
+    charge under subsection 6d.
292
+
293
+  A separable portion of the object code, whose source code is excluded
294
+from the Corresponding Source as a System Library, need not be
295
+included in conveying the object code work.
296
+
297
+  A "User Product" is either (1) a "consumer product", which means any
298
+tangible personal property which is normally used for personal, family,
299
+or household purposes, or (2) anything designed or sold for incorporation
300
+into a dwelling.  In determining whether a product is a consumer product,
301
+doubtful cases shall be resolved in favor of coverage.  For a particular
302
+product received by a particular user, "normally used" refers to a
303
+typical or common use of that class of product, regardless of the status
304
+of the particular user or of the way in which the particular user
305
+actually uses, or expects or is expected to use, the product.  A product
306
+is a consumer product regardless of whether the product has substantial
307
+commercial, industrial or non-consumer uses, unless such uses represent
308
+the only significant mode of use of the product.
309
+
310
+  "Installation Information" for a User Product means any methods,
311
+procedures, authorization keys, or other information required to install
312
+and execute modified versions of a covered work in that User Product from
313
+a modified version of its Corresponding Source.  The information must
314
+suffice to ensure that the continued functioning of the modified object
315
+code is in no case prevented or interfered with solely because
316
+modification has been made.
317
+
318
+  If you convey ans and
319
+protocols for communication across the network.
320
+
321
+  Corresponding Source conveyed, and Installation Information provided,
322
+in accord with this section must be in a format that is publicly
323
+documented (and with an implementation available to the public in
324
+source code form), and must require no special password or key for
325
+unpacking, reading or copying.
326
+
327
+  7. Additional Terms.
328
+
329
+  "Additional permissions" are terms that supplement the terms of this
330
+License by making exceptions from one or more of its conditions.
331
+Additional permissions that are applicable to the entire Program shall
332
+be treated as though they were included in this License, to the extent
333
+that they are valid under applicable law.  If additional permissions
334
+apply only to part of the Program, that part may be used separately
335
+under those permissions, but the entire Program remains governed by
336
+this License without regard to the additional permissions.
337
+
338
+  When you convey a copy of a covered work, you may at your option
339
+remove any additional permissions from that copy, or from any part of
340
+it.  (Additional permissions may be written to require their own
341
+removal in certain cases when you modify the work.)  You may place
342
+additional permissions on material, added by you to a covered work,
343
+for which you have or can give appropriate copyright permission.
344
+
345
+  Notwithstanding any other provision of this License, for material you
346
+add to a covered work, you may (if authorized by the copyright holders of
347
+that material) supplement the terms of this License with terms:
348
+
349
+    a) Disclaiming warranty or limiting liability differently from the
350
+    terms of sections 15 and 16 of this License; or
351
+
352
+    b) Requiring preservation of specified reasonable legal notices or
353
+    author attributions in that material or in the Appropriate Legal
354
+    Notices displayed by works containing it; or
355
+
356
+    c) Prohibiting misrepresentation of the origin of that material, or
357
+    requiring that modified versions of such material be marked in
358
+    reasonable ways as different from the original version; or
359
+
360
+    d) Limiting the use for publicity purposes of names of licensors or
361
+    authors of the material; or
362
+
363
+    e) Declining to grant rights under trademark law for use of some
364
+    trade names, trademarks, or service marks; or
365
+
366
+    f) Requiring indemnification of licensors and authors of that
367
+    material by anyone who conveys the material (or modified versions of
368
+    it) with contractual assumptions of liability to the recipient, for
369
+    any liability that these contractual assumptions directly impose on
370
+    those licensors and authors.
371
+
372
+  All other non-permissive additional terms are considered "further
373
+restrictions" within the meaning of section 10.  If the Program as you
374
+received it, or any part of it, contains a notice stating that it is
375
+governed by this License along with a term that is a further
376
+restriction, you may remove that term.  If a license document contains
377
+a further restriction but permits relicensing or conveying under this
378
+License, you may add to a covered work material governed by the terms
379
+of that license document, provided that the further restriction does
380
+not survive such relicensing or conveying.
381
+
382
+  If you add terms to a covered work in accord with this section, you
383
+must place, in the relevant source files, a statement of the
384
+additional terms that apply to those files, or a notice indicating
385
+where to find the applicable terms.
386
+
387
+  Additional terms, permissive or non-permissive, may be stated in the
388
+form of a separately written license, or stated as exceptions;
389
+the above requirements apply either way.
390
+
391
+  8. Termination.
392
+
393
+  You may not propagate or modify a covered work except as expressly
394
+provided under this License.  Any attempt otherwise to propagate or
395
+modify it is void, and will automatically terminate your rights under
396
+this License (including any patent licenses granted under the third
397
+paragraph of section 11).
398
+
399
+  However, if you cease all violation of this License, then your
400
+license from a particular copyright holder is reinstated (a)
401
+provisionally, unless and until the copyright hoation by some reasonable means
402
+prior to 60 days after the cessation.
403
+
404
+  Moreover, your license from a particular copyright holder is
405
+reinstated permanently if the copyright holder notifies you of the
406
+violation by some reasonable means, this is the first time you have
407
+received notice of violation of this License (for any work) from that
408
+copyright holder, and you cure the violation prior to 30 days after
409
+your receipt of the notice.
410
+
411
+  Termination of your rights under this section does not terminate the
412
+licenses of parties who have received copies or rights from you under
413
+this License.  If your rights have been terminated and not permanently
414
+reinstated, you do not qualify to receive new licenses for the same
415
+material under section 10.
416
+
417
+  9. Acceptance Not Required for Having Copies.
418
+
419
+  You are not required to accept this License in order to receive or
420
+run a copy of the Program.  Ancillary propagation of a covered work
421
+occurring solely as a consequence of using peer-to-peer transmission
422
+to receive a copy likewise does not require acceptance.  However,
423
+nothing other than this License grants you permission to propagate or
424
+modify any covered work.  These actions infringe copyright if you do
425
+not accept this License.  Therefore, by modifying or propagating a
426
+covered work, you indicate your acceptance of this License to do so.
427
+
428
+  10. Automatic Licensing of Downstream Recipients.
429
+
430
+  Each time you convey a covered work, the recipient automatically
431
+receives a license from the original licensors, to run, modify and
432
+propagate that work, subject to this License.  You are not responsible
433
+for enforcing compliance by third parties with this License.
434
+
435
+  An "entity transaction" is a transaction transferring control of an
436
+organization, or substantially all assets of one, or subdividing an
437
+organization, or merging organizations.  If propagation of a covered
438
+work results from an entity transaction, each party to that
439
+transaction who receives a copy of the work also receives whatever
440
+licenses to the work the party's predecessor in interest had or could
441
+give under the previous paragraph, plus a right to possession of the
442
+Corresponding Source of the work from the predecessor in interest, if
443
+the predecessor has it or can get it with reasonable efforts.
444
+
445
+  You may not impose any further restrictions on the exercise of the
446
+rights granted or affirmed under this License.  For example, you may
447
+not impose a license fee, royalty, or other charge for exercise of
448
+rights granted under this License, and you may not initiate litigation
449
+(including a cross-claim or counterclaim in a lawsuit) alleging that
450
+any patent claim is infringed by making, using, selling, offering for
451
+sale, or importing the Program or any portion of it.
452
+
453
+  11. Patents.
454
+
455
+  A "contributor" is a copyright holder who authorizes use under this
456
+License of the Program or a work on which the Program is based.  The
457
+work thus licensed is called the contributor's "contributor version".
458
+
459
+  A contributor's "essential patent claims" are all patent claims
460
+owned or controlled by the contributor, whether already acquired or
461
+hereafter acquired, that would be infringed by some manner, permitted
462
+by this License, of making, using, or selling its contributor version,
463
+but do not include claims that would be infringed only as a
464
+consequence of further modification of the contributor version.  For
465
+purposes of this definition, "control" includes the right to grant
466
+patent sublicenses in a manner consistent with the requirements of
467
+this License.
468
+
469
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
470
+patent license under the contributor's essential patent claims, to
471
+make, use, sell, offer for sale, import and otherwise run, modify and
472
+propagate the contents of its contributor version.
473
+
474
+  In the following three paragraphs, a "patent license" is any express
475
+agreement or commitment, however denominated, not to enforce a patent
476
+(such as an express permission to practice a patent or covenant not to
477
+sue for patent infringement).  To "grant" such a patent license to a
478
+party means to make such an agreement or Corresponding Source to be so
479
+available, or (2) arrange to deprive yourself of the benefit of the
480
+patent license for this particular work, or (3) arrange, in a manner
481
+consistent with the requirements of this License, to extend the patent
482
+license to downstream recipients.  "Knowingly relying" means you have
483
+actual knowledge that, but for the patent license, your conveying the
484
+covered work in a country, or your recipient's use of the covered work
485
+in a country, would infringe one or more identifiable patents in that
486
+country that you have reason to believe are valid.
487
+
488
+  If, pursuant to or in connection with a single transaction or
489
+arrangement, you convey, or propagate by procuring conveyance of, a
490
+covered work, and grant a patent license to some of the parties
491
+receiving the covered work authorizing them to use, propagate, modify
492
+or convey a specific copy of the covered work, then the patent license
493
+you grant is automatically extended to all recipients of the covered
494
+work and works based on it.
495
+
496
+  A patent license is "discriminatory" if it does not include within
497
+the scope of its coverage, prohibits the exercise of, or is
498
+conditioned on the non-exercise of one or more of the rights that are
499
+specifically granted under this License.  You may not convey a covered
500
+work if you are a party to an arrangement with a third party that is
501
+in the business of distributing software, under which you make payment
502
+to the third party based on the extent of your activity of conveying
503
+the work, and under which the third party grants, to any of the
504
+parties who would receive the covered work from you, a discriminatory
505
+patent license (a) in connection with copies of the covered work
506
+conveyed by you (or copies made from those copies), or (b) primarily
507
+for and in connection with specific products or compilations that
508
+contain the covered work, unless you entered into that arrangement,
509
+or that patent license was granted, prior to 28 March 2007.
510
+
511
+  Nothing in this License shall be construed as excluding or limiting
512
+any implied license or other defenses to infringement that may
513
+otherwise be available to you under applicable patent law.
514
+
515
+  12. No Surrender of Others' Freedom.
516
+
517
+  If conditions are imposed on you (whether by court order, agreement or
518
+otherwise) that contradict the conditions of this License, they do not
519
+excuse you from the conditions of this License.  If you cannot convey a
520
+covered work so as to satisfy simultaneously your obligations under this
521
+License and any other pertinent obligations, then as a consequence you may
522
+not convey it at all.  For example, if you agree to terms that obligate you
523
+to collect a royalty for further conveying from those to whom you convey
524
+the Program, the only way you could satisfy both those terms and this
525
+License would be to refrain entirely from conveying the Program.
526
+
527
+  13. Use with the GNU Affero General Public License.
528
+
529
+  Notwithstanding any other provision of this License, you have
530
+permission to link or combine any covered work with a work licensed
531
+under version 3 of the GNU Affero General Public License into a single
532
+combined work, and to convey the resulting work.  The terms of this
533
+License will continue to apply to the part which is the covered work,
534
+but the special requirements of the GNU Affero General Public License,
535
+section 13, concerning interaction through a network will apply to the
536
+combination as such.
537
+
538
+  14. Revised Versions of this License.
539
+
540
+  The Free Software Foundation may publish revised and/or new versions of
541
+the GNU General Public License from time to time.  Such new versions will
542
+be similar in spirit to the present version, but may differ in detail to
543
+address new problems or concerns.
544
+
545
+  Each version is given a distinguishing version number.  If the
546
+Program specifies that a certain numbered version of the GNU General
547
+Public License "or any later version" applies to it, you have the
548
+option of following the terms and conditions either of that numbered
549
+version or of any later version published by the Free Software
550
+Foundation.  If the Program does not specify a version number of the
551
+GNU Genexy's
552
+public statement of acceptance of a version permanently authorizes you
553
+to choose that version for the Program.
554
+
555
+  Later license versions may give you additional or different
556
+permissions.  However, no additional obligations are imposed on any
557
+author or copyright holder as a result of your choosing to follow a
558
+later version.
559
+
560
+  15. Disclaimer of Warranty.
561
+
562
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
563
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
564
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
565
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
566
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
567
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
568
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
569
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
570
+
571
+  16. Limitation of Liability.
572
+
573
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
574
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
575
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
576
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
577
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
578
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
579
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
580
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
581
+SUCH DAMAGES.
582
+
583
+  17. Interpretation of Sections 15 and 16.
584
+
585
+  If the disclaimer of warranty and limitation of liability provided
586
+above cannot be given local legal effect according to their terms,
587
+reviewing courts shall apply local law that most closely approximates
588
+an absolute waiver of all civil liability in connection with the
589
+Program, unless a warranty or assumption of liability accompanies a
590
+copy of the Program in return for a fee.
591
+
592
+                     END OF TERMS AND CONDITIONS
593
+
594
+            How to Apply These Terms to Your New Programs
595
+
596
+  If you develop a new program, and you want it to be of the greatest
597
+possible use to the public, the best way to achieve this is to make it
598
+free software which everyone can redistribute and change under these terms.
599
+
600
+  To do so, attach the following notices to the program.  It is safest
601
+to attach them to the start of each source file to most effectively
602
+state the exclusion of warranty; and each file should have at least
603
+the "copyright" line and a pointer to where the full notice is found.
604
+
605
+    <one line to give the program's name and a brief idea of what it does.>
606
+    Copyright (C) <year>  <name of author>
607
+
608
+    This program is free software: you can redistribute it and/or modify
609
+    it under the terms of the GNU General Public License as published by
610
+    the Free Software Foundation, either version 3 of the License, or
611
+    (at your option) any later version.
612
+
613
+    This program is distributed in the hope that it will be useful,
614
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
615
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
616
+    GNU General Public License for more details.
617
+
618
+    You should have received a copy of the GNU General Public License
619
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
620
+
621
+Also add information on how to contact you by electronic and paper mail.
622
+
623
+  If the program does terminal interaction, make it output a short
624
+notice like this when it starts in an interactive mode:
625
+
626
+    <program>  Copyright (C) <year>  <name of author>
627
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
628
+    This is free software, and you are welcome to redistribute it
629
+    under certain conditions; type `show c' for details.
630
+
631
+The hypothetical commands `show w' and `show c' should show the appropriate
632
+parts of the General Public License.  Of course, your program's commands
633
+might be different; for a GUI interface, you would use an "about box".
634
+
635
+  You should also get your employer (if you work as a programmerrams.  If your program is a subroutine library, you
636
+may consider it more useful to permit linking proprietary applications with
637
+the library.  If this is what you want to do, use the GNU Lesser General
638
+Public License instead of this License.  But first, please read
639
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
640
+

+ 1
- 0
NEWS View File

@@ -0,0 +1 @@
1
+19/03/15 : Initial commit on a git repo at version 1.0.0 (alpha)

+ 5
- 0
clean.sh View File

@@ -0,0 +1,5 @@
1
+#!/bin/bash
2
+
3
+
4
+rm -v $(dirname "$0")/*.pyc $(dirname "$0")/*.pyo
5
+

+ 33
- 0
main.py View File

@@ -0,0 +1,33 @@
1
+#!/usr/bin/python -O
2
+# -*- coding: utf-8 -*-#
3
+
4
+# Copyright 2015 Weber Yann
5
+#
6
+# This file is part of pyMapTraceroute.
7
+#
8
+#        pyMapTraceroute is free software: you can redistribute it and/or modify
9
+#        it under the terms of the GNU General Public License as published by
10
+#        the Free Software Foundation, either version 3 of the License, or
11
+#        (at your option) any later version.
12
+#
13
+#        pyMapTraceroute is distributed in the hope that it will be useful,
14
+#        but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+#        GNU General Public License for more details.
17
+#
18
+#        You should have received a copy of the GNU General Public License
19
+#        along with pyMapTraceroute.  If not, see <http://www.gnu.org/licenses/>.
20
+#
21
+
22
+import vtracert
23
+
24
+MAPFILE = 'mapData/borders.dat'
25
+MAPFILE = 'mapData/borders_xl.dat'
26
+
27
+width = 1024
28
+height = 768
29
+
30
+vtr = vtracert.Vtracert(MAPFILE, width, height)
31
+
32
+vtr.run()
33
+exit()

+ 1
- 0
mapData/SOURCES View File

@@ -0,0 +1 @@
1
+http://www.mappinghacks.com/data/

BIN
mapData/borders_s.dat.gz View File


+ 362141
- 0
mapData/borders_xl.dat
File diff suppressed because it is too large
View File


BIN
mapData/borders_xlshuf.dat.gz View File


BIN
mapData/borders_xs.dat.gz View File


BIN
mapData/borders_xsmall.dat.gz View File


+ 337
- 0
tracer.py View File

@@ -0,0 +1,337 @@
1
+# -*- coding: utf-8 -*-#
2
+
3
+# Copyright 2015 Weber Yann
4
+#
5
+# This file is part of pyMapTraceroute.
6
+#
7
+#        pyMapTraceroute is free software: you can redistribute it and/or modify
8
+#        it under the terms of the GNU General Public License as published by
9
+#        the Free Software Foundation, either version 3 of the License, or
10
+#        (at your option) any later version.
11
+#
12
+#        pyMapTraceroute is distributed in the hope that it will be useful,
13
+#        but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+#        GNU General Public License for more details.
16
+#
17
+#        You should have received a copy of the GNU General Public License
18
+#        along with pyMapTraceroute.  If not, see <http://www.gnu.org/licenses/>.
19
+#
20
+
21
+import os, re, GeoIP, time, string, pygame
22
+
23
+
24
+from subprocess import Popen, PIPE
25
+from pygame import gfxdraw
26
+
27
+import vtracemap
28
+import vtracert
29
+
30
+class Tracer:
31
+	
32
+	## Tracer instanciation
33
+	# @param vtr The Vtracert
34
+	def __init__(self, vtr):
35
+		
36
+		#Check vtr argument
37
+		if not isinstance(vtr, vtracert.Vtracert):
38
+			raise TypeError('Vtracert waited')
39
+		
40
+		self.vtr = vtr
41
+		
42
+		#Init object properties
43
+		self.initTrace()
44
+		self.gi = GeoIP.open("/usr/share/GeoIP/GeoIPCity.dat",GeoIP.GEOIP_STANDARD)
45
+		cproc = os.popen('curl --silent zered.org/getip.php')
46
+		self.src = cproc.readline().strip()
47
+		
48
+		
49
+		self.prev = None
50
+		
51
+		self.selected = [] #selected hop
52
+		
53
+		self.regetip = re.compile('^.*\(([^\)]*)\).*$');
54
+		self.reghost = re.compile('^ *[0-9]* *([^\(]*)\(.*$');
55
+		self.regHop = re.compile('^[^0-9]*([0-9]*).*$');
56
+		
57
+		pass
58
+	
59
+	## Object trace initialisation
60
+	def initTrace(self):
61
+		self.ips = []
62
+		self.hosts = []
63
+		self.pts = []
64
+		self.hops = []
65
+		self.coords = []
66
+		self.selected = []
67
+	
68
+	def progressStatus(self):
69
+		self.vtr.drawStatus("Traceroute in progress : ...", self.vtr.font['status'],self.vtr.col['trace_progress'])
70
+		pass
71
+	
72
+	## Generator that yield ips from a running traceroute
73
+	# @param The host to traceroute to
74
+	# @yield Hop's IP
75
+	def traceGen(self,dest_name):
76
+		
77
+		#Init tracer
78
+		self.initTrace();
79
+		
80
+		#Store source ip as first hop
81
+		self.storeIp(self.src)
82
+		self.hosts.append('localhost')
83
+		self.hops.append('0')
84
+		
85
+		#Update status bar
86
+		self.progressStatus()
87
+		self.vtr.flip()
88
+		yield self.src
89
+		
90
+		#Run traceroute process
91
+		p = Popen(['traceroute', dest_name], stdout=PIPE)
92
+		
93
+		#First line give us destination ip
94
+		line = p.stdout.readline()
95
+		
96
+		ml = self.regetip.match(line)
97
+		if ml != None:
98
+			dest_ip = ml.group(1)
99
+		else:
100
+			dest_ip = None
101
+		
102
+		#Reading traceroute output
103
+		while True:
104
+			line = p.stdout.readline()
105
+			if not line:
106
+				break
107
+			
108
+			print line
109
+			
110
+			#Getting hop number
111
+			ml = self.regHop.match(line)
112
+			if ml != None:
113
+				self.hops.append(ml.group(1))
114
+			else:
115
+				self.hops.append('?')
116
+			
117
+			#hop hostname
118
+			ml = self.reghost.match(line)
119
+			if ml != None:
120
+				self.hosts.append(ml.group(1))
121
+			else:
122
+				self.hosts.append('?')
123
+			#hop ip
124
+			ml = self.regetip.match(line)
125
+			if ml != None:
126
+				ip = ml.group(1)
127
+			else:
128
+				ip = None
129
+			
130
+			self.storeIp(ip)
131
+			
132
+				
133
+			strStatus = "Traceroute in progress : "
134
+			strStatus += self.hops[-1]+' '+self.hosts[-1]
135
+			if ip != None:
136
+				strStatus += '('+ip+')'
137
+			
138
+			self.vtr.drawStatus(strStatus, self.vtr.font['status'],self.vtr.col['trace_progress'])	
139
+			
140
+			self.drawRoute()
141
+			yield self.ips[-1]
142
+		
143
+		if dest_ip != None:
144
+			self.storeIp(dest_ip)
145
+			self.hops.append('Dest')
146
+			self.hosts.append(dest_name)
147
+			yield dest_ip
148
+	
149
+	## Store an hop's ip in object properties
150
+	# @param ip The ip adress to store
151
+	def storeIp(self,ip):
152
+		
153
+		nopts = False
154
+		
155
+		self.ips.append(ip)
156
+		
157
+		if ip != None:
158
+			#gir = self.gi.record_by_name(ip)
159
+			gir = self.gi.record_by_addr(ip)
160
+			if gir != None:
161
+				#print gir['latitude'], gir['longitude']
162
+				self.pts.append( ( gir['longitude'], gir['latitude']) )
163
+			else:
164
+				nopts = True
165
+		else:
166
+			nopts = True
167
+		
168
+		if nopts:
169
+			self.pts.append(None)
170
+		pass
171
+	
172
+	## Populate data by running a traceroute
173
+	# @param dest_name The host
174
+	def trace(self,dest_name):
175
+		#Traceroute generator
176
+		tr = self.traceGen(dest_name)
177
+		for ip in tr:
178
+			if ip != None:
179
+				pass #self.storeIp(ip)
180
+	
181
+	## Run a traceroute and interactively update the screen
182
+	# @param dest_name The host
183
+	def liveTrace(self,dest_name):
184
+		
185
+		#Traceroute generator
186
+		tr = self.traceGen(dest_name)
187
+		self.initDraw()
188
+
189
+		for ip in tr:
190
+			if ip != None:
191
+				#New hop
192
+				pts = self.pts[-1]
193
+				if pts != None:
194
+					dcoord = self.drawNext(pts)
195
+					self.coords.append(dcoord)
196
+				else:
197
+					self.coords.append(None)
198
+			#Update the screen
199
+			self.vtr.flip()
200
+		pass
201
+	
202
+	## Init a new trace drawing
203
+	def initDraw(self):
204
+		self.prev = None
205
+		self.coords = []
206
+		self.vtr.surf['trace'].fill((0,0,0,0))
207
+		pass
208
+	
209
+	## Draw the next hop in a route on the map
210
+	# Hops are circle (filled when selected) and
211
+	# the route is represented by line between circles
212
+	# @param (lon,lat) Hop coordinates
213
+	# @param selected A boolean
214
+	# @return The coordinates of the hop on the screen as (x,y)
215
+	def drawNext(self, (lon, lat), selected = False):
216
+		
217
+		if not selected :
218
+			#If not selected draw a circle
219
+			cdrawfun = pygame.gfxdraw.circle
220
+		else:
221
+			#If selected draw a filled circle
222
+			cdrawfun = pygame.gfxdraw.filled_circle
223
+		
224
+		(x,y) = self.vtr.trmap.latlon2ortho(lon, lat)
225
+		if self.prev == None:
226
+			#Route begining
227
+			cdrawfun(self.vtr.surf['trace'],x,y,3,self.vtr.col['trace_init'])
228
+		else:
229
+			#A new hop
230
+			cdrawfun(self.vtr.surf['trace'], x,y,5,self.vtr.col['trace_hop'])
231
+			(px,py) = self.prev
232
+			pygame.gfxdraw.line(self.vtr.surf['trace'], px,py,x,y, self.vtr.col['trace_trace'])
233
+		
234
+		self.prev = (x,y)
235
+		
236
+		return (x,y)
237
+	
238
+	## Draw an existing route on the map
239
+	# @param delay The time to wait between the draw of two hops (in float, seconds)
240
+	def drawTrace(self, delay = 0.1):
241
+		
242
+		self.initDraw()
243
+		
244
+		cnt = 1
245
+		for i,pt in enumerate(self.pts):
246
+			
247
+			if pt != None:
248
+				dcoord = self.drawNext(pt, (i in self.selected) )
249
+				self.coords.append(dcoord)
250
+				
251
+				if delay > 0:
252
+					self.drawRoute(cnt)
253
+					self.vtr.flip()
254
+					time.sleep(delay)
255
+				
256
+			else:
257
+				self.coords.append(None)
258
+			cnt += 1
259
+		self.drawRoute()
260
+		pass
261
+			
262
+			
263
+	## Draw the text representation of an existing route
264
+	# One line per hop at the bottom left of the screen
265
+	# @param stopAt Print the last 'stopAt' hops
266
+	def drawRoute(self, stopAt = 32):
267
+		
268
+		strStatus=''
269
+		
270
+		self.vtr.surf['tracetxt'].fill((0,0,0,0))
271
+		lh = self.vtr.font['trace_txt'].get_linesize()
272
+		
273
+		cy = self.vtr.surf['tracetxt'].get_height()-4
274
+		cy -= lh
275
+		
276
+		if stopAt < 0 or stopAt > len(self.ips):
277
+			rng = range(len(self.ips))
278
+		else:
279
+			rng = range(stopAt)
280
+		rng.reverse()
281
+		for i in rng:
282
+			strStatus = self.hops[i]+' '+self.hosts[i]
283
+			if self.ips[i] != None:
284
+				strStatus += '('+self.ips[i]+')'
285
+			
286
+			if i in self.selected:
287
+				col = self.vtr.col['trace_txtsel'] #selected color
288
+			else:
289
+				col = self.vtr.col['trace_txt'] #normal color
290
+				
291
+			statusSurf = self.vtr.font['trace_txt'].render(strStatus, 1, col)
292
+			
293
+			self.vtr.surf['tracetxt'].blit(statusSurf, (4,cy))
294
+			cy -= lh
295
+		pass
296
+	
297
+	## Search if there is a hop near a screen coordinate
298
+	# Will return mutliple host if the distance is equal
299
+	# @param (x,y) The on screen coordinates
300
+	# @param maxDist The maximum distance bellow wich a hop is selected
301
+	# @return A list of hop index
302
+	def searchHopByCoord(self, (x,y), maxDist = 10):
303
+		
304
+		maxDist = maxDist **2
305
+		
306
+		curRes = []
307
+		curMin = maxDist+1
308
+		
309
+		for (i,pos) in enumerate(self.coords):
310
+			if pos != None:
311
+				(cx,cy) = pos
312
+				d = ((cx-x)**2) + ((cy-y)**2)
313
+				if d <= curMin:
314
+					if d == curMin:
315
+						curRes.append(i)
316
+					else:
317
+						curRes = [i]
318
+					curMin = d
319
+					
320
+		
321
+		return curRes
322
+	
323
+	## Select hops given screen coordinate
324
+	# @param pos On screen coordinate in a (x,y) tuple
325
+	# @return A boolean set to True if hops were selected
326
+	def select(self, pos):
327
+		self.selected = self.searchHopByCoord(pos)
328
+		return (len(self.selected)>0)
329
+	
330
+	## Return a string representing selected hops ip
331
+	# @return One ip on each line, preffixed by \t
332
+	def selectedIp(self):
333
+		res = ""
334
+		for i in self.selected:
335
+			res += '\t'+str(self.hosts[i])+'('+str(self.ips[i])+')\n'
336
+		return res
337
+

+ 445
- 0
vtracemap.py View File

@@ -0,0 +1,445 @@
1
+# -*- coding: utf-8 -*-#
2
+
3
+# Copyright 2015 Weber Yann
4
+#
5
+# This file is part of pyMapTraceroute.
6
+#
7
+#        pyMapTraceroute is free software: you can redistribute it and/or modify
8
+#        it under the terms of the GNU General Public License as published by
9
+#        the Free Software Foundation, either version 3 of the License, or
10
+#        (at your option) any later version.
11
+#
12
+#        pyMapTraceroute is distributed in the hope that it will be useful,
13
+#        but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+#        GNU General Public License for more details.
16
+#
17
+#        You should have received a copy of the GNU General Public License
18
+#        along with pyMapTraceroute.  If not, see <http://www.gnu.org/licenses/>.
19
+#
20
+
21
+import math, pygame, os, json, time, itertools, multiprocessing, struct, sys
22
+
23
+from multiprocessing import Pool
24
+from functools import partial
25
+
26
+import vtracert
27
+
28
+PID4 = math.pi / 4.0
29
+LOGTPID4 = math.log1p(math.tan(PID4))
30
+
31
+## Function runned by the pool when drawing the map
32
+# @param (lon, lat) Coordinates
33
+# @param arg ( (lonmin,lonmax,latmin,latmax), scaleW, scaleH, xlim)
34
+# @return (x,y) or None
35
+def draw__ProcessFun((lon, lat), arg ):
36
+	
37
+	( (lonmin,lonmax,latmin,latmax), scaleW, scaleH, xlim) = arg
38
+	
39
+	if lonmin > lonmax:
40
+		test = (lon < lonmax and lon > lonmin)
41
+	else:
42
+		test = (lon > lonmin and lon < lonmax)
43
+		
44
+	if lat > latmin and lat < latmax and test:
45
+		
46
+		(x,y) = TraceMap._latlon2ortho(lon,lat,scaleW,scaleH,xlim)
47
+		
48
+		x%=scaleW
49
+		y%=scaleH
50
+		return (x,y)
51
+	return None
52
+
53
+
54
+## Handle a map for tracerouting
55
+# Give access to functions for coordinates convertion
56
+class TraceMap(object):
57
+	
58
+	def __init__(self, vtr, lonmin = -179, lonmax = 180, latmin = -100, latmax = 100):
59
+		
60
+		if not isinstance(vtr, vtracert.Vtracert):
61
+			raise TypeError('Vtracert waited')
62
+		
63
+		self.vtr = vtr
64
+		
65
+		#Loading datas
66
+		self.lonlat = TraceMap.lonlatFromFile(self.vtr.mapfile)
67
+		
68
+		self.xlimits = None
69
+		self.lonlatminmax = (lonmin,lonmax,latmin,latmax)
70
+		self.xlimits = self.genXlimits(lonmin,lonmax,latmin,latmax)
71
+		
72
+		#Pool used to draw the map (convert lon, lat into x,y)
73
+		self.pdraw = Pool(multiprocessing.cpu_count())
74
+		
75
+		pass
76
+	
77
+	def __destroy__(self):
78
+		self.pdraw.close()
79
+	
80
+	## Draw the map
81
+	# Automatically choose the fastest method to draw (with or without the pool)
82
+	# @param animated Use more time but its "fancy"
83
+	def draw(self,animated = True):
84
+		(a,_,b,_) = self.xlimits
85
+		if a + b > 400000:
86
+			self.__poolDraw() #Use the pool
87
+		else:
88
+			self.__soloDraw(False)
89
+		pass
90
+	
91
+	## Draw the map using the TraceMap::pdraw pool
92
+	# @param animated Useless
93
+	# @see TraceMap::draw(), TraceMap::__soloDraw(), __drawP()
94
+	def __poolDraw(self, animated = False):
95
+		
96
+		atime = time.time() #timer
97
+		
98
+		self.vtr.surf['map'].fill(self.vtr.col['bg'])
99
+		
100
+		#Array used because fastest
101
+		sufarr = pygame.surfarray.array2d(self.vtr.surf['map'])
102
+		
103
+		(lonmin,lonmax,latmin,latmax) = self.lonlatminmax
104
+		
105
+		w = self.vtr.surf['map'].get_width()
106
+		h = self.vtr.surf['map'].get_height()
107
+		
108
+		#Pass constants arguments to function
109
+		pDrawP = partial(draw__ProcessFun, arg = ( self.lonlatminmax, w, h, self.xlimits ) )
110
+		
111
+		toUpdate = self.pdraw.map(pDrawP, self.lonlat)
112
+		#Cleaning with set
113
+		toUpdate = set(toUpdate).difference(set([None]))
114
+		
115
+		for x,y in toUpdate:
116
+			sufarr[x][y] = self.vtr.col['map']
117
+		
118
+		#Blit array back on surface
119
+		pygame.surfarray.blit_array(self.vtr.surf['map'], sufarr)
120
+		
121
+		self.vtr.blitScreen('map')
122
+		
123
+		btime = time.time()#timer
124
+		print "Map draw spent ",(btime-atime)*1000,"miliseconds"
125
+		
126
+		pass
127
+	
128
+	## Draw the map using a single process
129
+	# @param animated If True the screen is updated while drawing (small time consumption)
130
+	# @see TraceMap::draw(), TraceMap::__soloDraw()
131
+	def __soloDraw(self, animated = True):
132
+		
133
+		atime = time.time()
134
+		
135
+		self.vtr.surf['map'].fill(self.vtr.col['bg'])
136
+		
137
+		#Array used because fastest
138
+		sufarr = pygame.surfarray.array2d(self.vtr.surf['map'])
139
+
140
+		cnt = 1 #Counter
141
+		
142
+		(lonmin,lonmax,latmin,latmax) = self.lonlatminmax
143
+
144
+		#Refresh if animated
145
+		lll = len(self.lonlat)
146
+		refresh = [ lll/20, lll/10, lll/2, (lll*3)/4 ]
147
+		
148
+		
149
+		for (lon,lat) in self.lonlat:
150
+			
151
+			if lonmin > lonmax:
152
+				test = (lon < lonmax and lon > lonmin)
153
+			else:
154
+				test = (lon > lonmin and lon < lonmax)
155
+				
156
+			if test and lat > latmin and lat < latmax:
157
+				(x,y) = self.latlon2ortho(lon,lat)
158
+				
159
+				x%=len(sufarr)
160
+				y%=len(sufarr[x])
161
+				
162
+				sufarr[x][y] = self.vtr.col['map']
163
+				
164
+				
165
+				if animated and self.vtr.surf['screen'] != None and cnt in refresh:
166
+					self.vtr.surf['map'].fill((0,0,0))
167
+					pygame.surfarray.blit_array(self.vtr.surf['map'], sufarr)
168
+					self.vtr.blitScreen('map')
169
+					
170
+					pygame.display.flip()
171
+				
172
+			cnt +=1
173
+		
174
+		self.vtr.surf['map'].fill((0,0,0))
175
+		#blit array back
176
+		pygame.surfarray.blit_array(self.vtr.surf['map'], sufarr)
177
+		self.vtr.blitScreen('map')
178
+		
179
+		if animated and self.vtr.surf['screen'] != None:
180
+			pygame.display.flip()
181
+			
182
+		btime = time.time()
183
+		print "Map OLDdraw spent ",(btime-atime)*1000,"miliseconds"
184
+	
185
+	## Generate limits from lon and lat to convert coordinates
186
+	# @param lonmin Longitude mini
187
+	# @param lonmax Longitude max
188
+	# @param latmin Latitude mini
189
+	# @param latmax Latitude max
190
+	def genXlimits(self, lonmin,lonmax,latmin,latmax):
191
+	
192
+		self.lonlatminmax = (lonmin,lonmax,latmin,latmax)
193
+	
194
+		(xs,ys) = self.latlon2ortho(lonmax, latmax, True)
195
+		(xl,yl) = self.latlon2ortho(lonmin, latmin, True)
196
+		
197
+		if xs<xl:
198
+			x1 = xs
199
+			x2 = xl
200
+		else:
201
+			x1 = xl
202
+			x2 = xs
203
+		
204
+		if ys<yl:
205
+			y1 = ys
206
+			y2 = yl
207
+		else:
208
+			y1 = yl
209
+			y2 = ys
210
+		
211
+		self.xlimits = (x2-x1,x1,y2-y1,y1)
212
+		return self.xlimits
213
+	
214
+	## Zoom on the map
215
+	# @param (cx,cy) Where to center the zoom
216
+	# @param zoom If True zoom if False zoom out and can be a direction str 'up' 'down' 'left' 'right' to move on the map
217
+	def zoom(self,(cx,cy), zoom = True):
218
+		
219
+		width = self.vtr.surf['map'].get_width()
220
+		height = self.vtr.surf['map'].get_height()
221
+		
222
+		zoomV = 0.3 #Zoom 'power'
223
+		moveD = 50 #Move 'power'
224
+		
225
+		if not isinstance(zoom, str):
226
+			#New height and width	
227
+			if zoom:
228
+				nw = (width * (1-zoomV))/2
229
+				nh = (height * (1-zoomV))/2
230
+			else:
231
+				nw = (width * (1+zoomV))/2
232
+				nh = (height * (1+zoomV))/2
233
+
234
+			#New limits virtual coordinates
235
+			xmin = int(cx - nw)
236
+			xmax = int(cx + nw)
237
+			
238
+			ymin = int(cy - nh)
239
+			ymax =  int(cy + nh)
240
+		else:
241
+			#Not zooming but moving
242
+			xmin = 0
243
+			xmax = self.vtr.surf['map'].get_width()
244
+			ymin = 0
245
+			ymax = self.vtr.surf['map'].get_height()
246
+				
247
+			if zoom == 'up':
248
+				ymin -= moveD
249
+				ymax -= moveD
250
+			elif zoom == 'down':
251
+				ymin += moveD
252
+				ymax += moveD
253
+			elif zoom == 'right':
254
+				xmin += moveD
255
+				xmax += moveD
256
+			else:
257
+				xmin -= moveD
258
+				xmax -= moveD
259
+		
260
+		#Calculating new lon and lat limits from new limits
261
+		savlimits = self.lonlatminmax
262
+		
263
+		(lonmin,latmin) = self.ortho2latlon(xmin,ymin)
264
+		(lonmax,latmax) = self.ortho2latlon(xmax,ymax)
265
+		
266
+		if latmin > latmax:
267
+			foo = latmin
268
+			latmin = latmax
269
+			latmax = foo
270
+
271
+		if lonmax-lonmin > 360 or latmax - latmin > 180:
272
+			#Less zoom is useless, recenter the map
273
+			lonmin = -179
274
+			lonmax = 179
275
+			latmin = -100
276
+			latmax = 100
277
+		
278
+		if (lonmin,lonmax,latmin,latmax) != savlimits: #only redraw if needed
279
+			
280
+			self.genXlimits(lonmin,lonmax,latmin,latmax)
281
+			
282
+			screen = self.vtr.surf['screen']
283
+			screen.blit(self.vtr.surf['map'],(0,0))
284
+			#zoombox draw
285
+			pygame.gfxdraw.line(screen,xmin,ymin,xmin,ymax,(255,255,100))
286
+			pygame.gfxdraw.line(screen,xmax,ymin,xmax,ymax,(255,255,100))
287
+			pygame.gfxdraw.line(screen,xmin,ymin,xmax,ymin,(255,255,100))
288
+			pygame.gfxdraw.line(screen,xmin,ymax,xmax,ymax,(255,255,100))
289
+			pygame.display.flip()
290
+			
291
+			#Redraw map
292
+			self.draw()
293
+			pass
294
+	
295
+	## Load coordinates from a file
296
+	# The file stores point like : lon lat
297
+	# @param coordFile The filename
298
+	# @return A list of tuple
299
+	@classmethod
300
+	def lonlatFromFile(c, coordFile):
301
+	
302
+		res = []
303
+		
304
+		fd = file(coordFile,"r")
305
+
306
+		buff = ''
307
+		lat = 0.0
308
+		lon = 0.0
309
+
310
+		#cread = fd.readline()
311
+
312
+		for line in fd:
313
+			line = line.strip()
314
+			(lon,lat) = line.rsplit(' ')
315
+			lon = float(lon)
316
+			lat = float(lat)
317
+			res.append((lon,lat))
318
+		
319
+		fd.close()
320
+		return res
321
+	
322
+	## Load packed data from file
323
+	# Packed file use less disk space but take more time to load.
324
+	# Not used by default
325
+	# @param coordFile The filename with packed datas
326
+	# @return a list of (lon,lat)
327
+	@classmethod
328
+	def lonlatFromPackFile(c, coordFile):
329
+		
330
+		res = []
331
+		
332
+		fd = file(coordFile,"rb")
333
+		
334
+		while True:
335
+			"""
336
+			r = fd.read(4)
337
+			if len(r) < 4:
338
+				break
339
+			lon = struct.unpack('f',r)
340
+			r = fd.read(4)
341
+			if len(r) < 4:
342
+				break
343
+			lat = struct.unpack('f',r)
344
+			"""
345
+			r = fd.read(8)
346
+			if len(r) < 8:
347
+				break
348
+			lon = struct.unpack('f',r[:4])
349
+			lat = struct.unpack('f',r[4:])
350
+			res.append((lon,lat))
351
+		
352
+		fd.close()
353
+		return res
354
+			
355
+	## Store data packed
356
+	# Packed file use less disk space but take more time to load.
357
+	# Not used by default
358
+	# @param coordFile The filename where we want to store data
359
+	@classmethod
360
+	def lonlatToPackFile(c, coordFile, lonlat):
361
+		
362
+		fd = file(coordFile, 'w+')
363
+		
364
+		buff = [ struct.pack('f', lon)+struct.pack('f', lat) for (lon, lat) in lonlat ]
365
+		buff = b''.join(buff)
366
+		
367
+		print len(buff)
368
+		
369
+		fd.write(buff)
370
+		fd.close()
371
+		pass
372
+			
373
+	
374
+	## Convert longitude and latitude to screen coordinates
375
+	# @param lon Longitude
376
+	# @param lat Lattitude
377
+	# @param nolimit If true don't scale
378
+	# @return (x,y)
379
+	# @see TraceMap::_latlon2ortho(), TraceMap::ortho2latlon()
380
+	def latlon2ortho(self, lon,lat, nolimit = False):
381
+		scaleW = self.vtr.surf['map'].get_width()
382
+		scaleH = self.vtr.surf['map'].get_height()
383
+		if nolimit:
384
+			xlim = None
385
+		else:
386
+			xlim = self.xlimits
387
+		
388
+		return TraceMap._latlon2ortho(lon,lat,scaleW,scaleH,xlim)
389
+	
390
+	## Body of TraceMap::latlon2ortho()
391
+	# Used like classmethode by __drawP()
392
+	# @param lon Longitude
393
+	# @param lat Lattitude
394
+	# @param scaleW Map width
395
+	# @param scaleH Map height
396
+	# @param xlimits If none dont scale
397
+	# @return (x,y)
398
+	# @see TraceMap::latlon2ortho(), TraceMap::ortho2latlon()
399
+	@classmethod
400
+	def _latlon2ortho(c, lon,lat , scaleW, scaleH, xlimits = None):
401
+		
402
+		width = scaleW * 707
403
+		height = scaleH * (707 * (scaleW/float(scaleH)))
404
+	
405
+		lat=math.radians(lat)
406
+		ratio = int(width/(math.pi*2.0))
407
+		x = int(width*((lon+180)/360.0))
408
+		y = int(height/2.0-LOGTPID4-lat/2.0*ratio)
409
+		
410
+		#Scaling with xlimits infos
411
+		if xlimits != None :
412
+			(dx,xs,dy,ys) = xlimits
413
+			x = int(scaleW * float(x-xs) / dx)
414
+			y = int(scaleH * float(y-ys) / dy)
415
+		
416
+		return (x,y)
417
+	
418
+	## Convert coordinates to longitude and latitude
419
+	# @param x X
420
+	# @param y Y
421
+	# @return (lon,lat)
422
+	# @see TraceMap::latlon2ortho()
423
+	def ortho2latlon(self, x,y):
424
+		
425
+		scaleW = self.vtr.surf['map'].get_width()
426
+		scaleH = self.vtr.surf['map'].get_height()
427
+		width = scaleW * 707
428
+		height = scaleH * (707 * (scaleW/float(scaleH)))
429
+		
430
+		
431
+		ratio = int(width/(math.pi*2.0))
432
+		
433
+		(dx,xs,dy,ys) = self.xlimits
434
+		
435
+		x = (x * dx / float(scaleW))+xs
436
+		y = (y * dy / float(scaleH))+ys
437
+		
438
+		lon = 180 - (360 * (x/float(width))) * -1
439
+		lat = math.degrees( (y- float(height) / 2 + LOGTPID4)/ratio ) * -2
440
+		
441
+		
442
+		lon -= 360
443
+		
444
+		return (lon,lat)
445
+	

+ 334
- 0
vtracert.py View File

@@ -0,0 +1,334 @@
1
+# -*- coding: utf-8 -*-#
2
+
3
+# Copyright 2015 Weber Yann
4
+#
5
+# This file is part of pyMapTraceroute.
6
+#
7
+#        pyMapTraceroute is free software: you can redistribute it and/or modify
8
+#        it under the terms of the GNU General Public License as published by
9
+#        the Free Software Foundation, either version 3 of the License, or
10
+#        (at your option) any later version.
11
+#
12
+#        pyMapTraceroute is distributed in the hope that it will be useful,
13
+#        but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+#        GNU General Public License for more details.
16
+#
17
+#        You should have received a copy of the GNU General Public License
18
+#        along with pyMapTraceroute.  If not, see <http://www.gnu.org/licenses/>.
19
+#
20
+
21
+import websocket
22
+import random
23
+import thread
24
+import time
25
+import json
26
+import os
27
+
28
+import pygame
29
+from pygame import gfxdraw
30
+
31
+import tracer
32
+import vtracemap
33
+
34
+class Vtracert:
35
+	
36
+	## Instanciate a visual tracert
37
+	# @param mapdatfile The filename containing the borders coordinates
38
+	# @param width Window width
39
+	# @param height Window height
40
+	# @param cols Override default colors, its a dict of tuple (r,g,b) (r,g,b,a), valid keys are : bg, map, prompt, status, trace_init, trace_hop, trace_trace
41
+	# @param fonts Override default font type and size its a dict of tuple (fontType, fontSize), valid keys are : prompt, status
42
+	# @param promptText The prompt when reading the host to traceroute
43
+	# @param defaultInput Default host to traceroute
44
+	def __init__(self, mapdatfile, width = 1024, height = 768, cols = dict(), fonts = dict(), promptText = "Type the ip or hostname to traceroute :    %s_", defaultInput = "gnu.org"):
45
+		
46
+		pygame.init() #Pygame init
47
+		
48
+		#Options
49
+		self.mapfile = mapdatfile
50
+		self.width = width
51
+		self.height = height
52
+		#Colors
53
+		self.col = dict()
54
+		self.col['bg'] = pygame.Color(0,0,0)
55
+		self.col['map'] = pygame.Color(15,8,63)
56
+		self.col['prompt'] = pygame.Color(200,200,200)
57
+		self.col['status'] = pygame.Color(200,200,200)
58
+		self.col['cur_status'] = self.col['status']
59
+		self.col['cur_statusline'] = self.col['status']
60
+		self.col['trace_init'] = pygame.Color(0,0xf0,0)
61
+		self.col['trace_hop'] = pygame.Color(0xf0,0xf0,0)
62
+		self.col['trace_trace'] = pygame.Color(0xf0,0,0)
63
+		self.col['trace_txt'] = pygame.Color(200, 200, 200, 125)
64
+		self.col['trace_txtsel'] = self.col['trace_hop']
65
+		self.col['trace_progress'] = pygame.Color(0,0xf0,0)
66
+		for n, c in cols:
67
+			self.col[n] = pygame.Color(c)
68
+		#Fonts
69
+		self.font = dict()
70
+		self.font['prompt'] = pygame.font.Font(None, 20)
71
+		self.font['status'] = pygame.font.Font(None,20)
72
+		self.font['cur_status'] = self.col['status']
73
+		self.font['trace_txt'] = pygame.font.Font(None,20)
74
+		for n, (ft,fs) in fonts:
75
+			self.font[n] = pygame.font.Font(ft,fs)
76
+		#Prompt options
77
+		self.promptText = promptText
78
+		self.inputText = defaultInput
79
+		
80
+		
81
+		
82
+		#Event filtering
83
+		pygame.event.set_allowed(None)
84
+		pygame.event.set_allowed([pygame.MOUSEBUTTONUP,pygame.KEYDOWN, pygame.KEYUP, pygame.QUIT])
85
+
86
+		#Surface creation
87
+		self.surf = dict()
88
+		self.surf['screen'] = pygame.display.set_mode((width, height), pygame.DOUBLEBUF )
89
+		self.surf['map'] = pygame.Surface((width, height),pygame.HWSURFACE)
90
+		self.surf['trace'] = pygame.Surface((width, height),pygame.HWSURFACE | pygame.SRCALPHA)
91
+		self.surf['tracetxt'] = pygame.Surface((width, height),pygame.HWSURFACE | pygame.SRCALPHA)
92
+		self.surf['status'] = None
93
+		
94
+		self.drawStatus('Loading...');
95
+		pygame.display.flip()
96
+		
97
+		
98
+		#Clipboard handling module initialisation
99
+		pygame.scrap.init()
100
+		
101
+		#Keyboard vars
102
+		self.caps = False
103
+		
104
+		#Map info
105
+		self.trmap = vtracemap.TraceMap(self)
106
+		self.tracer = tracer.Tracer(self)
107
+	
108
+	## Color accessor
109
+	# @param cname Color name
110
+	# @param v The value to set or False to get
111
+	# @return The color named cname
112
+	# @see Vtracert::opt()
113
+	def Col(self, cname, v = False):
114
+		return Vtracert.opt(cname, self.col, v)
115
+	## Surface accessor
116
+	# @param sname surface name
117
+	# @param v The value to set or False to get
118
+	# @return The surface named sname
119
+	# @see Vtracert::opt()
120
+	def Surf(self, sname, v = False):
121
+		return Vtracert.opt(sname, self.surf, v)
122
+	## Font accessor
123
+	# @param fname font name
124
+	# @param v The value to set or False to get
125
+	# @return The font named fname
126
+	# @see Vtracert::opt()
127
+	def Font(self, fname, v = False):
128
+		return Vtracert.opt(sname, self.font, v)
129
+	
130
+	## A generic class to handle dict properties
131
+	# @param cname The dict key
132
+	# @param dopt The dict
133
+	# @param v The value or False for get and not set
134
+	# @return dopt[cname]
135
+	# @see Vtracert::Col(), Vtracert::Surf(), Vtracert::Font()
136
+	@classmethod
137
+	def opt(c, cname, dopt, v):
138
+		if not (not v and isinstance(v,bool)):
139
+			dopt[cname] = v
140
+		return dopt[cname]
141
+	
142
+	## Blit a surface on the screen surface
143
+	# @param sname The surface name
144
+	# @param pos A tuple (x,y) for the blit position
145
+	# @return self.surf['screen'].blit(self.surf[sname], pos)
146
+	def blitScreen(self, sname, pos = (0,0) ):
147
+		return self.surf['screen'].blit(self.surf[sname], pos)
148
+	
149
+	def mapRedraw(self):
150
+		self.fillScreen()
151
+		self.trmap.draw()
152
+		self.flip()
153
+	
154
+	def fillScreen(self):
155
+		self.surf['screen'].fill(self.col['bg'])
156
+		pass
157
+	
158
+	def blit(self):
159
+		self.blitScreen('map')
160
+		self.blitScreen('status')
161
+		self.drawStatusLine()
162
+		self.blitScreen('trace')
163
+		self.blitScreen('tracetxt')
164
+		pass
165
+	
166
+	## Blit all surface and flip display
167
+	def flip(self, fill = True):
168
+		if fill:
169
+			self.fillScreen()
170
+		self.blit()
171
+		pygame.display.flip()
172
+		pass
173
+	
174
+	## Draw the prompt in the status surface
175
+	# @see Vtracert::drawStatus()
176
+	def drawPrompt(self):
177
+		self.drawStatus(self.promptText%(self.inputText), self.font['prompt'], self.col['prompt'])
178
+	
179
+	## Draw the status bar on the screen
180
+	# @param statusText The text to display in the status bar
181
+	# @param font The font used to render the text
182
+	# @param col The text color
183
+	# @param antialiasing A boolean telling if the text is rendered antialiased
184
+	# @param line A boolean telling if the status bar line has to be drawn
185
+	# @param lineCol The status bar line color (by default same as col)
186
+	def drawStatus(self, statusText, font = None, col = None, antialiasing = True, line = True, lineCol = None):
187
+		
188
+		if font == None:
189
+			font = self.font['status']
190
+		self.font['cur_status'] = font
191
+		
192
+		if col == None:
193
+			col = self.col['status']
194
+		self.col['cur_status'] = col
195
+		
196
+		if lineCol == None:
197
+			lineCol = col
198
+		self.col['cur_statusline'] = lineCol
199
+		
200
+		self.surf['status'] = font.render(statusText, antialiasing, col)
201
+		
202
+		#self.blitScreen('status')
203
+		
204
+		if line:
205
+			self.drawStatusLine()
206
+		
207
+		pass
208
+	
209
+	## Draw the status bar horizontal ruler
210
+	# @see Vtracert::drawStatus()
211
+	def drawStatusLine(self):
212
+		ly = self.font['cur_status'].get_linesize() + 2
213
+		pygame.gfxdraw.line(self.surf['screen'], 0, ly, self.width - 1, ly, self.col['cur_statusline'])
214
+		pass
215
+	
216
+	## Handle a KEYUP event
217
+	# @param evt Event
218
+	def keyupEvt(self, evt):
219
+		if evt.key == 303 or evt.key == 304: #caps release
220
+			self.caps = False
221
+			print "Caps released"
222
+		pass
223
+	
224
+	## Handles a KEYDOWN event
225
+	# @param evt Event
226
+	def keydownEvt(self, evt):
227
+		ccode = evt.key
228
+					
229
+		allowedChar = range(ord('a'),ord('z')+1) 
230
+		allowedChar += range(ord('A'),ord('Z')+1)
231
+		allowedChar += range(ord('0'),ord('9')+1)
232
+		allowedChar += [ord('.'),ord('\b'),ord('\r'),ord('\n')]
233
+		
234
+		allowedChar = [ chr(cc) for cc in allowedChar ]
235
+		
236
+		if ccode in [273,274,275,276]: #Arrow keys
237
+			if ccode == 273:
238
+				d = 'up'
239
+			elif ccode == 274:
240
+				d = 'down'
241
+			elif ccode == 275:
242
+				d = 'right'
243
+			else:
244
+				d = 'left'
245
+			
246
+			self.trmap.zoom( (None, None), d)
247
+			
248
+		elif ccode == 303 or ccode == 304: #caps
249
+			caps = True
250
+		elif evt.unicode in allowedChar:
251
+			
252
+			
253
+			cinput = evt.unicode
254
+			if cinput == '\b':
255
+				if len(self.inputText) > 0:
256
+					self.inputText = self.inputText[:-1]
257
+			elif cinput == '\r' or cinput == '\n':
258
+				print "OK, tracerouting %s ..."%self.inputText
259
+				dest = self.inputText
260
+				self.inputText = ""
261
+				
262
+				self.surf['trace'].fill((0,0,0,0))
263
+				
264
+				self.tracer.liveTrace(dest)
265
+				#self.tracer.trace(dest)
266
+				self.flip()
267
+				
268
+			else:
269
+				self.inputText += cinput
270
+			
271
+			self.drawPrompt()
272
+		pass
273
+	
274
+	## Handles a MOUSEBUTTONUP event
275
+	# @param evt Event
276
+	def mouseboutonupEvt(self, evt):
277
+		if evt.button == 4 or evt.button == 5: #scrollzoom
278
+				
279
+			if evt.button == 4 or evt.button == 1:
280
+				zoom = True
281
+			elif evt.button == 5 or evt.button == 3:
282
+				zoom = False
283
+				
284
+			self.trmap.zoom(evt.pos,zoom)
285
+			self.tracer.drawTrace()
286
+			self.blit()
287
+		#end scrollzoom
288
+		
289
+		elif evt.button == 1:
290
+			#Trying to select hops
291
+			if self.tracer.select(evt.pos):
292
+				print 'Selected : \n',self.tracer.selectedIp()
293
+			self.tracer.drawTrace(0)
294
+			
295
+		elif evt.button == 2:
296
+			clipTxt = pygame.scrap.get('TEXT')
297
+			if clipTxt:
298
+				inputTxt += clipTxt
299
+				self.drawPrompt()
300
+		else:
301
+			print "\n\n"
302
+			types = pygame.scrap.get_types()
303
+			for t in types:
304
+				print t,pygame.scrap.get(t)
305
+		pass
306
+	
307
+	
308
+	## Listen for pygame events
309
+	def run(self):
310
+		
311
+		self.drawPrompt();
312
+		self.mapRedraw();
313
+		self.flip()
314
+		
315
+		again = True
316
+		
317
+		while again:
318
+			evts = pygame.event.get()
319
+			if len(evts) > 0:
320
+				
321
+				for evt in evts:
322
+					if evt.type == pygame.QUIT:
323
+						again = False
324
+						break
325
+					elif evt.type == pygame.KEYUP:
326
+						self.keyupEvt(evt)
327
+					elif evt.type == pygame.KEYDOWN:
328
+						self.keydownEvt(evt)
329
+					elif evt.type == pygame.MOUSEBUTTONUP: 
330
+						self.mouseboutonupEvt(evt)
331
+					
332
+					self.drawPrompt();
333
+					self.flip()
334
+	

Loading…
Cancel
Save