From: david-sarah Date: Sun, 26 Dec 2010 02:05:08 +0000 (-0800) Subject: Remove unmaintained Mac GUI app. fixes #1282 X-Git-Url: https://git.rkrishnan.org/vdrive/%5B/%5D%20/COPYING.TGPPL.html?a=commitdiff_plain;h=195ddbcf7cde56d0af05a51cc498ea59f5810c08;p=tahoe-lafs%2Ftahoe-lafs.git Remove unmaintained Mac GUI app. fixes #1282 --- diff --git a/mac/COPYING.LGPL2 b/mac/COPYING.LGPL2 deleted file mode 100644 index 81f3c11a..00000000 --- a/mac/COPYING.LGPL2 +++ /dev/null @@ -1,170 +0,0 @@ -mac/fuse.py and mac/fuseparts/subbedopts.py are also available (at your option) under LGPL2 as well as under GPL2+|TGPPL1+ - -GNU Lesser General Public License - -Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - - (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - - These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - - Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - - In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -END OF TERMS AND CONDITIONS -How to Apply These Terms to Your New Libraries -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - signature of Ty Coon, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/mac/Makefile b/mac/Makefile deleted file mode 100644 index 47855fc7..00000000 --- a/mac/Makefile +++ /dev/null @@ -1,39 +0,0 @@ - -.PHONY: all dist build diskimage upload cleanup clean - -all: build - -dist: build diskimage upload cleanup - -build: - rsync -av ` sw_vers -productVersion | sed -e 's/^\(10\.[0-9]*\)\..*$$/\1/' `/ ./ - ln -sf ../contrib/fuse/impl_c/blackmatch.py tahoefuse.py - python setup.py py2app --no-chdir - -diskimage: - mv dist Allmydata-$(VERSION) - hdiutil create -ov -srcfolder Allmydata-$(VERSION) allmydata-rw.dmg - hdiutil convert -ov allmydata-rw.dmg -format UDRO -o allmydata-ro.dmg - hdiutil convert -ov allmydata-ro.dmg -format UDZO -o Allmydata-$(VERSION).dmg - hdiutil internet-enable -yes Allmydata-$(VERSION).dmg - rm -r Allmydata-$(VERSION) allmydata-rw.dmg allmydata-ro.dmg - -ifdef UPLOAD_DEST_FURLFILE -# N.B.: xfer-client.py requires foolscap, so we hack up PYTHONPATH to improve -# the chances of finding it (using the one that we just built) -# broken. To fix this just use flappclient. --Zooko 2010-06-06 -upload: - chmod a+r Allmydata-$(VERSION).dmg - PYTHONPATH=$(PYTHONPATH):../support/lib/python2.5/site-packages \ - python ../misc/xfer-client.py --furlfile $(UPLOAD_DEST_FURLFILE) \ - Allmydata-$(VERSION).dmg -else -upload: - $(error UPLOAD_DEST_FURLFILE must be set when using upload target. e.g. make upload UPLOAD_DEST_FURLFILE=~/.upload.furl) -endif - -cleanup: - rm Allmydata-$(VERSION).dmg - -clean: - rm -rf build dist diff --git a/mac/README.txt b/mac/README.txt deleted file mode 100644 index 4bf96459..00000000 --- a/mac/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -2009-02-07: - -Zooko wrote this what is in this directory after asking RobK about it: - -wxpython trappings to build a .app bundle which is both a gui app and (when launching the binary from within the .app bundle) a functioning bin/tahoe binary including "tahoe fuse" subcommand - diff --git a/mac/allmydata.icns b/mac/allmydata.icns deleted file mode 100644 index f1f21852..00000000 Binary files a/mac/allmydata.icns and /dev/null differ diff --git a/mac/allmydata_tahoe.py b/mac/allmydata_tahoe.py deleted file mode 100644 index a21fc796..00000000 --- a/mac/allmydata_tahoe.py +++ /dev/null @@ -1,58 +0,0 @@ -from allmydata.util import pkgresutil # override the pkg_resources zip provider for py2app deployment -pkgresutil.install() # this is done before nevow is imported by depends -import depends # import dependencies so that py2exe finds them -_junk = depends # appease pyflakes - -import sys - -from twisted.python import usage - -class ReplOptions(usage.Options): - pass - -def repl(config, stdout, stderr): - import code - return code.interact() - -class DbgRunnerExtension(object): - subCommands = [ - ["dbgrepl", None, ReplOptions, "Open a python interpreter"], - ] - dispatch = { - "dbgrepl": repl, - } - -class FuseOptions(usage.Options): - def parseOptions(self, args): - self.args = args - -def fuse(config, stdout, stderr): - import tahoefuse - tahoefuse.main(config.args) - -class FuseRunnerExtension(object): - subCommands = [ - ["fuse", None, FuseOptions, "Mount a filesystem via fuse"], - ] - dispatch = { - "fuse": fuse, - } - -def main(argv): - if len(argv) == 1: - # then we were given no args; do default mac node startup - from allmydata.gui.macapp import run_macapp - sys.exit(run_macapp()) - else: - # given any cmd line args, do 'tahoe' cli behaviour - from allmydata.scripts import runner - #runner_extensions = [DbgRunnerExtension, FuseRunnerExtension, ] - runner_extensions = [FuseRunnerExtension, ] - sys.exit(runner.runner(argv[1:], - install_node_control=False, - additional_commands=runner_extensions, - )) - -if __name__ == '__main__': - main(sys.argv) - diff --git a/mac/depends.py b/mac/depends.py deleted file mode 100644 index 341b41b7..00000000 --- a/mac/depends.py +++ /dev/null @@ -1,36 +0,0 @@ - -# nevow requires all these for its voodoo module import time adaptor registrations -from nevow import accessors, appserver, static, rend, url, util, query, i18n, flat -from nevow import guard, stan, testutil, context -from nevow.flat import flatmdom, flatstan, twist -from formless import webform, processors, annotate, iformless -from decimal import Decimal - - -#if sys.platform in ['darwin', ]: -from nevow.flat import flatsax -from xml.parsers import expat -from xml.sax import expatreader -junk = [ flatsax, expat, expatreader, ] - -try: - # these build hints are needed for nevow/xml on otto's 10.4 / py2.4 - # environment. they are broken on zandr's 10.5/py2.5 env, but are - # also unnecessary. - from xml.sax import sax2exts - from xml.sax.drivers2 import drv_pyexpat, drv_xmlproc - junk = [ sax2exts, drv_pyexpat, drv_xmlproc, ] -except: - pass - - - -import allmydata.web - -# junk to appease pyflakes's outrage at py2exe's needs -junk = [ - accessors, appserver, static, rend, url, util, query, i18n, flat, guard, stan, testutil, - context, flatmdom, flatstan, twist, webform, processors, annotate, iformless, Decimal, - allmydata, - ] - diff --git a/mac/fuse.py b/mac/fuse.py deleted file mode 100644 index ff71bf72..00000000 --- a/mac/fuse.py +++ /dev/null @@ -1,1000 +0,0 @@ -# -# Copyright (C) 2001 Jeff Epler -# Copyright (C) 2006 Csaba Henk -# -# This program can be distributed under the terms of the GNU LGPL. -# See the file COPYING. -# -# On 2009-09-21 Csaba Henk granted permission for this file to be -# licensed under the same terms as Tahoe-LAFS itself. -# - - -# suppress version mismatch warnings -try: - import warnings - warnings.filterwarnings('ignore', - 'Python C API version mismatch', - RuntimeWarning, - ) -except: - pass - -from string import join -import sys -from errno import * -from os import environ -import re -from fuseparts import __version__ -from fuseparts._fuse import main, FuseGetContext, FuseInvalidate -from fuseparts._fuse import FuseError, FuseAPIVersion -from fuseparts.subbedopts import SubOptsHive, SubbedOptFormatter -from fuseparts.subbedopts import SubbedOptIndentedFormatter, SubbedOptParse -from fuseparts.subbedopts import SUPPRESS_HELP, OptParseError -from fuseparts.setcompatwrap import set - - -########## -### -### API specification API. -### -########## - -# The actual API version of this module -FUSE_PYTHON_API_VERSION = (0, 2) - -def __getenv__(var, pattern = '.', trans = lambda x: x): - """ - Fetch enviroment variable and optionally transform it. Return `None` if - variable is unset. Bail out if value of variable doesn't match (optional) - regex pattern. - """ - - if var not in environ: - return None - val = environ[var] - rpat = pattern - if not isinstance(rpat, type(re.compile(''))): - rpat = re.compile(rpat) - if not rpat.search(val): - raise RuntimeError("env var %s doesn't match required pattern %s" % \ - (var, `pattern`)) - return trans(val) - -def get_fuse_python_api(): - if fuse_python_api: - return fuse_python_api - elif compat_0_1: - # deprecated way of API specification - return (0,1) - -def get_compat_0_1(): - return get_fuse_python_api() == (0, 1) - -# API version to be used -fuse_python_api = __getenv__('FUSE_PYTHON_API', '^[\d.]+$', - lambda x: tuple([int(i) for i in x.split('.')])) - -# deprecated way of API specification -compat_0_1 = __getenv__('FUSE_PYTHON_COMPAT', '^(0.1|ALL)$', lambda x: True) - -fuse_python_api = get_fuse_python_api() - -########## -### -### Parsing for FUSE. -### -########## - - - -class FuseArgs(SubOptsHive): - """ - Class representing a FUSE command line. - """ - - fuse_modifiers = {'showhelp': '-ho', - 'showversion': '-V', - 'foreground': '-f'} - - def __init__(self): - - SubOptsHive.__init__(self) - - self.modifiers = {} - self.mountpoint = None - - for m in self.fuse_modifiers: - self.modifiers[m] = False - - def __str__(self): - return '\n'.join(['< on ' + str(self.mountpoint) + ':', - ' ' + str(self.modifiers), ' -o ']) + \ - ',\n '.join(self._str_core()) + \ - ' >' - - def getmod(self, mod): - return self.modifiers[mod] - - def setmod(self, mod): - self.modifiers[mod] = True - - def unsetmod(self, mod): - self.modifiers[mod] = False - - def mount_expected(self): - if self.getmod('showhelp'): - return False - if self.getmod('showversion'): - return False - return True - - def assemble(self): - """Mangle self into an argument array""" - - self.canonify() - args = [sys.argv and sys.argv[0] or "python"] - if self.mountpoint: - args.append(self.mountpoint) - for m, v in self.modifiers.iteritems(): - if v: - args.append(self.fuse_modifiers[m]) - - opta = [] - for o, v in self.optdict.iteritems(): - opta.append(o + '=' + v) - opta.extend(self.optlist) - - if opta: - args.append("-o" + ",".join(opta)) - - return args - - def filter(self, other=None): - """ - Same as for SubOptsHive, with the following difference: - if other is not specified, `Fuse.fuseoptref()` is run and its result - will be used. - """ - - if not other: - other = Fuse.fuseoptref() - - return SubOptsHive.filter(self, other) - - - -class FuseFormatter(SubbedOptIndentedFormatter): - - def __init__(self, **kw): - if not 'indent_increment' in kw: - kw['indent_increment'] = 4 - SubbedOptIndentedFormatter.__init__(self, **kw) - - def store_option_strings(self, parser): - SubbedOptIndentedFormatter.store_option_strings(self, parser) - # 27 is how the lib stock help appears - self.help_position = max(self.help_position, 27) - self.help_width = self.width - self.help_position - - -class FuseOptParse(SubbedOptParse): - """ - This class alters / enhances `SubbedOptParse` so that it's - suitable for usage with FUSE. - - - When adding options, you can use the `mountopt` pseudo-attribute which - is equivalent with adding a subopt for option ``-o`` - (it doesn't require an option argument). - - - FUSE compatible help and version printing. - - - Error and exit callbacks are relaxed. In case of FUSE, the command - line is to be treated as a DSL [#]_. You don't wanna this module to - force an exit on you just because you hit a DSL syntax error. - - - Built-in support for conventional FUSE options (``-d``, ``-f`, ``-s``). - The way of this can be tuned by keyword arguments, see below. - - .. [#] http://en.wikipedia.org/wiki/Domain-specific_programming_language - - Keyword arguments for initialization - ------------------------------------ - - standard_mods - Boolean [default is `True`]. - Enables support for the usual interpretation of the ``-d``, ``-f`` - options. - - fetch_mp - Boolean [default is `True`]. - If it's True, then the last (non-option) argument - (if there is such a thing) will be used as the FUSE mountpoint. - - dash_s_do - String: ``whine``, ``undef``, or ``setsingle`` [default is ``whine``]. - The ``-s`` option -- traditionally for asking for single-threadedness -- - is an oddball: single/multi threadedness of a fuse-py fs doesn't depend - on the FUSE command line, we have direct control over it. - - Therefore we have two conflicting principles: - - - *Orthogonality*: option parsing shouldn't affect the backing `Fuse` - instance directly, only via its `fuse_args` attribute. - - - *POLS*: behave like other FUSE based fs-es do. The stock FUSE help - makes mention of ``-s`` as a single-threadedness setter. - - So, if we follow POLS and implement a conventional ``-s`` option, then - we have to go beyond the `fuse_args` attribute and set the respective - Fuse attribute directly, hence violating orthogonality. - - We let the fs authors make their choice: ``dash_s_do=undef`` leaves this - option unhandled, and the fs author can add a handler as she desires. - ``dash_s_do=setsingle`` enables the traditional behaviour. - - Using ``dash_s_do=setsingle`` is not problematic at all, but we want fs - authors be aware of the particularity of ``-s``, therefore the default is - the ``dash_s_do=whine`` setting which raises an exception for ``-s`` and - suggests the user to read this documentation. - - dash_o_handler - Argument should be a SubbedOpt instance (created with - ``action="store_hive"`` if you want it to be useful). - This lets you customize the handler of the ``-o`` option. For example, - you can alter or suppress the generic ``-o`` entry in help output. - """ - - def __init__(self, *args, **kw): - - self.mountopts = [] - - self.fuse_args = \ - 'fuse_args' in kw and kw.pop('fuse_args') or FuseArgs() - dsd = 'dash_s_do' in kw and kw.pop('dash_s_do') or 'whine' - if 'fetch_mp' in kw: - self.fetch_mp = bool(kw.pop('fetch_mp')) - else: - self.fetch_mp = True - if 'standard_mods' in kw: - smods = bool(kw.pop('standard_mods')) - else: - smods = True - if 'fuse' in kw: - self.fuse = kw.pop('fuse') - if not 'formatter' in kw: - kw['formatter'] = FuseFormatter() - doh = 'dash_o_handler' in kw and kw.pop('dash_o_handler') - - SubbedOptParse.__init__(self, *args, **kw) - - if doh: - self.add_option(doh) - else: - self.add_option('-o', action='store_hive', - subopts_hive=self.fuse_args, help="mount options", - metavar="opt,[opt...]") - - if smods: - self.add_option('-f', action='callback', - callback=lambda *a: self.fuse_args.setmod('foreground'), - help=SUPPRESS_HELP) - self.add_option('-d', action='callback', - callback=lambda *a: self.fuse_args.add('debug'), - help=SUPPRESS_HELP) - - if dsd == 'whine': - def dsdcb(option, opt_str, value, parser): - raise RuntimeError, """ - -! If you want the "-s" option to work, pass -! -! dash_s_do='setsingle' -! -! to the Fuse constructor. See docstring of the FuseOptParse class for an -! explanation why is it not set by default. -""" - - elif dsd == 'setsingle': - def dsdcb(option, opt_str, value, parser): - self.fuse.multithreaded = False - - elif dsd == 'undef': - dsdcb = None - else: - raise ArgumentError, "key `dash_s_do': uninterpreted value " + str(dsd) - - if dsdcb: - self.add_option('-s', action='callback', callback=dsdcb, - help=SUPPRESS_HELP) - - - def exit(self, status=0, msg=None): - if msg: - sys.stderr.write(msg) - - def error(self, msg): - SubbedOptParse.error(self, msg) - raise OptParseError, msg - - def print_help(self, file=sys.stderr): - SubbedOptParse.print_help(self, file) - print >> file - self.fuse_args.setmod('showhelp') - - def print_version(self, file=sys.stderr): - SubbedOptParse.print_version(self, file) - self.fuse_args.setmod('showversion') - - def parse_args(self, args=None, values=None): - o, a = SubbedOptParse.parse_args(self, args, values) - if a and self.fetch_mp: - self.fuse_args.mountpoint = a.pop() - return o, a - - def add_option(self, *opts, **attrs): - if 'mountopt' in attrs: - if opts or 'subopt' in attrs: - raise OptParseError( - "having options or specifying the `subopt' attribute conflicts with `mountopt' attribute") - opts = ('-o',) - attrs['subopt'] = attrs.pop('mountopt') - if not 'dest' in attrs: - attrs['dest'] = attrs['subopt'] - - SubbedOptParse.add_option(self, *opts, **attrs) - - - -########## -### -### The FUSE interface. -### -########## - - - -class ErrnoWrapper(object): - - def __init__(self, func): - self.func = func - - def __call__(self, *args, **kw): - try: - return apply(self.func, args, kw) - except (IOError, OSError), detail: - # Sometimes this is an int, sometimes an instance... - if hasattr(detail, "errno"): detail = detail.errno - return -detail - - -########### Custom objects for transmitting system structures to FUSE - -class FuseStruct(object): - - def __init__(self, **kw): - for k in kw: - setattr(self, k, kw[k]) - - -class Stat(FuseStruct): - """ - Auxiliary class which can be filled up stat attributes. - The attributes are undefined by default. - """ - - def __init__(self, **kw): - self.st_mode = None - self.st_ino = 0 - self.st_dev = 0 - self.st_nlink = None - self.st_uid = 0 - self.st_gid = 0 - self.st_size = 0 - self.st_atime = 0 - self.st_mtime = 0 - self.st_ctime = 0 - - FuseStruct.__init__(self, **kw) - - -class StatVfs(FuseStruct): - """ - Auxiliary class which can be filled up statvfs attributes. - The attributes are 0 by default. - """ - - def __init__(self, **kw): - - self.f_bsize = 0 - self.f_frsize = 0 - self.f_blocks = 0 - self.f_bfree = 0 - self.f_bavail = 0 - self.f_files = 0 - self.f_ffree = 0 - self.f_favail = 0 - self.f_flag = 0 - self.f_namemax = 0 - - FuseStruct.__init__(self, **kw) - - -class Direntry(FuseStruct): - """ - Auxiliary class for carrying directory entry data. - Initialized with `name`. Further attributes (each - set to 0 as default): - - offset - An integer (or long) parameter, used as a bookmark - during directory traversal. - This needs to be set it you want stateful directory - reading. - - type - Directory entry type, should be one of the stat type - specifiers (stat.S_IFLNK, stat.S_IFBLK, stat.S_IFDIR, - stat.S_IFCHR, stat.S_IFREG, stat.S_IFIFO, stat.S_IFSOCK). - - ino - Directory entry inode number. - - Note that Python's standard directory reading interface is - stateless and provides only names, so the above optional - attributes doesn't make sense in that context. - """ - - def __init__(self, name, **kw): - - self.name = name - self.offset = 0 - self.type = 0 - self.ino = 0 - - FuseStruct.__init__(self, **kw) - - -class Flock(FuseStruct): - """ - Class for representing flock structures (cf. fcntl(3)). - - It makes sense to give values to the `l_type`, `l_start`, - `l_len`, `l_pid` attributes (`l_whence` is not used by - FUSE, see ``fuse.h``). - """ - - def __init__(self, name, **kw): - - self.l_type = None - self.l_start = None - self.l_len = None - self.l_pid = None - - FuseStruct.__init__(self, **kw) - - -class Timespec(FuseStruct): - """ - Cf. struct timespec in time.h: - http://www.opengroup.org/onlinepubs/009695399/basedefs/time.h.html - """ - - def __init__(self, name, **kw): - - self.tv_sec = None - self.tv_nsec = None - - FuseStruct.__init__(self, **kw) - - -class FuseFileInfo(FuseStruct): - - def __init__(self, **kw): - - self.keep = False - self.direct_io = False - - FuseStruct.__init__(self, **kw) - - - -########## Interface for requiring certain features from your underlying FUSE library. - -def feature_needs(*feas): - """ - Get info about the FUSE API version needed for the support of some features. - - This function takes a variable number of feature patterns. - - A feature pattern is either: - - - an integer (directly referring to a FUSE API version number) - - a built-in feature specifier string (meaning defined by dictionary) - - a string of the form ``has_foo``, where ``foo`` is a filesystem method - (refers to the API version where the method has been introduced) - - a list/tuple of other feature patterns (matches each of its members) - - a regexp (meant to be matched against the builtins plus ``has_foo`` - patterns; can also be given by a string of the from "re:*") - - a negated regexp (can be given by a string of the form "!re:*") - - If called with no arguments, then the list of builtins is returned, mapped - to their meaning. - - Otherwise the function returns the smallest FUSE API version number which - has all the matching features. - - Builtin specifiers worth to explicit mention: - - ``stateful_files``: you want to use custom filehandles (eg. a file class). - - ``*``: you want all features. - - while ``has_foo`` makes sense for all filesystem method ``foo``, some - of these can be found among the builtins, too (the ones which can be - handled by the general rule). - - specifiers like ``has_foo`` refer to requirement that the library knows of - the fs method ``foo``. - """ - - fmap = {'stateful_files': 22, - 'stateful_dirs': 23, - 'stateful_io': ('stateful_files', 'stateful_dirs'), - 'stateful_files_keep_cache': 23, - 'stateful_files_direct_io': 23, - 'keep_cache': ('stateful_files_keep_cache',), - 'direct_io': ('stateful_files_direct_io',), - 'has_opendir': ('stateful_dirs',), - 'has_releasedir': ('stateful_dirs',), - 'has_fsyncdir': ('stateful_dirs',), - 'has_create': 25, - 'has_access': 25, - 'has_fgetattr': 25, - 'has_ftruncate': 25, - 'has_fsinit': ('has_init'), - 'has_fsdestroy': ('has_destroy'), - 'has_lock': 26, - 'has_utimens': 26, - 'has_bmap': 26, - 'has_init': 23, - 'has_destroy': 23, - '*': '!re:^\*$'} - - if not feas: - return fmap - - def resolve(args, maxva): - - for fp in args: - if isinstance(fp, int): - maxva[0] = max(maxva[0], fp) - continue - if isinstance(fp, list) or isinstance(fp, tuple): - for f in fp: - yield f - continue - ma = isinstance(fp, str) and re.compile("(!\s*|)re:(.*)").match(fp) - if isinstance(fp, type(re.compile(''))) or ma: - neg = False - if ma: - mag = ma.groups() - fp = re.compile(mag[1]) - neg = bool(mag[0]) - for f in fmap.keys() + [ 'has_' + a for a in Fuse._attrs ]: - if neg != bool(re.search(fp, f)): - yield f - continue - ma = re.compile("has_(.*)").match(fp) - if ma and ma.groups()[0] in Fuse._attrs and not fp in fmap: - yield 21 - continue - yield fmap[fp] - - maxva = [0] - while feas: - feas = set(resolve(feas, maxva)) - - return maxva[0] - - -def APIVersion(): - """Get the API version of your underlying FUSE lib""" - - return FuseAPIVersion() - - -def feature_assert(*feas): - """ - Takes some feature patterns (like in `feature_needs`). - Raises a fuse.FuseError if your underlying FUSE lib fails - to have some of the matching features. - - (Note: use a ``has_foo`` type feature assertion only if lib support - for method ``foo`` is *necessary* for your fs. Don't use this assertion - just because your fs implements ``foo``. The usefulness of ``has_foo`` - is limited by the fact that we can't guarantee that your FUSE kernel - module also supports ``foo``.) - """ - - fav = APIVersion() - - for fea in feas: - fn = feature_needs(fea) - if fav < fn: - raise FuseError( - "FUSE API version %d is required for feature `%s' but only %d is available" % \ - (fn, str(fea), fav)) - - -############# Subclass this. - -class Fuse(object): - """ - Python interface to FUSE. - - Basic usage: - - - instantiate - - - add options to `parser` attribute (an instance of `FuseOptParse`) - - - call `parse` - - - call `main` - """ - - _attrs = ['getattr', 'readlink', 'readdir', 'mknod', 'mkdir', - 'unlink', 'rmdir', 'symlink', 'rename', 'link', 'chmod', - 'chown', 'truncate', 'utime', 'open', 'read', 'write', 'release', - 'statfs', 'fsync', 'create', 'opendir', 'releasedir', 'fsyncdir', - 'flush', 'fgetattr', 'ftruncate', 'getxattr', 'listxattr', - 'setxattr', 'removexattr', 'access', 'lock', 'utimens', 'bmap', - 'fsinit', 'fsdestroy'] - - fusage = "%prog [mountpoint] [options]" - - def __init__(self, *args, **kw): - """ - Not much happens here apart from initializing the `parser` attribute. - Arguments are forwarded to the constructor of the parser class almost - unchanged. - - The parser class is `FuseOptParse` unless you specify one using the - ``parser_class`` keyword. (See `FuseOptParse` documentation for - available options.) - """ - - if not fuse_python_api: - raise RuntimeError, __name__ + """.fuse_python_api not defined. - -! Please define """ + __name__ + """.fuse_python_api internally (eg. -! -! (1) """ + __name__ + """.fuse_python_api = """ + `FUSE_PYTHON_API_VERSION` + """ -! -! ) or in the enviroment (eg. -! -! (2) FUSE_PYTHON_API=0.1 -! -! ). -! -! If you are actually developing a filesystem, probably (1) is the way to go. -! If you are using a filesystem written before 2007 Q2, probably (2) is what -! you want." -""" - - def malformed(): - raise RuntimeError, \ - "malformatted fuse_python_api value " + `fuse_python_api` - if not isinstance(fuse_python_api, tuple): - malformed() - for i in fuse_python_api: - if not isinstance(i, int) or i < 0: - malformed() - - if fuse_python_api > FUSE_PYTHON_API_VERSION: - raise RuntimeError, """ -! You require FUSE-Python API version """ + `fuse_python_api` + """. -! However, the latest available is """ + `FUSE_PYTHON_API_VERSION` + """. -""" - - self.fuse_args = \ - 'fuse_args' in kw and kw.pop('fuse_args') or FuseArgs() - - if get_compat_0_1(): - return self.__init_0_1__(*args, **kw) - - self.multithreaded = True - - if not 'usage' in kw: - kw['usage'] = self.fusage - if not 'fuse_args' in kw: - kw['fuse_args'] = self.fuse_args - kw['fuse'] = self - parserclass = \ - 'parser_class' in kw and kw.pop('parser_class') or FuseOptParse - - self.parser = parserclass(*args, **kw) - self.methproxy = self.Methproxy() - - def parse(self, *args, **kw): - """Parse command line, fill `fuse_args` attribute.""" - - ev = 'errex' in kw and kw.pop('errex') - if ev and not isinstance(ev, int): - raise TypeError, "error exit value should be an integer" - - try: - self.cmdline = self.parser.parse_args(*args, **kw) - except OptParseError: - if ev: - sys.exit(ev) - raise - - return self.fuse_args - - def main(self, args=None): - """Enter filesystem service loop.""" - - if get_compat_0_1(): - args = self.main_0_1_preamble() - - d = {'multithreaded': self.multithreaded and 1 or 0} - d['fuse_args'] = args or self.fuse_args.assemble() - - for t in 'file_class', 'dir_class': - if hasattr(self, t): - getattr(self.methproxy, 'set_' + t)(getattr(self,t)) - - for a in self._attrs: - b = a - if get_compat_0_1() and a in self.compatmap: - b = self.compatmap[a] - if hasattr(self, b): - c = '' - if get_compat_0_1() and hasattr(self, a + '_compat_0_1'): - c = '_compat_0_1' - d[a] = ErrnoWrapper(self.lowwrap(a + c)) - - try: - main(**d) - except FuseError: - if args or self.fuse_args.mount_expected(): - raise - - def lowwrap(self, fname): - """ - Wraps the fname method when the C code expects a different kind of - callback than we have in the fusepy API. (The wrapper is usually for - performing some checks or transfromations which could be done in C but - is simpler if done in Python.) - - Currently `open` and `create` are wrapped: a boolean flag is added - which indicates if the result is to be kept during the opened file's - lifetime or can be thrown away. Namely, it's considered disposable - if it's an instance of FuseFileInfo. - """ - fun = getattr(self, fname) - - if fname in ('open', 'create'): - def wrap(*a, **kw): - res = fun(*a, **kw) - if not res or type(res) == type(0): - return res - else: - return (res, type(res) != FuseFileInfo) - elif fname == 'utimens': - def wrap(path, acc_sec, acc_nsec, mod_sec, mod_nsec): - ts_acc = Timespec(tv_sec = acc_sec, tv_nsec = acc_nsec) - ts_mod = Timespec(tv_sec = mod_sec, tv_nsec = mod_nsec) - return fun(path, ts_acc, ts_mod) - else: - wrap = fun - - return wrap - - def GetContext(self): - return FuseGetContext(self) - - def Invalidate(self, path): - return FuseInvalidate(self, path) - - def fuseoptref(cls): - """ - Find out which options are recognized by the library. - Result is a `FuseArgs` instance with the list of supported - options, suitable for passing on to the `filter` method of - another `FuseArgs` instance. - """ - - import os, re - - pr, pw = os.pipe() - pid = os.fork() - if pid == 0: - os.dup2(pw, 2) - os.close(pr) - - fh = cls() - fh.fuse_args = FuseArgs() - fh.fuse_args.setmod('showhelp') - fh.main() - sys.exit() - - os.close(pw) - - fa = FuseArgs() - ore = re.compile("-o\s+([\w\[\]]+(?:=\w+)?)") - fpr = os.fdopen(pr) - for l in fpr: - m = ore.search(l) - if m: - o = m.groups()[0] - oa = [o] - # try to catch two-in-one options (like "[no]foo") - opa = o.split("[") - if len(opa) == 2: - o1, ox = opa - oxpa = ox.split("]") - if len(oxpa) == 2: - oo, o2 = oxpa - oa = [o1 + o2, o1 + oo + o2] - for o in oa: - fa.add(o) - - fpr.close() - return fa - - fuseoptref = classmethod(fuseoptref) - - - class Methproxy(object): - - def __init__(self): - - class mpx(object): - def __init__(self, name): - self.name = name - def __call__(self, *a, **kw): - return getattr(a[-1], self.name)(*(a[1:-1]), **kw) - - self.proxyclass = mpx - self.mdic = {} - self.file_class = None - self.dir_class = None - - def __call__(self, meth): - return meth in self.mdic and self.mdic[meth] or None - - def _add_class_type(cls, type, inits, proxied): - - def setter(self, xcls): - - setattr(self, type + '_class', xcls) - - for m in inits: - self.mdic[m] = xcls - - for m in proxied: - if hasattr(xcls, m): - self.mdic[m] = self.proxyclass(m) - - setattr(cls, 'set_' + type + '_class', setter) - - _add_class_type = classmethod(_add_class_type) - - Methproxy._add_class_type('file', ('open', 'create'), - ('read', 'write', 'fsync', 'release', 'flush', - 'fgetattr', 'ftruncate', 'lock')) - Methproxy._add_class_type('dir', ('opendir',), - ('readdir', 'fsyncdir', 'releasedir')) - - - def __getattr__(self, meth): - - m = self.methproxy(meth) - if m: - return m - - raise AttributeError, "Fuse instance has no attribute '%s'" % meth - - - -########## -### -### Compat stuff. -### -########## - - - - def __init_0_1__(self, *args, **kw): - - self.flags = 0 - multithreaded = 0 - - # default attributes - if args == (): - # there is a self.optlist.append() later on, make sure it won't - # bomb out. - self.optlist = [] - else: - self.optlist = args - self.optdict = kw - - if len(self.optlist) == 1: - self.mountpoint = self.optlist[0] - else: - self.mountpoint = None - - # grab command-line arguments, if any. - # Those will override whatever parameters - # were passed to __init__ directly. - argv = sys.argv - argc = len(argv) - if argc > 1: - # we've been given the mountpoint - self.mountpoint = argv[1] - if argc > 2: - # we've received mount args - optstr = argv[2] - opts = optstr.split(",") - for o in opts: - try: - k, v = o.split("=", 1) - self.optdict[k] = v - except: - self.optlist.append(o) - - - def main_0_1_preamble(self): - - cfargs = FuseArgs() - - cfargs.mountpoint = self.mountpoint - - if hasattr(self, 'debug'): - cfargs.add('debug') - - if hasattr(self, 'allow_other'): - cfargs.add('allow_other') - - if hasattr(self, 'kernel_cache'): - cfargs.add('kernel_cache') - - return cfargs.assemble() - - - def getattr_compat_0_1(self, *a): - from os import stat_result - - return stat_result(self.getattr(*a)) - - - def statfs_compat_0_1(self, *a): - - oout = self.statfs(*a) - lo = len(oout) - - svf = StatVfs() - svf.f_bsize = oout[0] # 0 - svf.f_frsize = oout[lo >= 8 and 7 or 0] # 1 - svf.f_blocks = oout[1] # 2 - svf.f_bfree = oout[2] # 3 - svf.f_bavail = oout[3] # 4 - svf.f_files = oout[4] # 5 - svf.f_ffree = oout[5] # 6 - svf.f_favail = lo >= 9 and oout[8] or 0 # 7 - svf.f_flag = lo >= 10 and oout[9] or 0 # 8 - svf.f_namemax = oout[6] # 9 - - return svf - - - def readdir_compat_0_1(self, path, offset, *fh): - - for name, type in self.getdir(path): - de = Direntry(name) - de.type = type - - yield de - - - compatmap = {'readdir': 'getdir'} diff --git a/mac/fuseparts/__init__.py b/mac/fuseparts/__init__.py deleted file mode 100644 index 09888577..00000000 --- a/mac/fuseparts/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.2" diff --git a/mac/fuseparts/setcompatwrap.py b/mac/fuseparts/setcompatwrap.py deleted file mode 100644 index 7ead738a..00000000 --- a/mac/fuseparts/setcompatwrap.py +++ /dev/null @@ -1,5 +0,0 @@ -try: - set() - set = set -except: - from sets import Set as set diff --git a/mac/fuseparts/subbedopts.py b/mac/fuseparts/subbedopts.py deleted file mode 100644 index 8a1f1ae8..00000000 --- a/mac/fuseparts/subbedopts.py +++ /dev/null @@ -1,271 +0,0 @@ -# -# Copyright (C) 2006 Csaba Henk -# -# This program can be distributed under the terms of the GNU LGPL. -# See the file COPYING. -# -# On 2009-09-21 Csaba Henk granted permission for this file to be -# licensed under the same terms as Tahoe-LAFS itself. -# - -from optparse import Option, OptionParser, OptParseError, OptionConflictError -from optparse import HelpFormatter, IndentedHelpFormatter, SUPPRESS_HELP -from fuseparts.setcompatwrap import set - -########## -### -### Generic suboption parsing stuff. -### -########## - - - -class SubOptsHive(object): - """ - Class for collecting unhandled suboptions. - """ - - def __init__(self): - - self.optlist = set() - self.optdict = {} - - def _str_core(self): - - sa = [] - for k, v in self.optdict.iteritems(): - sa.append(str(k) + '=' + str(v)) - - ra = (list(self.optlist) + sa) or ["(none)"] - ra.sort() - return ra - - def __str__(self): - return "< opts: " + ", ".join(self._str_core()) + " >" - - def canonify(self): - """ - Transform self to an equivalent canonical form: - delete optdict keys with False value, move optdict keys - with True value to optlist, stringify other values. - """ - - for k, v in self.optdict.iteritems(): - if v == False: - self.optdict.pop(k) - elif v == True: - self.optdict.pop(k) - self.optlist.add(v) - else: - self.optdict[k] = str(v) - - def filter(self, other): - """ - Throw away those options which are not in the other one. - Returns a new instance with the rejected options. - """ - - self.canonify() - other.canonify() - - rej = self.__class__() - rej.optlist = self.optlist.difference(other.optlist) - self.optlist.difference_update(rej.optlist) - for x in self.optdict.copy(): - if x not in other.optdict: - self.optdict.pop(x) - rej.optdict[x] = None - - return rej - - def add(self, opt, val=None): - """Add a suboption.""" - - ov = opt.split('=', 1) - o = ov[0] - v = len(ov) > 1 and ov[1] or None - - if (v): - if val != None: - raise AttributeError, "ambiguous option value" - val = v - - if val == False: - return - - if val in (None, True): - self.optlist.add(o) - else: - self.optdict[o] = val - - - -class SubbedOpt(Option): - """ - `Option` derivative enhanced with the attribute of being a suboption of - some other option (like ``foo`` and ``bar`` for ``-o`` in ``-o foo,bar``). - """ - - ATTRS = Option.ATTRS + ["subopt", "subsep", "subopts_hive"] - ACTIONS = Option.ACTIONS + ("store_hive",) - STORE_ACTIONS = Option.STORE_ACTIONS + ("store_hive",) - TYPED_ACTIONS = Option.TYPED_ACTIONS + ("store_hive",) - - def __init__(self, *opts, **attrs): - - self.subopt_map = {} - - if "subopt" in attrs: - self._short_opts = [] - self._long_opts = [] - self._set_opt_strings(opts) - self.baseopt = self._short_opts[0] or self._long_opts[0] - opts = () - - Option.__init__(self, *opts, **attrs) - - def __str__(self): - pf = "" - if hasattr(self, "subopt") and self.subopt: - pf = " %s...,%s,..." % (self.baseopt, self.subopt) - return Option.__str__(self) + pf - - def _check_opt_strings(self, opts): - return opts - - def _check_dest(self): - try: - Option._check_dest(self) - except IndexError: - if self.subopt: - self.dest = "__%s__%s" % (self.baseopt, self.subopt) - self.dest = self.dest.replace("-", "") - else: - raise - - def get_opt_string(self): - if hasattr(self, 'subopt'): - return self.subopt - else: - return Option.get_opt_string(self) - - def take_action(self, action, dest, opt, value, values, parser): - if action == "store_hive": - if not hasattr(values, dest) or getattr(values, dest) == None: - if hasattr(self, "subopts_hive") and self.subopts_hive: - hive = self.subopts_hive - else: - hive = parser.hive_class() - setattr(values, dest, hive) - for o in value.split(self.subsep or ","): - oo = o.split('=') - ok = oo[0] - ov = None - if (len(oo) > 1): - ov = oo[1] - if ok in self.subopt_map: - self.subopt_map[ok].process(ok, ov, values, parser) - else: - getattr(values, dest).add(*oo) - return - Option.take_action(self, action, dest, opt, value, values, parser) - - def register_sub(self, o): - """Register argument a suboption for `self`.""" - - if o.subopt in self.subopt_map: - raise OptionConflictError( - "conflicting suboption handlers for `%s'" % o.subopt, - o) - self.subopt_map[o.subopt] = o - - CHECK_METHODS = [] - for m in Option.CHECK_METHODS: - #if not m == Option._check_dest: - if not m.__name__ == '_check_dest': - CHECK_METHODS.append(m) - CHECK_METHODS.append(_check_dest) - - - -class SubbedOptFormatter(HelpFormatter): - - def format_option_strings(self, option): - if hasattr(option, "subopt") and option.subopt: - res = '-o ' + option.subopt - if option.takes_value(): - res += "=" - res += option.metavar or 'FOO' - return res - - return HelpFormatter.format_option_strings(self, option) - - - -class SubbedOptIndentedFormatter(IndentedHelpFormatter, SubbedOptFormatter): - - def format_option_strings(self, option): - return SubbedOptFormatter.format_option_strings(self, option) - - - -class SubbedOptParse(OptionParser): - """ - This class alters / enhances `OptionParser` with *suboption handlers*. - - That is, calling `sop.add_option('-x', subopt=foo)` installs a handler - which will be triggered if there is ``-x foo`` in the command line being - parsed (or, eg., ``-x foo,bar``). - - Moreover, ``-x`` implicitly gets a handler which collects the unhandled - suboptions of ``-x`` into a `SubOptsHive` instance (accessible post festam - via the `x` attribute of the returned Values object). (The only exception - is when ``-x`` has *explicitly* been added with action ``store_hive``. - This opens up the possibility of customizing the ``-x`` handler at some - rate.) - - Suboption handlers have all the nice features of normal option handlers, - eg. they are displayed in the automatically generated help message - (and can have their own help info). - """ - - def __init__(self, *args, **kw): - - if not 'formatter' in kw: - kw['formatter'] = SubbedOptIndentedFormatter() - if not 'option_class' in kw: - kw['option_class'] = SubbedOpt - if 'hive_class' in kw: - self.hive_class = kw.pop('hive_class') - else: - self.hive_class = SubOptsHive - - OptionParser.__init__(self, *args, **kw) - - def add_option(self, *args, **kwargs): - if 'action' in kwargs and kwargs['action'] == 'store_hive': - if 'subopt' in kwargs: - raise OptParseError( - """option can't have a `subopt' attr and `action="store_hive"' at the same time""") - if not 'type' in kwargs: - kwargs['type'] = 'string' - elif 'subopt' in kwargs: - o = self.option_class(*args, **kwargs) - - oo = self.get_option(o.baseopt) - if oo: - if oo.action != "store_hive": - raise OptionConflictError( - "can't add subopt as option has already a handler that doesn't do `store_hive'", - oo) - else: - self.add_option(o.baseopt, action='store_hive', - metavar="sub1,[sub2,...]") - oo = self.get_option(o.baseopt) - - oo.register_sub(o) - - args = (o,) - kwargs = {} - - return OptionParser.add_option(self, *args, **kwargs) diff --git a/mac/setup.py b/mac/setup.py deleted file mode 100644 index 9f84a0a9..00000000 --- a/mac/setup.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup -import py2app - -import glob -import os -import sys - -# pull in formless, as best way to grab its .css file depenedency -import formless - -def find_formless_css(): - fpath = formless.__path__[0] - # first look for it from a regular package install - f = os.path.join(fpath, 'freeform-default.css') - if os.path.exists(f): - return f - # then try looking within .egg structured files - pyver = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) - f = os.path.join(fpath, '../lib', pyver, 'site-packages/formless/freeform-default.css') - if os.path.exists(f): - return f - raise RuntimeError("Can't find formless .css file") - -data_files = [ - ('pkg_resources/allmydata/web', glob.glob('../src/allmydata/web/*')), - ('pkg_resources/formless', [find_formless_css()]), - ] - -from setuptools import find_packages - -packages = find_packages('../src') - -py2app_options = { - 'argv_emulation': True, - 'iconfile': 'allmydata.icns', - 'plist': { 'CFBundleIconFile': 'allmydata.icns', }, - } - -setup_args = { - 'name': 'Allmydata', - 'description': 'The various parts of the Allmydata Tahoe system', - 'author': 'Allmydata, Inc.', - 'app': [ 'allmydata_tahoe.py' ], - 'options': { 'py2app': py2app_options }, - 'data_files': data_files, - 'setup_requires': [ 'py2app', 'macholib>=1.2' ], - 'packages': packages, -} - - -if __name__ == '__main__': - if not os.path.exists('allmydata'): - os.symlink('../src/allmydata', 'allmydata') - setup(**setup_args) - -junk = [formless, py2app] -del junk - - - - diff --git a/src/allmydata/gui/__init__.py b/src/allmydata/gui/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/allmydata/gui/amdicon.py b/src/allmydata/gui/amdicon.py deleted file mode 100644 index a26ca3c3..00000000 --- a/src/allmydata/gui/amdicon.py +++ /dev/null @@ -1,69 +0,0 @@ -#---------------------------------------------------------------------- -# This file was generated by encode_icons.py -# -from wx import ImageFromStream, BitmapFromImage -from wx import EmptyIcon -import cStringIO - - -def getData(): - return \ -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\ -\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x04\ -\x1aIDATX\x85\xad\x97MLTW\x14\xc7\xff\xef\xbd\x997|\x8c\x86\xb1\x888\x0c\x06\ -\x17\x80\x03\xa1\x8a\t\xa9\x8d5a\xd3t\xd3\xa4\xed\xae+\xe3\xa6\xe9\x02v\x8d\ -\xdd\xb8\xd2%D\xb1\x06\x02]\xd9.\xba\xd0\xa4iBqaHHM\xcbnbGZeH\x8d\x16\xad\ -\xed\x14\x91\xe1c\x98\xb9\xf7\xbdw\xcf\xe9\x02\x9c\xf2\xf1\xde\x9b7\xc8\x99L\ -2\x99{\xce\xb9\xbfs\xee\xb9\xe7\xde\xabi\xba\x81\xa0\x12\x1eN2\xd9!\x90\x1d\ -\xc2\xdb\x87\x92\xa8\xab\x8abY\xe41\xb34\x0b=\xec\xc00mX}\x19-\xb0C\x00\xd0t\ -#\xd0\xd7\xb8\xde\xcd-\xa3\x1f\xf3\xcd\x99\t\xce\x895\xde*9\xb1\xc67g&\xb8e\ -\xec#\x0e}u\x8a\x83\xfa\xd4t#\x18\x80q\xed4_\xb8s\x85\xcbIN\xac\xf1\x85;W\ -\xd8\xb8v:0D\xf9\xc9\x87\xba\xf9\xfc\xc4eV;>S\xf3)\x9e\x9aO\xf1\xfdlf\xd7\ -\xd8\xf9\x89\xcbl\\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\x82do\x80\xb9\xec\ -\x02&\x1feP\xb0,\xd4\x98&\xde\xef8\x81\xf6\xc6\x06O}B\xa5\x00L\xa5J\xde)\x0f\ -\x9e\xfd\x83\xaf\x7f\xfe\x05\xe1\xda"\xec\xfeY-<\x9c\xe4\xfb\x93\x7f\xe2\xf3\ -s\xef\xe1\xe4\xb1\xa3\xee\x00{\xca\x80\xcb\x12,;K\xb8\x9dJo;\x0f\xec\xfeY\ -\xcd\x1c9\xc1\xb7S\xbf\xe2\xad\x06\x0bu\xa1\x18\xc2\xba\xb9\xcb\xdf\x1e\x00$\ -\x14;X\xb0\xb3\xf8\xd7z\x81U\xb5\x02b\x85e\xa1\x83\xbf\xdc}\x18\xd9\x03\xd5<\ -\x99\x1b\x07\x81P\xa5W\xe3p\xf8\x08\x8eW\xb5\xe1\x88\x19\xaf\x1c\x80\x99\xf0\ -B>\xc3\xbc|\x0c\x8b,\x10\x14\x14\x13\x88\x15\x98j\\\x1d1i\x90,A\xacP\xa0u,\ -\xda\x0bx\xb8\x9e\xc6a\xb3\x11k\x8ew}\xb8\x1eFy\xb5\x86\xb9\xe2\xef(\xa8\xf5\ -\xcd\x83E\xc2\xa2\x8d\x13\xae\xb1Y\xc0\x18\xea\xda\xd6\r\x8d\xa1.\x8e5\xadl\ -\xeaHX$7\xecX\xe2\xb9x\x8aU\xb5R\x19\xc0\xeb~.Y\xc2\xe2\xff\x9dY$\xd1p|\t\ -\xb5Q\xa7\x04a\x0cuq\xa4V\xa2\xae\xe5\xefM\x1d\x01\x8b$\x1c\xb672\x06\xdf\ -\xce\xed]\x03\x16I((\x10+\x106\xd2\xafX\x81\x0cB]3!\xff\xa8\x11\x00\xc0\xac\ -\xe1@"\x0bG/\x80\xc9\x7f\xb2\xe0\x00\xbc\xd1\x07\x88is\xfd\xb7C\xd8\xac\xef\ -\xd2/\x17iE\x00\xbc3\x03L\xdb\xb2\xe1\x90wk\xdd\x17\x00\x02C\x92\x00\x816\ -\xa3W`\xe6=GY9\x00\x13,\x96\xbe\xa9%+\x04m\xa0\x9b\xc9\xaa\xec%\x16\x08\x80\ -\xc1P\xec}\xff\x8b\xd4\xad"q.\xf5F\x13\xbf\x16\xd7mHN\xf0\x07k\x10\xf1\xf3\ -\xe7\n\xa0\xa4\x89\xe2bl_&/.\xc6\xa0D\xc4s\xdc\xf3i\xa6\rt\xb3Q%\xa1\x87\xfc\ -\xaf\xe2~B\x8e\x01%M\xcf\xeb\x18\x00\xfc\x07\x9aY\xdf_&\xed\xfd\xe8\x00\x00\ -\x00\x00IEND\xaeB`\x82' - -def getBitmap(): - return BitmapFromImage(getImage()) - -def getImage(): - stream = cStringIO.StringIO(getData()) - return ImageFromStream(stream) - -def getIcon(): - icon = EmptyIcon() - icon.CopyFromBitmap(getBitmap()) - return icon - - diff --git a/src/allmydata/gui/amdlogo.py b/src/allmydata/gui/amdlogo.py deleted file mode 100644 index 71456926..00000000 --- a/src/allmydata/gui/amdlogo.py +++ /dev/null @@ -1,173 +0,0 @@ -#---------------------------------------------------------------------- -# This file was generated by /opt/local/lib/python2.4/site-packages/wx-2.6-mac-unicode/wx/tools/img2py.py -# -from wx import ImageFromStream, BitmapFromImage -from wx import EmptyIcon -import cStringIO, zlib - - -def getData(): - return zlib.decompress( -'x\xda\x01\n\x0f\xf5\xf0\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x006\x00\ -\x00\x006\x08\x06\x00\x00\x00\x8cEj\xdd\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\ -\x08d\x88\x00\x00\x0e\xc1IDATh\x81\xbd\x9ai\x90\\Wu\xc7\x7f\xe7\xde\xb7\xf42\ -\xdd\xa3\x914\x92,\x8d$[\xdedIF62\x8b\xb0\xc16\xa0\x02C\xb1\x84J\xfc!T\xd9\ -\x15\x12Ha\x96PT\x92\xa2\x12 \xa4(Hp\x80\xa2\x1c\x8aP\x10\x92\x94M\x9cJ\x11\ -\x02$\x80C\x19\x8c\xcdb\xcb\x06\x83\xe5\x05!,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xfb8\x8em\x18\x86\x13\xc0\xa8\xf8\xfc%\ -\x1e@\xd997\x94\xa6i\xd9\x183\x90$\xc9`\xb7\xdb\xad\xb4\xdb\xed\xb85\xd5R&1\ -\xfa\x0b\x8d\xbbnzB\xff\xfa\xf5\x95(\x0e\x05\x01\xe7g\xe6\x0f\xef\xe7\x0c\ -\xb4\xf4z\x02\xd2\xfb\xd7\xac\xe4g\xe6\xc4\x1e\x99\x03J$wt\x11\x11z\xcd{\xe7\ -&Mbn\x90W}\xe9\xcd\x03/\xf9~X\x8d\x83J\xa5\x92V*\x95N\x1c\xc7SQ\x14M\x86a\ -\xd8\t\xc3\xb0\xa9\x94\x1a\xf7\xde\xfbi`\xb3\'\xb8\\\x98\x87\xbc\x9c\x8c\x9d\ -seA\xa241\xe1c\x13\x07\xd7g\xdeV\xc51d\xad\xad\xa7Y6`\x12S\xeb&\xddJ\x92$a\ -\x92\x18mR#i\x9ab3+\xd6fX\xe7\xe6\xc8W"(\xad\t\x82\x80 \x08|\x18\x86>\x8a"\ -\x17\xc7\xb1\x8d\xe38)\x94m*\xa5\xa6\xb4\xd6\xe3\x99\xb8F=\xa8\xb4/\x1f\xdax\ -\xc4k\xb1\xa2\xa4\x0bt\x94Rf\xb6\xee\xbd\x81\x008\r\xd8\xec\xbd\xf7y\xe6\xe0\ -\x9c#\x08\x02lf\tu\x98\x87\xc2\xccA\xa0f\x87\xfc*\x8e\xaa\xcf\xec\x80s\xae\ -\x92eY\xd9Z\x1b9\xe7\x94sN\x9cs\xd2{\xb8R\xca+\xa5\x9cR\xcaj\xad;A\x10t\x95\ -\xd6-D\x9ahZ\x90\xaf\x8ezc\x11\xa5 \x10|j\xb12W75\xaf\xacVJM\x03\xfb\x7f\xee\ -r\xc9\xfc\x835!h\x00\x00\x00\x00IEND\xaeB`\x82`\xcd|Q' ) - -def getBitmap(): - return BitmapFromImage(getImage()) - -def getImage(): - stream = cStringIO.StringIO(getData()) - return ImageFromStream(stream) - -def getIcon(): - icon = EmptyIcon() - icon.CopyFromBitmap(getBitmap()) - return icon - diff --git a/src/allmydata/gui/confwiz.py b/src/allmydata/gui/confwiz.py deleted file mode 100644 index 48af9b34..00000000 --- a/src/allmydata/gui/confwiz.py +++ /dev/null @@ -1,558 +0,0 @@ - -DEFAULT_SERVER_URL = 'https://www.allmydata.com/' - -BACKEND = 'native_client.php' -ACCOUNT_PAGE = 'account' -WELCOME_PAGE = 'welcome_install' -TAHOESVC_NAME = 'Tahoe' -WINFUSESVC_NAME = 'Allmydata SMB' - -CONVERGENCE_DOMAIN_TAG = "allmydata_root_cap_to_convergence_domain_tag_v1" - -import os -import re -import socket -import sys -#import time -import traceback -import urllib2 -from urllib import urlencode -import webbrowser -import wx - -from allmydata.util.assertutil import precondition -from allmydata.util import hashutil, base32 -from allmydata import uri -import allmydata -from allmydata.gui import amdlogo - -from foolscap.api import Tub -from twisted.python import usage - -class AuthError(Exception): - pass - -def unicode_to_utf8(uobj): - assert precondition(isinstance(uobj, unicode)) - return uobj.encode('utf-8') - - -def post(url, args): - argstr = urlencode(args) - conn = urllib2.urlopen(url, argstr) - return conn.read() - -def get_root_cap(url, user, passwd): - args = { - 'action': 'authenticate', - 'email': unicode_to_utf8(user), - 'passwd': unicode_to_utf8(passwd), - } - root_cap = post(url, args) - if root_cap == '0': - raise AuthError() - elif not uri.is_uri(root_cap): - raise ValueError('%r is not a URI' % (root_cap,)) - else: - return root_cap - -def create_account(url, user, passwd, subscribe): - args = { - 'action': 'create_account', - 'email': unicode_to_utf8(user), - 'passwd': unicode_to_utf8(passwd), - 'subscribe': subscribe and 'true' or 'false', - } - result_code = post(url, args) - return result_code - -def record_install(url, user, passwd, nodeid, nickname): - args = { - 'action': 'record_install', - 'email': unicode_to_utf8(user), - 'passwd': unicode_to_utf8(passwd), - 'nodeid': nodeid, - 'moniker': nickname, - } - result_code = post(url, args) - return result_code - -def record_uninstall(url, nodeid): - args = { - 'action': 'record_uninstall', - 'nodeid': nodeid, - } - result_code = post(url, args) - return result_code - -def get_introducer_furl(url): - return post(url, { 'action': 'getintroducerfurl' }) - -def get_config(url, user, passwd): - args = { - 'action': 'get_config', - 'email': unicode_to_utf8(user), - 'passwd': unicode_to_utf8(passwd), - } - config = post(url, args) - return config - -def get_basedir(): - if sys.platform == 'win32': - from allmydata.windows import registry - return registry.get_base_dir_path() - else: - return os.path.expanduser('~/.tahoe') - -def write_config_file(filename, contents): - basedir = get_basedir() - path = os.path.join(basedir, filename) - dirname = os.path.dirname(path) - if not os.path.exists(dirname): - os.makedirs(dirname) - iff = file(path, 'wb') - iff.write(contents) - iff.close() - -def write_root_cap(root_cap): - write_config_file('private/root_dir.cap', root_cap+'\n') - convergence = base32.b2a(hashutil.tagged_hash(CONVERGENCE_DOMAIN_TAG, root_cap)) - write_config_file('private/convergence', convergence+'\n') - -def get_nodeid(): - CERTFILE = "node.pem" - certfile = os.path.join(get_basedir(), "private", CERTFILE) - tub = Tub(certFile=certfile) - return tub.getTubID() - -def get_nickname(): - nick = None - nnfile = os.path.join(get_basedir(), 'nickname') - if os.path.exists(nnfile): - try: - fh = file(nnfile, 'rb') - nick = fh.read().strip() - fh.close() - except: - DisplayTraceback('Failed to read existing nickname file %s' % (nnfile,)) - if not nick: - nick = socket.gethostname() - return nick - -def maybe_write_file(filename, contents): - fname = os.path.join(get_basedir(), filename) - try: - if not os.path.exists(fname): - fh = file(fname, 'wb') - fh.write(contents) - fh.write('\n') - fh.close() - except: - DisplayTraceback('Failed to write file %s' % (fname,)) - -def configure(backend, user, passwd): - _config_re = re.compile('^([^:]*): (.*)$') - config = get_config(backend, user, passwd) - config_dict = {} - for line in config.split('\n'): - if line: - m = _config_re.match(line) - if m: - fname, contents = m.groups() - config_dict[fname] = contents - for fname, contents in config_dict.items(): - write_config_file(fname, contents+'\n') - -def start_windows_service(svc_name): - try: - import win32service - import win32serviceutil as wsu - if wsu.QueryServiceStatus(svc_name)[1] != win32service.SERVICE_RUNNING: - wsu.StartService(svc_name) - except: - DisplayTraceback('Failed to start windows service "%s"' % (svc_name,)) - -def maybe_start_services(): - if sys.platform == 'win32': - start_windows_service(TAHOESVC_NAME) - start_windows_service(WINFUSESVC_NAME) - -def DisplayTraceback(message): - xc = traceback.format_exception(*sys.exc_info()) - wx.MessageBox(u"%s\n (%s)"%(message,''.join(xc)), 'Error') - -class ConfWizApp(wx.App): - def __init__(self, server, open_welcome_page=False): - self.server = server - self.show_welcome = open_welcome_page - wx.App.__init__(self, 0) - - def get_backend(self): - return self.server + BACKEND - - def open_welcome_page(self): - if self.show_welcome: - args = {'v': str(allmydata.__version__), - 'plat': sys.platform, - } - webbrowser.open(self.server + WELCOME_PAGE + '?' + urlencode(args)) - - def OnInit(self): - try: - wx.InitAllImageHandlers() - - self.login_frame = WizardFrame(self, LoginPanel) - self.login_frame.CenterOnScreen() - self.SetTopWindow(self.login_frame) - #self.SetExitOnFrameDelete(True) - self.login_frame.Show(True) - - return True - except: - DisplayTraceback('config wizard init threw an exception') - - def swap_to_register_frame(self): - try: - self.login_frame.Show(False) - self.regiser_frame = WizardFrame(self, RegisterPanel) - self.regiser_frame.CenterOnScreen() - self.SetTopWindow(self.regiser_frame) - self.SetExitOnFrameDelete(True) - self.regiser_frame.Show(True) - except: - DisplayTraceback('config wizard threw an exception') - -class WizardFrame(wx.Frame): - def __init__(self, app, panel_class): - #title = 'Allmydata Config Wizard' - title = 'Setup - Allmydata' - wx.Frame.__init__(self, None, -1, title) - self.app = app - self.SetIcon(amdlogo.getIcon()) - self.Bind(wx.EVT_CLOSE, self.close) - - self.SetSizeHints(500, 360, 600, 800) - - banner = wx.Panel(self, -1) - banner.SetSize((496,58)) - banner.SetBackgroundColour(wx.WHITE) - - banner_title = wx.StaticText(banner, -1, panel_class.title) - banner_desc = wx.StaticText(banner, -1, " " + panel_class.description) - font = banner_title.GetFont() - font.SetWeight(wx.FONTWEIGHT_BOLD) - banner_title.SetFont(font) - banner_icon = wx.StaticBitmap(banner, -1, amdlogo.getBitmap()) - banner_label_sizer = wx.BoxSizer(wx.VERTICAL) - banner_label_sizer.Add(banner_title, 0, wx.EXPAND | wx.ALL, 2) - banner_label_sizer.Add(banner_desc, 0, wx.EXPAND | wx.ALL, 2) - - banner_sizer = wx.BoxSizer(wx.HORIZONTAL) - banner_sizer.Add(banner_label_sizer, 1, wx.EXPAND | wx.ALL, 12) - banner_sizer.Add(banner_icon, 0, wx.ALL, 12) - banner.SetSizer(banner_sizer) - banner.SetAutoLayout(True) - - background = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) - background.parent = self - - button_panel = wx.Panel(self, -1) - button_panel.SetSize((496, 64)) - - self.panel = panel_class(background, button_panel, app) - sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer.Add(wx.Size(2,2), 0, wx.EXPAND | wx.ALL, self.panel.padding) - background_sizer.Add(self.panel, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 26) - background_sizer.Add(wx.Size(2,2), 0, wx.EXPAND | wx.ALL, self.panel.padding) - background.SetSizer(background_sizer) - - - sizer.Add(banner, 0, wx.EXPAND | wx.HORIZONTAL, 0) - sizer.Add(background, 0, wx.EXPAND | wx.ALL, 0) - sizer.Add(button_panel, 0, wx.EXPAND | wx.HORIZONTAL, 0) - self.SetSizer(sizer) - self.SetAutoLayout(True) - self.Fit() - self.Layout() - - def close(self, event): - self.Show(False) - self.app.ExitMainLoop() - - -class LoginPanel(wx.Panel): - padding = 26 - title = 'Sign in' - description = 'Sign in to your existing account' - - def __init__(self, parent, button_panel, app): - wx.Panel.__init__(self, parent, -1) - self.parent = parent - self.app = app - - self.sizer = wx.BoxSizer(wx.VERTICAL) - - self.user_label = wx.StaticText(self, -1, 'Email') - self.pass_label = wx.StaticText(self, -1, 'Password') - self.user_field = wx.TextCtrl(self, -1, u'', size=(260,-1)) - self.pass_field = wx.TextCtrl(self, -1, u'', size=(260,-1), style=wx.TE_PASSWORD) - self.warning_label = wx.StaticText(self, -1, '') - self.warning_label.SetOwnForegroundColour(wx.RED) - wx.EVT_CHAR(self.user_field, self.on_user_entry) - wx.EVT_CHAR(self.pass_field, self.on_pass_entry) - login_sizer = wx.FlexGridSizer(2, 2, 5, 4) - login_sizer.Add(self.user_label, 0, wx.ALIGN_RIGHT | wx.ALL, 2) - login_sizer.Add(self.user_field, 0, wx.EXPAND | wx.ALL, 2) - login_sizer.Add(self.pass_label, 0, wx.ALIGN_RIGHT | wx.ALL, 2) - login_sizer.Add(self.pass_field, 0, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(login_sizer, 1, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(self.warning_label, 0, wx.CENTER | wx.ALL, 2) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) - - self.reg_label = wx.StaticText(button_panel, -1, "Don't have an account?") - self.reg_button = wx.Button(button_panel, -1, 'Create Account') - self.login_button = wx.Button(button_panel, -1, 'Sign In') - button_panel.Bind(wx.EVT_BUTTON, self.on_reg_button, self.reg_button) - button_panel.Bind(wx.EVT_BUTTON, self.on_login, self.login_button) - btn_sizer = wx.BoxSizer(wx.HORIZONTAL) - btn_sizer.Add(wx.Size(2,2), 1, wx.EXPAND | wx.ALL, 12) - btn_sizer.Add(self.reg_label, 0, wx.ALIGN_RIGHT | wx.ALL, 12) - btn_sizer.Add(self.reg_button, 0, wx.ALIGN_RIGHT | wx.ALL, 12) - btn_sizer.Add(self.login_button, 0, wx.ALIGN_RIGHT | wx.ALL, 12) - button_panel.SetSizer(btn_sizer) - self.button_panel = button_panel - - def on_reg_button(self, event): - self.app.swap_to_register_frame() - - def on_user_entry(self, event): - if event.GetKeyCode() == wx.WXK_RETURN: - self.pass_field.SetFocus() - else: - event.Skip() - - def on_pass_entry(self, event): - if event.GetKeyCode() == wx.WXK_RETURN: - self.on_login(event) - else: - event.Skip() - - def on_login(self, event): - user = self.user_field.GetValue() - passwd = self.pass_field.GetValue() - self.warning_label.SetLabel('Connecting...') - self.Layout() - wx.Yield() - - backend = self.app.get_backend() - - if passwd == '': - self.warning_label.SetLabel('You must enter a password') - self.pass_field.SetFocus() - self.Layout() - return - - try: - root_cap = get_root_cap(backend, user, passwd) - write_root_cap(root_cap) - except AuthError: - self.warning_label.SetLabel('Your email and/or password is incorrect') - self.user_field.SetFocus() - self.Layout() - return - - nodeid = get_nodeid() - nickname = get_nickname() - ret = record_install(backend, user, passwd, nodeid, nickname) - if ret != 'ok': - wx.MessageBox('Error "%s" recording this system (%s)' % (ret, nodeid), 'Error') - - configure(backend, user, passwd) - maybe_start_services() - maybe_write_file('nickname', nickname) - maybe_write_file('accountname', user) - - self.app.open_welcome_page() - - # exit - self.parent.parent.Close() - -class RegisterPanel(wx.Panel): - padding = 7 - title = 'Create account' - description = 'Create a new account on Allmydata' - - def __init__(self, parent, button_panel, app): - wx.Panel.__init__(self, parent, -1) - self.parent = parent - self.app = app - - self.sizer = wx.BoxSizer(wx.VERTICAL) - - self.user_label = wx.StaticText(self, -1, 'Email') - self.pass_label = wx.StaticText(self, -1, 'Password') - self.conf_label = wx.StaticText(self, -1, 'Confirm Password') - self.user_field = wx.TextCtrl(self, -1, u'', size=(260,-1)) - self.pass_field = wx.TextCtrl(self, -1, u'', size=(260,-1), style=wx.TE_PASSWORD) - self.conf_field = wx.TextCtrl(self, -1, u'', size=(260,-1), style=wx.TE_PASSWORD) - self.subscribe_box = wx.CheckBox(self, -1, 'Sign up for our Newsletter') - self.subscribe_box.SetValue(True) - self.warning_label = wx.StaticText(self, -1, '') - self.warning_label.SetOwnForegroundColour(wx.RED) - wx.EVT_CHAR(self.user_field, self.on_user_entry) - wx.EVT_CHAR(self.pass_field, self.on_pass_entry) - wx.EVT_CHAR(self.conf_field, self.on_conf_entry) - login_sizer = wx.FlexGridSizer(3, 2, 5, 4) - login_sizer.Add(self.user_label, 0, wx.ALIGN_RIGHT | wx.ALL, 2) - login_sizer.Add(self.user_field, 0, wx.EXPAND | wx.ALL, 2) - login_sizer.Add(self.pass_label, 0, wx.ALIGN_RIGHT | wx.ALL, 2) - login_sizer.Add(self.pass_field, 0, wx.EXPAND | wx.ALL, 2) - login_sizer.Add(self.conf_label, 0, wx.ALIGN_RIGHT | wx.ALL, 2) - login_sizer.Add(self.conf_field, 0, wx.EXPAND | wx.ALL, 2) - login_sizer.Add(wx.Size(2,2), 0, wx.ALIGN_RIGHT | wx.ALL, 2) - self.sizer.Add(login_sizer, 0, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(self.warning_label, 0, wx.CENTER | wx.ALL, 2) - self.sizer.Add(wx.Size(2,2), 0, wx.EXPAND | wx.ALL, 4) - self.sizer.Add(self.subscribe_box, 0, wx.CENTER | wx.ALL, 2) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) - - self.reg_button = wx.Button(button_panel, -1, 'Create Account') - button_panel.Bind(wx.EVT_BUTTON, self.on_create_account, self.reg_button) - btn_sizer = wx.BoxSizer(wx.HORIZONTAL) - btn_sizer.Add(wx.Size(2,2), 1, wx.EXPAND | wx.ALL, 12) - btn_sizer.Add(self.reg_button, 0, wx.ALIGN_RIGHT | wx.ALL, 12) - button_panel.SetSizer(btn_sizer) - self.button_panel = button_panel - - self.Fit() - - def on_user_entry(self, event): - if event.GetKeyCode() == wx.WXK_RETURN: - self.pass_field.SetFocus() - else: - event.Skip() - - def on_pass_entry(self, event): - if event.GetKeyCode() == wx.WXK_RETURN: - self.conf_field.SetFocus() - else: - event.Skip() - - def on_conf_entry(self, event): - if event.GetKeyCode() == wx.WXK_RETURN: - self.on_create_account(event) - else: - event.Skip() - - def on_create_account(self, event): - user = self.user_field.GetValue() - passwd = self.pass_field.GetValue() - pconf = self.conf_field.GetValue() - subscribe = self.subscribe_box.IsChecked() - self.warning_label.SetLabel('Connecting...') - self.Layout() - wx.Yield() - - if passwd == '': - self.warning_label.SetLabel('You must enter a password') - self.pass_field.SetFocus() - self.Layout() - return - - if passwd != pconf: - self.warning_label.SetLabel("Passwords don't match") - self.pass_field.SetValue('') - self.conf_field.SetValue('') - self.pass_field.SetFocus() - self.Layout() - return - - backend = self.app.get_backend() - - #print 'calling create_account', time.asctime() - result_code = create_account(backend, user, passwd, subscribe) - - if result_code == 'account_exists': - # try and log into it; if valid, use it anyway - try: - #print 'calling get_root_cap (ae)', time.asctime() - root_cap = get_root_cap(backend, user, passwd) - write_root_cap(root_cap) - except AuthError: - self.warning_label.SetLabel('That email address is already registered') - self.user_field.SetFocus() - self.Layout() - return - elif result_code == 'error': - self.warning_label.SetLabel('an error occurred') - self.user_field.SetFocus() - self.Layout() - return - elif result_code == 'ok': - #print 'calling get_root_cap (ok)', time.asctime() - root_cap = get_root_cap(backend, user, passwd) - write_root_cap(root_cap) - else: - self.warning_label.SetLabel('an unexpected error occurred ("%s")' % (result_code,)) - self.user_field.SetFocus() - self.Layout() - return - - nodeid = get_nodeid() - nickname = get_nickname() - ret = record_install(backend, user, passwd, nodeid, nickname) - if ret != 'ok': - wx.MessageBox('Error "%s" recording this system (%s)' % (ret, nodeid), 'Error') - - configure(backend, user, passwd) - maybe_start_services() - maybe_write_file('nickname', nickname) - maybe_write_file('accountname', user) - - self.app.open_welcome_page() - - # exit - self.parent.parent.Close() - -def do_uninstall(server_url): - nodeid = get_nodeid() - ret = record_uninstall(server_url + BACKEND, nodeid) - print ret - if ret != 'ok': - print 'Error "%s" recording uninstall of this system (%s)' % (ret, nodeid) - -class Options(usage.Options): - synopsis = "Usage: confwiz [options]" - - optFlags = [ - ['uninstall', 'u', 'record uninstall'], - ] - optParameters = [ - ['server', 's', DEFAULT_SERVER_URL, 'url of server to contact'], - ] - -def main(argv): - config = Options() - try: - config.parseOptions(argv[1:]) - except usage.error, e: - print config - print "%s: %s" % (sys.argv[0], e) - sys.exit(-1) - - server = config['server'] - if not server.endswith('/'): - server += '/' - - if config['uninstall']: - do_uninstall(server) - else: - app = ConfWizApp(server) - app.MainLoop() - - -if __name__ == '__main__': - main(sys.argv) diff --git a/src/allmydata/gui/macapp.py b/src/allmydata/gui/macapp.py deleted file mode 100644 index d8fa2342..00000000 --- a/src/allmydata/gui/macapp.py +++ /dev/null @@ -1,566 +0,0 @@ - -import operator -import os -import stat -from subprocess import Popen, PIPE -import sys -import thread -import threading -import traceback -import urllib -import webbrowser - -import wx -from twisted.internet import reactor -from twisted.python import log, logfile - -import allmydata -from allmydata import client -from allmydata.gui.confwiz import ConfWizApp, ACCOUNT_PAGE, DEFAULT_SERVER_URL -from allmydata.scripts.common import get_aliases -from allmydata.gui import amdicon, amdlogo - -DEFAULT_FUSE_TIMEOUT = 300 - -TRY_TO_INSTALL_TAHOE_SCRIPT = True -TAHOE_SCRIPT = '''#!/bin/bash -if [ "x${*}x" == "xx" ] -then - %(exe)s --help -else - %(exe)s "${@}" -fi -''' - -def run_macapp(): - nodedir = os.path.expanduser('~/.tahoe') - if not os.path.isdir(nodedir): - app_supp = os.path.expanduser('~/Library/Application Support/Allmydata Tahoe/') - if not os.path.isdir(app_supp): - os.makedirs(app_supp) - os.symlink(app_supp, nodedir) - - app_cont = AppContainer(nodedir) - return app_cont.run() - -class MacGuiClient(client.Client): - """ - This is a subclass of the tahoe 'client' node, which hooks into the - client's 'notice something went wrong' mechanism, to display the fact - in a manner sensible for a wx gui app - """ - def __init__(self, nodedir, app_cont): - self.app_cont = app_cont - client.Client.__init__(self, nodedir) - - def _service_startup_failed(self, failure): - wx.CallAfter(self.wx_abort, failure) - log.msg('node service startup failed') - log.err(failure) - - def wx_abort(self, failure): - wx.MessageBox(failure.getTraceback(), 'Fatal Error in Node startup') - self.app_cont.guiapp.ExitMainLoop() - -class AppContainer(object): - """ - This is the 'container' for the mac app, which takes care of initial - configuration concerns - e.g. running the confwiz before going any further - - of launching the reactor, and within it the tahoe node, on a separate thread, - and then lastly of launching the actual wx gui app and waiting for it to exit. - """ - def __init__(self, nodedir): - self.nodedir = nodedir - - def files_exist(self, file_list): - extant_conf = [ os.path.exists(os.path.join(self.nodedir, f)) for f in file_list ] - return reduce(operator.__and__, extant_conf) - - def is_config_incomplete(self): - necessary_conf_files = ['introducer.furl', 'private/root_dir.cap'] - need_config = not self.files_exist(necessary_conf_files) - if need_config: - print 'some config is missing from nodedir (%s): %s' % (self.nodedir, necessary_conf_files) - return need_config - - def run(self): - # handle initial config - if not os.path.exists(os.path.join(self.nodedir, 'webport')): - f = file(os.path.join(self.nodedir, 'webport'), 'wb') - f.write('3456') - f.close() - - if self.is_config_incomplete(): - confwiz = ConfWizApp(DEFAULT_SERVER_URL, open_welcome_page=True) - confwiz.MainLoop() - - if self.is_config_incomplete(): - print 'config still incomplete; confwiz cancelled, exiting' - return 1 - - # set up twisted logging. this will become part of the node rsn. - logdir = os.path.join(self.nodedir, 'logs') - if not os.path.exists(logdir): - os.makedirs(logdir) - lf = logfile.LogFile('tahoesvc.log', logdir) - log.startLogging(lf) - - if TRY_TO_INSTALL_TAHOE_SCRIPT: - self.maybe_install_tahoe_script() - - # actually start up the node and the ui - os.chdir(self.nodedir) - - # start the reactor thread up, launch the tahoe node therein - self.start_reactor() - - try: - # launch the actual gui on the wx event loop, wait for it to quit - self.guiapp = MacGuiApp(app_cont=self) - self.guiapp.MainLoop() - log.msg('gui mainloop exited') - except: - log.err() - - # shutdown the reactor, hence tahoe node, before exiting - self.stop_reactor() - - return 0 - - def start_reactor(self): - self.reactor_shutdown = threading.Event() - thread.start_new_thread(self.launch_reactor, ()) - - def launch_reactor(self): - # run the node itself - #c = client.Client(self.nodedir) - c = MacGuiClient(self.nodedir, app_cont=self) - reactor.callLater(0, c.startService) # after reactor startup - reactor.run(installSignalHandlers=False) - self.reactor_shutdown.set() - - def stop_reactor(self): - # trigger reactor shutdown, and block waiting on it - reactor.callFromThread(reactor.stop) - log.msg('waiting for reactor shutdown') - self.reactor_shutdown.wait() - log.msg('reactor shut down') - - def maybe_install_tahoe_script(self): - path_candidates = ['/usr/local/bin', '~/bin', '~/Library/bin'] - env_path = map(os.path.expanduser, os.environ['PATH'].split(':')) - if not sys.executable.endswith('/python'): - print 'not installing tahoe script: unexpected sys.exe "%s"' % (sys.executable,) - return - for path_candidate in map(os.path.expanduser, env_path): - tahoe_path = path_candidate + '/tahoe' - if os.path.exists(tahoe_path): - print 'not installing "tahoe": it already exists at "%s"' % (tahoe_path,) - return - for path_candidate in map(os.path.expanduser, path_candidates): - if path_candidate not in env_path: - print path_candidate, 'not in', env_path - continue - tahoe_path = path_candidate + '/tahoe' - try: - print 'trying to install "%s"' % (tahoe_path,) - bin_path = (sys.executable[:-6] + 'Allmydata') - script = TAHOE_SCRIPT % { 'exe': bin_path } - f = file(tahoe_path, 'wb') - f.write(script) - f.close() - mode = stat.S_IRUSR|stat.S_IXUSR|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH - os.chmod(tahoe_path, mode) - print 'installed "%s"' % (tahoe_path,) - return - except: - print 'unable to write %s' % (tahoe_path,) - traceback.print_exc() - else: - print 'no remaining candidate paths for installation of tahoe script' - - -def DisplayTraceback(message): - xc = traceback.format_exception(*sys.exc_info()) - wx.MessageBox(u"%s\n (%s)"%(message,''.join(xc)), 'Error') - -WEBOPEN_ID = wx.NewId() -ACCOUNT_PAGE_ID = wx.NewId() -MOUNT_ID = wx.NewId() - -class SplashFrame(wx.Frame): - def __init__(self): - no_resz = wx.DEFAULT_FRAME_STYLE & ~ (wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX) - wx.Frame.__init__(self, None, -1, 'Allmydata', style=no_resz) - - self.SetSizeHints(100, 100, 600, 800) - self.SetIcon(amdicon.getIcon()) - self.Bind(wx.EVT_CLOSE, self.on_close) - - background = wx.Panel(self, -1) - background.parent = self - self.login_panel = SplashPanel(background, self.on_close) - sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer.Add(self.login_panel, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 26) - background.SetSizer(background_sizer) - sizer.Add(background, 0, wx.EXPAND | wx.ALL, 0) - self.SetSizer(sizer) - self.SetAutoLayout(True) - self.Fit() - self.Layout() - - def on_close(self, event): - self.Show(False) - -class SplashPanel(wx.Panel): - def __init__(self, parent, on_close): - wx.Panel.__init__(self, parent, -1) - self.parent = parent - - hbox = wx.BoxSizer(wx.HORIZONTAL) - vbox = wx.BoxSizer(wx.VERTICAL) - self.sizer = wx.BoxSizer(wx.VERTICAL) - - self.icon = wx.StaticBitmap(self, -1, amdlogo.getBitmap()) - self.label = wx.StaticText(self, -1, 'Allmydata') - bigfont = self.label.GetFont() - bigfont.SetPointSize(26) - smlfont = self.label.GetFont() - smlfont.SetPointSize(10) - self.label.SetFont(bigfont) - ver = "Version 3.0 (%s)" % (allmydata.__version__,) - self.ver_label = wx.StaticText(self, -1, ver) - self.ver_label.SetFont(smlfont) - copy = u"Copyright \N{COPYRIGHT SIGN} 2004-2008 Allmydata Inc.," - self.copy_label = wx.StaticText(self, -1, copy) - self.copy_label.SetFont(smlfont) - self.res_label = wx.StaticText(self, -1, "All Rights Reserved.") - self.res_label.SetFont(smlfont) - ##self.ok = wx.Button(self, -1, 'Ok') - ##self.Bind(wx.EVT_BUTTON, on_close, self.ok) - hbox.Add(self.icon, 0, wx.CENTER | wx.ALL, 2) - vbox.Add(self.label, 0, wx.CENTER | wx.ALL, 2) - vbox.Add(self.ver_label, 0, wx.CENTER | wx.ALL, 2) - hbox.Add(vbox) - self.sizer.Add(hbox) - self.sizer.Add(wx.Size(8,8), 1, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(self.copy_label, 0, wx.CENTER | wx.ALL, 2) - self.sizer.Add(self.res_label, 0, wx.CENTER | wx.ALL, 2) - #self.sizer.Add(wx.Size(42,42), 1, wx.EXPAND | wx.ALL, 2) - ##self.sizer.Add(self.ok, 0, wx.CENTER | wx.ALL, 2) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) - - -class MountFrame(wx.Frame): - def __init__(self, guiapp): - wx.Frame.__init__(self, None, -1, 'Allmydata Mount Filesystem') - - self.SetSizeHints(100, 100, 600, 800) - self.SetIcon(amdicon.getIcon()) - self.Bind(wx.EVT_CLOSE, self.on_close) - - background = wx.Panel(self, -1) - background.parent = self - self.mount_panel = MountPanel(background, self.on_close, guiapp) - sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer = wx.BoxSizer(wx.VERTICAL) - background_sizer.Add(self.mount_panel, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 26) - background.SetSizer(background_sizer) - sizer.Add(background, 0, wx.EXPAND | wx.ALL, 0) - self.SetSizer(sizer) - self.SetAutoLayout(True) - self.Fit() - self.Layout() - - def on_close(self, event): - self.Show(False) - -class MountPanel(wx.Panel): - def __init__(self, parent, on_close, guiapp): - wx.Panel.__init__(self, parent, -1) - self.parent = parent - self.guiapp = guiapp - - self.sizer = wx.BoxSizer(wx.VERTICAL) - - self.label = wx.StaticText(self, -1, 'Allmydata Mount Filesystem') - self.mnt_label = wx.StaticText(self, -1, 'Mount') - self.alias_choice = wx.Choice(self, -1, (120, 64), choices=self.guiapp.aliases.keys()) - root_dir = self.alias_choice.FindString('tahoe') - if root_dir != -1: - self.alias_choice.SetSelection(root_dir) - self.at_label = wx.StaticText(self, -1, 'at') - self.mountpoint = wx.TextCtrl(self, -1, 'choose a mount dir', size=(256,22)) - self.mnt_browse = wx.Button(self, -1, 'Browse') - mount_sizer = wx.BoxSizer(wx.HORIZONTAL) - mount_sizer.Add(self.mnt_label, 0, wx.ALL, 4) - mount_sizer.Add(self.alias_choice, 0, wx.ALL, 4) - mount_sizer.Add(self.at_label, 0, wx.ALL, 4) - mount_sizer.Add(self.mountpoint, 0, wx.ALL, 4) - mount_sizer.Add(self.mnt_browse, 0, wx.ALL, 4) - self.mount = wx.Button(self, -1, 'Mount') - self.Bind(wx.EVT_BUTTON, self.on_mount, self.mount) - #self.Bind(wx.EVT_CHOICE, self.on_choice, self.alias_choice) - self.Bind(wx.EVT_BUTTON, self.on_mnt_browse, self.mnt_browse) - self.sizer.Add(self.label, 0, wx.CENTER | wx.ALL, 2) - self.sizer.Add(wx.Size(28,28), 1, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(mount_sizer, 0, wx.EXPAND | wx.ALL, 0) - self.sizer.Add(wx.Size(28,28), 1, wx.EXPAND | wx.ALL, 2) - self.sizer.Add(self.mount, 0, wx.CENTER | wx.ALL, 2) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) - - def on_mount(self, event): - mountpoint = str(self.mountpoint.GetValue()) - if not os.path.isdir(mountpoint): - wx.MessageBox(u'"%s" is not a directory' % (mountpoint,)) - else: - alias_name = self.alias_choice.GetStringSelection() - self.do_mount(alias_name, mountpoint) - - def on_mnt_browse(self, event): - dlg = wx.DirDialog(self, "Choose a Mountpoint Directory:", - style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON) - if dlg.ShowModal() == wx.ID_OK: - mountpoint = dlg.GetPath() - self.mountpoint.SetValue(mountpoint) - dlg.Destroy() - - def do_mount(self, alias_name, mountpoint): - log.msg('do_mount(%r, %r)' % (alias_name, mountpoint)) - self.guiapp.mount_filesystem(alias_name, mountpoint) - self.parent.parent.Show(False) - -class MacGuiApp(wx.App): - config = { - 'auto-mount': True, - 'auto-open': True, - 'show-webopen': False, - 'daemon-timeout': DEFAULT_FUSE_TIMEOUT, - } - - def __init__(self, app_cont): - self.app_cont = app_cont - self.nodedir = app_cont.nodedir - self.load_config() - self.mounted_filesystems = {} - self.aliases = get_aliases(self.nodedir) - wx.App.__init__(self) - - ## load up setting from gui.conf dir - def load_config(self): - log.msg('load_config') - confdir = os.path.join(self.nodedir, 'gui.conf') - config = {} - config.update(self.config) - for k in self.config: - f = os.path.join(confdir, k) - if os.path.exists(f): - val = file(f, 'rb').read().strip() - if type(self.config[k]) == bool: - if val.lower() in ['y', 'yes', 'true', 'on', '1']: - val = True - else: - val = False - elif type(self.config[k]) == int: - val = int(val) - config[k] = val - self.config = config - - ## GUI wx init - def OnInit(self): - log.msg('OnInit') - try: - self.frame = SplashFrame() - self.frame.CenterOnScreen() - self.frame.Show(True) - self.SetTopWindow(self.frame) - - # self.load_config() - - wx.FutureCall(4096, self.on_timer, None) - - self.mount_frame = MountFrame(guiapp=self) - - self.setup_dock_icon() - menubar = self.setup_app_menu(self.frame) - self.frame.SetMenuBar(menubar) - - return True - except: - DisplayTraceback('exception on startup') - sys.exit() - - ## WX menu and event handling - - def on_timer(self, event): - self.frame.Show(False) - self.perhaps_automount() - - def setup_dock_icon(self): - self.tbicon = wx.TaskBarIcon() - #self.tbicon.SetIcon(amdicon.getIcon(), "Allmydata") - wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.on_dock_menu) - - def setup_app_menu(self, frame): - menubar = wx.MenuBar() - file_menu = wx.Menu() - if self.config['show-webopen']: - webopen_menu = wx.Menu() - self.webopen_menu_ids = {} - for alias in self.aliases: - mid = wx.NewId() - self.webopen_menu_ids[mid] = alias - item = webopen_menu.Append(mid, alias) - frame.Bind(wx.EVT_MENU, self.on_webopen, item) - file_menu.AppendMenu(WEBOPEN_ID, 'Open Web UI', webopen_menu) - item = file_menu.Append(ACCOUNT_PAGE_ID, text='Open Account Page') - frame.Bind(wx.EVT_MENU, self.on_account_page, item) - item = file_menu.Append(MOUNT_ID, text='Mount Filesystem') - frame.Bind(wx.EVT_MENU, self.on_mount, item) - item = file_menu.Append(wx.ID_ABOUT, text='About') - frame.Bind(wx.EVT_MENU, self.on_about, item) - item = file_menu.Append(wx.ID_EXIT, text='Quit') - frame.Bind(wx.EVT_MENU, self.on_quit, item) - menubar.Append(file_menu, 'File') - return menubar - - def on_dock_menu(self, event): - dock_menu = wx.Menu() - item = dock_menu.Append(wx.NewId(), text='About') - self.tbicon.Bind(wx.EVT_MENU, self.on_about, item) - if self.config['show-webopen']: - item = dock_menu.Append(WEBOPEN_ID, text='Open Web Root') - self.tbicon.Bind(wx.EVT_MENU, self.on_webopen, item) - item = dock_menu.Append(ACCOUNT_PAGE_ID, text='Open Account Page') - self.tbicon.Bind(wx.EVT_MENU, self.on_account_page, item) - item = dock_menu.Append(MOUNT_ID, text='Mount Filesystem') - self.tbicon.Bind(wx.EVT_MENU, self.on_mount, item) - self.tbicon.PopupMenu(dock_menu) - - def on_about(self, event): - self.frame.Show(True) - - def on_quit(self, event): - self.unmount_filesystems() - self.ExitMainLoop() - - def on_webopen(self, event): - alias = self.webopen_menu_ids.get(event.GetId()) - #log.msg('on_webopen() alias=%r' % (alias,)) - self.webopen(alias) - - def on_account_page(self, event): - webbrowser.open(DEFAULT_SERVER_URL + ACCOUNT_PAGE) - - def on_mount(self, event): - self.mount_frame.Show(True) - - ## Gui App methods - - def perhaps_automount(self): - if self.config['auto-mount']: - mountpoint = os.path.join(self.nodedir, 'mnt/__auto__') - if not os.path.isdir(mountpoint): - os.makedirs(mountpoint) - self.mount_filesystem('tahoe', mountpoint, 'Allmydata') - - def webopen(self, alias=None): - log.msg('webopen: %r' % (alias,)) - if alias is None: - alias = 'tahoe' - root_uri = self.aliases.get(alias) - if root_uri: - nodeurl = file(os.path.join(self.nodedir, 'node.url'), 'rb').read().strip() - if nodeurl[-1] != "/": - nodeurl += "/" - url = nodeurl + "uri/%s/" % urllib.quote(root_uri) - webbrowser.open(url) - - def mount_filesystem(self, alias_name, mountpoint, display_name=None): - log.msg('mount_filesystem(%r,%r,%r)' % (alias_name, mountpoint, display_name)) - log.msg('sys.exec = %r' % (sys.executable,)) - - # first determine if we can find the 'tahoe' binary (i.e. contents of .app) - if not sys.executable.endswith('Allmydata.app/Contents/MacOS/python'): - log.msg("can't find allmydata.app: sys.executable = %r" % (sys.executable,)) - wx.MessageBox("Can't determine location of Allmydata.app") - return False - bin_path = sys.executable[:-6] + 'Allmydata' - log.msg('%r exists: %r' % (bin_path, os.path.exists(bin_path),)) - - # check mountpoint exists - if not os.path.exists(mountpoint): - log.msg('mountpoint %r does not exist' % (mountpoint,)) - return False - - # figure out options for fuse_main - foptions = [] - foptions.append('-olocal') # required to display in Finder on leopard - #foptions.append('-ofstypename=allmydata') # shown in 'get info' - if display_name is None: - display_name = alias_name - foptions.append('-ovolname=%s' % (display_name,)) - timeout = self.config['daemon-timeout'] - foptions.append('-odaemon_timeout=%d' % (timeout,)) - icns_path = os.path.join(self.nodedir, 'private/icons', alias_name+'.icns') - log.msg('icns_path %r exists: %s' % (icns_path, os.path.exists(icns_path))) - if not os.path.exists(icns_path): - icns_path = os.path.normpath(os.path.join(os.path.dirname(sys.executable), - '../Resources/allmydata.icns')) - log.msg('set icns_path=%s' % (icns_path,)) - if os.path.exists(icns_path): - foptions.append('-ovolicon=%s' % (icns_path,)) - - - # actually launch tahoe fuse - command = [bin_path, 'fuse', '--alias', alias_name] + foptions + [mountpoint] - #log.msg('spawning command %r' % (command,)) - #proc = Popen(command, cwd=self.nodedir, stdout=PIPE, stderr=PIPE) - #log.msg('spawned process, pid %s' % (proc.pid,)) - self.async_run_cmd(command) - - # log the outcome, record the fact that we mounted this fs - #wx.FutureCall(4096, self.check_proc, proc, 'fuse') - self.mounted_filesystems[display_name] = mountpoint - - # open finder, if configured to do so - if self.config['auto-open']: - wx.FutureCall(4096, self.sync_run_cmd, ['/usr/bin/open', mountpoint]) - return True - - def unmount_filesystems(self): - # the user may've already unmounted some, but we should ensure that - # anything the gui mounted gets shut down, since they all depend on - # the tahoe node, which is going away - for name, mountpoint in self.mounted_filesystems.items(): - log.msg('unmounting %r (%s)' % (name, mountpoint)) - self.sync_run_cmd(['/sbin/umount', mountpoint]) - - def sync_run_cmd(self, argv): - log.msg('synchronously running command: %r' % (argv,)) - proc = Popen(argv, cwd=self.nodedir, stdout=PIPE, stderr=PIPE) - proc.wait() - self.check_proc(proc) - - def async_run_cmd(self, argv): - log.msg('asynchronously running command: %r' % (argv,)) - proc = Popen(argv, cwd=self.nodedir, stdout=PIPE, stderr=PIPE) - log.msg('spawned process, pid: %s' % (proc.pid,)) - wx.FutureCall(4096, self.check_proc, proc, 'async fuse process:') - - def check_proc(self, proc, description=None): - message = [] - if description is not None: - message.append(description) - message.append('pid: %s retcode: %s' % (proc.pid, proc.returncode,)) - stdout = proc.stdout.read() - if stdout: - message.append('\nstdout:\n%s' % (stdout,)) - stderr = proc.stderr.read() - if stderr: - message.append('\nstdout:\n%s' % (stderr,)) - log.msg(' '.join(message)) -