thunar-dropbox-plugin-0.2.1+dfsg1/ 0000755 0001750 0001750 00000000000 12501157127 016175 5 ustar unit193 unit193 thunar-dropbox-plugin-0.2.1+dfsg1/ChangeLog 0000644 0001750 0001750 00000000621 12476607361 017761 0 ustar unit193 unit193 0.2.1:
- Fixed crash when files with invalid UTF-8 encoded filenames were selected.
- Resolve symbolic links in paths.
- Install library with proper permissions, respect --libdir.
0.2.0:
- Broke comptability with older version of thunar in favor of
Thunar 1.2.0
0.1.1:
- Added thunar-dropbox.png because 'dropbox.png' was not available on
certain distributions.
0.1.0:
- First release.
thunar-dropbox-plugin-0.2.1+dfsg1/COPYING 0000644 0001750 0001750 00000104513 12476373015 017243 0 ustar unit193 unit193 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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 .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
thunar-dropbox-plugin-0.2.1+dfsg1/AUTHORS 0000644 0001750 0001750 00000000450 12476607170 017255 0 ustar unit193 unit193 Thunar-Dropbox authors/contributors:
Maato
- Developer
Pablo Lezaeta
- Install library with proper permissions, respect --libdir.
- README
Hudd A
- Fixed crash when files with invalid UTF-8 encoded filenames were selected. thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/ 0000775 0001750 0001750 00000000000 12501157127 017765 5 ustar unit193 unit193 thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/3rdparty/ 0000755 0001750 0001750 00000000000 12501157127 021533 5 ustar unit193 unit193 thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/3rdparty/fluid.py 0000644 0001750 0001750 00000001144 11277625176 023225 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import Task
from TaskGen import extension
Task.simple_task_type('fluid','${FLUID} -c -o ${TGT[0].abspath(env)} -h ${TGT[1].abspath(env)} ${SRC}','BLUE',shell=False,ext_out='.cxx')
def fluid(self,node):
cpp=node.change_ext('.cpp')
hpp=node.change_ext('.hpp')
self.create_task('fluid',node,[cpp,hpp])
if'cxx'in self.features:
self.allnodes.append(cpp)
def detect(conf):
fluid=conf.find_program('fluid',var='FLUID',mandatory=True)
conf.check_cfg(path='fltk-config',package='',args='--cxxflags --ldflags',uselib_store='FLTK',mandatory=True)
extension('.fl')(fluid)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/3rdparty/boost.py 0000644 0001750 0001750 00000017661 11344754026 023253 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import os.path,glob,types,re,sys
import Configure,config_c,Options,Utils,Logs
from Logs import warn
from Configure import conf
boost_code='''
#include
#include
int main() { std::cout << BOOST_VERSION << std::endl; }
'''
boost_libpath=['/usr/lib','/usr/local/lib','/opt/local/lib','/sw/lib','/lib']
boost_cpppath=['/usr/include','/usr/local/include','/opt/local/include','/sw/include']
STATIC_NOSTATIC='nostatic'
STATIC_BOTH='both'
STATIC_ONLYSTATIC='onlystatic'
is_versiontag=re.compile('^\d+_\d+_?\d*$')
is_threadingtag=re.compile('^mt$')
is_abitag=re.compile('^[sgydpn]+$')
is_toolsettag=re.compile('^(acc|borland|como|cw|dmc|darwin|gcc|hp_cxx|intel|kylix|vc|mgw|qcc|sun|vacpp)\d*$')
is_pythontag=re.compile('^py[0-9]{2}$')
def set_options(opt):
opt.add_option('--boost-includes',type='string',default='',dest='boostincludes',help='path to the boost directory where the includes are e.g. /usr/local/include/boost-1_35')
opt.add_option('--boost-libs',type='string',default='',dest='boostlibs',help='path to the directory where the boost libs are e.g. /usr/local/lib')
def string_to_version(s):
version=s.split('.')
if len(version)<3:return 0
return int(version[0])*100000+int(version[1])*100+int(version[2])
def version_string(version):
major=version/100000
minor=version/100%1000
minor_minor=version%100
if minor_minor==0:
return"%d_%d"%(major,minor)
else:
return"%d_%d_%d"%(major,minor,minor_minor)
def libfiles(lib,pattern,lib_paths):
result=[]
for lib_path in lib_paths:
libname=pattern%('boost_%s[!_]*'%lib)
result+=glob.glob(os.path.join(lib_path,libname))
return result
def get_boost_version_number(self,dir):
try:
return self.run_c_code(compiler='cxx',code=boost_code,includes=dir,execute=1,env=self.env.copy(),type='cprogram',compile_mode='cxx',compile_filename='test.cpp')
except Configure.ConfigurationError,e:
return-1
def set_default(kw,var,val):
if not var in kw:
kw[var]=val
def tags_score(tags,kw):
score=0
needed_tags={'threading':kw['tag_threading'],'abi':kw['tag_abi'],'toolset':kw['tag_toolset'],'version':kw['tag_version'],'python':kw['tag_python']}
if kw['tag_toolset']is None:
v=kw['env']
toolset=v['CXX_NAME']
if v['CXX_VERSION']:
version_no=v['CXX_VERSION'].split('.')
toolset+=version_no[0]
if len(version_no)>1:
toolset+=version_no[1]
needed_tags['toolset']=toolset
found_tags={}
for tag in tags:
if is_versiontag.match(tag):found_tags['version']=tag
if is_threadingtag.match(tag):found_tags['threading']=tag
if is_abitag.match(tag):found_tags['abi']=tag
if is_toolsettag.match(tag):found_tags['toolset']=tag
if is_pythontag.match(tag):found_tags['python']=tag
for tagname in needed_tags.iterkeys():
if needed_tags[tagname]is not None and tagname in found_tags:
if re.compile(needed_tags[tagname]).match(found_tags[tagname]):
score+=kw['score_'+tagname][0]
else:
score+=kw['score_'+tagname][1]
return score
def validate_boost(self,kw):
ver=kw.get('version','')
for x in'min_version max_version version'.split():
set_default(kw,x,ver)
set_default(kw,'lib','')
kw['lib']=Utils.to_list(kw['lib'])
set_default(kw,'env',self.env)
set_default(kw,'libpath',boost_libpath)
set_default(kw,'cpppath',boost_cpppath)
for x in'tag_threading tag_version tag_toolset'.split():
set_default(kw,x,None)
set_default(kw,'tag_abi','^[^d]*$')
set_default(kw,'python',str(sys.version_info[0])+str(sys.version_info[1]))
set_default(kw,'tag_python','^py'+kw['python']+'$')
set_default(kw,'score_threading',(10,-10))
set_default(kw,'score_abi',(10,-10))
set_default(kw,'score_python',(10,-10))
set_default(kw,'score_toolset',(1,-1))
set_default(kw,'score_version',(100,-100))
set_default(kw,'score_min',0)
set_default(kw,'static',STATIC_NOSTATIC)
set_default(kw,'found_includes',False)
set_default(kw,'min_score',0)
set_default(kw,'errmsg','not found')
set_default(kw,'okmsg','ok')
def find_boost_includes(self,kw):
boostPath=getattr(Options.options,'boostincludes','')
if boostPath:
boostPath=[os.path.normpath(os.path.expandvars(os.path.expanduser(boostPath)))]
else:
boostPath=Utils.to_list(kw['cpppath'])
min_version=string_to_version(kw.get('min_version',''))
max_version=string_to_version(kw.get('max_version',''))or(sys.maxint-1)
version=0
for include_path in boostPath:
boost_paths=glob.glob(os.path.join(include_path,'boost*'))
for path in boost_paths:
pathname=os.path.split(path)[-1]
ret=-1
if pathname=='boost':
path=include_path
ret=self.get_boost_version_number(path)
elif pathname.startswith('boost-'):
ret=self.get_boost_version_number(path)
ret=int(ret)
if ret!=-1 and ret>=min_version and ret<=max_version and ret>version:
boost_path=path
version=ret
if not version:
self.fatal('boost headers not found! (required version min: %s max: %s)'%(kw['min_version'],kw['max_version']))
return False
found_version=version_string(version)
versiontag='^'+found_version+'$'
if kw['tag_version']is None:
kw['tag_version']=versiontag
elif kw['tag_version']!=versiontag:
warn('boost header version %r and tag_version %r do not match!'%(versiontag,kw['tag_version']))
env=self.env
env['CPPPATH_BOOST']=boost_path
env['BOOST_VERSION']=found_version
self.found_includes=1
ret='Version %s (%s)'%(found_version,boost_path)
return ret
def find_boost_library(self,lib,kw):
def find_library_from_list(lib,files):
lib_pattern=re.compile('.*boost_(.*?)\..*')
result=(None,None)
resultscore=kw['min_score']-1
for file in files:
m=lib_pattern.search(file,1)
if m:
libname=m.group(1)
libtags=libname.split('-')[1:]
currentscore=tags_score(libtags,kw)
if currentscore>resultscore:
result=(libname,file)
resultscore=currentscore
return result
lib_paths=getattr(Options.options,'boostlibs','')
if lib_paths:
lib_paths=[os.path.normpath(os.path.expandvars(os.path.expanduser(lib_paths)))]
else:
lib_paths=Utils.to_list(kw['libpath'])
v=kw.get('env',self.env)
(libname,file)=(None,None)
if kw['static']in[STATIC_NOSTATIC,STATIC_BOTH]:
st_env_prefix='LIB'
files=libfiles(lib,v['shlib_PATTERN'],lib_paths)
(libname,file)=find_library_from_list(lib,files)
if libname is None and kw['static']in[STATIC_ONLYSTATIC,STATIC_BOTH]:
st_env_prefix='STATICLIB'
staticLibPattern=v['staticlib_PATTERN']
if self.env['CC_NAME']=='msvc':
staticLibPattern='lib'+staticLibPattern
files=libfiles(lib,staticLibPattern,lib_paths)
(libname,file)=find_library_from_list(lib,files)
if libname is not None:
v['LIBPATH_BOOST_'+lib.upper()]=[os.path.split(file)[0]]
if self.env['CC_NAME']=='msvc'and os.path.splitext(file)[1]=='.lib':
v[st_env_prefix+'_BOOST_'+lib.upper()]=['libboost_'+libname]
else:
v[st_env_prefix+'_BOOST_'+lib.upper()]=['boost_'+libname]
return
self.fatal('lib boost_'+lib+' not found!')
def check_boost(self,*k,**kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler tool first, for example conf.check_tool("g++")')
self.validate_boost(kw)
ret=None
try:
if not kw.get('found_includes',None):
self.check_message_1(kw.get('msg_includes','boost headers'))
ret=self.find_boost_includes(kw)
except Configure.ConfigurationError,e:
if'errmsg'in kw:
self.check_message_2(kw['errmsg'],'YELLOW')
if'mandatory'in kw:
if Logs.verbose>1:
raise
else:
self.fatal('the configuration failed (see %r)'%self.log.name)
else:
if'okmsg'in kw:
self.check_message_2(kw.get('okmsg_includes',ret))
for lib in kw['lib']:
self.check_message_1('library boost_'+lib)
try:
self.find_boost_library(lib,kw)
except Configure.ConfigurationError,e:
ret=False
if'errmsg'in kw:
self.check_message_2(kw['errmsg'],'YELLOW')
if'mandatory'in kw:
if Logs.verbose>1:
raise
else:
self.fatal('the configuration failed (see %r)'%self.log.name)
else:
if'okmsg'in kw:
self.check_message_2(kw['okmsg'])
return ret
conf(get_boost_version_number)
conf(validate_boost)
conf(find_boost_includes)
conf(find_boost_library)
conf(check_boost)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Environment.py 0000644 0001750 0001750 00000007626 11344754027 022662 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os,copy,re
import Logs,Options,Utils
from Constants import*
re_imp=re.compile('^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
class Environment(object):
__slots__=("table","parent")
def __init__(self,filename=None):
self.table={}
if filename:
self.load(filename)
def __contains__(self,key):
if key in self.table:return True
try:return self.parent.__contains__(key)
except AttributeError:return False
def __str__(self):
keys=set()
cur=self
while cur:
keys.update(cur.table.keys())
cur=getattr(cur,'parent',None)
keys=list(keys)
keys.sort()
return"\n".join(["%r %r"%(x,self.__getitem__(x))for x in keys])
def __getitem__(self,key):
try:
while 1:
x=self.table.get(key,None)
if not x is None:
return x
self=self.parent
except AttributeError:
return[]
def __setitem__(self,key,value):
self.table[key]=value
def __delitem__(self,key):
del self.table[key]
def pop(self,key,*args):
if len(args):
return self.table.pop(key,*args)
return self.table.pop(key)
def set_variant(self,name):
self.table[VARIANT]=name
def variant(self):
try:
while 1:
x=self.table.get(VARIANT,None)
if not x is None:
return x
self=self.parent
except AttributeError:
return DEFAULT
def copy(self):
newenv=Environment()
newenv.parent=self
return newenv
def detach(self):
tbl=self.get_merged_dict()
try:
delattr(self,'parent')
except AttributeError:
pass
else:
keys=tbl.keys()
for x in keys:
tbl[x]=copy.deepcopy(tbl[x])
self.table=tbl
def get_flat(self,key):
s=self[key]
if isinstance(s,str):return s
return' '.join(s)
def _get_list_value_for_modification(self,key):
try:
value=self.table[key]
except KeyError:
try:value=self.parent[key]
except AttributeError:value=[]
if isinstance(value,list):
value=value[:]
else:
value=[value]
else:
if not isinstance(value,list):
value=[value]
self.table[key]=value
return value
def append_value(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
current_value.extend(value)
else:
current_value.append(value)
def prepend_value(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
current_value=value+current_value
self.table[var]=current_value
else:
current_value.insert(0,value)
def append_unique(self,var,value):
current_value=self._get_list_value_for_modification(var)
if isinstance(value,list):
for value_item in value:
if value_item not in current_value:
current_value.append(value_item)
else:
if value not in current_value:
current_value.append(value)
def get_merged_dict(self):
table_list=[]
env=self
while 1:
table_list.insert(0,env.table)
try:env=env.parent
except AttributeError:break
merged_table={}
for table in table_list:
merged_table.update(table)
return merged_table
def store(self,filename):
file=open(filename,'w')
merged_table=self.get_merged_dict()
keys=list(merged_table.keys())
keys.sort()
for k in keys:file.write('%s = %r\n'%(k,merged_table[k]))
file.close()
def load(self,filename):
tbl=self.table
code=Utils.readf(filename)
for m in re_imp.finditer(code):
g=m.group
tbl[g(2)]=eval(g(3))
Logs.debug('env: %s',self.table)
def get_destdir(self):
if self.__getitem__('NOINSTALL'):return''
return Options.options.destdir
def update(self,d):
for k,v in d.iteritems():
self[k]=v
def __getattr__(self,name):
if name in self.__slots__:
return object.__getattr__(self,name)
else:
return self[name]
def __setattr__(self,name,value):
if name in self.__slots__:
object.__setattr__(self,name,value)
else:
self[name]=value
def __delattr__(self,name):
if name in self.__slots__:
object.__delattr__(self,name)
else:
del self[name]
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Build.py 0000644 0001750 0001750 00000047047 11362610130 021400 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os,sys,errno,re,glob,gc,datetime,shutil
try:import cPickle
except:import pickle as cPickle
import Runner,TaskGen,Node,Scripting,Utils,Environment,Task,Logs,Options
from Logs import debug,error,info
from Constants import*
SAVED_ATTRS='root srcnode bldnode node_sigs node_deps raw_deps task_sigs id_nodes'.split()
bld=None
class BuildError(Utils.WafError):
def __init__(self,b=None,t=[]):
self.bld=b
self.tasks=t
self.ret=1
Utils.WafError.__init__(self,self.format_error())
def format_error(self):
lst=['Build failed:']
for tsk in self.tasks:
txt=tsk.format_error()
if txt:lst.append(txt)
sep=' '
if len(lst)>2:
sep='\n'
return sep.join(lst)
def group_method(fun):
def f(*k,**kw):
if not k[0].is_install:
return False
postpone=True
if'postpone'in kw:
postpone=kw['postpone']
del kw['postpone']
if postpone:
m=k[0].task_manager
if not m.groups:m.add_group()
m.groups[m.current_group].post_funs.append((fun,k,kw))
if not'cwd'in kw:
kw['cwd']=k[0].path
else:
fun(*k,**kw)
return f
class BuildContext(Utils.Context):
def __init__(self):
global bld
bld=self
self.task_manager=Task.TaskManager()
self.id_nodes=0
self.idx={}
self.all_envs={}
self.bdir=''
self.path=None
self.deps_man=Utils.DefaultDict(list)
self.cache_node_abspath={}
self.cache_scanned_folders={}
self.uninstall=[]
for v in'cache_node_abspath task_sigs node_deps raw_deps node_sigs'.split():
var={}
setattr(self,v,var)
self.cache_dir_contents={}
self.all_task_gen=[]
self.task_gen_cache_names={}
self.cache_sig_vars={}
self.log=None
self.root=None
self.srcnode=None
self.bldnode=None
class node_class(Node.Node):
pass
self.node_class=node_class
self.node_class.__module__="Node"
self.node_class.__name__="Nodu"
self.node_class.bld=self
self.is_install=None
def __copy__(self):
raise Utils.WafError('build contexts are not supposed to be cloned')
def load(self):
try:
env=Environment.Environment(os.path.join(self.cachedir,'build.config.py'))
except(IOError,OSError):
pass
else:
if env['version']1:raise
if data:
for x in SAVED_ATTRS:setattr(self,x,data[x])
else:
debug('build: Build cache loading failed')
finally:
if f:f.close()
gc.enable()
def save(self):
gc.disable()
self.root.__class__.bld=None
Node.Nodu=self.node_class
db=os.path.join(self.bdir,DBFILE)
file=open(db+'.tmp','wb')
data={}
for x in SAVED_ATTRS:data[x]=getattr(self,x)
cPickle.dump(data,file,-1)
file.close()
try:os.unlink(db)
except OSError:pass
os.rename(db+'.tmp',db)
self.root.__class__.bld=self
gc.enable()
def clean(self):
debug('build: clean called')
precious=set([])
for env in self.all_envs.values():
for x in env[CFG_FILES]:
node=self.srcnode.find_resource(x)
if node:
precious.add(node.id)
def clean_rec(node):
for x in list(node.childs.keys()):
nd=node.childs[x]
tp=nd.id&3
if tp==Node.DIR:
clean_rec(nd)
elif tp==Node.BUILD:
if nd.id in precious:continue
for env in self.all_envs.values():
try:os.remove(nd.abspath(env))
except OSError:pass
node.childs.__delitem__(x)
clean_rec(self.srcnode)
for v in'node_sigs node_deps task_sigs raw_deps cache_node_abspath'.split():
setattr(self,v,{})
def compile(self):
debug('build: compile called')
self.flush()
self.generator=Runner.Parallel(self,Options.options.jobs)
def dw(on=True):
if Options.options.progress_bar:
if on:sys.stderr.write(Logs.colors.cursor_on)
else:sys.stderr.write(Logs.colors.cursor_off)
debug('build: executor starting')
back=os.getcwd()
os.chdir(self.bldnode.abspath())
try:
try:
dw(on=False)
self.generator.start()
except KeyboardInterrupt:
dw()
if Runner.TaskConsumer.consumers:
self.save()
raise
except Exception:
dw()
raise
else:
dw()
if Runner.TaskConsumer.consumers:
self.save()
if self.generator.error:
raise BuildError(self,self.task_manager.tasks_done)
finally:
os.chdir(back)
def install(self):
debug('build: install called')
self.flush()
if self.is_install<0:
lst=[]
for x in self.uninstall:
dir=os.path.dirname(x)
if not dir in lst:lst.append(dir)
lst.sort()
lst.reverse()
nlst=[]
for y in lst:
x=y
while len(x)>4:
if not x in nlst:nlst.append(x)
x=os.path.dirname(x)
nlst.sort()
nlst.reverse()
for x in nlst:
try:os.rmdir(x)
except OSError:pass
def new_task_gen(self,*k,**kw):
if self.task_gen_cache_names:
self.task_gen_cache_names={}
kw['bld']=self
if len(k)==0:
ret=TaskGen.task_gen(*k,**kw)
else:
cls_name=k[0]
try:cls=TaskGen.task_gen.classes[cls_name]
except KeyError:raise Utils.WscriptError('%s is not a valid task generator -> %s'%(cls_name,[x for x in TaskGen.task_gen.classes]))
ret=cls(*k,**kw)
return ret
def __call__(self,*k,**kw):
if self.task_gen_cache_names:
self.task_gen_cache_names={}
kw['bld']=self
return TaskGen.task_gen(*k,**kw)
def load_envs(self):
try:
lst=Utils.listdir(self.cachedir)
except OSError,e:
if e.errno==errno.ENOENT:
raise Utils.WafError('The project was not configured: run "waf configure" first!')
else:
raise
if not lst:
raise Utils.WafError('The cache directory is empty: reconfigure the project')
for file in lst:
if file.endswith(CACHE_SUFFIX):
env=Environment.Environment(os.path.join(self.cachedir,file))
name=file[:-len(CACHE_SUFFIX)]
self.all_envs[name]=env
self.init_variants()
for env in self.all_envs.values():
for f in env[CFG_FILES]:
newnode=self.path.find_or_declare(f)
try:
hash=Utils.h_file(newnode.abspath(env))
except(IOError,AttributeError):
error("cannot find "+f)
hash=SIG_NIL
self.node_sigs[env.variant()][newnode.id]=hash
self.bldnode=self.root.find_dir(self.bldnode.abspath())
self.path=self.srcnode=self.root.find_dir(self.srcnode.abspath())
self.cwd=self.bldnode.abspath()
def setup(self,tool,tooldir=None,funs=None):
if isinstance(tool,list):
for i in tool:self.setup(i,tooldir)
return
if not tooldir:tooldir=Options.tooldir
module=Utils.load_tool(tool,tooldir)
if hasattr(module,"setup"):module.setup(self)
def init_variants(self):
debug('build: init variants')
lstvariants=[]
for env in self.all_envs.values():
if not env.variant()in lstvariants:
lstvariants.append(env.variant())
self.lst_variants=lstvariants
debug('build: list of variants is %r',lstvariants)
for name in lstvariants+[0]:
for v in'node_sigs cache_node_abspath'.split():
var=getattr(self,v)
if not name in var:
var[name]={}
def load_dirs(self,srcdir,blddir,load_cache=1):
assert(os.path.isabs(srcdir))
assert(os.path.isabs(blddir))
self.cachedir=os.path.join(blddir,CACHE_DIR)
if srcdir==blddir:
raise Utils.WafError("build dir must be different from srcdir: %s <-> %s "%(srcdir,blddir))
self.bdir=blddir
self.load()
if not self.root:
Node.Nodu=self.node_class
self.root=Node.Nodu('',None,Node.DIR)
if not self.srcnode:
self.srcnode=self.root.ensure_dir_node_from_path(srcdir)
debug('build: srcnode is %s and srcdir %s',self.srcnode.name,srcdir)
self.path=self.srcnode
try:os.makedirs(blddir)
except OSError:pass
if not self.bldnode:
self.bldnode=self.root.ensure_dir_node_from_path(blddir)
self.init_variants()
def rescan(self,src_dir_node):
if self.cache_scanned_folders.get(src_dir_node.id,None):return
self.cache_scanned_folders[src_dir_node.id]=True
if hasattr(self,'repository'):self.repository(src_dir_node)
if not src_dir_node.name and sys.platform=='win32':
return
parent_path=src_dir_node.abspath()
try:
lst=set(Utils.listdir(parent_path))
except OSError:
lst=set([])
self.cache_dir_contents[src_dir_node.id]=lst
cache=self.node_sigs[0]
for x in src_dir_node.childs.values():
if x.id&3!=Node.FILE:continue
if x.name in lst:
try:
cache[x.id]=Utils.h_file(x.abspath())
except IOError:
raise Utils.WafError('The file %s is not readable or has become a dir'%x.abspath())
else:
try:del cache[x.id]
except KeyError:pass
del src_dir_node.childs[x.name]
h1=self.srcnode.height()
h2=src_dir_node.height()
lst=[]
child=src_dir_node
while h2>h1:
lst.append(child.name)
child=child.parent
h2-=1
lst.reverse()
try:
for variant in self.lst_variants:
sub_path=os.path.join(self.bldnode.abspath(),variant,*lst)
self.listdir_bld(src_dir_node,sub_path,variant)
except OSError:
for node in src_dir_node.childs.values():
if node.id&3!=Node.BUILD:
continue
for dct in self.node_sigs.values():
if node.id in dct:
dct.__delitem__(node.id)
src_dir_node.childs.__delitem__(node.name)
for variant in self.lst_variants:
sub_path=os.path.join(self.bldnode.abspath(),variant,*lst)
try:
os.makedirs(sub_path)
except OSError:
pass
def listdir_src(self,parent_node):
pass
def remove_node(self,node):
pass
def listdir_bld(self,parent_node,path,variant):
i_existing_nodes=[x for x in parent_node.childs.values()if x.id&3==Node.BUILD]
lst=set(Utils.listdir(path))
node_names=set([x.name for x in i_existing_nodes])
remove_names=node_names-lst
ids_to_remove=[x.id for x in i_existing_nodes if x.name in remove_names]
cache=self.node_sigs[variant]
for nid in ids_to_remove:
if nid in cache:
cache.__delitem__(nid)
def get_env(self):
return self.env_of_name('default')
def set_env(self,name,val):
self.all_envs[name]=val
env=property(get_env,set_env)
def add_manual_dependency(self,path,value):
if isinstance(path,Node.Node):
node=path
elif os.path.isabs(path):
node=self.root.find_resource(path)
else:
node=self.path.find_resource(path)
self.deps_man[node.id].append(value)
def launch_node(self):
try:
return self.p_ln
except AttributeError:
self.p_ln=self.root.find_dir(Options.launch_dir)
return self.p_ln
def glob(self,pattern,relative=True):
path=self.path.abspath()
files=[self.root.find_resource(x)for x in glob.glob(path+os.sep+pattern)]
if relative:
files=[x.path_to_parent(self.path)for x in files if x]
else:
files=[x.abspath()for x in files if x]
return files
def add_group(self,*k):
self.task_manager.add_group(*k)
def set_group(self,*k,**kw):
self.task_manager.set_group(*k,**kw)
def hash_env_vars(self,env,vars_lst):
idx=str(id(env))+str(vars_lst)
try:return self.cache_sig_vars[idx]
except KeyError:pass
lst=[str(env[a])for a in vars_lst]
ret=Utils.h_list(lst)
debug('envhash: %r %r',ret,lst)
self.cache_sig_vars[idx]=ret
return ret
def name_to_obj(self,name,env):
cache=self.task_gen_cache_names
if not cache:
for x in self.all_task_gen:
vt=x.env.variant()+'_'
if x.name:
cache[vt+x.name]=x
else:
if isinstance(x.target,str):
target=x.target
else:
target=' '.join(x.target)
v=vt+target
if not cache.get(v,None):
cache[v]=x
return cache.get(env.variant()+'_'+name,None)
def flush(self,all=1):
self.ini=datetime.datetime.now()
self.task_gen_cache_names={}
self.name_to_obj('',self.env)
debug('build: delayed operation TaskGen.flush() called')
if Options.options.compile_targets:
debug('task_gen: posting objects listed in compile_targets')
target_objects=Utils.DefaultDict(list)
for target_name in Options.options.compile_targets.split(','):
target_name=target_name.strip()
for env in self.all_envs.values():
obj=self.name_to_obj(target_name,env)
if obj:
target_objects[target_name].append(obj)
if not target_name in target_objects and all:
raise Utils.WafError("target '%s' does not exist"%target_name)
to_compile=[]
for x in target_objects.values():
for y in x:
to_compile.append(id(y))
for i in xrange(len(self.task_manager.groups)):
g=self.task_manager.groups[i]
self.task_manager.current_group=i
if Logs.verbose:
Logs.debug('group: group %s'%([x for x in self.task_manager.groups_names if id(self.task_manager.groups_names[x])==id(g)][0]))
for tg in g.tasks_gen:
if id(tg)in to_compile:
if Logs.verbose:
Logs.debug('group: %s'%tg)
tg.post()
else:
debug('task_gen: posting objects (normal)')
ln=self.launch_node()
if ln.is_child_of(self.bldnode)or not ln.is_child_of(self.srcnode):
ln=self.srcnode
proj_node=self.root.find_dir(os.path.split(Utils.g_module.root_path)[0])
if proj_node.id!=self.srcnode.id:
ln=self.srcnode
for i in xrange(len(self.task_manager.groups)):
g=self.task_manager.groups[i]
self.task_manager.current_group=i
if Logs.verbose:
Logs.debug('group: group %s'%([x for x in self.task_manager.groups_names if id(self.task_manager.groups_names[x])==id(g)][0]))
for tg in g.tasks_gen:
if not tg.path.is_child_of(ln):
continue
if Logs.verbose:
Logs.debug('group: %s'%tg)
tg.post()
def env_of_name(self,name):
try:
return self.all_envs[name]
except KeyError:
error('no such environment: '+name)
return None
def progress_line(self,state,total,col1,col2):
n=len(str(total))
Utils.rot_idx+=1
ind=Utils.rot_chr[Utils.rot_idx%4]
ini=self.ini
pc=(100.*state)/total
eta=Utils.get_elapsed_time(ini)
fs="[%%%dd/%%%dd][%%s%%2d%%%%%%s][%s]["%(n,n,ind)
left=fs%(state,total,col1,pc,col2)
right='][%s%s%s]'%(col1,eta,col2)
cols=Utils.get_term_cols()-len(left)-len(right)+2*len(col1)+2*len(col2)
if cols<7:cols=7
ratio=int((cols*state)/total)-1
bar=('='*ratio+'>').ljust(cols)
msg=Utils.indicator%(left,bar,right)
return msg
def do_install(self,src,tgt,chmod=O644):
if self.is_install>0:
if not Options.options.force:
try:
st1=os.stat(tgt)
st2=os.stat(src)
except OSError:
pass
else:
if st1.st_mtime>=st2.st_mtime and st1.st_size==st2.st_size:
return False
srclbl=src.replace(self.srcnode.abspath(None)+os.sep,'')
info("* installing %s as %s"%(srclbl,tgt))
try:os.remove(tgt)
except OSError:pass
try:
shutil.copy2(src,tgt)
os.chmod(tgt,chmod)
except IOError:
try:
os.stat(src)
except(OSError,IOError):
error('File %r does not exist'%src)
raise Utils.WafError('Could not install the file %r'%tgt)
return True
elif self.is_install<0:
info("* uninstalling %s"%tgt)
self.uninstall.append(tgt)
try:
os.remove(tgt)
except OSError,e:
if e.errno!=errno.ENOENT:
if not getattr(self,'uninstall_error',None):
self.uninstall_error=True
Logs.warn('build: some files could not be uninstalled (retry with -vv to list them)')
if Logs.verbose>1:
Logs.warn('could not remove %s (error code %r)'%(e.filename,e.errno))
return True
red=re.compile(r"^([A-Za-z]:)?[/\\\\]*")
def get_install_path(self,path,env=None):
if not env:env=self.env
destdir=env.get_destdir()
path=path.replace('/',os.sep)
destpath=Utils.subst_vars(path,env)
if destdir:
destpath=os.path.join(destdir,self.red.sub('',destpath))
return destpath
def install_dir(self,path,env=None):
if env:
assert isinstance(env,Environment.Environment),"invalid parameter"
else:
env=self.env
if not path:
return[]
destpath=self.get_install_path(path,env)
if self.is_install>0:
info('* creating %s'%destpath)
Utils.check_dir(destpath)
elif self.is_install<0:
info('* removing %s'%destpath)
self.uninstall.append(destpath+'/xxx')
def install_files(self,path,files,env=None,chmod=O644,relative_trick=False,cwd=None):
if env:
assert isinstance(env,Environment.Environment),"invalid parameter"
else:
env=self.env
if not path:return[]
if not cwd:
cwd=self.path
if isinstance(files,str)and'*'in files:
gl=cwd.abspath()+os.sep+files
lst=glob.glob(gl)
else:
lst=Utils.to_list(files)
if not getattr(lst,'__iter__',False):
lst=[lst]
destpath=self.get_install_path(path,env)
Utils.check_dir(destpath)
installed_files=[]
for filename in lst:
if isinstance(filename,str)and os.path.isabs(filename):
alst=Utils.split_path(filename)
destfile=os.path.join(destpath,alst[-1])
else:
if isinstance(filename,Node.Node):
nd=filename
else:
nd=cwd.find_resource(filename)
if not nd:
raise Utils.WafError("Unable to install the file %r (not found in %s)"%(filename,cwd))
if relative_trick:
destfile=os.path.join(destpath,filename)
Utils.check_dir(os.path.dirname(destfile))
else:
destfile=os.path.join(destpath,nd.name)
filename=nd.abspath(env)
if self.do_install(filename,destfile,chmod):
installed_files.append(destfile)
return installed_files
def install_as(self,path,srcfile,env=None,chmod=O644,cwd=None):
if env:
assert isinstance(env,Environment.Environment),"invalid parameter"
else:
env=self.env
if not path:
raise Utils.WafError("where do you want to install %r? (%r?)"%(srcfile,path))
if not cwd:
cwd=self.path
destpath=self.get_install_path(path,env)
dir,name=os.path.split(destpath)
Utils.check_dir(dir)
if isinstance(srcfile,Node.Node):
src=srcfile.abspath(env)
else:
src=srcfile
if not os.path.isabs(srcfile):
node=cwd.find_resource(srcfile)
if not node:
raise Utils.WafError("Unable to install the file %r (not found in %s)"%(srcfile,cwd))
src=node.abspath(env)
return self.do_install(src,destpath,chmod)
def symlink_as(self,path,src,env=None,cwd=None):
if sys.platform=='win32':
return
if not path:
raise Utils.WafError("where do you want to install %r? (%r?)"%(src,path))
tgt=self.get_install_path(path,env)
dir,name=os.path.split(tgt)
Utils.check_dir(dir)
if self.is_install>0:
link=False
if not os.path.islink(tgt):
link=True
elif os.readlink(tgt)!=src:
link=True
if link:
try:os.remove(tgt)
except OSError:pass
info('* symlink %s (-> %s)'%(tgt,src))
os.symlink(src,tgt)
return 0
else:
try:
info('* removing %s'%(tgt))
os.remove(tgt)
return 0
except OSError:
return 1
def exec_command(self,cmd,**kw):
debug('runner: system command -> %s',cmd)
if self.log:
self.log.write('%s\n'%cmd)
kw['log']=self.log
try:
if not kw.get('cwd',None):
kw['cwd']=self.cwd
except AttributeError:
self.cwd=kw['cwd']=self.bldnode.abspath()
return Utils.exec_command(cmd,**kw)
def printout(self,s):
f=self.log or sys.stderr
f.write(s)
f.flush()
def add_subdirs(self,dirs):
self.recurse(dirs,'build')
def pre_recurse(self,name_or_mod,path,nexdir):
if not hasattr(self,'oldpath'):
self.oldpath=[]
self.oldpath.append(self.path)
self.path=self.root.find_dir(nexdir)
return{'bld':self,'ctx':self}
def post_recurse(self,name_or_mod,path,nexdir):
self.path=self.oldpath.pop()
def pre_build(self):
if hasattr(self,'pre_funs'):
for m in self.pre_funs:
m(self)
def post_build(self):
if hasattr(self,'post_funs'):
for m in self.post_funs:
m(self)
def add_pre_fun(self,meth):
try:self.pre_funs.append(meth)
except AttributeError:self.pre_funs=[meth]
def add_post_fun(self,meth):
try:self.post_funs.append(meth)
except AttributeError:self.post_funs=[meth]
def use_the_magic(self):
Task.algotype=Task.MAXPARALLEL
Task.file_deps=Task.extract_deps
self.magic=True
install_as=group_method(install_as)
install_files=group_method(install_files)
symlink_as=group_method(symlink_as)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/__init__.py 0000644 0001750 0001750 00000000053 11277625176 022107 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Utils.py 0000644 0001750 0001750 00000032421 11360136405 021435 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,string,errno,traceback,inspect,re,shutil,datetime,gc
try:from UserDict import UserDict
except ImportError:from collections import UserDict
if sys.hexversion>=0x2060000 or os.name=='java':
import subprocess as pproc
else:
import pproc
import Logs
from Constants import*
try:
from collections import deque
except ImportError:
class deque(list):
def popleft(self):
return self.pop(0)
is_win32=sys.platform=='win32'
try:
from collections import defaultdict as DefaultDict
except ImportError:
class DefaultDict(dict):
def __init__(self,default_factory):
super(DefaultDict,self).__init__()
self.default_factory=default_factory
def __getitem__(self,key):
try:
return super(DefaultDict,self).__getitem__(key)
except KeyError:
value=self.default_factory()
self[key]=value
return value
class WafError(Exception):
def __init__(self,*args):
self.args=args
try:
self.stack=traceback.extract_stack()
except:
pass
Exception.__init__(self,*args)
def __str__(self):
return str(len(self.args)==1 and self.args[0]or self.args)
class WscriptError(WafError):
def __init__(self,message,wscript_file=None):
if wscript_file:
self.wscript_file=wscript_file
self.wscript_line=None
else:
try:
(self.wscript_file,self.wscript_line)=self.locate_error()
except:
(self.wscript_file,self.wscript_line)=(None,None)
msg_file_line=''
if self.wscript_file:
msg_file_line="%s:"%self.wscript_file
if self.wscript_line:
msg_file_line+="%s:"%self.wscript_line
err_message="%s error: %s"%(msg_file_line,message)
WafError.__init__(self,err_message)
def locate_error(self):
stack=traceback.extract_stack()
stack.reverse()
for frame in stack:
file_name=os.path.basename(frame[0])
is_wscript=(file_name==WSCRIPT_FILE or file_name==WSCRIPT_BUILD_FILE)
if is_wscript:
return(frame[0],frame[1])
return(None,None)
indicator=is_win32 and'\x1b[A\x1b[K%s%s%s\r'or'\x1b[K%s%s%s\r'
try:
from fnv import new as md5
import Constants
Constants.SIG_NIL='signofnv'
def h_file(filename):
m=md5()
try:
m.hfile(filename)
x=m.digest()
if x is None:raise OSError("not a file")
return x
except SystemError:
raise OSError("not a file"+filename)
except ImportError:
try:
try:
from hashlib import md5
except ImportError:
from md5 import md5
def h_file(filename):
f=open(filename,'rb')
m=md5()
while(filename):
filename=f.read(100000)
m.update(filename)
f.close()
return m.digest()
except ImportError:
md5=None
class ordered_dict(UserDict):
def __init__(self,dict=None):
self.allkeys=[]
UserDict.__init__(self,dict)
def __delitem__(self,key):
self.allkeys.remove(key)
UserDict.__delitem__(self,key)
def __setitem__(self,key,item):
if key not in self.allkeys:self.allkeys.append(key)
UserDict.__setitem__(self,key,item)
def exec_command(s,**kw):
if'log'in kw:
kw['stdout']=kw['stderr']=kw['log']
del(kw['log'])
kw['shell']=isinstance(s,str)
try:
proc=pproc.Popen(s,**kw)
return proc.wait()
except OSError:
return-1
if is_win32:
def exec_command(s,**kw):
if'log'in kw:
kw['stdout']=kw['stderr']=kw['log']
del(kw['log'])
kw['shell']=isinstance(s,str)
if len(s)>2000:
startupinfo=pproc.STARTUPINFO()
startupinfo.dwFlags|=pproc.STARTF_USESHOWWINDOW
kw['startupinfo']=startupinfo
try:
if'stdout'not in kw:
kw['stdout']=pproc.PIPE
kw['stderr']=pproc.PIPE
proc=pproc.Popen(s,**kw)
(stdout,stderr)=proc.communicate()
Logs.info(stdout)
if stderr:
Logs.error(stderr)
return proc.returncode
else:
proc=pproc.Popen(s,**kw)
return proc.wait()
except OSError:
return-1
listdir=os.listdir
if is_win32:
def listdir_win32(s):
if re.match('^[A-Za-z]:$',s):
s+=os.sep
if not os.path.isdir(s):
e=OSError()
e.errno=errno.ENOENT
raise e
return os.listdir(s)
listdir=listdir_win32
def waf_version(mini=0x010000,maxi=0x100000):
ver=HEXVERSION
try:min_val=mini+0
except TypeError:min_val=int(mini.replace('.','0'),16)
if min_val>ver:
Logs.error("waf version should be at least %s (%s found)"%(mini,ver))
sys.exit(0)
try:max_val=maxi+0
except TypeError:max_val=int(maxi.replace('.','0'),16)
if max_val=0x3000000:
raise ImportError("Waf requires Python >= 2.3 but the raw source requires Python 2.4, 2.5 or 2.6")
def ex_stack():
exc_type,exc_value,tb=sys.exc_info()
if Logs.verbose>1:
exc_lines=traceback.format_exception(exc_type,exc_value,tb)
return''.join(exc_lines)
return str(exc_value)
def to_list(sth):
if isinstance(sth,str):
return sth.split()
else:
return sth
g_loaded_modules={}
g_module=None
def load_module(file_path,name=WSCRIPT_FILE):
try:
return g_loaded_modules[file_path]
except KeyError:
pass
module=imp.new_module(name)
try:
code=readf(file_path,m='rU')
except(IOError,OSError):
raise WscriptError('Could not read the file %r'%file_path)
module.waf_hash_val=code
sys.path.insert(0,os.path.dirname(file_path))
try:
exec(compile(code,file_path,'exec'),module.__dict__)
except Exception:
exc_type,exc_value,tb=sys.exc_info()
raise WscriptError("".join(traceback.format_exception(exc_type,exc_value,tb)),file_path)
sys.path.pop(0)
g_loaded_modules[file_path]=module
return module
def set_main_module(file_path):
global g_module
g_module=load_module(file_path,'wscript_main')
g_module.root_path=file_path
try:
g_module.APPNAME
except:
g_module.APPNAME='noname'
try:
g_module.VERSION
except:
g_module.VERSION='1.0'
def to_hashtable(s):
tbl={}
lst=s.split('\n')
for line in lst:
if not line:continue
mems=line.split('=')
tbl[mems[0]]=mems[1]
return tbl
def get_term_cols():
return 80
try:
import struct,fcntl,termios
except ImportError:
pass
else:
if Logs.got_tty:
def myfun():
dummy_lines,cols=struct.unpack("HHHH",fcntl.ioctl(sys.stderr.fileno(),termios.TIOCGWINSZ,struct.pack("HHHH",0,0,0,0)))[:2]
return cols
try:
myfun()
except:
pass
else:
get_term_cols=myfun
rot_idx=0
rot_chr=['\\','|','/','-']
def split_path(path):
return path.split('/')
def split_path_cygwin(path):
if path.startswith('//'):
ret=path.split('/')[2:]
ret[0]='/'+ret[0]
return ret
return path.split('/')
re_sp=re.compile('[/\\\\]')
def split_path_win32(path):
if path.startswith('\\\\'):
ret=re.split(re_sp,path)[2:]
ret[0]='\\'+ret[0]
return ret
return re.split(re_sp,path)
if sys.platform=='cygwin':
split_path=split_path_cygwin
elif is_win32:
split_path=split_path_win32
def copy_attrs(orig,dest,names,only_if_set=False):
for a in to_list(names):
u=getattr(orig,a,())
if u or not only_if_set:
setattr(dest,a,u)
def def_attrs(cls,**kw):
'''
set attributes for class.
@param cls [any class]: the class to update the given attributes in.
@param kw [dictionary]: dictionary of attributes names and values.
if the given class hasn't one (or more) of these attributes, add the attribute with its value to the class.
'''
for k,v in kw.iteritems():
if not hasattr(cls,k):
setattr(cls,k,v)
def quote_define_name(path):
fu=re.compile("[^a-zA-Z0-9]").sub("_",path)
fu=fu.upper()
return fu
def quote_whitespace(path):
return(path.strip().find(' ')>0 and'"%s"'%path or path).replace('""','"')
def trimquotes(s):
if not s:return''
s=s.rstrip()
if s[0]=="'"and s[-1]=="'":return s[1:-1]
return s
def h_list(lst):
m=md5()
m.update(str(lst))
return m.digest()
def h_fun(fun):
try:
return fun.code
except AttributeError:
try:
h=inspect.getsource(fun)
except IOError:
h="nocode"
try:
fun.code=h
except AttributeError:
pass
return h
def pprint(col,str,label='',sep=os.linesep):
sys.stderr.write("%s%s%s %s%s"%(Logs.colors(col),str,Logs.colors.NORMAL,label,sep))
def check_dir(dir):
try:
os.stat(dir)
except OSError:
try:
os.makedirs(dir)
except OSError,e:
raise WafError("Cannot create folder '%s' (original error: %s)"%(dir,e))
def cmd_output(cmd,**kw):
silent=False
if'silent'in kw:
silent=kw['silent']
del(kw['silent'])
if'e'in kw:
tmp=kw['e']
del(kw['e'])
kw['env']=tmp
kw['shell']=isinstance(cmd,str)
kw['stdout']=pproc.PIPE
if silent:
kw['stderr']=pproc.PIPE
try:
p=pproc.Popen(cmd,**kw)
output=p.communicate()[0]
except OSError,e:
raise ValueError(str(e))
if p.returncode:
if not silent:
msg="command execution failed: %s -> %r"%(cmd,str(output))
raise ValueError(msg)
output=''
return output
reg_subst=re.compile(r"(\\\\)|(\$\$)|\$\{([^}]+)\}")
def subst_vars(expr,params):
def repl_var(m):
if m.group(1):
return'\\'
if m.group(2):
return'$'
try:
return params.get_flat(m.group(3))
except AttributeError:
return params[m.group(3)]
return reg_subst.sub(repl_var,expr)
def unversioned_sys_platform_to_binary_format(unversioned_sys_platform):
if unversioned_sys_platform in('linux','freebsd','netbsd','openbsd','sunos'):
return'elf'
elif unversioned_sys_platform=='darwin':
return'mac-o'
elif unversioned_sys_platform in('win32','cygwin','uwin','msys'):
return'pe'
return'elf'
def unversioned_sys_platform():
s=sys.platform
if s=='java':
from java.lang import System
s=System.getProperty('os.name')
if s=='Mac OS X':
return'darwin'
elif s.startswith('Windows '):
return'win32'
elif s=='OS/2':
return'os2'
elif s=='HP-UX':
return'hpux'
elif s in('SunOS','Solaris'):
return'sunos'
else:s=s.lower()
if s=='win32'or s.endswith('os2')and s!='sunos2':return s
return re.split('\d+$',s)[0]
def detect_platform():
s=sys.platform
for x in'cygwin linux irix sunos hpux aix darwin'.split():
if s.find(x)>=0:
return x
if os.name in'posix java os2'.split():
return os.name
return s
def load_tool(tool,tooldir=None):
'''
load_tool: import a Python module, optionally using several directories.
@param tool [string]: name of tool to import.
@param tooldir [list]: directories to look for the tool.
@return: the loaded module.
Warning: this function is not thread-safe: plays with sys.path,
so must run in sequence.
'''
if tooldir:
assert isinstance(tooldir,list)
sys.path=tooldir+sys.path
try:
try:
return __import__(tool)
except ImportError,e:
Logs.error('Could not load the tool %r in %r:\n%s'%(tool,sys.path,e))
raise
finally:
if tooldir:
sys.path=sys.path[len(tooldir):]
def readf(fname,m='r'):
f=open(fname,m)
try:
txt=f.read()
finally:
f.close()
return txt
def nada(*k,**kw):
pass
def diff_path(top,subdir):
top=os.path.normpath(top).replace('\\','/').split('/')
subdir=os.path.normpath(subdir).replace('\\','/').split('/')
if len(top)==len(subdir):return''
diff=subdir[len(top)-len(subdir):]
return os.path.join(*diff)
class Context(object):
def set_curdir(self,dir):
self.curdir_=dir
def get_curdir(self):
try:
return self.curdir_
except AttributeError:
self.curdir_=os.getcwd()
return self.get_curdir()
curdir=property(get_curdir,set_curdir)
def recurse(self,dirs,name=''):
if not name:
name=inspect.stack()[1][3]
if isinstance(dirs,str):
dirs=to_list(dirs)
for x in dirs:
if os.path.isabs(x):
nexdir=x
else:
nexdir=os.path.join(self.curdir,x)
base=os.path.join(nexdir,WSCRIPT_FILE)
file_path=base+'_'+name
try:
txt=readf(file_path,m='rU')
except(OSError,IOError):
try:
module=load_module(base)
except OSError:
raise WscriptError('No such script %s'%base)
try:
f=module.__dict__[name]
except KeyError:
raise WscriptError('No function %s defined in %s'%(name,base))
if getattr(self.__class__,'pre_recurse',None):
self.pre_recurse(f,base,nexdir)
old=self.curdir
self.curdir=nexdir
try:
f(self)
finally:
self.curdir=old
if getattr(self.__class__,'post_recurse',None):
self.post_recurse(module,base,nexdir)
else:
dc={'ctx':self}
if getattr(self.__class__,'pre_recurse',None):
dc=self.pre_recurse(txt,file_path,nexdir)
old=self.curdir
self.curdir=nexdir
try:
try:
exec(compile(txt,file_path,'exec'),dc)
except Exception:
exc_type,exc_value,tb=sys.exc_info()
raise WscriptError("".join(traceback.format_exception(exc_type,exc_value,tb)),base)
finally:
self.curdir=old
if getattr(self.__class__,'post_recurse',None):
self.post_recurse(txt,file_path,nexdir)
if is_win32:
old=shutil.copy2
def copy2(src,dst):
old(src,dst)
shutil.copystat(src,src)
setattr(shutil,'copy2',copy2)
def zip_folder(dir,zip_file_name,prefix):
import zipfile
zip=zipfile.ZipFile(zip_file_name,'w',compression=zipfile.ZIP_DEFLATED)
base=os.path.abspath(dir)
if prefix:
if prefix[-1]!=os.sep:
prefix+=os.sep
n=len(base)
for root,dirs,files in os.walk(base):
for f in files:
archive_name=prefix+root[n:]+os.sep+f
zip.write(root+os.sep+f,archive_name,zipfile.ZIP_DEFLATED)
zip.close()
def get_elapsed_time(start):
delta=datetime.datetime.now()-start
days=int(delta.days)
hours=int(delta.seconds/3600)
minutes=int((delta.seconds-hours*3600)/60)
seconds=delta.seconds-hours*3600-minutes*60+float(delta.microseconds)/1000/1000
result=''
if days:
result+='%dd'%days
if days or hours:
result+='%dh'%hours
if days or hours or minutes:
result+='%dm'%minutes
return'%s%.3fs'%(result,seconds)
if os.name=='java':
try:
gc.disable()
gc.enable()
except NotImplementedError:
gc.disable=gc.enable
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/pproc.py 0000644 0001750 0001750 00000034712 11277625176 021504 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
mswindows=(sys.platform=="win32")
import os
import types
import traceback
import gc
class CalledProcessError(Exception):
def __init__(self,returncode,cmd):
self.returncode=returncode
self.cmd=cmd
def __str__(self):
return"Command '%s' returned non-zero exit status %d"%(self.cmd,self.returncode)
if mswindows:
import threading
import msvcrt
if 0:
import pywintypes
from win32api import GetStdHandle,STD_INPUT_HANDLE,STD_OUTPUT_HANDLE,STD_ERROR_HANDLE
from win32api import GetCurrentProcess,DuplicateHandle,GetModuleFileName,GetVersion
from win32con import DUPLICATE_SAME_ACCESS,SW_HIDE
from win32pipe import CreatePipe
from win32process import CreateProcess,STARTUPINFO,GetExitCodeProcess,STARTF_USESTDHANDLES,STARTF_USESHOWWINDOW,CREATE_NEW_CONSOLE
from win32event import WaitForSingleObject,INFINITE,WAIT_OBJECT_0
else:
from _subprocess import*
class STARTUPINFO:
dwFlags=0
hStdInput=None
hStdOutput=None
hStdError=None
wShowWindow=0
class pywintypes:
error=IOError
else:
import select
import errno
import fcntl
import pickle
__all__=["Popen","PIPE","STDOUT","call","check_call","CalledProcessError"]
try:
MAXFD=os.sysconf("SC_OPEN_MAX")
except:
MAXFD=256
try:
False
except NameError:
False=0
True=1
_active=[]
def _cleanup():
for inst in _active[:]:
if inst.poll(_deadstate=sys.maxint)>=0:
try:
_active.remove(inst)
except ValueError:
pass
PIPE=-1
STDOUT=-2
def call(*popenargs,**kwargs):
return Popen(*popenargs,**kwargs).wait()
def check_call(*popenargs,**kwargs):
retcode=call(*popenargs,**kwargs)
cmd=kwargs.get("args")
if cmd is None:
cmd=popenargs[0]
if retcode:
raise CalledProcessError(retcode,cmd)
return retcode
def list2cmdline(seq):
result=[]
needquote=False
for arg in seq:
bs_buf=[]
if result:
result.append(' ')
needquote=(" "in arg)or("\t"in arg)or arg==""
if needquote:
result.append('"')
for c in arg:
if c=='\\':
bs_buf.append(c)
elif c=='"':
result.append('\\'*len(bs_buf)*2)
bs_buf=[]
result.append('\\"')
else:
if bs_buf:
result.extend(bs_buf)
bs_buf=[]
result.append(c)
if bs_buf:
result.extend(bs_buf)
if needquote:
result.extend(bs_buf)
result.append('"')
return''.join(result)
class Popen(object):
def __init__(self,args,bufsize=0,executable=None,stdin=None,stdout=None,stderr=None,preexec_fn=None,close_fds=False,shell=False,cwd=None,env=None,universal_newlines=False,startupinfo=None,creationflags=0):
_cleanup()
self._child_created=False
if not isinstance(bufsize,(int,long)):
raise TypeError("bufsize must be an integer")
if mswindows:
if preexec_fn is not None:
raise ValueError("preexec_fn is not supported on Windows platforms")
if close_fds:
raise ValueError("close_fds is not supported on Windows platforms")
else:
if startupinfo is not None:
raise ValueError("startupinfo is only supported on Windows platforms")
if creationflags!=0:
raise ValueError("creationflags is only supported on Windows platforms")
self.stdin=None
self.stdout=None
self.stderr=None
self.pid=None
self.returncode=None
self.universal_newlines=universal_newlines
(p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite)=self._get_handles(stdin,stdout,stderr)
self._execute_child(args,executable,preexec_fn,close_fds,cwd,env,universal_newlines,startupinfo,creationflags,shell,p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite)
if mswindows:
if stdin is None and p2cwrite is not None:
os.close(p2cwrite)
p2cwrite=None
if stdout is None and c2pread is not None:
os.close(c2pread)
c2pread=None
if stderr is None and errread is not None:
os.close(errread)
errread=None
if p2cwrite:
self.stdin=os.fdopen(p2cwrite,'wb',bufsize)
if c2pread:
if universal_newlines:
self.stdout=os.fdopen(c2pread,'rU',bufsize)
else:
self.stdout=os.fdopen(c2pread,'rb',bufsize)
if errread:
if universal_newlines:
self.stderr=os.fdopen(errread,'rU',bufsize)
else:
self.stderr=os.fdopen(errread,'rb',bufsize)
def _translate_newlines(self,data):
data=data.replace("\r\n","\n")
data=data.replace("\r","\n")
return data
def __del__(self,sys=sys):
if not self._child_created:
return
self.poll(_deadstate=sys.maxint)
if self.returncode is None and _active is not None:
_active.append(self)
def communicate(self,input=None):
if[self.stdin,self.stdout,self.stderr].count(None)>=2:
stdout=None
stderr=None
if self.stdin:
if input:
self.stdin.write(input)
self.stdin.close()
elif self.stdout:
stdout=self.stdout.read()
elif self.stderr:
stderr=self.stderr.read()
self.wait()
return(stdout,stderr)
return self._communicate(input)
if mswindows:
def _get_handles(self,stdin,stdout,stderr):
if stdin is None and stdout is None and stderr is None:
return(None,None,None,None,None,None)
p2cread,p2cwrite=None,None
c2pread,c2pwrite=None,None
errread,errwrite=None,None
if stdin is None:
p2cread=GetStdHandle(STD_INPUT_HANDLE)
if p2cread is not None:
pass
elif stdin is None or stdin==PIPE:
p2cread,p2cwrite=CreatePipe(None,0)
p2cwrite=p2cwrite.Detach()
p2cwrite=msvcrt.open_osfhandle(p2cwrite,0)
elif isinstance(stdin,int):
p2cread=msvcrt.get_osfhandle(stdin)
else:
p2cread=msvcrt.get_osfhandle(stdin.fileno())
p2cread=self._make_inheritable(p2cread)
if stdout is None:
c2pwrite=GetStdHandle(STD_OUTPUT_HANDLE)
if c2pwrite is not None:
pass
elif stdout is None or stdout==PIPE:
c2pread,c2pwrite=CreatePipe(None,0)
c2pread=c2pread.Detach()
c2pread=msvcrt.open_osfhandle(c2pread,0)
elif isinstance(stdout,int):
c2pwrite=msvcrt.get_osfhandle(stdout)
else:
c2pwrite=msvcrt.get_osfhandle(stdout.fileno())
c2pwrite=self._make_inheritable(c2pwrite)
if stderr is None:
errwrite=GetStdHandle(STD_ERROR_HANDLE)
if errwrite is not None:
pass
elif stderr is None or stderr==PIPE:
errread,errwrite=CreatePipe(None,0)
errread=errread.Detach()
errread=msvcrt.open_osfhandle(errread,0)
elif stderr==STDOUT:
errwrite=c2pwrite
elif isinstance(stderr,int):
errwrite=msvcrt.get_osfhandle(stderr)
else:
errwrite=msvcrt.get_osfhandle(stderr.fileno())
errwrite=self._make_inheritable(errwrite)
return(p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite)
def _make_inheritable(self,handle):
return DuplicateHandle(GetCurrentProcess(),handle,GetCurrentProcess(),0,1,DUPLICATE_SAME_ACCESS)
def _find_w9xpopen(self):
w9xpopen=os.path.join(os.path.dirname(GetModuleFileName(0)),"w9xpopen.exe")
if not os.path.exists(w9xpopen):
w9xpopen=os.path.join(os.path.dirname(sys.exec_prefix),"w9xpopen.exe")
if not os.path.exists(w9xpopen):
raise RuntimeError("Cannot locate w9xpopen.exe, which is needed for Popen to work with your shell or platform.")
return w9xpopen
def _execute_child(self,args,executable,preexec_fn,close_fds,cwd,env,universal_newlines,startupinfo,creationflags,shell,p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite):
if not isinstance(args,types.StringTypes):
args=list2cmdline(args)
if startupinfo is None:
startupinfo=STARTUPINFO()
if None not in(p2cread,c2pwrite,errwrite):
startupinfo.dwFlags|=STARTF_USESTDHANDLES
startupinfo.hStdInput=p2cread
startupinfo.hStdOutput=c2pwrite
startupinfo.hStdError=errwrite
if shell:
startupinfo.dwFlags|=STARTF_USESHOWWINDOW
startupinfo.wShowWindow=SW_HIDE
comspec=os.environ.get("COMSPEC","cmd.exe")
args=comspec+" /c "+args
if(GetVersion()>=0x80000000L or os.path.basename(comspec).lower()=="command.com"):
w9xpopen=self._find_w9xpopen()
args='"%s" %s'%(w9xpopen,args)
creationflags|=CREATE_NEW_CONSOLE
try:
hp,ht,pid,tid=CreateProcess(executable,args,None,None,1,creationflags,env,cwd,startupinfo)
except pywintypes.error,e:
raise WindowsError(*e.args)
self._child_created=True
self._handle=hp
self.pid=pid
ht.Close()
if p2cread is not None:
p2cread.Close()
if c2pwrite is not None:
c2pwrite.Close()
if errwrite is not None:
errwrite.Close()
def poll(self,_deadstate=None):
if self.returncode is None:
if WaitForSingleObject(self._handle,0)==WAIT_OBJECT_0:
self.returncode=GetExitCodeProcess(self._handle)
return self.returncode
def wait(self):
if self.returncode is None:
obj=WaitForSingleObject(self._handle,INFINITE)
self.returncode=GetExitCodeProcess(self._handle)
return self.returncode
def _readerthread(self,fh,buffer):
buffer.append(fh.read())
def _communicate(self,input):
stdout=None
stderr=None
if self.stdout:
stdout=[]
stdout_thread=threading.Thread(target=self._readerthread,args=(self.stdout,stdout))
stdout_thread.setDaemon(True)
stdout_thread.start()
if self.stderr:
stderr=[]
stderr_thread=threading.Thread(target=self._readerthread,args=(self.stderr,stderr))
stderr_thread.setDaemon(True)
stderr_thread.start()
if self.stdin:
if input is not None:
self.stdin.write(input)
self.stdin.close()
if self.stdout:
stdout_thread.join()
if self.stderr:
stderr_thread.join()
if stdout is not None:
stdout=stdout[0]
if stderr is not None:
stderr=stderr[0]
if self.universal_newlines and hasattr(file,'newlines'):
if stdout:
stdout=self._translate_newlines(stdout)
if stderr:
stderr=self._translate_newlines(stderr)
self.wait()
return(stdout,stderr)
else:
def _get_handles(self,stdin,stdout,stderr):
p2cread,p2cwrite=None,None
c2pread,c2pwrite=None,None
errread,errwrite=None,None
if stdin is None:
pass
elif stdin==PIPE:
p2cread,p2cwrite=os.pipe()
elif isinstance(stdin,int):
p2cread=stdin
else:
p2cread=stdin.fileno()
if stdout is None:
pass
elif stdout==PIPE:
c2pread,c2pwrite=os.pipe()
elif isinstance(stdout,int):
c2pwrite=stdout
else:
c2pwrite=stdout.fileno()
if stderr is None:
pass
elif stderr==PIPE:
errread,errwrite=os.pipe()
elif stderr==STDOUT:
errwrite=c2pwrite
elif isinstance(stderr,int):
errwrite=stderr
else:
errwrite=stderr.fileno()
return(p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite)
def _set_cloexec_flag(self,fd):
try:
cloexec_flag=fcntl.FD_CLOEXEC
except AttributeError:
cloexec_flag=1
old=fcntl.fcntl(fd,fcntl.F_GETFD)
fcntl.fcntl(fd,fcntl.F_SETFD,old|cloexec_flag)
def _close_fds(self,but):
for i in xrange(3,MAXFD):
if i==but:
continue
try:
os.close(i)
except:
pass
def _execute_child(self,args,executable,preexec_fn,close_fds,cwd,env,universal_newlines,startupinfo,creationflags,shell,p2cread,p2cwrite,c2pread,c2pwrite,errread,errwrite):
if isinstance(args,types.StringTypes):
args=[args]
else:
args=list(args)
if shell:
args=["/bin/sh","-c"]+args
if executable is None:
executable=args[0]
errpipe_read,errpipe_write=os.pipe()
self._set_cloexec_flag(errpipe_write)
gc_was_enabled=gc.isenabled()
gc.disable()
try:
self.pid=os.fork()
except:
if gc_was_enabled:
gc.enable()
raise
self._child_created=True
if self.pid==0:
try:
if p2cwrite:
os.close(p2cwrite)
if c2pread:
os.close(c2pread)
if errread:
os.close(errread)
os.close(errpipe_read)
if p2cread:
os.dup2(p2cread,0)
if c2pwrite:
os.dup2(c2pwrite,1)
if errwrite:
os.dup2(errwrite,2)
if p2cread and p2cread not in(0,):
os.close(p2cread)
if c2pwrite and c2pwrite not in(p2cread,1):
os.close(c2pwrite)
if errwrite and errwrite not in(p2cread,c2pwrite,2):
os.close(errwrite)
if close_fds:
self._close_fds(but=errpipe_write)
if cwd is not None:
os.chdir(cwd)
if preexec_fn:
apply(preexec_fn)
if env is None:
os.execvp(executable,args)
else:
os.execvpe(executable,args,env)
except:
exc_type,exc_value,tb=sys.exc_info()
exc_lines=traceback.format_exception(exc_type,exc_value,tb)
exc_value.child_traceback=''.join(exc_lines)
os.write(errpipe_write,pickle.dumps(exc_value))
os._exit(255)
if gc_was_enabled:
gc.enable()
os.close(errpipe_write)
if p2cread and p2cwrite:
os.close(p2cread)
if c2pwrite and c2pread:
os.close(c2pwrite)
if errwrite and errread:
os.close(errwrite)
data=os.read(errpipe_read,1048576)
os.close(errpipe_read)
if data!="":
os.waitpid(self.pid,0)
child_exception=pickle.loads(data)
raise child_exception
def _handle_exitstatus(self,sts):
if os.WIFSIGNALED(sts):
self.returncode=-os.WTERMSIG(sts)
elif os.WIFEXITED(sts):
self.returncode=os.WEXITSTATUS(sts)
else:
raise RuntimeError("Unknown child exit status!")
def poll(self,_deadstate=None):
if self.returncode is None:
try:
pid,sts=os.waitpid(self.pid,os.WNOHANG)
if pid==self.pid:
self._handle_exitstatus(sts)
except os.error:
if _deadstate is not None:
self.returncode=_deadstate
return self.returncode
def wait(self):
if self.returncode is None:
pid,sts=os.waitpid(self.pid,0)
self._handle_exitstatus(sts)
return self.returncode
def _communicate(self,input):
read_set=[]
write_set=[]
stdout=None
stderr=None
if self.stdin:
self.stdin.flush()
if input:
write_set.append(self.stdin)
else:
self.stdin.close()
if self.stdout:
read_set.append(self.stdout)
stdout=[]
if self.stderr:
read_set.append(self.stderr)
stderr=[]
input_offset=0
while read_set or write_set:
rlist,wlist,xlist=select.select(read_set,write_set,[])
if self.stdin in wlist:
bytes_written=os.write(self.stdin.fileno(),buffer(input,input_offset,512))
input_offset+=bytes_written
if input_offset>=len(input):
self.stdin.close()
write_set.remove(self.stdin)
if self.stdout in rlist:
data=os.read(self.stdout.fileno(),1024)
if data=="":
self.stdout.close()
read_set.remove(self.stdout)
stdout.append(data)
if self.stderr in rlist:
data=os.read(self.stderr.fileno(),1024)
if data=="":
self.stderr.close()
read_set.remove(self.stderr)
stderr.append(data)
if stdout is not None:
stdout=''.join(stdout)
if stderr is not None:
stderr=''.join(stderr)
if self.universal_newlines and hasattr(file,'newlines'):
if stdout:
stdout=self._translate_newlines(stdout)
if stderr:
stderr=self._translate_newlines(stderr)
self.wait()
return(stdout,stderr)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Task.py 0000644 0001750 0001750 00000052113 11362610130 021231 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os,shutil,sys,re,random,datetime,tempfile,shlex
from Utils import md5
import Build,Runner,Utils,Node,Logs,Options
from Logs import debug,warn,error
from Constants import*
algotype=NORMAL
COMPILE_TEMPLATE_SHELL='''
def f(task):
env = task.env
wd = getattr(task, 'cwd', None)
p = env.get_flat
cmd = \'\'\' %s \'\'\' % s
return task.exec_command(cmd, cwd=wd)
'''
COMPILE_TEMPLATE_NOSHELL='''
def f(task):
env = task.env
wd = getattr(task, 'cwd', None)
def to_list(xx):
if isinstance(xx, str): return [xx]
return xx
lst = []
%s
lst = [x for x in lst if x]
return task.exec_command(lst, cwd=wd)
'''
file_deps=Utils.nada
class TaskManager(object):
def __init__(self):
self.groups=[]
self.tasks_done=[]
self.current_group=0
self.groups_names={}
def get_next_set(self):
ret=None
while not ret and self.current_group0:
self.set_order(keys[i],keys[j])
elif val<0:
self.set_order(keys[j],keys[i])
def tasks_in_parallel(self):
if not self.ready:self.prepare()
keys=self.cstr_groups.keys()
unconnected=[]
remainder=[]
for u in keys:
for k in self.cstr_order.values():
if u in k:
remainder.append(u)
break
else:
unconnected.append(u)
toreturn=[]
for y in unconnected:
toreturn.extend(self.cstr_groups[y])
for y in unconnected:
try:self.cstr_order.__delitem__(y)
except KeyError:pass
self.cstr_groups.__delitem__(y)
if not toreturn and remainder:
raise Utils.WafError("circular order constraint detected %r"%remainder)
return toreturn
def tasks_by_max_jobs(self):
if not self.ready:self.prepare()
if not self.temp_tasks:self.temp_tasks=self.tasks_in_parallel()
if not self.temp_tasks:return(None,None)
maxjobs=MAXJOBS
ret=[]
remaining=[]
for t in self.temp_tasks:
m=getattr(t,"maxjobs",getattr(self.__class__,"maxjobs",MAXJOBS))
if m>maxjobs:
remaining.append(t)
elif m task failed (err #%d): %r"%(self.err_code,self)
except AttributeError:
return" -> task failed: %r"%self
elif self.hasrun==MISSING:
return" -> missing files: %r"%self
else:
return''
def install(self):
bld=self.generator.bld
d=self.attr('install')
if self.attr('install_path'):
lst=[a.relpath_gen(bld.srcnode)for a in self.outputs]
perm=self.attr('chmod',O644)
if self.attr('src'):
lst+=[a.relpath_gen(bld.srcnode)for a in self.inputs]
if self.attr('filename'):
dir=self.install_path.rstrip(os.sep)+os.sep+self.attr('filename')
bld.install_as(dir,lst[0],self.env,perm)
else:
bld.install_files(self.install_path,lst,self.env,perm)
class Task(TaskBase):
vars=[]
def __init__(self,env,**kw):
TaskBase.__init__(self,**kw)
self.env=env
self.inputs=[]
self.outputs=[]
self.deps_nodes=[]
self.run_after=[]
def __str__(self):
env=self.env
src_str=' '.join([a.nice_path(env)for a in self.inputs])
tgt_str=' '.join([a.nice_path(env)for a in self.outputs])
if self.outputs:sep=' -> '
else:sep=''
return'%s: %s%s%s\n'%(self.__class__.__name__.replace('_task',''),src_str,sep,tgt_str)
def __repr__(self):
return"".join(['\n\t{task: ',self.__class__.__name__," ",",".join([x.name for x in self.inputs])," -> ",",".join([x.name for x in self.outputs]),'}'])
def unique_id(self):
try:
return self.uid
except AttributeError:
m=md5()
up=m.update
up(self.__class__.__name__)
up(self.env.variant())
p=None
for x in self.inputs+self.outputs:
if p!=x.parent.id:
p=x.parent.id
up(x.parent.abspath())
up(x.name)
self.uid=m.digest()
return self.uid
def set_inputs(self,inp):
if isinstance(inp,list):self.inputs+=inp
else:self.inputs.append(inp)
def set_outputs(self,out):
if isinstance(out,list):self.outputs+=out
else:self.outputs.append(out)
def set_run_after(self,task):
assert isinstance(task,TaskBase)
self.run_after.append(task)
def add_file_dependency(self,filename):
node=self.generator.bld.path.find_resource(filename)
self.deps_nodes.append(node)
def signature(self):
try:return self.cache_sig[0]
except AttributeError:pass
self.m=md5()
exp_sig=self.sig_explicit_deps()
var_sig=self.sig_vars()
imp_sig=SIG_NIL
if self.scan:
try:
imp_sig=self.sig_implicit_deps()
except ValueError:
return self.signature()
ret=self.m.digest()
self.cache_sig=(ret,exp_sig,imp_sig,var_sig)
return ret
def runnable_status(self):
if self.inputs and(not self.outputs):
if not getattr(self.__class__,'quiet',None):
warn("invalid task (no inputs OR outputs): override in a Task subclass or set the attribute 'quiet' %r"%self)
for t in self.run_after:
if not t.hasrun:
return ASK_LATER
env=self.env
bld=self.generator.bld
new_sig=self.signature()
key=self.unique_id()
try:
prev_sig=bld.task_sigs[key][0]
except KeyError:
debug("task: task %r must run as it was never run before or the task code changed",self)
return RUN_ME
for node in self.outputs:
variant=node.variant(env)
try:
if bld.node_sigs[variant][node.id]!=new_sig:
return RUN_ME
except KeyError:
debug("task: task %r must run as the output nodes do not exist",self)
return RUN_ME
if Logs.verbose:self.debug_why(bld.task_sigs[key])
if new_sig!=prev_sig:
return RUN_ME
return SKIP_ME
def post_run(self):
bld=self.generator.bld
env=self.env
sig=self.signature()
ssig=sig.encode('hex')
variant=env.variant()
for node in self.outputs:
try:
os.stat(node.abspath(env))
except OSError:
self.hasrun=MISSING
self.err_msg='-> missing file: %r'%node.abspath(env)
raise Utils.WafError
bld.node_sigs[variant][node.id]=sig
bld.task_sigs[self.unique_id()]=self.cache_sig
if not Options.cache_global or Options.options.nocache or not self.outputs:
return None
if getattr(self,'cached',None):
return None
dname=os.path.join(Options.cache_global,ssig)
tmpdir=tempfile.mkdtemp(prefix=Options.cache_global)
try:
shutil.rmtree(dname)
except:
pass
try:
for node in self.outputs:
variant=node.variant(env)
dest=os.path.join(tmpdir,node.name)
shutil.copy2(node.abspath(env),dest)
except(OSError,IOError):
try:
shutil.rmtree(tmpdir)
except:
pass
else:
try:
os.rename(tmpdir,dname)
except OSError:
try:
shutil.rmtree(tmpdir)
except:
pass
else:
try:
os.chmod(dname,O755)
except:
pass
def can_retrieve_cache(self):
if not Options.cache_global or Options.options.nocache or not self.outputs:
return None
env=self.env
sig=self.signature()
ssig=sig.encode('hex')
dname=os.path.join(Options.cache_global,ssig)
try:
t1=os.stat(dname).st_mtime
except OSError:
return None
for node in self.outputs:
variant=node.variant(env)
orig=os.path.join(dname,node.name)
try:
shutil.copy2(orig,node.abspath(env))
os.utime(orig,None)
except(OSError,IOError):
debug('task: failed retrieving file')
return None
try:
t2=os.stat(dname).st_mtime
except OSError:
return None
if t1!=t2:
return None
for node in self.outputs:
self.generator.bld.node_sigs[variant][node.id]=sig
if Options.options.progress_bar<1:
self.generator.bld.printout('restoring from cache %r\n'%node.bldpath(env))
self.cached=True
return 1
def debug_why(self,old_sigs):
new_sigs=self.cache_sig
def v(x):
return x.encode('hex')
debug("Task %r",self)
msgs=['Task must run','* Source file or manual dependency','* Implicit dependency','* Environment variable']
tmp='task: -> %s: %s %s'
for x in xrange(len(msgs)):
if(new_sigs[x]!=old_sigs[x]):
debug(tmp,msgs[x],v(old_sigs[x]),v(new_sigs[x]))
def sig_explicit_deps(self):
bld=self.generator.bld
up=self.m.update
for x in self.inputs+getattr(self,'dep_nodes',[]):
if not x.parent.id in bld.cache_scanned_folders:
bld.rescan(x.parent)
variant=x.variant(self.env)
try:
up(bld.node_sigs[variant][x.id])
except KeyError:
raise Utils.WafError('Missing node signature for %r (required by %r)'%(x,self))
if bld.deps_man:
additional_deps=bld.deps_man
for x in self.inputs+self.outputs:
try:
d=additional_deps[x.id]
except KeyError:
continue
for v in d:
if isinstance(v,Node.Node):
bld.rescan(v.parent)
variant=v.variant(self.env)
try:
v=bld.node_sigs[variant][v.id]
except KeyError:
raise Utils.WafError('Missing node signature for %r (required by %r)'%(v,self))
elif hasattr(v,'__call__'):
v=v()
up(v)
for x in self.deps_nodes:
v=bld.node_sigs[x.variant(self.env)][x.id]
up(v)
return self.m.digest()
def sig_vars(self):
bld=self.generator.bld
env=self.env
act_sig=bld.hash_env_vars(env,self.__class__.vars)
self.m.update(act_sig)
dep_vars=getattr(self,'dep_vars',None)
if dep_vars:
self.m.update(bld.hash_env_vars(env,dep_vars))
return self.m.digest()
scan=None
def sig_implicit_deps(self):
bld=self.generator.bld
key=self.unique_id()
prev_sigs=bld.task_sigs.get(key,())
if prev_sigs:
try:
if prev_sigs[2]==self.compute_sig_implicit_deps():
return prev_sigs[2]
except(KeyError,OSError):
pass
del bld.task_sigs[key]
raise ValueError('rescan')
(nodes,names)=self.scan()
if Logs.verbose:
debug('deps: scanner for %s returned %s %s',str(self),str(nodes),str(names))
bld.node_deps[key]=nodes
bld.raw_deps[key]=names
try:
sig=self.compute_sig_implicit_deps()
except KeyError:
try:
nodes=[]
for k in bld.node_deps.get(self.unique_id(),[]):
if k.id&3==2:
if not k.id in bld.node_sigs[0]:
nodes.append(k)
else:
if not k.id in bld.node_sigs[self.env.variant()]:
nodes.append(k)
except:
nodes='?'
raise Utils.WafError('Missing node signature for %r (for implicit dependencies %r)'%(nodes,self))
return sig
def compute_sig_implicit_deps(self):
upd=self.m.update
bld=self.generator.bld
tstamp=bld.node_sigs
env=self.env
for k in bld.node_deps.get(self.unique_id(),[]):
if not k.parent.id in bld.cache_scanned_folders:
bld.rescan(k.parent)
if k.id&3==2:
upd(tstamp[0][k.id])
else:
upd(tstamp[env.variant()][k.id])
return self.m.digest()
def funex(c):
dc={}
exec(c,dc)
return dc['f']
reg_act=re.compile(r"(?P\\)|(?P\$\$)|(?P\$\{(?P\w+)(?P.*?)\})",re.M)
def compile_fun_shell(name,line):
extr=[]
def repl(match):
g=match.group
if g('dollar'):return"$"
elif g('backslash'):return'\\\\'
elif g('subst'):extr.append((g('var'),g('code')));return"%s"
return None
line=reg_act.sub(repl,line)
parm=[]
dvars=[]
app=parm.append
for(var,meth)in extr:
if var=='SRC':
if meth:app('task.inputs%s'%meth)
else:app('" ".join([a.srcpath(env) for a in task.inputs])')
elif var=='TGT':
if meth:app('task.outputs%s'%meth)
else:app('" ".join([a.bldpath(env) for a in task.outputs])')
else:
if not var in dvars:dvars.append(var)
app("p('%s')"%var)
if parm:parm="%% (%s) "%(',\n\t\t'.join(parm))
else:parm=''
c=COMPILE_TEMPLATE_SHELL%(line,parm)
debug('action: %s',c)
return(funex(c),dvars)
def compile_fun_noshell(name,line):
extr=[]
def repl(match):
g=match.group
if g('dollar'):return"$"
elif g('subst'):extr.append((g('var'),g('code')));return"<<|@|>>"
return None
line2=reg_act.sub(repl,line)
params=line2.split('<<|@|>>')
buf=[]
dvars=[]
app=buf.append
for x in xrange(len(extr)):
params[x]=params[x].strip()
if params[x]:
app("lst.extend(%r)"%params[x].split())
(var,meth)=extr[x]
if var=='SRC':
if meth:app('lst.append(task.inputs%s)'%meth)
else:app("lst.extend([a.srcpath(env) for a in task.inputs])")
elif var=='TGT':
if meth:app('lst.append(task.outputs%s)'%meth)
else:app("lst.extend([a.bldpath(env) for a in task.outputs])")
else:
app('lst.extend(to_list(env[%r]))'%var)
if not var in dvars:dvars.append(var)
if params[-1]:
app("lst.extend(%r)"%shlex.split(params[-1]))
fun=COMPILE_TEMPLATE_NOSHELL%"\n\t".join(buf)
debug('action: %s',fun)
return(funex(fun),dvars)
def compile_fun(name,line,shell=None):
if line.find('<')>0 or line.find('>')>0 or line.find('&&')>0:
shell=True
if shell is None:
if sys.platform=='win32':
shell=False
else:
shell=True
if shell:
return compile_fun_shell(name,line)
else:
return compile_fun_noshell(name,line)
def simple_task_type(name,line,color='GREEN',vars=[],ext_in=[],ext_out=[],before=[],after=[],shell=None):
(fun,dvars)=compile_fun(name,line,shell)
fun.code=line
return task_type_from_func(name,fun,vars or dvars,color,ext_in,ext_out,before,after)
def task_type_from_func(name,func,vars=[],color='GREEN',ext_in=[],ext_out=[],before=[],after=[]):
params={'run':func,'vars':vars,'color':color,'name':name,'ext_in':Utils.to_list(ext_in),'ext_out':Utils.to_list(ext_out),'before':Utils.to_list(before),'after':Utils.to_list(after),}
cls=type(Task)(name,(Task,),params)
TaskBase.classes[name]=cls
return cls
def always_run(cls):
old=cls.runnable_status
def always(self):
old(self)
return RUN_ME
cls.runnable_status=always
def update_outputs(cls):
old_post_run=cls.post_run
def post_run(self):
old_post_run(self)
bld=self.outputs[0].__class__.bld
for output in self.outputs:
bld.node_sigs[self.env.variant()][output.id]=Utils.h_file(output.abspath(self.env))
cls.post_run=post_run
old_runnable_status=cls.runnable_status
def runnable_status(self):
status=old_runnable_status(self)
if status!=RUN_ME:
return status
try:
bld=self.outputs[0].__class__.bld
new_sig=self.signature()
prev_sig=bld.task_sigs[self.unique_id()][0]
if prev_sig==new_sig:
for x in self.outputs:
if not x.id in bld.node_sigs[self.env.variant()]:
return RUN_ME
return SKIP_ME
except KeyError:
pass
except IndexError:
pass
return RUN_ME
cls.runnable_status=runnable_status
def extract_outputs(tasks):
v={}
for x in tasks:
try:
(ins,outs)=v[x.env.variant()]
except KeyError:
ins={}
outs={}
v[x.env.variant()]=(ins,outs)
for a in getattr(x,'inputs',[]):
try:ins[a.id].append(x)
except KeyError:ins[a.id]=[x]
for a in getattr(x,'outputs',[]):
try:outs[a.id].append(x)
except KeyError:outs[a.id]=[x]
for(ins,outs)in v.values():
links=set(ins.iterkeys()).intersection(outs.iterkeys())
for k in links:
for a in ins[k]:
for b in outs[k]:
a.set_run_after(b)
def extract_deps(tasks):
extract_outputs(tasks)
out_to_task={}
for x in tasks:
v=x.env.variant()
try:
lst=x.outputs
except AttributeError:
pass
else:
for node in lst:
out_to_task[(v,node.id)]=x
dep_to_task={}
for x in tasks:
try:
x.signature()
except:
pass
v=x.env.variant()
key=x.unique_id()
for k in x.generator.bld.node_deps.get(x.unique_id(),[]):
try:dep_to_task[(v,k.id)].append(x)
except KeyError:dep_to_task[(v,k.id)]=[x]
deps=set(dep_to_task.keys()).intersection(set(out_to_task.keys()))
for idx in deps:
for k in dep_to_task[idx]:
k.set_run_after(out_to_task[idx])
for x in tasks:
try:
delattr(x,'cache_sig')
except AttributeError:
pass
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Options.py 0000644 0001750 0001750 00000013356 11360136405 021776 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import os,sys,imp,types,tempfile,optparse
import Logs,Utils
from Constants import*
cmds='distclean configure build install clean uninstall check dist distcheck'.split()
commands={}
is_install=False
options={}
arg_line=[]
launch_dir=''
tooldir=''
lockfile=os.environ.get('WAFLOCK','.lock-wscript')
try:cache_global=os.path.abspath(os.environ['WAFCACHE'])
except KeyError:cache_global=''
platform=Utils.unversioned_sys_platform()
conf_file='conf-runs-%s-%d.pickle'%(platform,ABI)
remote_repo=['http://waf.googlecode.com/svn/']
default_prefix=os.environ.get('PREFIX')
if not default_prefix:
if platform=='win32':default_prefix=tempfile.gettempdir()
else:default_prefix='/usr/local/'
default_jobs=os.environ.get('JOBS',-1)
if default_jobs<1:
try:
if'SC_NPROCESSORS_ONLN'in os.sysconf_names:
default_jobs=os.sysconf('SC_NPROCESSORS_ONLN')
else:
default_jobs=int(Utils.cmd_output(['sysctl','-n','hw.ncpu']))
except:
if os.name=='java':
from java.lang import Runtime
default_jobs=Runtime.getRuntime().availableProcessors()
else:
default_jobs=int(os.environ.get('NUMBER_OF_PROCESSORS',1))
default_destdir=os.environ.get('DESTDIR','')
def get_usage(self):
cmds_str=[]
module=Utils.g_module
if module:
tbl=module.__dict__
keys=list(tbl.keys())
keys.sort()
if'build'in tbl:
if not module.build.__doc__:
module.build.__doc__='builds the project'
if'configure'in tbl:
if not module.configure.__doc__:
module.configure.__doc__='configures the project'
ban=['set_options','init','shutdown']
optlst=[x for x in keys if not x in ban and type(tbl[x])is type(parse_args_impl)and tbl[x].__doc__ and not x.startswith('_')]
just=max([len(x)for x in optlst])
for x in optlst:
cmds_str.append(' %s: %s'%(x.ljust(just),tbl[x].__doc__))
ret='\n'.join(cmds_str)
else:
ret=' '.join(cmds)
return'''waf [command] [options]
Main commands (example: ./waf build -j4)
%s
'''%ret
setattr(optparse.OptionParser,'get_usage',get_usage)
def create_parser(module=None):
Logs.debug('options: create_parser is called')
parser=optparse.OptionParser(conflict_handler="resolve",version='waf %s (%s)'%(WAFVERSION,WAFREVISION))
parser.formatter.width=Utils.get_term_cols()
p=parser.add_option
p('-j','--jobs',type='int',default=default_jobs,help='amount of parallel jobs (%r)'%default_jobs,dest='jobs')
p('-k','--keep',action='store_true',default=False,help='keep running happily on independent task groups',dest='keep')
p('-v','--verbose',action='count',default=0,help='verbosity level -v -vv or -vvv [default: 0]',dest='verbose')
p('--nocache',action='store_true',default=False,help='ignore the WAFCACHE (if set)',dest='nocache')
p('--zones',action='store',default='',help='debugging zones (task_gen, deps, tasks, etc)',dest='zones')
p('-p','--progress',action='count',default=0,help='-p: progress bar; -pp: ide output',dest='progress_bar')
p('--targets',action='store',default='',help='build given task generators, e.g. "target1,target2"',dest='compile_targets')
gr=optparse.OptionGroup(parser,'configuration options')
parser.add_option_group(gr)
gr.add_option('-b','--blddir',action='store',default='',help='build dir for the project (configuration)',dest='blddir')
gr.add_option('-s','--srcdir',action='store',default='',help='src dir for the project (configuration)',dest='srcdir')
gr.add_option('--prefix',help='installation prefix (configuration) [default: %r]'%default_prefix,default=default_prefix,dest='prefix')
gr=optparse.OptionGroup(parser,'installation options')
parser.add_option_group(gr)
gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir')
gr.add_option('-f','--force',action='store_true',default=False,help='force file installation',dest='force')
return parser
def parse_args_impl(parser,_args=None):
global options,commands,arg_line
(options,args)=parser.parse_args(args=_args)
arg_line=args
commands={}
for var in cmds:commands[var]=0
if not args:
commands['build']=1
args.append('build')
for arg in args:
commands[arg]=True
if'check'in args:
idx=args.index('check')
try:
bidx=args.index('build')
if bidx>idx:
raise ValueError('build before check')
except ValueError,e:
args.insert(idx,'build')
if args[0]!='init':
args.insert(0,'init')
if options.keep:options.jobs=1
if options.jobs<1:options.jobs=1
if'install'in sys.argv or'uninstall'in sys.argv:
options.destdir=options.destdir and os.path.abspath(os.path.expanduser(options.destdir))
Logs.verbose=options.verbose
Logs.init_log()
if options.zones:
Logs.zones=options.zones.split(',')
if not Logs.verbose:Logs.verbose=1
elif Logs.verbose>0:
Logs.zones=['runner']
if Logs.verbose>2:
Logs.zones=['*']
class Handler(Utils.Context):
parser=None
def __init__(self,module=None):
self.parser=create_parser(module)
self.cwd=os.getcwd()
Handler.parser=self
def add_option(self,*k,**kw):
self.parser.add_option(*k,**kw)
def add_option_group(self,*k,**kw):
return self.parser.add_option_group(*k,**kw)
def get_option_group(self,opt_str):
return self.parser.get_option_group(opt_str)
def sub_options(self,*k,**kw):
if not k:raise Utils.WscriptError('folder expected')
self.recurse(k[0],name='set_options')
def tool_options(self,*k,**kw):
if not k[0]:
raise Utils.WscriptError('invalid tool_options call %r %r'%(k,kw))
tools=Utils.to_list(k[0])
path=Utils.to_list(kw.get('tdir',kw.get('tooldir',tooldir)))
for tool in tools:
tool=tool.replace('++','xx')
if tool=='java':tool='javaw'
if tool.lower()=='unittest':tool='unittestw'
module=Utils.load_tool(tool,path)
try:
fun=module.set_options
except AttributeError:
pass
else:
fun(kw.get('option_group',self))
def parse_args(self,args=None):
parse_args_impl(self.parser,args)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/TaskGen.py 0000644 0001750 0001750 00000024573 11360136405 021702 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import os,traceback,copy
import Build,Task,Utils,Logs,Options
from Logs import debug,error,warn
from Constants import*
typos={'sources':'source','targets':'target','include':'includes','define':'defines','importpath':'importpaths','install_var':'install_path','install_subdir':'install_path','inst_var':'install_path','inst_dir':'install_path','feature':'features',}
class register_obj(type):
def __init__(cls,name,bases,dict):
super(register_obj,cls).__init__(name,bases,dict)
name=cls.__name__
suffix='_taskgen'
if name.endswith(suffix):
task_gen.classes[name.replace(suffix,'')]=cls
class task_gen(object):
__metaclass__=register_obj
mappings={}
mapped={}
prec=Utils.DefaultDict(list)
traits=Utils.DefaultDict(set)
classes={}
def __init__(self,*kw,**kwargs):
self.prec=Utils.DefaultDict(list)
self.source=''
self.target=''
self.meths=[]
self.mappings={}
self.features=list(kw)
self.tasks=[]
self.default_chmod=O644
self.default_install_path=None
self.allnodes=[]
self.bld=kwargs.get('bld',Build.bld)
self.env=self.bld.env.copy()
self.path=self.bld.path
self.name=''
self.idx=self.bld.idx[self.path.id]=self.bld.idx.get(self.path.id,0)+1
for key,val in kwargs.iteritems():
setattr(self,key,val)
self.bld.task_manager.add_task_gen(self)
self.bld.all_task_gen.append(self)
def __str__(self):
return(""%(self.name or self.target,self.__class__.__name__,str(self.path)))
def __setattr__(self,name,attr):
real=typos.get(name,name)
if real!=name:
warn('typo %s -> %s'%(name,real))
if Logs.verbose>0:
traceback.print_stack()
object.__setattr__(self,real,attr)
def to_list(self,value):
if isinstance(value,str):return value.split()
else:return value
def apply(self):
keys=set(self.meths)
self.features=Utils.to_list(self.features)
for x in self.features+['*']:
st=task_gen.traits[x]
if not st:
warn('feature %r does not exist - bind at least one method to it'%x)
keys.update(st)
prec={}
prec_tbl=self.prec or task_gen.prec
for x in prec_tbl:
if x in keys:
prec[x]=prec_tbl[x]
tmp=[]
for a in keys:
for x in prec.values():
if a in x:break
else:
tmp.append(a)
out=[]
while tmp:
e=tmp.pop()
if e in keys:out.append(e)
try:
nlst=prec[e]
except KeyError:
pass
else:
del prec[e]
for x in nlst:
for y in prec:
if x in prec[y]:
break
else:
tmp.append(x)
if prec:raise Utils.WafError("graph has a cycle %s"%str(prec))
out.reverse()
self.meths=out
debug('task_gen: posting %s %d',self,id(self))
for x in out:
try:
v=getattr(self,x)
except AttributeError:
raise Utils.WafError("tried to retrieve %s which is not a valid method"%x)
debug('task_gen: -> %s (%d)',x,id(self))
v()
def post(self):
if not self.name:
if isinstance(self.target,list):
self.name=' '.join(self.target)
else:
self.name=self.target
if getattr(self,'posted',None):
return
self.apply()
debug('task_gen: posted %s',self.name)
self.posted=True
def get_hook(self,ext):
try:return self.mappings[ext]
except KeyError:
try:return task_gen.mappings[ext]
except KeyError:return None
def create_task(self,name,src=None,tgt=None,env=None):
env=env or self.env
task=Task.TaskBase.classes[name](env.copy(),generator=self)
if src:
task.set_inputs(src)
if tgt:
task.set_outputs(tgt)
self.tasks.append(task)
return task
def name_to_obj(self,name):
return self.bld.name_to_obj(name,self.env)
def find_sources_in_dirs(self,dirnames,excludes=[],exts=[]):
err_msg="'%s' attribute must be a list"
if not isinstance(excludes,list):
raise Utils.WscriptError(err_msg%'excludes')
if not isinstance(exts,list):
raise Utils.WscriptError(err_msg%'exts')
lst=[]
dirnames=self.to_list(dirnames)
ext_lst=exts or list(self.mappings.keys())+list(task_gen.mappings.keys())
for name in dirnames:
anode=self.path.find_dir(name)
if not anode or not anode.is_child_of(self.bld.srcnode):
raise Utils.WscriptError("Unable to use '%s' - either because it's not a relative path"", or it's not child of '%s'."%(name,self.bld.srcnode))
self.bld.rescan(anode)
for name in self.bld.cache_dir_contents[anode.id]:
if name.startswith('.'):
continue
(base,ext)=os.path.splitext(name)
if ext in ext_lst and not name in lst and not name in excludes:
lst.append((anode.relpath_gen(self.path)or'.')+os.path.sep+name)
lst.sort()
self.source=self.to_list(self.source)
if not self.source:self.source=lst
else:self.source+=lst
def clone(self,env):
newobj=task_gen(bld=self.bld)
for x in self.__dict__:
if x in['env','bld']:
continue
elif x in["path","features"]:
setattr(newobj,x,getattr(self,x))
else:
setattr(newobj,x,copy.copy(getattr(self,x)))
newobj.__class__=self.__class__
if isinstance(env,str):
newobj.env=self.bld.all_envs[env].copy()
else:
newobj.env=env.copy()
return newobj
def get_inst_path(self):
return getattr(self,'_install_path',getattr(self,'default_install_path',''))
def set_inst_path(self,val):
self._install_path=val
install_path=property(get_inst_path,set_inst_path)
def get_chmod(self):
return getattr(self,'_chmod',getattr(self,'default_chmod',O644))
def set_chmod(self,val):
self._chmod=val
chmod=property(get_chmod,set_chmod)
def declare_extension(var,func):
try:
for x in Utils.to_list(var):
task_gen.mappings[x]=func
except:
raise Utils.WscriptError('declare_extension takes either a list or a string %r'%var)
task_gen.mapped[func.__name__]=func
def declare_order(*k):
assert(len(k)>1)
n=len(k)-1
for i in xrange(n):
f1=k[i]
f2=k[i+1]
if not f1 in task_gen.prec[f2]:
task_gen.prec[f2].append(f1)
def declare_chain(name='',action='',ext_in='',ext_out='',reentrant=True,color='BLUE',install=0,before=[],after=[],decider=None,rule=None,scan=None):
action=action or rule
if isinstance(action,str):
act=Task.simple_task_type(name,action,color=color)
else:
act=Task.task_type_from_func(name,action,color=color)
act.ext_in=tuple(Utils.to_list(ext_in))
act.ext_out=tuple(Utils.to_list(ext_out))
act.before=Utils.to_list(before)
act.after=Utils.to_list(after)
act.scan=scan
def x_file(self,node):
if decider:
ext=decider(self,node)
else:
ext=ext_out
if isinstance(ext,str):
out_source=node.change_ext(ext)
if reentrant:
self.allnodes.append(out_source)
elif isinstance(ext,list):
out_source=[node.change_ext(x)for x in ext]
if reentrant:
for i in xrange((reentrant is True)and len(out_source)or reentrant):
self.allnodes.append(out_source[i])
else:
raise Utils.WafError("do not know how to process %s"%str(ext))
tsk=self.create_task(name,node,out_source)
if node.__class__.bld.is_install:
tsk.install=install
declare_extension(act.ext_in,x_file)
def bind_feature(name,methods):
lst=Utils.to_list(methods)
task_gen.traits[name].update(lst)
def taskgen(func):
setattr(task_gen,func.__name__,func)
return func
def feature(*k):
def deco(func):
setattr(task_gen,func.__name__,func)
for name in k:
task_gen.traits[name].update([func.__name__])
return func
return deco
def before(*k):
def deco(func):
setattr(task_gen,func.__name__,func)
for fun_name in k:
if not func.__name__ in task_gen.prec[fun_name]:
task_gen.prec[fun_name].append(func.__name__)
return func
return deco
def after(*k):
def deco(func):
setattr(task_gen,func.__name__,func)
for fun_name in k:
if not fun_name in task_gen.prec[func.__name__]:
task_gen.prec[func.__name__].append(fun_name)
return func
return deco
def extension(var):
def deco(func):
setattr(task_gen,func.__name__,func)
try:
for x in Utils.to_list(var):
task_gen.mappings[x]=func
except:
raise Utils.WafError('extension takes either a list or a string %r'%var)
task_gen.mapped[func.__name__]=func
return func
return deco
def apply_core(self):
find_resource=self.path.find_resource
for filename in self.to_list(self.source):
x=self.get_hook(filename)
if x:
x(self,filename)
else:
node=find_resource(filename)
if not node:raise Utils.WafError("source not found: '%s' in '%s'"%(filename,str(self.path)))
self.allnodes.append(node)
for node in self.allnodes:
x=self.get_hook(node.suffix())
if not x:
raise Utils.WafError("Cannot guess how to process %s (got mappings %r in %r) -> try conf.check_tool(..)?"%(str(node),self.__class__.mappings.keys(),self.__class__))
x(self,node)
feature('*')(apply_core)
def exec_rule(self):
if not getattr(self,'rule',None):
return
try:
self.meths.remove('apply_core')
except ValueError:
pass
func=self.rule
vars2=[]
if isinstance(func,str):
(func,vars2)=Task.compile_fun('',self.rule,shell=getattr(self,'shell',True))
func.code=self.rule
name=getattr(self,'name',None)or self.target or self.rule
if not isinstance(name,str):
name=str(self.idx)
cls=Task.task_type_from_func(name,func,getattr(self,'vars',vars2))
tsk=self.create_task(name)
dep_vars=getattr(self,'dep_vars',['ruledeps'])
if dep_vars:
tsk.dep_vars=dep_vars
if isinstance(self.rule,str):
tsk.env.ruledeps=self.rule
else:
tsk.env.ruledeps=Utils.h_fun(self.rule)
if getattr(self,'target',None):
cls.quiet=True
tsk.outputs=[self.path.find_or_declare(x)for x in self.to_list(self.target)]
if getattr(self,'source',None):
cls.quiet=True
tsk.inputs=[]
for x in self.to_list(self.source):
y=self.path.find_resource(x)
if not y:
raise Utils.WafError('input file %r could not be found (%r)'%(x,self.path.abspath()))
tsk.inputs.append(y)
if self.allnodes:
tsk.inputs.extend(self.allnodes)
if getattr(self,'scan',None):
cls.scan=self.scan
if getattr(self,'install_path',None):
tsk.install_path=self.install_path
if getattr(self,'cwd',None):
tsk.cwd=self.cwd
if getattr(self,'on_results',None):
Task.update_outputs(cls)
if getattr(self,'always',None):
Task.always_run(cls)
for x in['after','before','ext_in','ext_out']:
setattr(cls,x,getattr(self,x,[]))
feature('*')(exec_rule)
before('apply_core')(exec_rule)
def sequence_order(self):
if self.meths and self.meths[-1]!='sequence_order':
self.meths.append('sequence_order')
return
if getattr(self,'seq_start',None):
return
if getattr(self.bld,'prev',None):
self.bld.prev.post()
for x in self.bld.prev.tasks:
for y in self.tasks:
y.set_run_after(x)
self.bld.prev=self
feature('seq')(sequence_order)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Constants.py 0000644 0001750 0001750 00000001502 11362610130 022277 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
HEXVERSION=0x105016
WAFVERSION="1.5.16"
WAFREVISION="7610:7647M"
ABI=7
O644=420
O755=493
MAXJOBS=99999999
CACHE_DIR='c4che'
CACHE_SUFFIX='.cache.py'
DBFILE='.wafpickle-%d'%ABI
WSCRIPT_FILE='wscript'
WSCRIPT_BUILD_FILE='wscript_build'
WAF_CONFIG_LOG='config.log'
WAF_CONFIG_H='config.h'
SIG_NIL='iluvcuteoverload'
VARIANT='_VARIANT_'
DEFAULT='default'
SRCDIR='srcdir'
BLDDIR='blddir'
APPNAME='APPNAME'
VERSION='VERSION'
DEFINES='defines'
UNDEFINED=()
BREAK="break"
CONTINUE="continue"
JOBCONTROL="JOBCONTROL"
MAXPARALLEL="MAXPARALLEL"
NORMAL="NORMAL"
NOT_RUN=0
MISSING=1
CRASHED=2
EXCEPTION=3
SKIPPED=8
SUCCESS=9
ASK_LATER=-1
SKIP_ME=-2
RUN_ME=-3
LOG_FORMAT="%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
HOUR_FORMAT="%H:%M:%S"
TEST_OK=True
CFG_FILES='cfg_files'
INSTALL=1337
UNINSTALL=-1337
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Configure.py 0000644 0001750 0001750 00000017162 11362610130 022255 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import os,shlex,sys,time
try:import cPickle
except ImportError:import pickle as cPickle
import Environment,Utils,Options,Logs
from Logs import warn
from Constants import*
try:
from urllib import request
except:
from urllib import urlopen
else:
urlopen=request.urlopen
conf_template='''# project %(app)s configured on %(now)s by
# waf %(wafver)s (abi %(abi)s, python %(pyver)x on %(systype)s)
# using %(args)s
#
'''
class ConfigurationError(Utils.WscriptError):
pass
autoconfig=False
def find_file(filename,path_list):
for directory in Utils.to_list(path_list):
if os.path.exists(os.path.join(directory,filename)):
return directory
return''
def find_program_impl(env,filename,path_list=[],var=None,environ=None):
if not environ:
environ=os.environ
try:path_list=path_list.split()
except AttributeError:pass
if var:
if env[var]:return env[var]
if var in environ:env[var]=environ[var]
if not path_list:path_list=environ.get('PATH','').split(os.pathsep)
ext=(Options.platform=='win32')and'.exe,.com,.bat,.cmd'or''
for y in[filename+x for x in ext.split(',')]:
for directory in path_list:
x=os.path.join(directory,y)
if os.path.isfile(x):
if var:env[var]=x
return x
return''
class ConfigurationContext(Utils.Context):
tests={}
error_handlers=[]
def __init__(self,env=None,blddir='',srcdir=''):
self.env=None
self.envname=''
self.environ=dict(os.environ)
self.line_just=40
self.blddir=blddir
self.srcdir=srcdir
self.all_envs={}
self.cwd=self.curdir=os.getcwd()
self.tools=[]
self.setenv(DEFAULT)
self.lastprog=''
self.hash=0
self.files=[]
self.tool_cache=[]
if self.blddir:
self.post_init()
def post_init(self):
self.cachedir=os.path.join(self.blddir,CACHE_DIR)
path=os.path.join(self.blddir,WAF_CONFIG_LOG)
try:os.unlink(path)
except(OSError,IOError):pass
try:
self.log=open(path,'w')
except(OSError,IOError):
self.fatal('could not open %r for writing'%path)
app=Utils.g_module.APPNAME
if app:
ver=getattr(Utils.g_module,'VERSION','')
if ver:
app="%s (%s)"%(app,ver)
now=time.ctime()
pyver=sys.hexversion
systype=sys.platform
args=" ".join(sys.argv)
wafver=WAFVERSION
abi=ABI
self.log.write(conf_template%vars())
def __del__(self):
if hasattr(self,'log')and self.log:
self.log.close()
def fatal(self,msg):
raise ConfigurationError(msg)
def check_tool(self,input,tooldir=None,funs=None):
tools=Utils.to_list(input)
if tooldir:tooldir=Utils.to_list(tooldir)
for tool in tools:
tool=tool.replace('++','xx')
if tool=='java':tool='javaw'
if tool.lower()=='unittest':tool='unittestw'
mag=(tool,id(self.env),funs)
if mag in self.tool_cache:
continue
self.tool_cache.append(mag)
if not tooldir:
_Tools=Options.tooldir[0]
_3rdparty=os.sep.join((_Tools,'..','3rdparty'))
for d in(_Tools,_3rdparty):
lst=os.listdir(d)
if tool+'.py'in lst:
break
else:
for x in Utils.to_list(Options.remote_repo):
for sub in['branches/waf-%s/wafadmin/3rdparty'%WAFVERSION,'trunk/wafadmin/3rdparty']:
url='/'.join((x,sub,tool+'.py'))
try:
web=urlopen(url)
if web.getcode()!=200:
continue
except Exception,e:
continue
else:
try:
loc=open(_3rdparty+os.sep+tool+'.py','wb')
loc.write(web.read())
web.close()
finally:
loc.close()
Logs.warn('downloaded %s from %s'%(tool,url))
else:
break
module=Utils.load_tool(tool,tooldir)
if funs is not None:
self.eval_rules(funs)
else:
func=getattr(module,'detect',None)
if func:
if type(func)is type(find_file):func(self)
else:self.eval_rules(func)
self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
def sub_config(self,k):
self.recurse(k,name='configure')
def pre_recurse(self,name_or_mod,path,nexdir):
return{'conf':self,'ctx':self}
def post_recurse(self,name_or_mod,path,nexdir):
if not autoconfig:
return
self.hash=hash((self.hash,getattr(name_or_mod,'waf_hash_val',name_or_mod)))
self.files.append(path)
def store(self,file=''):
if not os.path.isdir(self.cachedir):
os.makedirs(self.cachedir)
if not file:
file=open(os.path.join(self.cachedir,'build.config.py'),'w')
file.write('version = 0x%x\n'%HEXVERSION)
file.write('tools = %r\n'%self.tools)
file.close()
if not self.all_envs:
self.fatal('nothing to store in the configuration context!')
for key in self.all_envs:
tmpenv=self.all_envs[key]
tmpenv.store(os.path.join(self.cachedir,key+CACHE_SUFFIX))
def set_env_name(self,name,env):
self.all_envs[name]=env
return env
def retrieve(self,name,fromenv=None):
try:
env=self.all_envs[name]
except KeyError:
env=Environment.Environment()
env['PREFIX']=os.path.abspath(os.path.expanduser(Options.options.prefix))
self.all_envs[name]=env
else:
if fromenv:warn("The environment %s may have been configured already"%name)
return env
def setenv(self,name):
self.env=self.retrieve(name)
self.envname=name
def add_os_flags(self,var,dest=None):
try:self.env.append_value(dest or var,Utils.to_list(self.environ[var]))
except KeyError:pass
def check_message_1(self,sr):
self.line_just=max(self.line_just,len(sr))
for x in('\n',self.line_just*'-','\n',sr,'\n'):
self.log.write(x)
Utils.pprint('NORMAL',"%s :"%sr.ljust(self.line_just),sep='')
def check_message_2(self,sr,color='GREEN'):
self.log.write(sr)
self.log.write('\n')
Utils.pprint(color,sr)
def check_message(self,th,msg,state,option=''):
sr='Checking for %s %s'%(th,msg)
self.check_message_1(sr)
p=self.check_message_2
if state:p('ok '+str(option))
else:p('not found','YELLOW')
def check_message_custom(self,th,msg,custom,option='',color='PINK'):
sr='Checking for %s %s'%(th,msg)
self.check_message_1(sr)
self.check_message_2(custom,color)
def find_program(self,filename,path_list=[],var=None,mandatory=False):
ret=None
if var:
if self.env[var]:
ret=self.env[var]
elif var in os.environ:
ret=os.environ[var]
if not isinstance(filename,list):filename=[filename]
if not ret:
for x in filename:
ret=find_program_impl(self.env,x,path_list,var,environ=self.environ)
if ret:break
self.check_message_1('Checking for program %s'%' or '.join(filename))
self.log.write(' find program=%r paths=%r var=%r\n -> %r\n'%(filename,path_list,var,ret))
if ret:
Utils.pprint('GREEN',str(ret))
else:
Utils.pprint('YELLOW','not found')
if mandatory:
self.fatal('The program %r is required'%filename)
if var:
self.env[var]=ret
return ret
def cmd_to_list(self,cmd):
if isinstance(cmd,str)and cmd.find(' '):
try:
os.stat(cmd)
except OSError:
return shlex.split(cmd)
else:
return[cmd]
return cmd
def __getattr__(self,name):
r=self.__class__.__dict__.get(name,None)
if r:return r
if name and name.startswith('require_'):
for k in['check_','find_']:
n=name.replace('require_',k)
ret=self.__class__.__dict__.get(n,None)
if ret:
def run(*k,**kw):
r=ret(self,*k,**kw)
if not r:
self.fatal('requirement failure')
return r
return run
self.fatal('No such method %r'%name)
def eval_rules(self,rules):
self.rules=Utils.to_list(rules)
for x in self.rules:
f=getattr(self,x)
if not f:self.fatal("No such method '%s'."%x)
try:
f()
except Exception,e:
ret=self.err_handler(x,e)
if ret==BREAK:
break
elif ret==CONTINUE:
continue
else:
self.fatal(e)
def err_handler(self,fun,error):
pass
def conf(f):
setattr(ConfigurationContext,f.__name__,f)
return f
def conftest(f):
ConfigurationContext.tests[f.__name__]=f
return conf(f)
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/ansiterm.py 0000644 0001750 0001750 00000014301 11336610525 022157 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys,os
try:
if(not sys.stderr.isatty())or(not sys.stdout.isatty()):
raise ValueError('not a tty')
from ctypes import*
class COORD(Structure):
_fields_=[("X",c_short),("Y",c_short)]
class SMALL_RECT(Structure):
_fields_=[("Left",c_short),("Top",c_short),("Right",c_short),("Bottom",c_short)]
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_=[("Size",COORD),("CursorPosition",COORD),("Attributes",c_short),("Window",SMALL_RECT),("MaximumWindowSize",COORD)]
class CONSOLE_CURSOR_INFO(Structure):
_fields_=[('dwSize',c_ulong),('bVisible',c_int)]
sbinfo=CONSOLE_SCREEN_BUFFER_INFO()
csinfo=CONSOLE_CURSOR_INFO()
hconsole=windll.kernel32.GetStdHandle(-11)
windll.kernel32.GetConsoleScreenBufferInfo(hconsole,byref(sbinfo))
if sbinfo.Size.X<10 or sbinfo.Size.Y<10:raise Exception('small console')
windll.kernel32.GetConsoleCursorInfo(hconsole,byref(csinfo))
except Exception:
pass
else:
import re,threading
to_int=lambda number,default:number and int(number)or default
wlock=threading.Lock()
STD_OUTPUT_HANDLE=-11
STD_ERROR_HANDLE=-12
class AnsiTerm(object):
def __init__(self):
self.hconsole=windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
self.cursor_history=[]
def screen_buffer_info(self):
sbinfo=CONSOLE_SCREEN_BUFFER_INFO()
windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole,byref(sbinfo))
return sbinfo
def clear_line(self,param):
mode=param and int(param)or 0
sbinfo=self.screen_buffer_info()
if mode==1:
line_start=COORD(0,sbinfo.CursorPosition.Y)
line_length=sbinfo.Size.X
elif mode==2:
line_start=COORD(sbinfo.CursorPosition.X,sbinfo.CursorPosition.Y)
line_length=sbinfo.Size.X-sbinfo.CursorPosition.X
else:
line_start=sbinfo.CursorPosition
line_length=sbinfo.Size.X-sbinfo.CursorPosition.X
chars_written=c_int()
windll.kernel32.FillConsoleOutputCharacterA(self.hconsole,c_char(' '),line_length,line_start,byref(chars_written))
windll.kernel32.FillConsoleOutputAttribute(self.hconsole,sbinfo.Attributes,line_length,line_start,byref(chars_written))
def clear_screen(self,param):
mode=to_int(param,0)
sbinfo=self.screen_buffer_info()
if mode==1:
clear_start=COORD(0,0)
clear_length=sbinfo.CursorPosition.X*sbinfo.CursorPosition.Y
elif mode==2:
clear_start=COORD(0,0)
clear_length=sbinfo.Size.X*sbinfo.Size.Y
windll.kernel32.SetConsoleCursorPosition(self.hconsole,clear_start)
else:
clear_start=sbinfo.CursorPosition
clear_length=((sbinfo.Size.X-sbinfo.CursorPosition.X)+sbinfo.Size.X*(sbinfo.Size.Y-sbinfo.CursorPosition.Y))
chars_written=c_int()
windll.kernel32.FillConsoleOutputCharacterA(self.hconsole,c_char(' '),clear_length,clear_start,byref(chars_written))
windll.kernel32.FillConsoleOutputAttribute(self.hconsole,sbinfo.Attributes,clear_length,clear_start,byref(chars_written))
def push_cursor(self,param):
sbinfo=self.screen_buffer_info()
self.cursor_history.push(sbinfo.CursorPosition)
def pop_cursor(self,param):
if self.cursor_history:
old_pos=self.cursor_history.pop()
windll.kernel32.SetConsoleCursorPosition(self.hconsole,old_pos)
def set_cursor(self,param):
x,sep,y=param.partition(';')
x=to_int(x,1)-1
y=to_int(y,1)-1
sbinfo=self.screen_buffer_info()
new_pos=COORD(min(max(0,x),sbinfo.Size.X),min(max(0,y),sbinfo.Size.Y))
windll.kernel32.SetConsoleCursorPosition(self.hconsole,new_pos)
def set_column(self,param):
x=to_int(param,1)-1
sbinfo=self.screen_buffer_info()
new_pos=COORD(min(max(0,x),sbinfo.Size.X),sbinfo.CursorPosition.Y)
windll.kernel32.SetConsoleCursorPosition(self.hconsole,new_pos)
def move_cursor(self,x_offset=0,y_offset=0):
sbinfo=self.screen_buffer_info()
new_pos=COORD(min(max(0,sbinfo.CursorPosition.X+x_offset),sbinfo.Size.X),min(max(0,sbinfo.CursorPosition.Y+y_offset),sbinfo.Size.Y))
windll.kernel32.SetConsoleCursorPosition(self.hconsole,new_pos)
def move_up(self,param):
self.move_cursor(y_offset=-to_int(param,1))
def move_down(self,param):
self.move_cursor(y_offset=to_int(param,1))
def move_left(self,param):
self.move_cursor(x_offset=-to_int(param,1))
def move_right(self,param):
self.move_cursor(x_offset=to_int(param,1))
def next_line(self,param):
sbinfo=self.screen_buffer_info()
self.move_cursor(x_offset=-sbinfo.CursorPosition.X,y_offset=to_int(param,1))
def prev_line(self,param):
sbinfo=self.screen_buffer_info()
self.move_cursor(x_offset=-sbinfo.CursorPosition.X,y_offset=-to_int(param,1))
escape_to_color={(0,30):0x0,(0,31):0x4,(0,32):0x2,(0,33):0x4+0x2,(0,34):0x1,(0,35):0x1+0x4,(0,36):0x2+0x4,(0,37):0x1+0x2+0x4,(1,30):0x1+0x2+0x4,(1,31):0x4+0x8,(1,32):0x2+0x8,(1,33):0x4+0x2+0x8,(1,34):0x1+0x8,(1,35):0x1+0x4+0x8,(1,36):0x1+0x2+0x8,(1,37):0x1+0x2+0x4+0x8,}
def set_color(self,param):
intensity,sep,color=param.partition(';')
intensity=to_int(intensity,0)
color=to_int(color,0)
if intensity and not color:
color,intensity=intensity,color
attrib=self.escape_to_color.get((intensity,color),0x7)
windll.kernel32.SetConsoleTextAttribute(self.hconsole,attrib)
def show_cursor(self,param):
csinfo.bVisible=1
windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref(csinfo))
def hide_cursor(self,param):
csinfo.bVisible=0
windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref(csinfo))
ansi_command_table={'A':move_up,'B':move_down,'C':move_right,'D':move_left,'E':next_line,'F':prev_line,'G':set_column,'H':set_cursor,'f':set_cursor,'J':clear_screen,'K':clear_line,'h':show_cursor,'l':hide_cursor,'m':set_color,'s':push_cursor,'u':pop_cursor,}
ansi_tokans=re.compile('(?:\x1b\[([0-9?;]*)([a-zA-Z])|([^\x1b]+))')
def write(self,text):
wlock.acquire()
for param,cmd,txt in self.ansi_tokans.findall(text):
if cmd:
cmd_func=self.ansi_command_table.get(cmd)
if cmd_func:
cmd_func(self,param)
else:
chars_written=c_int()
if isinstance(txt,unicode):
windll.kernel32.WriteConsoleW(self.hconsole,txt,len(txt),byref(chars_written),None)
else:
windll.kernel32.WriteConsoleA(self.hconsole,txt,len(txt),byref(chars_written),None)
wlock.release()
def flush(self):
pass
def isatty(self):
return True
sys.stderr=sys.stdout=AnsiTerm()
os.environ['TERM']='vt100'
thunar-dropbox-plugin-0.2.1+dfsg1/wafadmin/Runner.py 0000644 0001750 0001750 00000007463 11353731254 021623 0 ustar unit193 unit193 #! /usr/bin/env python
# encoding: utf-8
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import sys,random,time,threading,traceback
try:from Queue import Queue
except ImportError:from queue import Queue
import Build,Utils,Logs,Options
from Logs import debug,error
from Constants import*
GAP=15
run_old=threading.Thread.run
def run(*args,**kwargs):
try:
run_old(*args,**kwargs)
except(KeyboardInterrupt,SystemExit):
raise
except:
sys.excepthook(*sys.exc_info())
threading.Thread.run=run
class TaskConsumer(threading.Thread):
ready=Queue(0)
consumers=[]
def __init__(self):
threading.Thread.__init__(self)
self.setDaemon(1)
self.start()
def run(self):
try:
self.loop()
except:
pass
def loop(self):
while 1:
tsk=TaskConsumer.ready.get()
m=tsk.master
if m.stop:
m.out.put(tsk)
continue
try:
tsk.generator.bld.printout(tsk.display())
if tsk.__class__.stat:ret=tsk.__class__.stat(tsk)
else:ret=tsk.call_run()
except Exception,e:
tsk.err_msg=Utils.ex_stack()
tsk.hasrun=EXCEPTION
m.error_handler(tsk)
m.out.put(tsk)
continue
if ret:
tsk.err_code=ret
tsk.hasrun=CRASHED
else:
try:
tsk.post_run()
except Utils.WafError:
pass
except Exception:
tsk.err_msg=Utils.ex_stack()
tsk.hasrun=EXCEPTION
else:
tsk.hasrun=SUCCESS
if tsk.hasrun!=SUCCESS:
m.error_handler(tsk)
m.out.put(tsk)
class Parallel(object):
def __init__(self,bld,j=2):
self.numjobs=j
self.manager=bld.task_manager
self.manager.current_group=0
self.total=self.manager.total()
self.outstanding=[]
self.maxjobs=MAXJOBS
self.frozen=[]
self.out=Queue(0)
self.count=0
self.processed=1
self.stop=False
self.error=False
def get_next(self):
if not self.outstanding:
return None
return self.outstanding.pop(0)
def postpone(self,tsk):
if random.randint(0,1):
self.frozen.insert(0,tsk)
else:
self.frozen.append(tsk)
def refill_task_list(self):
while self.count>self.numjobs+GAP or self.count>=self.maxjobs:
self.get_out()
while not self.outstanding:
if self.count:
self.get_out()
if self.frozen:
self.outstanding+=self.frozen
self.frozen=[]
elif not self.count:
(jobs,tmp)=self.manager.get_next_set()
if jobs!=None:self.maxjobs=jobs
if tmp:self.outstanding+=tmp
break
def get_out(self):
ret=self.out.get()
self.manager.add_finished(ret)
if not self.stop and getattr(ret,'more_tasks',None):
self.outstanding+=ret.more_tasks
self.total+=len(ret.more_tasks)
self.count-=1
def error_handler(self,tsk):
if not Options.options.keep:
self.stop=True
self.error=True
def start(self):
if TaskConsumer.consumers:
while len(TaskConsumer.consumers)